ヘッダーをスキップ
Oracle® Fusion Middleware Oracle Enterprise Repository統合ガイド
11g リリース1 (11.1.1.7)
B72433-02
  目次へ移動
目次
索引へ移動
索引

前
 
次
 

26 プロジェクトAPI

この章では、プロジェクトAPIのユースケースについて説明します。このユースケースで、プロジェクトの作成、読込み、更新、問合せおよび検証を行う方法、プロジェクト・アセットと連携する方法、およびOracle Enterprise Repositoryでプロジェクト・ユーザーに変更を加える方法について解説します。

この章では、次の項目について説明します。

26.1 概要

この項では、プロジェクトの作成、読込み、更新、問合せおよび検証について説明します。いくつかのエンティティがプロジェクト(関連プロジェクト、ユーザー、使用済アセットおよび作成済アセット)にアタッチされます。これらのエンティティの追加および削除についても、この項で説明します。

必要な追加のインポート(すべての例で使用できないものもあります。)

import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.query.ProjectCriteria;
import com.flashline.registry.openapi.entity.KeyValuePair;
import com.flashline.registry.openapi.entity.Results;
import java.text.SimpleDateFormat;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.ProjectEntities;

26.2 ユースケース

この項では、プロジェクトAPIを使用するユースケースについて説明します。含まれる内容は、次のとおりです。

26.2.1 ユースケース: 新しいプロジェクトの作成

説明

このメソッドは、プロジェクトの作成、ユーザーの割当ておよび関連プロジェクトの割当てを行います。

プロジェクトのルール

  • プロジェクトには、割当て済のプロジェクト・リーダーが含まれている必要があります。

  • プロジェクト名は一意である必要があります。nullにすることはできません。

  • プロジェクトは部門に割り当てられている必要があります。

  • プロジェクトに見積もられた時間は0より大きい整数である必要があります。

サンプル・コード

例26-1 ユースケース: 新しいプロジェクトの作成

package com.flashline.sample.projectapi;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateNewProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      Project lProject = null;
      ProjectEntities lProjectEntities = null;
      String[] lLeaderIds = null;
      //
---------------------------------------------------------------------------------
--
      lProject = new Project();
      lProjectEntities = new ProjectEntities();
      //
-----------------------------------------------------------------------------------
      // set the name of project
      lProject.setName("NEW_PROJECT_NAME");
      //
---------------------------------------------------------------------------------
--
      // set the name of the project's department
      lProject.setDepartmentID(50000); // a department with id 50000 must
                                        // already exist
      //
---------------------------------------------------------------------------------
--
      // set the userids of the project leaders
      lLeaderIds = new String[] { "99" };
      lProjectEntities.setLeaderIDs(lLeaderIds);
      //
---------------------------------------------------------------------------------
--
      repository.projectCreate(authToken, lProject, lProjectEntities);
    } catch (OpenAPIException oapie) {
      System.out.println("\t --- ServerCode = " + oapie.getServerErrorCode());
      System.out.println("\t --- Message    = " + oapie.getMessage());
    } catch (Exception e) {
      System.out.println("\t --- ErrorMessage = " + e.getMessage());
    }
  }
}

26.2.2 ユースケース: プロジェクトの読込み

説明

プロジェクトを検索し、そのプロジェクトの抽出、作成済アセット、ユーザーおよび関連プロジェクトを読み込みます。

サンプル・コード

