Overview Use Cases Oracle Fusion Middleware Online Documentation Library

AcceptableValueLists API 14-3

14.2.2 Use Case: Find an Acceptable Value List and use it in an asset

Description Populate an assets single or multiple selection lists with acceptable values. Sample code is as follows: 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 mainString pArgs[] throws OpenAPIException, RemoteException, ServiceException { try { Connect to Oracle Enterprise Repository URL lURL = null; lURL = new URLpArgs[0]; FlashlineRegistry repository = new FlashlineRegistryServiceLocator .getFlashlineRegistrylURL; Authenticate with OER AuthToken authToken = repository.authTokenCreatepArgs[1], pArgs[2]; Find the AcceptableValueList AcceptableValueListCriteria criteria = new AcceptableValueListCriteria; criteria.setNameCriteriaMy AcceptableValueList; AcceptableValueList[] acceptableValueLists = repository .acceptableValueListQueryauthToken, 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.equalsMy Value { myAcceptableValue = acceptableValues[i]; break; } 14-4 Oracle Fusion Middleware Integration Guide for Oracle Enterprise Repository } long myAcceptableValueID = myAcceptableValue.getID; Asset myAsset = repository.assetReadauthToken, 561; String customData = myAsset.getCustomData; Modify customData to use myAcceptableValueID. String modifiedCustomData = customData; ... save modified custom data myAsset.setCustomDatamodifiedCustomData; repository.assetUpdateauthToken, myAsset; } catch OpenAPIException lEx { System.out.printlnServerCode = + lEx.getServerErrorCode; System.out.printlnMessage = + lEx.getMessage; System.out.printlnStackTrace:; lEx.printStackTrace; } catch RemoteException lEx { lEx.printStackTrace; } catch ServiceException lEx { lEx.printStackTrace; } catch MalformedURLException lEx { lEx.printStackTrace; } } } 15 Asset API 15-1 15 Asset API This chapter provides an overview of Asset API and describes the use cases using this API. This chapter contains the following sections: ■ Section 15.1, Overview