Java 클라이언트 API를 사용하여 정책을 작성할 수 있습니다.
RAMSession ramSession = getPolicyContext().getRAMSession();
RAMAsset ramAsset = getPolicyContext().getRAMAsset();
여러 Rational® Asset Manager Java™ API 클래스를 사용하여 현재 자산을 업데이트할 수 있습니다. 예를 들어, 관계를 추가하거나 조치를 설정할 수 있습니다. 또한 API 클래스를 사용하여 자산, 자산 속성, 아티팩트에 대해 작업할 수 있습니다.
또한 Java API를 사용하여 정책을 실행 중인 자산 옆에 자산을 작성하거나 변경할 수도 있습니다. ram.client API를 사용하는 경우, 최고의 성능을 위해 자산 업데이트를 단일 세션으로 제한하십시오.
RAMSession session = getPolicyContext().getRAMSession();
RAMAsset currentAsset = this.getPolicyContext().getRAMAsset();
// Use the client APIs to make changes to the asset ...
// You can also modify or create other assets:
RAMAsset asset = session.createAsset("1.0");
asset.setName("Test Asset");
asset.setCommunity(session.getCommunity("Sample Application Development"));
asset.setAssetType(session.getAssetType("Business Solution"));
asset.setShortDescription("Test asset");
asset.setOwners(new RAMUser[] { session.getUser("admin") });
// Commit changes to the asset repository for the current asset:
session.putAsset(currentAsset);
// You can use queueAssetForPut and then putAssets to queue and then
// commit all assets you have changed in the session as one transaction:
session.queueAssetForPut(currentAsset);
// Commit changes to all assets you have changed in the session:
session.putAssets(new NullProgressMonitor());
Java 클라이언트 API에 대해서는 클라이언트 패키지와 공통 데이터 패키지를 참조하십시오.
추가 예제에 대해서는 이 주제의 예제 섹션과 Rational Asset Manager Java API 사용을 참조하십시오.
RAMAsset myAsset = getPolicyContext().getRAMAsset();
AssetAttribute myAttribute = myAsset.getAssetAttribute("Family Name");
String[] myAttrValue = myAttribute.getValues();
myAttribute = myAsset.getAssetAttribute("Work Item");
myAttrValue = myAttribute.getValues();
myAttribute = myAsset.getAssetAttribute("Requirement");
myAttrValue = myAttribute.getValues();
SearchQuery query = session.createAssetQuery(queryParam);
int offset = 0;
int maxResults = 100;
query.setResultsStartIndex(offset);
query.setMaxResults(maxResults);
SearchResult result = session.getAssets(query);
RAMAsset newAsset = session.createAsset("1.0");
newAsset.setName("The new related asset");
newAsset.setCommunity(session.getCommunity("Rational Asset Manager Development"));
newAsset.setAssetType(session.getAssetType("Specification"));
newAsset.setShortDescription("The Specification asset is required.");
AssetID id = new AssetID();
id.setGUID(newAsset.getId());
id.setVersion(newAsset.getVersion());
public Result test() { try {
// Create a query
String queryParam = null;
RAMSession session = getPolicyContext().getRAMSession();
SearchQuery query = session.createAssetQuery(queryParam);
int offset = 0;
int maxResults = 100;
query.setResultsStartIndex(offset);
query.setMaxResults(maxResults);
SearchResult result = session.getAssets(query);
if (result != null && result.getAssetSearchResults() != null) {
AssetSearchResult[] assets = result.getAssetSearchResults();
for (AssetSearchResult asset : assets) {
AssetInformation assetInformation = asset.getAsset();
// Modify an asset here, for example,
// create a "DependsOn" relationship from Release and Implementation type assets to a Specification asset of the same name using the client APIs, like this:
// Relationship theRelationships = session.getRelationships
// getRelationships().add(newItem);
}
}
}
// Catch exceptions...
Result result = new Result();
result.setMessage("Success");
return result;
}
// Get the asset
RAMAsset ramAsset = getRAMAsset();
// Get the location and content of the artifacts
RAMFolderArtifact srcFolderArtifact = (RAMFolderArtifact)ramAsset.getArtifactsRoot();
Artifact[] srcArtifacts = srcFolderArtifact.computeArtifactsAsFlatList(new NullProgressMonitor());
for (Artifact artifact : srcArtifacts) {
RAMArtifact ramArtifact = (RAMArtifact) artifact;
InputStream is = ramArtifact.downloadContents();
f = File.createTempFile("theArtifact", null, new File(ramSession.getLocalStorageLocation()));
UtilitiesCommon.copyStreams(is, new FileOutputStream(f), null, true, true);
}