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

前
 
次
 

22 抽出API

この章では、抽出APIのユースケースについて説明します。このユースケースで、Oracle Enterprise Repositoryにおいて、アセットの抽出、抽出の読込み、抽出の更新を行う方法について解説します。

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

22.1 概要

「使用-ダウンロード」(抽出)プロセスの一部として、ユーザーは選択したアセットを特定のプロジェクトに関連付けるように要求されます。これらの使用状況のインスタンスは、調査(使用状況の更新に含まれます)とともに、Oracle Enterprise Repository内のメトリックの主要なドライバです。


注意:

以前の製品リリースでは、抽出という用語は、アセットのペイロードのダウンロードやアクセスなどの行為を説明するために使用されていました。その後、抽出という用語は使用 - ダウンロードという語句に置き換わりました。ただし、抽出APIのドキュメントのコンテキスト内で、抽出という用語の使用例(特にコード例)の多くは、REX APIの使用を単純化するためにそのままになっていることに注意してください。


定義

関連するサブシステム

22.2 ユースケース

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

22.2.1 ユースケース: アセットの抽出

説明

抽出は、ユーザーがアセットをプロジェクトで使用するために関連付けると作成されます。このプロセス中に、関連しているアセットのリストも抽出用に使用可能になります。この場合、ユーザーは、プライマリ・アセットと関連アセットの両方を同時に抽出できます。各アセットに一意の抽出が記録されます。抽出を作成すると、0からn個の抽出ダウンロードを含む配列が作成されます。各ダウンロードのファイル情報の値は、0から1です。ファイル情報にはファイルに関する基本情報が含まれます。この情報は、ファイルへのリンクを作成するために使用します。

アセットを抽出するには、次の条件を満たす必要があります。

  • ユーザーは、アセットが抽出されるプロジェクトのメンバーである必要があります。

  • ユーザーは、適切なロール・タイプに割り当てられている必要があります。

  • プロジェクトは、オープンである必要があります。

  • アセットは、登録済でアクティブである必要があります。

  • 「カスタム・アクセス設定」が有効になっている場合、抽出を実行するユーザーは、指定したアセットに対して適切なアクセス権を持っている必要があります。

  • 「カスタム・アクセス設定」が有効になっている場合、抽出を実行するユーザーは、適切な権限を持っているファイルに対してのみファイル情報を受け取ります。

  • これらの条件は、使用される適切なメソッドでチェックされます。条件を満たさない場合、例外がスローされます。

サンプル・コード

例22-1 ユースケース: アセットの抽出

