It's all about the answers!

Ask a question

RAM customer ANT library download search


Chris Devine (612) | asked Jul 23 '10, 2:41 a.m.
Hello,

We have a schema where a parent asset represents a release and it has many related assets which are components of the system for a given release.

Using the RAM custom ANT library I'd like to be able to download the latest version of a component asset by specifying the parent asset GUID (or better still by name and version) and also the name of a related component asset. I've looked through the RAM ANT APIs and this doesn't seem to be possible currently. The search element of the download task doesn't seem to give me a way to specify the relationship.

Should I write my own ANT task to perform this specialized query and return a GUID that I could then use in the download task?

18 answers



permanent link
Eric Bordeau (27632) | answered Oct 03 '11, 9:58 a.m.
JAZZ DEVELOPER
If you give the search an ID, you should be able to use the property helper to get the assets and GUIDs. (Note that the following script won't work as-is. I left out a lot for brevity's sake.)

<ram:propertyHelper />

<ram:download>
<ram:search id="mySearch" name="My Asset" version="1.0" />
</ram:download>
<echo message="GUID: ${mySearch.assets[0].GUID}" />

permanent link
Bilal Ahmed (5611) | answered Oct 04 '11, 3:38 a.m.
Thanks Eric. But as expected the code didnt work. I am still trying to work out the internal referencing of the assests.

The following code didnt work either:

<ram:propertyHelper />

<ram:download destdir="${lib.dir}" server="ramServer" extract="true" overwrite="true">
<ram:search id="mySearch" name="${ram.asset.name}" version="1.0" />
</ram:download>
<echo message="GUID: ${mySearch.assets[0].assetAttributes[0].name}" /><echo>

I am not sure how to reference the assets within the search result.

permanent link
Rich Kulp (3.6k38) | answered Oct 04 '11, 9:16 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
echo message="GUID:
${mySearch.assets.assetAttributes.name}"
/><echo


That's not the guid. That's the name of the first attribute (if there is
one, this could actually be an error because there may not be any
attributes).

If you said that:

<echo>

doesn't give you the guid, then what did it show?


--
Rich Kulp
Rational Asset Manager developer

permanent link
Eric Bordeau (27632) | answered Oct 04 '11, 10:40 a.m.
JAZZ DEVELOPER
Sorry, the echo part was wrong. Try this:

<ram:propertyHelper />

<ram:download>
<ram:search id="results" name="My Asset" version="1.0" />
</ram:download>
<echo message="GUID: ${results[0].GUID}" />

permanent link
Bilal Ahmed (5611) | answered Oct 05 '11, 2:45 a.m.
echo message="GUID:
${mySearch.assets.assetAttributes.name}"
/><echo


That's not the guid. That's the name of the first attribute (if there is
one, this could actually be an error because there may not be any
attributes).

If you said that:

<echo>

doesn't give you the guid, then what did it show?


--
Rich Kulp
Rational Asset Manager developer


Hi Rich,
The following prints out a list of all the attributes associated with an asset.


<echo message="Asset Attribute: ${results[0].assetAttributes[1].name}" />
<echo message="Asset Attribute: ${results[0].assetAttributes[2].name}" />
<echo message="Asset Attribute: ${results[0].assetAttributes[3].name}" />
<echo message="Asset Attribute: ${results[0].assetAttributes[4].name}" />

permanent link
Bilal Ahmed (5611) | answered Oct 05 '11, 2:56 a.m.
Sorry, the echo part was wrong. Try this:

<ram:propertyHelper />

<ram:download>
<ram:search id="results" name="My Asset" version="1.0" />
</ram:download>
<echo message="GUID: ${results[0].GUID}" />




Thanks Eric, the code works. I can now retrieve the GUID from the search results.


<ram:propertyHelper />
<ram:download destdir="${lib.dir}" server="ramServer" extract="true" overwrite="true">
<ram:search id="results" query="name:(${ram.asset.name}) state:(approved) />
</ram:download>
<echo message="Name: ${results[0].name}" />
<echo message="GUID: ${results[0].GUID}" />
<echo message="State: ${results[0].assetType}" />


How can I access assets related to results
I have tried the following and it didnt work:

<!-- The following didnt work -->

<echo message="RelatedAsset 1: ${results[0].relatedAssetList[0].assetName}" />

<echo message="RelatedAsset 1: ${results[0].relatedAssetList[0].relatedAsset[0].name}" />

<echo message="RelatedAsset 1: ${results[0].relatedAssetList[0].relatedAsset[0].assetName}" />

<echo message="RelatedAsset 2: ${results[0].relatedAssetList[0].name}" />

<echo message="RelatedAsset 3: ${results[0].RelatedAsset[0].assetName}" />

<echo message="RelatedAsset 4: ${results[0].relatedAsset[0].relationshipType}" />

<echo message="RelatedAsset 5: ${results[0].RelatedAsset.relationshipType}" />


I assume I am referencing the Related Assets incorrectly. Not sure what the correct reference is.

Thanks again for your help Eric. :)


permanent link
Eric Bordeau (27632) | answered Oct 05 '11, 10:10 a.m.
JAZZ DEVELOPER
The property helper works by giving you access to public, no-parameter get methods of RAMAsset and the public, no-parameter get methods of the objects those methods return, ad infinitum. So in this case, you have the search results object (which is an array of RAMAssets) and you want information about the related assets. RAMAsset has a getRelationships() method, so you would do something like this:

<echo message="Related asset 1 GUID: ${results[0].relationships[0].childAssetGUID}" />


getRelationships() returns an array of Relationship objects. I'm not positive, but I think in reality they will be of type RAMRelationship and you'll have access to any of its public get methods. If not, you could take the GUID and version and use the <ram:asset> tag to get its properties.

permanent link
Bilal Ahmed (5611) | answered Oct 06 '11, 12:05 a.m.
Thank you Eric!

Absolutely spot on!

Following code works:
<echo message="Related asset 1 GUID: ${results[0].relationships[0].childAssetGUID}" />

<echo message="Related asset 2 GUID: ${results[0].relationships[0].childAssetVersion}" />
<echo message="Related asset 3 GUID: ${results[0].relationships[0].relationshipTypeName}" />

Which corresponds to the following methods:
getChildAssetGUID()

getChildAssetVersion()
getParentAsset()
getRelationshipTypeName()

Thanks again! :)

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.