| Oracle® Fusion Middleware Oracle Enterprise Repository統合ガイド 11g リリース1 (11.1.1.7) B72433-02 |
|
![]() 前 |
![]() 次 |
この章では、アセット・タイプAPIのユースケースについて説明します。このユースケースで、リポジトリへの新しいタイプの追加、新しいコンプライアンス・テンプレートのタイプの作成、タイプの特定、アセット・タイプで使用できるタブのリストの取得、およびOracle Enterprise Repository内でのすべてのアセット・タイプのタブの取得を行う方法について解説します。
この章では、次の項目について説明します。
タイプ(アセット・タイプおよびコンプライアンス・テンプレート)では、アセットの構造を定義します。タイプは、主に2つの部分から構成されます。
エディタ
アセットのために格納されるメタデータを定義し、アセット・エディタでのメタデータ要素の編成方法を指定します。
ビューア
Oracle Enterprise Repositoryにおけるアセット詳細でのメタデータ要素の表示方法を定義します。
タイプを作成または編集する場合、許容値リストとカテゴリ分けタイプはメタデータ要素として使用します。これらのメタデータ要素は、タイプのエディタおよびビューアXMLで、ID別に参照します。アセットを作成または編集する場合、タイプはアセット(Asset.GetCustomData())のカスタム・データで使用されるメタデータ要素を定義します。
|
注意:
|
この項では、AssetType APIを使用するユースケースについて説明します。内容は次のとおりです。
説明
新しいタイプをリポジトリに追加します。
サンプル・コード
例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 ユースケース: コンプライアンス・テンプレート・タイプの作成
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-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-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();
}
}
}
説明
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();
}