package com.flashline.sample.extractionapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
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.ExtractionDownload;
import com.flashline.registry.openapi.entity.FileInfo;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ExtractAsset {
  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 ASSET_ID_1 = 589;     // must be a valid asset id in OER
      long ASSET_ID_2 = 569;     // must be a valid asset id in OER
      long PROJECT_ID = 50000;   // must be a valid project id in OER
      long EXTRACTION_ID = 0;
      // ----------------------------------------
      // Create a new extraction
      long[] lAssetIDs = { ASSET_ID_1, ASSET_ID_2 };
      ExtractionDownload[] extractionDownloads =
 repository.extractionCreate(authToken, PROJECT_ID, lAssetIDs);
      System.out.println("Number of new extraction downloads created: " +
 extractionDownloads.length);
      // ----------------------------------------
      // Read an extraction by project and asset
      Extraction extraction =
 repository.extractionReadByProjectAndAsset(authToken, PROJECT_ID, ASSET_ID_1);
      EXTRACTION_ID = extraction.getID();
      // ----------------------------------------
      // Read an extraction by ID
      Extraction extractionByID = repository.extractionRead(authToken, EXTRACTION
_ID);
      System.out.println("The extraction '"+extractionByID.getDisplayName()+"' was
 read by id ("+EXTRACTION_ID+")");
      // ----------------------------------------
      // Read asset extractions
      Extraction[] assetExtractions =
 repository.extractionReadAssetExtractions(authToken, PROJECT_ID, ASSET_ID_1,
 true);
      System.out.println("The number of extractions for this asset is:
 "+(assetExtractions==null ? 0 : assetExtractions.length));
      // ----------------------------------------
      // Read project extractions
      Extraction[] projectExtractions =
 repository.extractionReadProjectExtractions(authToken, PROJECT_ID, true);
      System.out.println("The number of extractions for this project is:
 "+(projectExtractions==null ? 0 : projectExtractions.length));
      // ----------------------------------------
      // Read related assets
      Asset[] relatedAssets = repository.extractionReadRelatedAssets(authToken,
 ASSET_ID_2);
      System.out.println("The number of related assets is: "+relatedAssets==null ?
 0 : relatedAssets.length);
      // ----------------------------------------
      // Read File-Info for an extraction
      List fileInfosList = new ArrayList();
      if (projectExtractions != null) {
        for (int i = 0; i < projectExtractions.length; i++) {
          extraction = repository.extractionRead(authToken,
 projectExtractions[i].getID());
          fileInfosList.add(repository.extractionReadFileInfos(authToken,
 extraction));
        }
      }
      // ----------------------------------------
      // Get File
      List fileInfoList = new ArrayList();
      Iterator fileInfosListIter = fileInfosList.iterator();
      while (fileInfosListIter.hasNext()) {
        FileInfo[] fileInfos = (FileInfo[]) fileInfosListIter.next();
        for (int i = 0; i < fileInfos.length; i++) {
          fileInfoList.add(fileInfos[i]);
        }
      }
      String[] fileLinks = new String[fileInfoList.size()];
      for (int i = 0; i < fileInfoList.size(); i++) {
        FileInfo fileInfo = (FileInfo) fileInfoList.get(i);
        fileLinks[i] = repository.repositoryFileTranslator(authToken, fileInfo);
        System.out.println("Project extraction file-info link: "+fileLinks[i]);
      }
      // -----------------------------------
      // 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();
    }
  }
}

FileInfoオブジェクトについての注意

FileInfoオブジェクトは、抽出したアセットに関連付けられた個々のファイルを示します。ファイルの物理的な場所は、次の2つのメソッドで取得できます。

  1. FileInfoオブジェクトのdownloadURIプロパティ(fileInfo.getDownloadURI()など)を使用します。

  2. FileInfoオブジェクトを渡す、OpenAPIメソッドのrepositoryFileTranslator(flashlineRegistry.repositoryFileTranslator(authToken, fileInfo)など)を使用します。


    注意:

    Oracle Enterprise Repository固有のパスを示す、FileInfoオブジェクトのURIプロパティを使用しないでください。


22.2.2 ユースケース: 抽出の読込み

説明

アセットの抽出のユースケースで説明されたメソッド以外のメソッドを使用して、抽出を読み込みます。抽出は、アセット、プロジェクトまたはユーザーでグループ化できます。抽出のグループ化によって使用するメソッドが決定されます。

抽出を読み込むには、次の条件を満たす必要があります。

  • プロジェクトは、オープンである必要があります。

  • アセットは、登録済でアクティブである必要があります。

  • 抽出は、アクティブである必要があります。

これらの条件は、使用される適切なメソッドでチェックされます。条件を満たさない場合、例外がスローされます。

サンプル・コード

例22-2 ユースケース: 抽出の読込み

package com.flashline.sample.extractionapi;
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.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ExtractRead {
  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 PROJECT_ID = 50000; // must be a valid project id in the OER
      long ASSET_ID = 569;    // must be a valid asset id in the OER
      // ----------------------------------------
      // Read project extractions
      Extraction[] projectExtractions = repository
          .extractionReadProjectExtractions(authToken, PROJECT_ID, true);
      // ----------------------------------------
      // Read asset extractions
      Extraction[] assetExtractions = repository
          .extractionReadAssetExtractions(authToken, PROJECT_ID, ASSET_ID, true);
      // ----------------------------------------
      // Read user extractions
      Extraction[] userExtractions = repository
          .extractionReadUserExtractions(authToken, true);
      // ----------------------------------------
      // Read related assets
      Asset[] assets = repository.extractionReadRelatedAssets(authToken,
          ASSET_ID);
    } 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();
    }
  }
}

22.2.3 ユースケース: 抽出の更新

説明

抽出レコードは、アセットの状態が変更されたか、アセットの使用者がアセットの調査を終了したときに更新されます。状態の変更と調査の完了は別のトランザクションにできます。また、一緒に行うこともできます。

抽出を更新するには、次の条件を満たす必要があります。

  • プロジェクトは、オープンである必要があります。

  • アセットは、登録済でアクティブである必要があります。

  • 抽出は、アクティブである必要があります。

  • 実行した調査は、アクティブである必要があります。

これらの条件は、使用される適切なメソッドでチェックされます。条件を満たさない場合、例外がスローされます。

サンプル・コード

例22-3 ユースケース: 抽出の更新

