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

前
 
次
 

17 アセット・タイプAPI

この章では、アセット・タイプAPIのユースケースについて説明します。このユースケースで、リポジトリへの新しいタイプの追加、新しいコンプライアンス・テンプレートのタイプの作成、タイプの特定、アセット・タイプで使用できるタブのリストの取得、およびOracle Enterprise Repository内でのすべてのアセット・タイプのタブの取得を行う方法について解説します。

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

17.1 概要

タイプ(アセット・タイプおよびコンプライアンス・テンプレート)では、アセットの構造を定義します。タイプは、主に2つの部分から構成されます。

タイプを作成または編集する場合、許容値リストとカテゴリ分けタイプはメタデータ要素として使用します。これらのメタデータ要素は、タイプのエディタおよびビューアXMLで、ID別に参照します。アセットを作成または編集する場合、タイプはアセット(Asset.GetCustomData())のカスタム・データで使用されるメタデータ要素を定義します。


注意:

  • この項のコード例ではアセット・タイプを参照していますが、ユースケースで記述されたプロセスがアセット・タイプとコンプライアンス・テンプレートの両方を作成するために使用されることに注意してください。コンプライアンス・テンプレートの詳細は、Oracle Fusion Middleware Oracle Enterprise Repository構成ガイドを参照してください。

  • エディタおよびビューアのメタデータは、CDATAをエスケープしたXMLとして表現されます。したがって、多数のアセット・タイプがassetTypeQueryのコールで返される場合、一部のXMLパーサーがエンティティの拡張の制限を超える可能性があります。一般的なパーサーでは、デフォルトのエンティティ拡張の制限が64,000に設定されているものがあります。この制限を超えた場合、コマンドライン・パラメータ(entityExpansionLimit)を渡して、この制限値をJAXP準拠のプロセッサ上で増加できます。たとえば、JVMに次のパラメータを渡すと、エンティティ拡張の制限が5MBに増加します。

    java -DentityExpansionLimit=5242880 com.example.MyApp


17.2 ユースケース

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

17.2.1 ユースケース: 新しいタイプの作成および編集

説明

新しいタイプをリポジトリに追加します。

サンプル・コード

例17-1 ユースケース: 新しいタイプの作成および編集

package com.flashline.sample.assettypeapi;
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.AssetType;
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 CreateNewAssetType {
  public static void main(String pArgs[]) throws RemoteException,
 OpenAPIException,
      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]);
      // //////////////////////////////
      // Select an existing Type on which to base the new one
      // //////////////////////////////
      String newAssetTypeName = "My AssetType";
      long baseAssetTypeID = 151;
      AssetType newAssetType = repository.assetTypeCreateClone(
          authToken, baseAssetTypeID, newAssetTypeName);
      System.out.println("The new Asset Type id =\"" + newAssetType.getID()
          + "\"");
      // //////////////////////////////
      // Manipulate xml strings
      // //////////////////////////////
      String lEditorXML = newAssetType.getEditorXML();
      String lViewerXML = newAssetType.getViewerXML();
      // Perform XML manipulation on the editor and viewer definitions...
      // //////////////////////////////
      // Set the new editor/viewer definitions on the asset type, and save the
      // type back to OER
      // //////////////////////////////
      newAssetType.setEditorXML(lEditorXML);
      newAssetType.setViewerXML(lViewerXML);
      repository.assetTypeUpdate(authToken, newAssetType);
      // ----------------------------------------
      // clean up sample
      repository.assetTypeDelete(authToken, newAssetType.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();
    }
  }
}

17.2.2 ユースケース: コンプライアンス・テンプレート・タイプの作成

説明

新しいコンプライアンス・テンプレートをリポジトリに追加します。

サンプル・コード

例17-2 ユースケース: コンプライアンス・テンプレート・タイプの作成

package com.flashline.sample.assettypeapi;
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.AssetType;
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 CreateNewComplianceTemplateType {
  public static void main(String pArgs[]) throws RemoteException,
 OpenAPIException,
      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]);
      // //////////////////////////////
      // Create a new compliance template.
      // //////////////////////////////
      String newAssetTypeName = "My Compliance
 Template"+Calendar.getInstance().getTimeInMillis();
      AssetType newAssetType = repository
          .assetTypeCreateComplianceTemplate(authToken, newAssetTypeName);
    } 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();
    }
  }
}

17.2.3 ユースケース: タイプの検索

説明

リポジトリ内でタイプを検索します。

サンプル・コード

例17-3 ユースケース: タイプの検索

package com.flashline.sample.assettypeapi;
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.AssetType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.AssetTypeCriteria;
import com.flashline.registry.openapi.query.SearchTerm;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class FindAssetType {
  public static void main(String pArgs[]) throws RemoteException,
 OpenAPIException,
      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]);
      // //////////////////////////////
      // Create SearchTerms and set them on the AssetSearchCriteria
      // //////////////////////////////
      AssetTypeCriteria assetTypeCriteria = new AssetTypeCriteria();
      SearchTerm[] searchTerms = new SearchTerm[1];
      searchTerms[0] = new SearchTerm();
      searchTerms[0].setKey("name");
      searchTerms[0].setValue("Component");
      assetTypeCriteria.setSearchTerms(searchTerms);
      // //////////////////////////////
      // Perform the search using the specified criteria
      // //////////////////////////////
      AssetType[] assetTypes = repository.assetTypeQuery(authToken,
          assetTypeCriteria);
    } 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();
    }
  }
}

回避するメソッド:

  • setIcon

  • setID

17.2.4 ユースケース: アセット・タイプのタブの取得

説明

アセット・タイプに使用できるタブ・リストを取得します。

サンプル・コード

例17-4 ユースケース: アセット・タイプのタブ・リストの取得

package com.flashline.sample.assettypeapi;
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.TabTypeBean;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ReadTabTypes {
  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);
      TabTypeBean[] lTabTypeBeans = null;
      ///////////////////////////////////
      // Login to OER
      ///////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      ///////////////////////////////////
      // read the tab types of an assettype
      ///////////////////////////////////
      lTabTypeBeans = repository.assetTypeTabsRead(authToken, 100);
    } 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();
    }
  }
}

17.2.5 ユースケース: すべてのアセット・タイプのタブの取得

説明

Oracle Enterprise Repository内のすべてのアセット・タイプのタブを取得します。

サンプル・コード

例17-5 ユースケース: すべてのアセット・タイプのタブの取得

package com.flashline.sample.assettypeapi;
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.TabTypeBean;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ReadTabTypes {
  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);
      TabTypeBean[] lTabTypeBeans = null;
      ///////////////////////////////////
      // Login to OER
      ///////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      ///////////////////////////////////
      // read the tab types of an assettype
      ///////////////////////////////////
      lTabTypeBeans = repository.assetTypeTabsRead(authToken, 100);
    } 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();
    }
  }
}

RelationshipTypeQueryの例

try
{
   RelationshipTypeCriteria rCriteria = new RelationshipTypeCriteria();
   RelationshipType[] allRelationshipTypes =
 FlashlineRegistry.relationshipQuery(lAuthToken, rCriteria);
}
catch (OpenAPIException e)
{
     e.printStackTrace();
}
catch (RemoteException re)
{
    re.printStackTrace();
}