例26-2 ユースケース: プロジェクトの読込み

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.query.ProjectCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ReadProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // Read a project
      ProjectCriteria projectCriteria = new ProjectCriteria();
      projectCriteria.setNameCriteria("Project A");
      Project[] projects = repository.projectQuery(authToken,
          projectCriteria);
      if (projects.length > 0) {
        try {
          Project projectRead = (Project) projects[0];
          Extraction[] lExtractions = repository.projectReadExtractions(
              authToken, projectRead);
          Asset[] lAssets = repository.projectReadProducedAssets(
              authToken, projectRead);
          Project[] childProjects = repository.projectReadChildProjects(
              authToken, projectRead);
          Project[] parentProjects = repository
              .projectReadParentProjects(authToken, projectRead);
          RegistryUser[] members = repository.projectReadMembers(
              authToken, projectRead);
          RegistryUser[] leaders = repository.projectReadLeaders(
              authToken, projectRead);
        } catch (OpenAPIException ex) {
          ex.printStackTrace();
        }
      } else {
        System.out.println("No projects found");
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

26.2.3 ユースケース: プロジェクトの検証

説明

プロジェクトを検証すると、ユーザーは、プロジェクトの保存が試行される前に、検証エラーを取得できます。

サンプル・コード

例26-3 ユースケース: プロジェクトの検証

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Department;
import com.flashline.registry.openapi.entity.KeyValuePair;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.Results;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ValidateProject {
  public static void main(String pArgs[]) throws OpenAPIException,
      RemoteException, ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      Project lProject = new Project();
      Results lResults = new Results();
      String[] lLeaders = { "100" };
      Department department = repository.departmentRead(authToken, "Department
 Name");
      ProjectEntities lProjectEntities = new ProjectEntities();
      // -----------------------------------
      // set the project data
      lProjectEntities.setLeaderIDs(lLeaders);
      lProject.setName("Project Name");
      lProject.setDepartmentName("DEPARTMENT_NAME");
      // -----------------------------------
      // Validate a project
      lResults = repository.projectValidate(authToken, lProject,
 lProjectEntities);
      KeyValuePair[] lPairs = lResults.getErrors();
      for (int i = 0; i < lPairs.length; i++) {
        KeyValuePair lPair = lPairs[i];
        System.out.println(lPair.getValue());
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

26.2.4 ユースケース: プロジェクトの更新

説明

特定のプロジェクトに関連付けられた情報およびデータを更新します。

サンプル・コード

例26-4 ユースケース: プロジェクトの更新

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Department;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      Project lProject = new Project();
      Department department = new Department();
      ProjectEntities lProjectEntities = new ProjectEntities();
      // -----------------------------------
      // creating a new temporary project for sample
      Project lSampleProject = createProject(repository, authToken);
      // -----------------------------------
      // read an existing project
      try {
        lProject = repository.projectRead(authToken, lSampleProject.getID());
      } catch (OpenAPIException ex) {
        throw ex;
      }
      // -----------------------------------
      // change project data
      lProject.setName("Update "+lProject.getName());
      lProject.setDescription("Updated Description");
      try {
        department = repository.departmentRead(authToken,
            "Different Department");
        if (department==null) {
          System.out.println("dept is null");
          department = repository.departmentCreate(authToken, "Different
 Department",
              "Different Department description...");
        }
      } catch (OpenAPIException ex) {
        throw ex;
      }
      lProject.setDepartmentID(department.getID());
      lProject.setAddByDefault(true);
      lProject.setEstimatedHours(50);
      java.util.Calendar lCal = new java.util.GregorianCalendar();
      SimpleDateFormat sdf = new SimpleDateFormat("M/d/yy");
      lCal.setTime(sdf.parse("1/1/04"));
      lProject.setStartDate(lCal);
      // -----------------------------------
      // Update the project
      lProject = (Project) repository.projectUpdate(authToken,
          lProject, lProjectEntities);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    } catch (Exception e) {
    }
  }
  protected static Project createProject(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName("Project "+Calendar.getInstance().getTimeInMillis());
    lProject.setDepartmentID(50000); // a department with id 50000 must
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
}

26.2.5 ユースケース: プロジェクトの作成済アセットの更新

説明

ユーザーが、プロジェクトの作成済アセットを設定するために、単一のデータベース・トランザクションを実行できるようになります。

サンプル・コード

例26-5 ユースケース: プロジェクトの作成済アセットの更新

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.APIValidationException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectProducedAssets {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      ProjectEntities lProjectEntities = new ProjectEntities();
      Asset lSampleAsset1 = createAsset(repository, authToken);
      Asset lSampleAsset2 = createAsset(repository, authToken);
      String[] assetIds = { ""+lSampleAsset1.getID(), ""+lSampleAsset2.getID() };
      try {
        // -----------------------------------
        // read an existing project
        Project projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // set the produced asset ids
        lProjectEntities.setAssetIDs(assetIds);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead,
            lProjectEntities);
      } catch (APIValidationException ex) {
        ex.printStackTrace();
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Asset createAsset(FlashlineRegistry repository, AuthToken
 authToken)
      throws OpenAPIException, RemoteException {
    Asset myAsset = repository.assetCreate(authToken,
        "My Produced Asset", ""+Calendar.getInstance().getTimeInMillis(), 144);
    return myAsset;
  }
}

26.2.6 ユースケース: プロジェクトからの作成済アセットの削除

説明

プロジェクトから作成済アセットを削除します。

サンプル・コード

例26-6 ユースケース: プロジェクトからの作成済アセットの削除

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.APIValidationException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class RemoveProducedAssetsFromProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      ProjectEntities lProjectEntities = new ProjectEntities();
      String[] assetIds = { "569", "589" };
      try {
        // -----------------------------------
        // read an existing project
        Project projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // set the remove assets ids
        lProjectEntities.setRemovedAssetIDs(assetIds);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead,
            lProjectEntities);
      } catch (APIValidationException ex) {
        ex.printStackTrace();
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
As an alternative, produced assets may be removed by specifying the assets that
 are to remain on the project.
    Sample Code:
package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class RemoveProducedAssetsFromProject2 {
  public static void main(String pArgs[])
      throws OpenAPIException, RemoteException, ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // An alternate way of removing produced assets is to specify which assets
      // you wish to remain on the project.
      String[] assetIDs = { "569" };
      ProjectEntities lEntities = new ProjectEntities();
      Project projectRead = new Project();
      try {
        // -----------------------------------
        // read an existing project
        projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // set the entities of the produced assets
        lEntities.setAssetIDs(assetIDs);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lEntities);
      } catch (OpenAPIException ex) {
        ex.printStackTrace();
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

26.2.7 ユースケース: プロジェクトのアセット使用状況の更新

説明

ユーザーが、プロジェクトに関連付けられた抽出を拒否できるようになります。

サンプル・コード

例26-7 ユースケース: プロジェクトのアセット使用状況の更新

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.List;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectAsset;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectExtractions {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // Update a project's extractions
      ProjectEntities lProjectEntities = null;
      try {
        // -----------------------------------
        // read an existing project
        Project projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // get an extraction or create one
        long lExtractionID = 0;
        ProjectAsset[] lProjectAssets = projectRead.getAssets();
        if (lProjectAssets!=null && lProjectAssets.length>0) {
          lProjectAssets[0].getStatus();
          lExtractionID = lProjectAssets[0].getID();
        } else {
          lProjectEntities = new ProjectEntities();
          lExtractionID = repository.assetRead(authToken, 569).getID();
          String[] lAssetIDs = { ""+lExtractionID };
          lProjectEntities.setAssetIDs(lAssetIDs);
          repository.projectUpdate(authToken, projectRead, lProjectEntities);
        }
        // -----------------------------------
        // set the rejected assets ids
        String[] rejectedIds = null;
        projectRead = repository.projectRead(authToken, 50000); // reload modified
 project
        Extraction[] lExtractions = repository.projectReadExtractions(authToken,
 projectRead);
        rejectedIds = new String[lExtractions.length];
        for (int i=0; lExtractions!=null && i<lExtractions.length; i++) {
          rejectedIds[i] = ""+lExtractions[i].getID();
        }
        lProjectEntities = new ProjectEntities();
        lProjectEntities.setRejectedIDs(rejectedIds);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lProjectEntities);
      } catch (OpenAPIException ex) {
        ex.printStackTrace();
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

26.2.8 ユースケース: 非表示のアセットのあるプロジェクトの終了

説明

プロジェクトを終了する際に、DEPLOYEDまたはREJECTEDとして指定されていないプロジェクトで使用されたアセットの使用状況ステータスを更新する必要があります。

ただし、AquaLogic Enterprise Repositoryの拡張ロール・ベース・アクセス制御(RBAC)設定では、プロジェクト・リーダーはプロジェクトで使用されたすべてのアセットを表示できないことがあります。

プロジェクトが終了した場合、拒否されていない非表示のアセットは、自動的にDEPLOYEDとして指定されます。

AquaLogic Enterprise Repositoryを使用している場合、プロジェクト・リーダーは、プロジェクトに非表示のアセットが含まれていることを通知され、非表示のアセットの使用状況ステータスを更新してアセット値の調査を完了するために必要なアクセス権を持っているユーザーに問い合せる機会を与えられます。適切なユーザーが必要なアクションを行ったことをプロジェクト・リーダーが認識すると、プロジェクトを終了できます。

次の例に、プロジェクトの終了時にプロジェクト・リーダーに非表示となっているアセットのステータスを更新するための、プログラムでのFLEXメカニズムを示します。

サンプル・コード

例26-8 ユースケース: 非表示のアセットのあるプロジェクトの終了

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.List;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectAsset;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectExtractions {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // Update a project's extractions
      ProjectEntities lProjectEntities = null;
      try {
        // -----------------------------------
        // read an existing project
        Project projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // get an extraction or create one
        long lExtractionID = 0;
        ProjectAsset[] lProjectAssets = projectRead.getAssets();
        if (lProjectAssets!=null && lProjectAssets.length>0) {
          lProjectAssets[0].getStatus();
          lExtractionID = lProjectAssets[0].getID();
        } else {
          lProjectEntities = new ProjectEntities();
          lExtractionID = repository.assetRead(authToken, 569).getID();
          String[] lAssetIDs = { ""+lExtractionID };
          lProjectEntities.setAssetIDs(lAssetIDs);
          repository.projectUpdate(authToken, projectRead, lProjectEntities);
        }
        // -----------------------------------
        // set the rejected assets ids
        String[] rejectedIds = null;
        projectRead = repository.projectRead(authToken, 50000); // reload modified
 project
        Extraction[] lExtractions = repository.projectReadExtractions(authToken,
 projectRead);
        rejectedIds = new String[lExtractions.length];
        for (int i=0; lExtractions!=null && i<lExtractions.length; i++) {
          rejectedIds[i] = ""+lExtractions[i].getID();
        }
        lProjectEntities = new ProjectEntities();
        lProjectEntities.setRejectedIDs(rejectedIds);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lProjectEntities);
      } catch (OpenAPIException ex) {
        ex.printStackTrace();
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

26.2.9 ユースケース: プロジェクトへのユーザーと関連プロジェクトの追加

説明

ユーザーをプロジェクトに追加するプロセスは、関連ユーザーを追加するプロセスと同様です。

サンプル・コード

例26-9 ユースケース: プロジェクトへのユーザーと関連プロジェクトの追加

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.APIValidationException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class AddUsersAndRelatedProjectsToProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // Add users and related projects to a project
      Project projectRead = new Project();
      String[] newLeaderIDs = { "99" };
      ProjectEntities lEntities = new ProjectEntities();
      try {
        // -----------------------------------
        // read an existing project
        projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // create two new projects
        Project lParentProject = createNewProject(repository, authToken, "My
 Parent Project");
        Project lChildProject = createNewProject(repository, authToken, "My Child
 Project");
        String[] newParentIDs = { ""+lParentProject.getID() };
        String[] newChildIDs = { ""+lChildProject.getID() };
        // -----------------------------------
        // create two new users
        RegistryUser lUserOne = createNewUser(repository, authToken, "one");
        RegistryUser lUserTwo = createNewUser(repository, authToken, "two");
        String[] newMemberIDs = { ""+lUserOne.getID(), ""+lUserTwo.getID() };
        // -----------------------------------
        // set the added leader ids
        lEntities.setAddedLeaderIDs(newLeaderIDs);
        // -----------------------------------
        // set the added member ids
        lEntities.setAddedMemberIDs(newMemberIDs);
        // -----------------------------------
        // set the added children project ids
        lEntities.setAddedChildIDs(newChildIDs);
        // -----------------------------------
        // set the added parent project ids
        lEntities.setAddedParentIDs(newParentIDs);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lEntities);
      } catch (OpenAPIException ex) {
        throw ex;
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createNewProject(FlashlineRegistry repository,
 AuthToken authToken, String pName)
      throws APIValidationException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName(pName+" "+Calendar.getInstance().getTimeInMillis()); // force
 uniqueness
    lProject.setDepartmentID(50000); // a department with id 50000 must already
 exist
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createNewUser(FlashlineRegistry repository,
 AuthToken authToken, String pUserName)
      throws APIValidationException, RemoteException {
    String lUserName = pUserName + Calendar.getInstance().getTimeInMillis(); //
 force uniqueness
    RegistryUser lRegistryUser = repository.userCreate(authToken, lUserName,
 "First", pUserName,
        pUserName+"@example.com", pUserName, false, false, false);
    return lRegistryUser;
  }
}

次に例に、ユーザーと関連プロジェクトの別の追加方法を示します。この例では、追加済のユーザーまたはプロジェクトは、プロジェクトに割当て済のユーザーまたはプロジェクトのみです。IDの文字列配列に含まれていないユーザーまたはプロジェクトは、プロジェクトから削除されます。この方法を選択すると、ユーザーの追加と削除が1つの手順で行えます。

サンプル・コード

例26-10 ユースケース: プロジェクトに対するユーザーの追加と削除

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.APIValidationException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class AddUsersAndRelatedProjectsToProject2 {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // The following example presents an alternate way of adding users and
      // related projects.
      // In this example the added users/projects are the ONLY
      // users/projects assigned to the project.
      // Any users/projects not included in the String Array of IDs are
      // removed from the project.
      // This option combines adding and removing users into one step.
      Project projectRead = new Project();
      String[] newLeaderIDs = { "50003" };
      ProjectEntities lEntities = new ProjectEntities();
      try {
        // -----------------------------------
        // read an existing project
        projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // create two new projects
        Project lParentProject = createNewProject(repository, authToken, "My
 Parent Project");
        Project lChildProject = createNewProject(repository, authToken, "My Child
 Project");
        String[] newParentIDs = { ""+lParentProject.getID() };
        String[] newChildIDs = { ""+lChildProject.getID() };
        // -----------------------------------
        // create two new users
        RegistryUser lUserOne = createNewUser(repository, authToken, "one");
        RegistryUser lUserTwo = createNewUser(repository, authToken, "two");
        String[] newMemberIDs = { ""+lUserOne.getID(), ""+lUserTwo.getID() };
        // -----------------------------------
        // set the leader ids
        lEntities.setLeaderIDs(newLeaderIDs);
        // -----------------------------------
        // set the member ids
        lEntities.setMemberIDs(newMemberIDs);
        // -----------------------------------
        // set the children project ids
        lEntities.setChildIDs(newChildIDs);
        // -----------------------------------
        // set the parent project ids
        lEntities.setParentIDs(newParentIDs);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lEntities);
      } catch (OpenAPIException ex) {
        throw ex;
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createNewProject(FlashlineRegistry repository,
 AuthToken authToken, String pName)
      throws APIValidationException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName(pName+" "+Calendar.getInstance().getTimeInMillis()); // force
 uniqueness
    lProject.setDepartmentID(50000); // a department with id 50000 must already
 exist
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createNewUser(FlashlineRegistry repository,
 AuthToken authToken, String pUserName)
      throws APIValidationException, RemoteException {
    String lUserName = pUserName + Calendar.getInstance().getTimeInMillis(); //
 force uniqueness
    RegistryUser lRegistryUser = repository.userCreate(authToken, lUserName,
 "First", pUserName,
        pUserName+"@example.com", pUserName, false, false, false);
    return lRegistryUser;
  }
}

26.2.10 ユースケース: プロジェクトからの関連プロジェクトとユーザーの削除

説明

ユーザーをプロジェクトから削除するプロセスは、関連プロジェクトを削除するプロセスと同様です。

サンプル・コード

例26-11 ユースケース: プロジェクトからの関連プロジェクトとユーザーの削除

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class RemoveRelatedProjectsAndUsersFromProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      long lParentProjectID = createProject(repository, authToken).getID();
      long lChildProject1ID = createProject(repository, authToken).getID();
      long lChildProject2ID = createProject(repository, authToken).getID();
      long lUser1ID = createUser(repository, authToken).getID();
      long lUser2ID = createUser(repository, authToken).getID();
      long lUser3ID = createUser(repository, authToken).getID();
      long lUser4ID = createUser(repository, authToken).getID();
      long lUser5ID = createUser(repository, authToken).getID();
      long lUser6ID = createUser(repository, authToken).getID();
      // -----------------------------------
      // Remove related projects and users from a project
      Project projectRead = new Project();
      String[] removedParentProjectIDs = { ""+lParentProjectID };
      String[] removedChildProjectIDs = { ""+lChildProject1ID, ""+lChildProject2ID
 };
      String[] removedLeaderIDs = { ""+lUser1ID };
      String[] removedMemberIDs = { ""+lUser2ID };
      ProjectEntities lEntities = new ProjectEntities();
      try {
        projectRead = repository.projectRead(authToken, 50000);
      } catch (OpenAPIException ex) {
        throw ex;
      }
      try {
        // -----------------------------------
        // set the removed parent project ids
        lEntities.setRemovedParentIDs(removedParentProjectIDs);
        // -----------------------------------
        // set the removed children project ids
        lEntities.setRemovedChildIDs(removedChildProjectIDs);
        // -----------------------------------
        // set the remove leader ids
        lEntities.setRemovedLeaderIDs(removedLeaderIDs);
        // -----------------------------------
        // set the removed member ids
        lEntities.setRemovedMemberIDs(removedMemberIDs);
        // -----------------------------------
        // set the exraction reassignment decisions
        ExtractionReassignmentDecision[] decisions = new
 ExtractionReassignmentDecision[2];
        ExtractionReassignmentDecision decision = new
 ExtractionReassignmentDecision();
        decision.setUserID(lUser3ID);
        decision.setReassignUserID(lUser4ID);
        decisions[0] = decision;
        decision = new ExtractionReassignmentDecision();
        decision.setUserID(lUser5ID);
        decision.setReassignUserID(lUser6ID);
        decisions[1] = decision;
        // -----------------------------------
        // set the userid for the reassigned extracions
        lEntities.setReassignIDs(decisions);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lEntities);
      } catch (OpenAPIException ex) {
        throw ex;
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createProject(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName("Project "+Calendar.getInstance().getTimeInMillis());
    lProject.setDepartmentID(50000); // a department with id 50000 must
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}

別の方法として、次の例では、削除するユーザーまたはプロジェクトを指定するのではなく、残すユーザーまたはプロジェクトを指定します。

サンプル・コード

例26-12 ユースケース: プロジェクトに特定のユーザーとプロジェクトを残す

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class RemoveRelatedProjectsAndUsersFromProject2 {
  public static void main(String pArgs[])
      throws OpenAPIException, RemoteException, ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // As an alternative, the following example tells the system which
      // users/projects to keep,
      // rather than telling it which ones to remove.
      Project projectRead = new Project();
      String[] lParentProjectIDs = { "50003" };
      String[] lChildProjectIDs = { "50002", "50001" };
      String[] lLeaderIDs = { "50001" };
      String[] lMemberIDs = { "50005" };
      ProjectEntities lEntities = new ProjectEntities();
      try {
        projectRead = repository.projectRead(authToken, 50000);
      } catch (OpenAPIException ex) {
        throw ex;
      }
      try {
        // -----------------------------------
        // set the parent project ids
        lEntities.setParentIDs(lParentProjectIDs);
        // -----------------------------------
        // set the children project ids
        lEntities.setChildIDs(lChildProjectIDs);
        // -----------------------------------
        // set the leader ids
        lEntities.setLeaderIDs(lLeaderIDs);
        // -----------------------------------
        // set the member ids
        lEntities.setMemberIDs(lMemberIDs);
        // -----------------------------------
        // set the extraction reassignment decisions
        ExtractionReassignmentDecision[] decisions = new
 ExtractionReassignmentDecision[2];
        ExtractionReassignmentDecision decision = new
 ExtractionReassignmentDecision();
        decision.setUserID(50011);
        decision.setReassignUserID(50001);
        decisions[0] = decision;
        decision = new ExtractionReassignmentDecision();
        decision.setUserID(50012);
        decision.setReassignUserID(50005);
        decisions[1] = decision;
        // -----------------------------------
        // set the userid for the reassigned extracions
        lEntities.setReassignIDs(decisions);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lEntities);
      } catch (OpenAPIException ex) {
        throw ex;
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

26.2.11 ユースケース: プロジェクトの抽出の更新 - 同じプロジェクトまたは別のプロジェクトにおける別のユーザーへの抽出の再割当て

説明

抽出はユーザー間で再度割り当てることができます。抽出を再度割り当てられるユーザーは、同じプロジェクトまたは別のプロジェクトに存在できます。

サンプル・コード

例26-13 ユースケース: プロジェクトの抽出の更新

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectExtractionswithReassign {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      Project lProject = null;
      long currentProjectID = 50000; // an existing project with id 50000 must
                                      // exist
      long someProjectID = 0; // an existing project with id 50001 must
                                  // exist where re-extractions are being
                                  // assigned to
      long extractionID = 50002; // the id of the extraction being reassigned
      long reassignUserID = 0; // the id of the user being assigned to this
                                    // extraction
      // -----------------------------------
      // Update a project's extractions - reassign extractions to a different
      // user on the same or different project
      // -----------------------------------
      // read a project, get a sample project
      lProject = repository.projectRead(authToken, currentProjectID);
      someProjectID = createProject(repository, authToken).getID();
      // -----------------------------------
      // get a member of the project to reassign
      Project lReassignProject = repository.projectRead(authToken, someProjectID);
      String[] memberIDs = repository.projectReadMemberIDs(authToken,
 lReassignProject);
      if (memberIDs!=null && memberIDs.length>0) {
        reassignUserID = Long.parseLong(memberIDs[0]);
      }
      // -----------------------------------
      // if no members exist, create a user and add them
      if (reassignUserID==0) {
        ProjectEntities lProjectEntities = new ProjectEntities();
        reassignUserID = createUser(repository, authToken).getID();
        String[] newMemberIDs = { ""+reassignUserID };
        lProjectEntities.setAddedMemberIDs(newMemberIDs);
        repository.projectUpdate(authToken, lReassignProject, lProjectEntities);
      }
      // -----------------------------------
      // set the extraction reassignment decision
      ExtractionReassignmentDecision[] lDecisions = new
 ExtractionReassignmentDecision[1];
      ExtractionReassignmentDecision lDecision = new
 ExtractionReassignmentDecision();
      // -----------------------------------
      // set the reassigned project id
      lDecision.setProjectID(someProjectID);
      // -----------------------------------
      // specify which extraction (by id)
      lDecision.setExtractionID(extractionID);
      // -----------------------------------
      // set the reassigned user id
      lDecision.setReassignUserID(reassignUserID);
      lDecisions[0] = lDecision;
      // -----------------------------------
      // reassign project extractions
      repository.projectReassignExtractions(authToken, lProject,
          lDecisions);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createProject(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName("Project "+Calendar.getInstance().getTimeInMillis());
    lProject.setDepartmentID(50000); // a department with id 50000 must
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}

26.2.12 ユースケース: プロジェクトのユーザーの更新 - 別のプロジェクトへのユーザーとその抽出の再割当て

説明

ユーザーとその抽出を別のプロジェクトに再度割り当てます。

サンプル・コード

例26-14 ユースケース: 別のプロジェクトへのプロジェクト・ユーザーとユーザーの抽出の再割当て

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectExtractionswithReassign {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      Project lProject = null;
      long currentProjectID = 50000; // an existing project with id 50000 must
                                      // exist
      long someProjectID = 0; // an existing project with id 50001 must
                                  // exist where re-extractions are being
                                  // assigned to
      long extractionID = 50002; // the id of the extraction being reassigned
      long reassignUserID = 0; // the id of the user being assigned to this
                                    // extraction
      // -----------------------------------
      // Update a project's extractions - reassign extractions to a different
      // user on the same or different project
      // -----------------------------------
      // read a project, get a sample project
      lProject = repository.projectRead(authToken, currentProjectID);
      someProjectID = createProject(repository, authToken).getID();
      // -----------------------------------
      // get a member of the project to reassign
      Project lReassignProject = repository.projectRead(authToken, someProjectID);
      String[] memberIDs = repository.projectReadMemberIDs(authToken,
 lReassignProject);
      if (memberIDs!=null && memberIDs.length>0) {
        reassignUserID = Long.parseLong(memberIDs[0]);
      }
      // -----------------------------------
      // if no members exist, create a user and add them
      if (reassignUserID==0) {
        ProjectEntities lProjectEntities = new ProjectEntities();
        reassignUserID = createUser(repository, authToken).getID();
        String[] newMemberIDs = { ""+reassignUserID };
        lProjectEntities.setAddedMemberIDs(newMemberIDs);
        repository.projectUpdate(authToken, lReassignProject, lProjectEntities);
      }
      // -----------------------------------
      // set the extraction reassignment decision
      ExtractionReassignmentDecision[] lDecisions = new
 ExtractionReassignmentDecision[1];
      ExtractionReassignmentDecision lDecision = new
 ExtractionReassignmentDecision();
      // -----------------------------------
      // set the reassigned project id
      lDecision.setProjectID(someProjectID);
      // -----------------------------------
      // specify which extraction (by id)
      lDecision.setExtractionID(extractionID);
      // -----------------------------------
      // set the reassigned user id
      lDecision.setReassignUserID(reassignUserID);
      lDecisions[0] = lDecision;
      // -----------------------------------
      // reassign project extractions
      repository.projectReassignExtractions(authToken, lProject,
          lDecisions);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createProject(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName("Project "+Calendar.getInstance().getTimeInMillis());
    lProject.setDepartmentID(50000); // a department with id 50000 must
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}

26.2.13 ユースケース: プロジェクトのユーザーの更新 - 別のプロジェクトへのユーザーのみ(ユーザーの抽出は除く)の再割当て

説明

ユーザーはプロジェクト間で再度割り当てることができます。抽出を伴わないでユーザーを移動する場合、ユーザーを再度割り当てる前に、まず、抽出を別のプロジェクト・メンバーに再度割り当てる必要があります。

サンプル・コード

例26-15 ユースケース: 別のプロジェクトへのユーザーのみの再割当て

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.ProjectUserType;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectUserWithReassign2 {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1], pArgs[2]);
      Project lProject = null;
      Project someProject = null; // the id the other project
      Project reassignProject = null; // the id of the project being reassigned
      long currentProjectID = 50000; // the id of the current project
      long extractionID = 0; // the id of the extraction
      long extractionReassignUserID = 0; // the id of the user being
                                              // reassigned
      long projectReassignUserID = 0; // the id of the user being reassigned
      // -----------------------------------
      // Update a project's user - reassign only the user (not their
      // extractions) to another project
      // -----------------------------------
      // read a project
      lProject = repository.projectRead(authToken, currentProjectID);
      // -----------------------------------
      // create some projects
      someProject = createProject(repository, authToken);
      reassignProject = createProject(repository, authToken);
      // -----------------------------------
      // get a member of the project to reassign
      String[] memberIDs = repository.projectReadMemberIDs(authToken, lProject);
      if (memberIDs!=null && memberIDs.length>0) {
        extractionReassignUserID = Long.parseLong(memberIDs[0]);
        if (memberIDs.length>1) {
          projectReassignUserID = Long.parseLong(memberIDs[0]);
        }
      }
      // -----------------------------------
      // if no members exist, create users and add them
      if (extractionReassignUserID==0) {
        ProjectEntities lProjectEntities = new ProjectEntities();
        extractionReassignUserID = createUser(repository, authToken).getID();
        lProjectEntities.setAddedMemberIDs(new String[]{
 ""+extractionReassignUserID });
        repository.projectUpdate(authToken, lProject, lProjectEntities);
      }
      if (projectReassignUserID==0) {
        ProjectEntities lProjectEntities = new ProjectEntities();
        projectReassignUserID = createUser(repository, authToken).getID();
        lProjectEntities.setAddedMemberIDs(new String[]{ ""+projectReassignUserID
 });
        repository.projectUpdate(authToken, lProject, lProjectEntities);
      }
      // get extraction for user or create one
      Extraction[] lAssetExtractions =
 repository.projectReadExtractions(authToken, lProject);
      if (lAssetExtractions!=null && lAssetExtractions.length>0) {
        extractionID = lAssetExtractions[0].getID();
      }
      if (extractionID==0) {
        // create new extraction
        ProjectEntities lProjectEntities = new ProjectEntities();
        Asset lAsset = repository.assetRead(authToken, 569);
        lProjectEntities.setAssetIDs(new String[]{ ""+lAsset.getID() });
        repository.projectUpdate(authToken, lProject, lProjectEntities);
      }
      // -----------------------------------
      // add users to reassign project (if they aren't already)
      {
        Project lReassignProject = repository.projectRead(authToken,
 reassignProject.getID());
        boolean isMemberExtraction = false, isMemberProject = false;
        String[] reassignMemberIDs = repository.projectReadMemberIDs(authToken,
 lReassignProject);
        for (int i=0; reassignMemberIDs!=null && i<reassignMemberIDs.length; i++)
 {
          if
 (Long.parseLong(reassignMemberIDs[i].trim())==extractionReassignUserID)
 isMemberExtraction = true;
          if (Long.parseLong(reassignMemberIDs[i].trim())==projectReassignUserID)
 isMemberProject = true;
        }
        if (!isMemberExtraction) {
          ProjectEntities lProjectEntities = new ProjectEntities();
          lProjectEntities.setAddedMemberIDs(new String[]{
 ""+extractionReassignUserID });
          repository.projectUpdate(authToken, lReassignProject, lProjectEntities);
        }
        if (!isMemberProject) {
          ProjectEntities lProjectEntities = new ProjectEntities();
          lProjectEntities.setAddedMemberIDs(new String[]{
 ""+projectReassignUserID });
          repository.projectUpdate(authToken, lReassignProject, lProjectEntities);
        }
      }
      // -----------------------------------
      // add users to some project (if they aren't already)
      {
        Project lSomeProject = repository.projectRead(authToken,
 someProject.getID());
        boolean isMemberExtraction = false, isMemberProject = false;
        String[] SomeMemberIDs = repository.projectReadMemberIDs(authToken,
 lSomeProject);
        for (int i=0; SomeMemberIDs!=null && i<SomeMemberIDs.length; i++) {
          if (Long.parseLong(SomeMemberIDs[i].trim())==extractionReassignUserID)
 isMemberExtraction = true;
          if (Long.parseLong(SomeMemberIDs[i].trim())==projectReassignUserID)
 isMemberProject = true;
        }
        if (!isMemberExtraction) {
          ProjectEntities lProjectEntities = new ProjectEntities();
          lProjectEntities.setAddedMemberIDs(new String[]{
 ""+extractionReassignUserID });
          repository.projectUpdate(authToken, lSomeProject, lProjectEntities);
        }
        if (!isMemberProject) {
          ProjectEntities lProjectEntities = new ProjectEntities();
          lProjectEntities.setAddedMemberIDs(new String[]{
 ""+projectReassignUserID });
          repository.projectUpdate(authToken, lSomeProject, lProjectEntities);
        }
      }
      // -----------------------------------
      // set extraction reassignment decision
      ExtractionReassignmentDecision[] lDecisions = new
 ExtractionReassignmentDecision[1];
      ExtractionReassignmentDecision lDecision = new
 ExtractionReassignmentDecision();
      // set the reassign decision's project id
      lDecision.setProjectID(someProject.getID());
      // set the reassign decision's extraction id
      lDecision.setExtractionID(extractionID);
      // set the reassign decision's reassigned user ids
      lDecision.setReassignUserID(extractionReassignUserID);
      lDecisions[0] = lDecision;
      // reassign project extractions
      repository.projectReassignExtractions(authToken, lProject,
          lDecisions);
      // verify reassignment
      lProject = repository.projectRead(authToken, currentProjectID);
      ProjectUserType userType = repository
          .projectReadUserTypes(authToken);
      lDecisions = new ExtractionReassignmentDecision[1];
      lDecision = new ExtractionReassignmentDecision();
      lDecision.setProjectID(reassignProject.getID());
      lDecision.setReassignUserID(projectReassignUserID);
      lDecision.setReassignType(userType.getUserTypeLeader());
      lDecisions[0] = lDecision;
      repository.projectReassignUsers(authToken, lProject, lDecisions);
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createProject(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName("Project "+Calendar.getInstance().getTimeInMillis());
    lProject.setDepartmentID(50000); // a department with id 50000 must
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}

26.2.14 ユースケース: プロジェクトとアセット用に指定された値の読込み

説明

プロジェクトとアセット用に値を指定された詳細情報を読み込みます。

サンプル・コード

例26-16 ユースケース: プロジェクトとアセット用に指定された値の読込み

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Answer;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Choice;
import com.flashline.registry.openapi.entity.ChoiceList;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.ExtractionDownload;
import com.flashline.registry.openapi.entity.ProjectAssetValue;
import com.flashline.registry.openapi.entity.Question;
import com.flashline.registry.openapi.entity.SurveyTaken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ReadValueProvidedForProjectAndAsset {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // Read the value provided for a project and asset
      long projectid = 50000; // the id of the project
      long assetid = 569; // the id of the asset
      // -----------------------------------
      // Make sure the project has an extraction
      long[] lAssetIDs = { assetid };
      ExtractionDownload[] extractionDownload =
 repository.extractionCreate(authToken, projectid, lAssetIDs);
      Extraction extraction =
 repository.extractionReadByProjectAndAsset(authToken, projectid, assetid);
      // -----------------------------------
      // take survey and update
      SurveyTaken surveyTaken = takeSurvey(repository, authToken, extraction);
      surveyTaken = repository.surveyTakenUpdate(authToken, surveyTaken);
      extraction = repository.extractionUpdateSurvey(authToken, extraction,
 surveyTaken);
      // -----------------------------------
      // read project asset values
      ProjectAssetValue[] projectAssetValues = repository
          .projectAssetValueRead(authToken, projectid, assetid);
      if (projectAssetValues != null) {
        for (int i = 0; i < projectAssetValues.length; i++) {
          ProjectAssetValue projectAssetValue = projectAssetValues[i];
          projectAssetValue.getUserInfo().getUserName();
          projectAssetValue.getExtractionDate();
          projectAssetValue.getExtractionStatus();
          projectAssetValue.getPredictedValue();
          projectAssetValue.isPredictedValueSelected();
          projectAssetValue.getConsumerFoundValue();
          projectAssetValue.getConsumerUsage();
          projectAssetValue.getConsumerValue();
          projectAssetValue.isConsumerValueSelected();
          projectAssetValue.getProjectLeadUsage();
          projectAssetValue.getProjectLeadValue();
          projectAssetValue.isProjectLeadValueSelected();
          projectAssetValue.getAssetUsage();
          projectAssetValue.getAssetValue();
          projectAssetValue.getAssetValueSource();
        }
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static SurveyTaken takeSurvey(FlashlineRegistry repository, AuthToken
 authToken, Extraction extraction)
      throws OpenAPIException, RemoteException {
    // -----------------------------------
    // take survey
    SurveyTaken surveyTaken = repository.surveyTakenRead(authToken, extraction);
    Question[] questions = repository.surveyReadQuestions(authToken);
    ChoiceList choiceList = null;
    Choice[] choices = null;
    Answer[] answers = new Answer[4];
    for(int i=0; i<answers.length; i++){
      answers[i] = new Answer();
    }
    // -----------------------------------
    //Sort questions
    Question[] sortedQuestions = new Question[4];
    for (int i=0;i<questions.length;i++) {
      if (questions[i].getId()==100) {
        sortedQuestions[0] = questions[i];
      }
      if (questions[i].getId()==101) {
        sortedQuestions[1] = questions[i];
      }
      if (questions[i].getId()==102) {
        sortedQuestions[2] = questions[i];
      }
      if (questions[i].getId()==103) {
        sortedQuestions[3] = questions[i];
      }
    }
    answers[0].setQuestionId(sortedQuestions[0].getId());
    choiceList = sortedQuestions[0].getChoiceList();
    choices = choiceList.getChoices();
    answers[0].setChoiceId(choices[0].getId());
    answers[0].setValue(choices[0].getValue());
    answers[1].setQuestionId(sortedQuestions[1].getId());
    answers[1].setChoiceId(0);
    answers[1].setValue("100");
    answers[2].setQuestionId(sortedQuestions[2].getId());
    answers[2].setChoiceId(0);
    answers[2].setValue("200");
    answers[3].setQuestionId(sortedQuestions[3].getId());
    choiceList = sortedQuestions[3].getChoiceList();
    choices = choiceList.getChoices();
    answers[3].setChoiceId(choices[3].getId());
    answers[3].setValue(choices[3].getValue());
    surveyTaken.setAnswers(answers);
    return surveyTaken;
  }
}

26.2.15 ユースケース: プロジェクトとアセット用に指定された値の更新 - 予測値の使用

説明

予測値を使用して、プロジェクトとアセット用に指定された値を更新します。

サンプル・コード

例26-17 ユースケース: プロジェクトとアセット用に指定された値の更新 - 予測値の使用

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Answer;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Choice;
import com.flashline.registry.openapi.entity.ChoiceList;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.ExtractionDownload;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectAssetValue;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.Question;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.entity.SurveyTaken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateValueProvidedForProjectAndUserWithPredictedValue {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(
          pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1], pArgs[2]);
      // -----------------------------------
      // Update the value provided for a project and asset - use predicted value
      long userid = repository.userReadByAuthToken(authToken).getID(); // the id
 of the user
      long projectid = 50000; // the id of the project
      long assetid = 569; // the id of the asset
      repository.testExtractionResetDatabaseForProject(projectid); // for sample
 *only*
      Project lProject = repository.projectRead(authToken, projectid);
      // -----------------------------------
      // if no user id exists, create a user
      if (userid==0) {
        userid = createUser(repository, authToken).getID();
      }
      ProjectEntities lProjectEntities = new ProjectEntities();
      lProjectEntities.setAddedLeaderIDs(new String[]{ ""+userid });
      repository.projectUpdate(authToken, lProject, lProjectEntities);
      // -----------------------------------
      // Get a RegistryUser for a user
      RegistryUser user = repository.userRead(authToken, userid);
      // -----------------------------------
      // Make sure the project has an extraction
      long[] lAssetIDs = { assetid };
      ExtractionDownload[] extractionDownload =
 repository.extractionCreate(authToken, projectid, lAssetIDs);
      Extraction extraction =
 repository.extractionReadByProjectAndAsset(authToken, projectid, assetid);
      // -----------------------------------
      // take survey
      SurveyTaken surveyTaken = repository.surveyTakenRead(authToken, extraction);
      Question[] questions = repository.surveyReadQuestions(authToken);
      ChoiceList choiceList = null;
      Choice[] choices = null;
      Answer[] answers = new Answer[4];
      for(int i=0; i<answers.length; i++){
        answers[i] = new Answer();
      }
      // -----------------------------------
      //Sort questions
      Question[] sortedQuestions = new Question[4];
      for (int i=0;i<questions.length;i++) {
        if (questions[i].getId()==100) {
          sortedQuestions[0] = questions[i];
        }
        if (questions[i].getId()==101) {
          sortedQuestions[1] = questions[i];
        }
        if (questions[i].getId()==102) {
          sortedQuestions[2] = questions[i];
        }
        if (questions[i].getId()==103) {
          sortedQuestions[3] = questions[i];
        }
      }
      answers[0].setQuestionId(sortedQuestions[0].getId());
      choiceList = sortedQuestions[0].getChoiceList();
      choices = choiceList.getChoices();
      answers[0].setChoiceId(choices[0].getId());
      answers[0].setValue(choices[0].getValue());
      answers[1].setQuestionId(sortedQuestions[1].getId());
      answers[1].setChoiceId(0);
      answers[1].setValue("100");
      answers[2].setQuestionId(sortedQuestions[2].getId());
      answers[2].setChoiceId(0);
      answers[2].setValue("200");
      answers[3].setQuestionId(sortedQuestions[3].getId());
      choiceList = sortedQuestions[3].getChoiceList();
      choices = choiceList.getChoices();
      answers[3].setChoiceId(choices[3].getId());
      answers[3].setValue(choices[3].getValue());
      surveyTaken.setAnswers(answers);
      // -----------------------------------
      // update survey
      surveyTaken = repository.surveyTakenUpdate(authToken, surveyTaken);
      extraction = repository.extractionUpdateSurvey(authToken, extraction,
 surveyTaken);
      // -----------------------------------
      // Get a ProjectAssetValue for a project asset and user.
      ProjectAssetValue projectAssetValue = repository
          .projectAssetValueReadForUser(authToken, projectid, assetid, user);
      if (projectAssetValue != null) {
        // -----------------------------------
        // update the project asset value
        projectAssetValue = repository.projectAssetValueUpdate(
            authToken, projectAssetValue, "predicted_selected");
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}

26.2.16 ユースケース: プロジェクトとアセット用に指定された値の更新 - 使用者の値の使用

説明

使用者の値を使用して、プロジェクトとアセット用に指定された値を更新します。

サンプル・コード

例26-18 ユースケース: プロジェクトとアセット用に指定された値の更新 - 使用者の値の使用

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Answer;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Choice;
import com.flashline.registry.openapi.entity.ChoiceList;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.ExtractionDownload;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectAssetValue;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.Question;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.entity.SurveyTaken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateValueProvidedForProjectAndUserWithConsumerValue {
  public static void main(String[] pArgs) {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(
          pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1], pArgs[2]);
      // -----------------------------------
      // Update the value-provided for a project and asset - use consumer value
      long userID = repository.userReadByAuthToken(authToken).getID(); // ID of
 the user being read
      long projectID = 50000; // ID of project being updated
      long assetID = 569; // ID of asset
      repository.testExtractionResetDatabaseForProject(projectID); // for sample
 *only*
      Project lProject = repository.projectRead(authToken, projectID);
      // -----------------------------------
      // if no user id exists, create a user
      if (userID==0) {
        userID = createUser(repository, authToken).getID();
      }
      ProjectEntities lProjectEntities = new ProjectEntities();
      lProjectEntities.setAddedLeaderIDs(new String[]{ ""+userID });
      repository.projectUpdate(authToken, lProject, lProjectEntities);
      // -----------------------------------
      // Get the user
      RegistryUser user = repository.userRead(authToken, userID);
      // -----------------------------------
      // Make sure the project has an extraction
      long[] lAssetIDs = { assetID };
      ExtractionDownload[] extractionDownload =
 repository.extractionCreate(authToken, projectID, lAssetIDs);
      Extraction extraction =
 repository.extractionReadByProjectAndAsset(authToken, projectID, assetID);
      // -----------------------------------
      // take survey
      SurveyTaken surveyTaken = repository.surveyTakenRead(authToken, extraction);
      Question[] questions = repository.surveyReadQuestions(authToken);
      ChoiceList choiceList = null;
      Choice[] choices = null;
      Answer[] answers = new Answer[4];
      for(int i=0; i<answers.length; i++){
        answers[i] = new Answer();
      }
      // -----------------------------------
      //Sort questions
      Question[] sortedQuestions = new Question[4];
      for (int i=0;i<questions.length;i++) {
        if (questions[i].getId()==100) {
          sortedQuestions[0] = questions[i];
        }
        if (questions[i].getId()==101) {
          sortedQuestions[1] = questions[i];
        }
        if (questions[i].getId()==102) {
          sortedQuestions[2] = questions[i];
        }
        if (questions[i].getId()==103) {
          sortedQuestions[3] = questions[i];
        }
      }
      answers[0].setQuestionId(sortedQuestions[0].getId());
      choiceList = sortedQuestions[0].getChoiceList();
      choices = choiceList.getChoices();
      answers[0].setChoiceId(choices[0].getId());
      answers[0].setValue(choices[0].getValue());
      answers[1].setQuestionId(sortedQuestions[1].getId());
      answers[1].setChoiceId(0);
      answers[1].setValue("100");
      answers[2].setQuestionId(sortedQuestions[2].getId());
      answers[2].setChoiceId(0);
      answers[2].setValue("200");
      answers[3].setQuestionId(sortedQuestions[3].getId());
      choiceList = sortedQuestions[3].getChoiceList();
      choices = choiceList.getChoices();
      answers[3].setChoiceId(choices[3].getId());
      answers[3].setValue(choices[3].getValue());
      surveyTaken.setAnswers(answers);
      // -----------------------------------
      // update survey
      surveyTaken = repository.surveyTakenUpdate(authToken, surveyTaken);
      extraction = repository.extractionUpdateSurvey(authToken, extraction,
 surveyTaken);
      // -----------------------------------
      // Get a ProjectAssetValue for a project asset and user.
      ProjectAssetValue projectAssetValue = repository
          .projectAssetValueReadForUser(authToken, projectID, assetID, user);
      if (projectAssetValue != null) {
        // If a ProjectAssetValue does not exist for this project, asset, and
        // user combination a null value is returned.
        ProjectAssetValue projectAssetValueSelection = new ProjectAssetValue();
        projectAssetValue = repository.projectAssetValueUpdate(
            authToken, projectAssetValue, "consumer_selected");
      }
    } catch (OpenAPIException oapie) {
      System.out.println("ServerCode = " + oapie.getServerErrorCode());
      System.out.println("Message    = " + oapie.getMessage());
      System.out.println("StackTrace:");
      oapie.printStackTrace();
    } catch (RemoteException re) {
      re.printStackTrace();
    } catch (ServiceException se) {
      se.printStackTrace();
    } catch (MalformedURLException mue) {
      mue.printStackTrace();
    }
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}

26.2.17 ユースケース: プロジェクトとアセット用に指定された値の更新 - プロジェクト・リーダーの値の使用

説明

プロジェクト・リーダーの値を使用して、プロジェクトとアセット用に指定された値を更新します。

サンプル・コード

例26-19 ユースケース: プロジェクトとアセット用に指定された値の更新 - プロジェクト・リーダーの値の使用

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Answer;
import com.flashline.registry.openapi.entity.AssetUsageType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Choice;
import com.flashline.registry.openapi.entity.ChoiceList;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.ExtractionDownload;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectAssetValue;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.Question;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.entity.SurveyTaken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateValueProvidedForProjectAndUserWithLeadValue {
  public static void main(String[] pArgs) {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(
          pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1], pArgs[2]);
      // -----------------------------------
      // Update the value provided for a project and asset - use project lead
 value
      long userID = repository.userReadByAuthToken(authToken).getID(); // ID of
 the user being read
      long projectID = 50000; // ID of project being updated
      long assetID = 569; // ID of asset
      float newValue = 50.0f; // Project asset value
      repository.testExtractionResetDatabaseForProject(projectID); // for sample
 *only*
      Project lProject = repository.projectRead(authToken, projectID);
      // -----------------------------------
      // if no user id exists, create a user
      if (userID==0) {
        userID = createUser(repository, authToken).getID();
      }
      ProjectEntities lProjectEntities = new ProjectEntities();
      lProjectEntities.setAddedLeaderIDs(new String[]{ ""+userID });
      repository.projectUpdate(authToken, lProject, lProjectEntities);
      // -----------------------------------
      // Get a RegistryUser for a user.
      RegistryUser user = repository.userRead(authToken, userID);
      // -----------------------------------
      // Make sure the project has an extraction
      long[] lAssetIDs = { assetID };
      ExtractionDownload[] extractionDownload =
 repository.extractionCreate(authToken, projectID, lAssetIDs);
      Extraction extraction =
 repository.extractionReadByProjectAndAsset(authToken, projectID, assetID);
      // -----------------------------------
      // take survey
      SurveyTaken surveyTaken = repository.surveyTakenRead(authToken, extraction);
      Question[] questions = repository.surveyReadQuestions(authToken);
      ChoiceList choiceList = null;
      Choice[] choices = null;
      Answer[] answers = new Answer[4];
      for(int i=0; i<answers.length; i++){
        answers[i] = new Answer();
      }
      // -----------------------------------
      //Sort questions
      Question[] sortedQuestions = new Question[4];
      for (int i=0;i<questions.length;i++) {
        if (questions[i].getId()==100) {
          sortedQuestions[0] = questions[i];
        }
        if (questions[i].getId()==101) {
          sortedQuestions[1] = questions[i];
        }
        if (questions[i].getId()==102) {
          sortedQuestions[2] = questions[i];
        }
        if (questions[i].getId()==103) {
          sortedQuestions[3] = questions[i];
        }
      }
      answers[0].setQuestionId(sortedQuestions[0].getId());
      choiceList = sortedQuestions[0].getChoiceList();
      choices = choiceList.getChoices();
      answers[0].setChoiceId(choices[0].getId());
      answers[0].setValue(choices[0].getValue());
      answers[1].setQuestionId(sortedQuestions[1].getId());
      answers[1].setChoiceId(0);
      answers[1].setValue("100");
      answers[2].setQuestionId(sortedQuestions[2].getId());
      answers[2].setChoiceId(0);
      answers[2].setValue("200");
      answers[3].setQuestionId(sortedQuestions[3].getId());
      choiceList = sortedQuestions[3].getChoiceList();
      choices = choiceList.getChoices();
      answers[3].setChoiceId(choices[3].getId());
      answers[3].setValue(choices[3].getValue());
      surveyTaken.setAnswers(answers);
      // -----------------------------------
      // update survey
      surveyTaken = repository.surveyTakenUpdate(authToken, surveyTaken);
      extraction = repository.extractionUpdateSurvey(authToken, extraction,
 surveyTaken);
      // -----------------------------------
      // Get a ~ProjectAssetValue for a project asset and user.
      ProjectAssetValue projectAssetValue = repository
          .projectAssetValueReadForUser(authToken, projectID, assetID, user);
      if (projectAssetValue != null) {
        // A null value is returned if no If a ProjectAssetValue does not exists
        // for this project, asset, and user combination.
        // -----------------------------------
        // Get an ~AssetUsageType array.
        AssetUsageType[] usageTypes = repository
            .projectAssetValueReadTypes(authToken);
        projectAssetValue.setProjectLeadUsage(usageTypes[1].getName()); 
// Set the projectAssetValue to a AssetUsageType value.
        projectAssetValue.setProjectLeadValue(newValue); // Set to a new value.
        ProjectAssetValue projectAssetValueSelection = new ProjectAssetValue();
        projectAssetValue = repository.projectAssetValueUpdate(
            authToken, projectAssetValue, "predicted_selected");
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}