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

前
 
次
 

32 ベンダーAPI

この章では、ベンダーAPIのユースケースについて説明します。このユースケースで、Oracle Enterprise Repositoryにおいてベンダーの追加または割当てを行う方法について解説します。

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

32.1 概要

ベンダーはアセットの元のソースであり、アセットをサポートします。ベンダーは、単一の名前の文字列で識別されます。

検証: ベンダーを保存する場合、Oracle Enterprise Repositoryは、現在、次の内容を検証します。

関連するサブシステム

アセットとベンダー間には1対多の関係があります(たとえば、複数のアセットは同じベンダーにリンクできますが、1つのアセットは1つのベンダーしか持つことができません)。アセットを作成または編集する場合、ベンダーをアセットに関連付けるベンダーIDメタデータ要素を変更できます。

追加で必要なインポート

import com.flashline.registry.openapi.entity.Vendor;
import com.flashline.registry.openapi.query.VendorCriteria;

32.2 ユースケース

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

32.2.1 ユースケース: ベンダーの操作

説明

  • 新しいベンダーをOracle Enterprise Repositoryに追加します。

  • 既存のベンダーをアセットに割り当てます。

サンプル・コード

例32-1 ユースケース: ベンダーの追加または割当て

package com.flashline.sample.vendorapi;
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.Vendor;
import com.flashline.registry.openapi.query.VendorCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class Vendors {
  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]);
      // -----------------------------------------
      // Create a new vendor
      String newVendorName = "My Vendor";
      Vendor newVendor = repository.vendorCreate(authToken, newVendorName);
      System.out.println("The new vendor id =\"" + newVendor.getID() + "\"");
      // -----------------------------------------
      // Find a vendor and update an asset to use it
      VendorCriteria criteria = new VendorCriteria();
      criteria.setNameCriteria(newVendorName);
      Vendor[] vendors = repository.vendorQuery(authToken, criteria);
      long myVendorID = vendors[0].getID();
      long MY_ASSET_ID = 569;
      Asset myAsset = repository.assetRead(authToken, MY_ASSET_ID);
      // MY_ASSET_ID must be the asset id of an asset in the repository
      myAsset.setVendorID(myVendorID);
      repository.assetUpdate(authToken, myAsset);
      // ----------------------------------------
      // clean up
      myAsset.setVendorID(0);
      repository.vendorDelete(authToken, newVendor.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();
    }
  }
}