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

前
 
次
 

15 許容値リストAPI

この章では、許容値リストAPIのユースケースについて説明します。このユースケースで、新しい許容値リストを作成し、これをOracle Enterprise Repositoryに入力し、アセットの単一または複数の選択リストに許容値を移入する方法について解説します。

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

15.1 概要

許容値リストは、単一および複数の選択ドロップダウン・ボックスのメタデータ要素で使用します。

アセット・タイプを作成または編集する場合、許容値リストはメタデータ要素として使用します。これらのメタデータ要素は、アセット・タイプ/コンプライアンス・テンプレートのエディタおよびビューアXMLで、ID別に参照します。

アセットを作成または編集する場合、許容値リストに含まれる値は、特定のアセット・タイプ/コンプライアンス・テンプレート用に定義されたメタデータ要素のオプションとして使用します。許容値リストの許容値を使用するには、アセット(Asset.GetCustomData())のカスタム・データを変更して、許容値のIDを参照します。

15.2 ユースケース

この項では、許容値リストAPIを使用するユースケースについて説明します。内容は次のとおりです。

15.2.1 ユースケース: 許容値リストの作成および編集

説明

新しい許容値リストを作成し、これをOracle Enterprise Repositoryに入力します。

サンプル・コード

例15-1 ユースケース: 許容値リストの作成および編集

package com.flashline.sample.acceptablevaluelists;
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.AcceptableValue;
import com.flashline.registry.openapi.entity.AcceptableValueList;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateAndEditAcceptableValueList {
  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]);
      // //////////////////////////////
      // Build an array of acceptable values for the list.
      // //////////////////////////////
      String newAcceptableValueListName = "My AcceptableValueList
 "+Calendar.getInstance().getTimeInMillis();
      AcceptableValue[] acceptableValues = new AcceptableValue[3];
      acceptableValues[0] = new AcceptableValue();
      acceptableValues[0].setValue("My Value");
      acceptableValues[1] = new AcceptableValue();
      acceptableValues[1].setValue("My Next Value");
      acceptableValues[2] = new AcceptableValue();
      acceptableValues[2].setValue("My Last Value");
      // //////////////////////////////
      // Create the AcceptableValueList in Repository
      // //////////////////////////////
      AcceptableValueList newAcceptableValueList = repository
          .acceptableValueListCreate(authToken, newAcceptableValueListName,
              acceptableValues);
      System.out.println("The new acceptableValueList id  =\""
          + newAcceptableValueList.getID() + "\"");
    } 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();
    }
  }
}

15.2.2 ユースケース: 許容値リストの検索およびアセットでの使用

説明

アセットの単一または複数の選択リストに許容値を移入します。

サンプル・コード

例15-2 ユースケース: リストへの許容値の移入

package com.flashline.sample.acceptablevaluelists;
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.AcceptableValue;
import com.flashline.registry.openapi.entity.AcceptableValueList;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.AcceptableValueListCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class FindAcceptableValueListAndUseInAsset {
  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]);
      // //////////////////////////////
      // Find the AcceptableValueList
      // //////////////////////////////
      AcceptableValueListCriteria criteria = new AcceptableValueListCriteria();
      criteria.setNameCriteria("My AcceptableValueList");
      AcceptableValueList[] acceptableValueLists = repository
          .acceptableValueListQuery(authToken, criteria);
      AcceptableValueList myAcceptableValueList = acceptableValueLists[0];
      AcceptableValue[] acceptableValues = myAcceptableValueList
          .getAcceptableValues();
      // //////////////////////////////
      // Find one value within the AcceptableValueList
      // //////////////////////////////
      AcceptableValue myAcceptableValue = null;
      for (int i = 0; i < acceptableValues.length; i++) {
        if (acceptableValues[i].getValue().equals("My Value")) {
          myAcceptableValue = acceptableValues[i];
          break;
        }
      }
      long myAcceptableValueID = myAcceptableValue.getID();
      Asset myAsset = repository.assetRead(authToken, 561);
      String customData = myAsset.getCustomData();
      // //////////////////////////////
      // Modify customData to use myAcceptableValueID.
      // //////////////////////////////
      String modifiedCustomData = customData;
      // ...
      // //////////////////////////////
      // save modified custom data
      // //////////////////////////////
      myAsset.setCustomData(modifiedCustomData);
      repository.assetUpdate(authToken, myAsset);
    } 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();
    }
  }
}