package com.flashline.sample.extractionapi;
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.Categorization;
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.IExtraction;
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 ExtractUpdate {
  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 PROJECT_ID = 50000; // must be a valid project id in the OER
      long ASSET_ID = 569; // must be a valid asset id in the OER
      // ----------------------------------------
      // Create a new extraction
      long[] lAssetIDs = { ASSET_ID };
      ExtractionDownload[] extractionDownloads =
 repository.extractionCreate(authToken, PROJECT_ID, lAssetIDs);
      Extraction[] assetExtractions = repository
          .extractionReadAssetExtractions(authToken, PROJECT_ID, ASSET_ID, true);
      ///////////////////////////////////////////////////////////////////////////
      // this assumes that there is at least 1 extraction and the first one is
      // used
      ///////////////////////////////////////////////////////////////////////////
      IExtraction iExtraction = repository
          .extractionReadExtractionStates(authToken);
      Extraction extraction = repository.extractionRead(authToken,
          assetExtractions[0].getID());
      ///////////////////////////////////////////////////////////////////////////
      // can set the status of the extraction to 'Deployed', 'Rejected', or 'In
      // Process'.
      ///////////////////////////////////////////////////////////////////////////
      assetExtractions[0].setStatus("In Process");
      extraction = repository.extractionTentativelyAccept(authToken,
          extraction);
      SurveyTaken surveyTaken = repository.surveyTakenRead(authToken,
          extraction);
      extraction = repository.extractionUpdateSurvey(authToken,
          extraction, surveyTaken);
      extraction.setStatus(iExtraction.getInProcess());
      surveyTaken = repository.surveyTakenRead(authToken, extraction);
      extraction = repository.extractionUpdateSurvey(authToken,
          extraction, surveyTaken);
      Categorization[] rejectionReasons = repository
          .extractionReadRejectionReasons(authToken);
      surveyTaken = repository.surveyTakenRead(authToken, extraction);
      extraction = repository.extractionUpdateSurvey(authToken,
          extraction, 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();
      }
      answers[0].setQuestionId(questions[0].getId());
      choiceList = questions[0].getChoiceList();
      choices = choiceList.getChoices();
      answers[0].setChoiceId(choices[0].getId());
      answers[0].setValue(choices[0].getValue());
      answers[1].setQuestionId(questions[1].getId());
      answers[1].setChoiceId(0);
      answers[1].setValue("100");
      answers[2].setQuestionId(questions[2].getId());
      answers[2].setChoiceId(0);
      answers[2].setValue("200");
      answers[3].setQuestionId(questions[3].getId());
      choiceList = questions[3].getChoiceList();
      choices = choiceList.getChoices();
      answers[3].setChoiceId(choices[3].getId());
      answers[3].setValue(choices[3].getValue());
      surveyTaken.setAnswers(answers);
      surveyTaken = repository.surveyTakenUpdate(authToken, surveyTaken);
      // -----------------------------------
      // 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();
    }
  }
}

短所

状態の変更または調査の実行は2つの手順のプロセスであることに注意してください。最初の手順は、状態の変更または調査の実行です。2番目の手順は、extractionUpdateStatusメソッドを使用して抽出のステータスを更新することです。状態の変更と調査の実行は別のトランザクションにできます。また、一緒に行うこともできます。一緒に行う場合、extractionUpdateStatusメソッドを一度だけ呼び出す必要があります。

extractionUpdateStatusメソッドはSurveyTakenが必要です。extractionUpdateStatusメソッドが呼び出されたときに調査が実行されたかどうかに関係なく、これは必要です(状態の変更など)。surveyTakenReadメソッドを使用して、この調査を取得します。この抽出の調査が行われていない場合、surveyTakenReadメソッドによって作成されます。

Oracle Enterprise Repositoryで、現在の調査は4つの質問から構成されます。調査が実行されると、4つの質問に対する回答を格納する配列が作成されます。それぞれの調査には有効な3つの情報が含まれている必要があります。

  • 値(質問に対するユーザーの回答)

  • 質問ID

  • 選択ID

質問2と3は回答が1つの質問なので、常に選択IDは0に設定されています。質問1と4は複数の回答があります。複数の回答はsurveyReadChoiceListメソッドを使用して取得されます。

回避するメソッド:

次のオブジェクトは、抽出サブシステムおよび調査サブシステムで使用します。

  • Extraction

  • ExtractionDownload

  • FileInfo

  • SurveyTaken

  • Question

  • ChoiceList

  • Choice

  • Answer

これらのオブジェクト内でgetメソッドのいずれかを使用することが可能です。残りのすべてのメソッド(特にsetメソッド)の使用は避ける必要があります。残りのメソッドで発生したイベントは、抽出および調査サブシステムのメソッドで対応されています。