Batch update thru excel problem
I am trying to write code for batch update of asset using excel sheet...
Is it possible to get .java file for RAMAsset class from somewhere?? Reason: I have multiple attributes added in row for one asset. When I am trying to add asset attributes using 'setAssetAttributes public void setAssetAttributes(AssetAttribute[] customAttributes)' function from RAmClient api... What its doing is its overwriting all the asset attribute one by one, and getting just last attribute mapped correctly. I have tried to pass AssetAttribute[] array object as well. as AssetAttribute[] customAttributes=new AssetAttribute; //get value in customAttributes=<>; (for both name and value) //and after the loop for columns newAsset.setAssetAttributes(customAttributes); but its not working as well.. so i thought if i can get .java file above, than i can see how RAM is implementing it..so i can make sure what to pass. |
7 answers
If these are attributes are modeled on the Asset type you should use getAssetAttribute(String) or getAssetAttributes() find the attribute value you wanted to update and just set the values.
If you wanted to use self defined attributes not modeled in the asset type you can use setAssetAttributes(AssetAttribute[]) but you neeed to set the full list of attribute names and values you want set on the asset. I am trying to write code for batch update of asset using excel sheet... |
Yes, these are attributes modeled on the Asset type. Have one question if i use getAssetAttribute(String).
RAMAssetAttribute attribute = session.getAssetAttribute(assetattr_val); attribute.setValues(new String[] {cellRowVal});//value from excel session.put(attribute , new NullProgressMonitor()); But this is not working. Log says "You cannot set values on an attribute unless it is obtained from an asset.". So this can only be achieved by AssetAttribute attribute = newAsset.getAssetAttribute(assetattr_val);//where RAMxyz newAsset = session.XYZ attribute.setValues(new String[] {cellRowVal});//value from excel session.put(newAsset, new NullProgressMonitor()); Now aboove code will only work if asset is available is RAM (so can be extracted). But in my case i have new asset (and bulk upload from Excel) so its not there in RAM yet. Hence can't apply this code... And session.creatAsset than get that againis also not feasible without populating mandatory attribute, for which whole excersize is. Any suggestion in this?? Thanks in advance |
You first example is trying to modify the Attribute definition which you cannot set a value to.
The second example should work for new or existing assets. The one caveat is you need to set the community and asset type on the new asset before calling getAssetAttribute(String) so that it can load the attribute constraints for the new asset. Yes, these are attributes modeled on the Asset type. Have one question if i use getAssetAttribute(String). |
Thanks a lot. I have successfully achieved it.
But fall into different issue related to authentication. While creating session object, i don't want to get repository url, username, password from excel sheet. Anyway in my eclipse/rsa tool i will be having repository connection, now how can I extract repository url, username, password from there, to use in my code. Thanks in Advance. |
So are you saying that your application is an eclipse plugin installed in conjunction with the RAM plugin?
You can than do the following to create a RAMSession without knowing the password... // Create a connection to Rational Asset Manager final String URL = "http://ramsrvr.test.com:8080/com.ibm.ram.repository.web.ws.tomcat"; final String USERID = "mylogin"; RepositoryIdentification id = new RepositoryIdentification(null, URL, USERID); RAMSession session = RichClientCorePlugin.getDefault().createClientSession(id); or you can get a list off all configured repository connections via... List<RepositoryIdentification> ids = RichClientCorePlugin.getDefault().getRepositoryIdentifications(); Thanks a lot. I have successfully achieved it. |
Thanks Again, Achieved this as well.
But got one issue related to previous question. In RAM, I have modeled attributes in such a way that, some of those provide Single Selection Option, some Multiple Selection Option and some as Plain Text. I am successfully able to submit attributes with Single Selection Option, and Plain Text. But attributes with Multiple Selection Option are not getting populated. FYI... code is AssetAttribute attribute = newAsset.getAssetAttribute(assetattr_val);//where RAMxyz newAsset = session.XYZ if (//some code.... cell value contains ",") attribute.setValues(cellRowMultiVal); //cellRowMultiVal==array of values from excel else attribute.setValues(new String[] {cellRowVal});//value from excel session.put(newAsset, new NullProgressMonitor()); |
|
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.