要在资产之间添加关系,请使用 RAMAsset.addRelatedAsset(Asset, RelationshipType)。
//Fetch Existing asset
RAMAsset existingAsset = session.getAsset("{5FAC1496-4860-B417-340D-ABE9A58B3C7D}");
// Create a 3nd asset
RAMAsset thirdAsset = session.createAsset("1.0");
thirdAsset.setName("Third Related Asset");
thirdAsset.setCommunity(session.getCommunity("Rational Asset Manager Development"));
thirdAsset.setAssetType(session.getAssetType("Documentation"));
thirdAsset.setShortDescription("Third asset is a relationship test");
//Relate the 1st asset to the second asset
existingAsset.addRelatedAsset(newAsset, session.getRelationshipType("Tutorial"));
// Relate the 2nd asset to the first asset
newAsset.addRelatedAsset(existingAsset, session.getRelationshipType("Implementation"));
// Relate the 2nd asset to the 3rd asset
newAsset.addRelatedAsset(thirdAsset, session.getRelationshipType("Dependency"));
session.queueAssetForPut(thirdAsset);
session.queueAssetForPut(newAsset);
session.queueAssetForPut(existingAsset);
session.putAssets(new NullProgressMonitor());