How to view/see an asset categorization using Ant
Hello All,
Using Ant scripting, is there a way to use the ram client to view the custom attributes and categorization of an asset?
For example, I can write this script to see the name of my asset...
<target name="viewAsset1" depends="preReq">
<ram:propertyHelper />
<ram:asset id="myasset" server="ramServer" guid="${ram.asset.guid}" version="${ram.asset.version}" />
<echo message="Asset Name = ${myasset.Name}" />
</target>
I could then use this name attribute in a variety of ways. The Name is a built in attribute and is available to me through the Asset interface. So that's no problem.
For the custom attributes and categorization, I see that there is an "AssetAttribute" (getAssetAttribute) and a "Categorizations" (getCategorizations) methods as part of the Asset interface. But these methods require parameters. I assume these are how I would retrieve the custom attributes and categorization information. Is this correct? How do I specify the parameters for these via an Ant script?
Thanks for any help!
Accepted answer
The only thing I can think of is to iterate over the collection until you find the one you want. For instance, you could do something like this (using the Ant-Contrib if functionality). It's not pretty, but it should do the trick. (Note: for categories, you'd need to iterate over the schemas first, then when you find the schema you want, iterate over the categories.)
<target ... >
...
<ram:iterate collection="asset.assetAttributes" param="attr" target="handleAttribute" />
</target>
<target name="handleAttribute">
<if>
<equals arg1="${attr.name}" arg2="My Attribute" />
<then>
Do something...
</then>
</if>
</target>
<target ... >
...
<ram:iterate collection="asset.assetAttributes" param="attr" target="handleAttribute" />
</target>
<target name="handleAttribute">
<if>
<equals arg1="${attr.name}" arg2="My Attribute" />
<then>
Do something...
</then>
</if>
</target>