It's all about the answers!

Ask a question

How can I add constraint of relation type for asset type by


Zhe Yan (2151) | asked May 04 '10, 11:33 p.m.
I want to add constraint of relation type for asset type by RAM API, but I cannot find that operations neither by java client nor web service API. I can create relation type, can create asset type, but no idea to connect them together. Have any idea? Thanks.

2 answers



permanent link
Kevin Bauer (34621) | answered May 05 '10, 10:30 a.m.
JAZZ DEVELOPER
I want to add constraint of relation type for asset type by RAM API, but I cannot find that operations neither by java client nor web service API. I can create relation type, can create asset type, but no idea to connect them together. Have any idea? Thanks.


Unfortunately we have not had the time to fully flush out all the admin functions into API. We do not have a simple way to accomplish adding a relationship constraint to an Asset Type. However the constraints are stored in the Asset Type configuration. This can be set via the API.

I would recommend setting up your asset type in the UI just as you would like it. Than writing a test case that gets the Asset Type from the session and prints it out.


RAMAssetType type = session.getAssetType("AAA");
String config = type.getConfiguration();
System.out.println(config);


For example I have an Asset Type that requires a relationship of type "documentation" to an Asset of type Specification.


<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.ram.common.emf:AssetTypeConfiguration xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:com.ibm.ram.common.emf="http:///com/ibm/ram/common/emf.ecore">
<constraints xsi:type="com.ibm.ram.common.emf:RelationshipGrouping">
<constraints count="1" relationship="documentation" requiredAssetType="classif/assetTypesSchema.xmi#specification"/>
</constraints>
</com.ibm.ram.common.emf:AssetTypeConfiguration>


Once you have the XML that describes the AssetType constraints you would like you can set this value in the configuration when programmatic creating a new type...


RAMAssetType type = session.createAssetType("New Type");
type.setDescription("This is a test type created to show how to programtically create a relationship constraint");
StringBuffer config = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
config.append("<com.ibm.ram.common.emf:AssetTypeConfiguration xmi:version=\"2.0\"\n");
config.append(" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:com.ibm.ram.common.emf=\"http:///com/ibm/ram/common/emf.ecore\">");
config.append(" <constraints xsi:type=\"com.ibm.ram.common.emf:RelationshipGrouping\">");
config.append(" <constraints count=\"1\" relationship=\"documentation\" requiredAssetType=\"classif/assetTypesSchema.xmi#specification\"/>");
config.append(" </constraints>");
config.append("</com.ibm.ram.common.emf:AssetTypeConfiguration>");
type.setConfiguration(config.toString());

session.put(type, new RAMStatusMonitor(){
@Override
public void appendStatus(Object targetObject, int severity, int code, String message, Throwable exception) {
System.out.println(severity + " - " + code + " " + targetObject + ": " + message);
if(exception != null) exception.printStackTrace();
}}
);


There is an enhancement to better expose this functionality in the API...

https://jazz.net/jazz02/web/projects/Rational%20Asset%20Manager#action=com.ibm.team.workitem.viewWorkItem&id=25210

It is currently not in plan for 7.5

permanent link
Zhe Yan (2151) | answered May 06 '10, 5:45 a.m.
Thank you very much. I will test on it.

Your answer


Register or to post your answer.