It's all about the answers!

Ask a question

How to get value from Custom Attribute?


Avinash Bamane (20215) | asked Jul 23 '15, 7:46 a.m.
Hello,
I am using number of Custom Attributes in my code. I am using following types of Custom Attributes,
String, Contributor, Category and Boolean
I am able to get values from Custom Attribute whose type is String and Boolean, but for others I am getting objects. Can anyone please help me? Here is the code,

//here Custom Attribute(owner) is of type Contributor
myattr = workItemCommon.findAttribute(workItem.getProjectArea(), "owner", monitor);
owner = (ContributorHandleImpl) workItem.getValue(myattr);
//here Custom Attribute(groupOwner) is of type Category                  
myattr = workItemCommon.findAttribute(workItem.getProjectArea(), "groupOwner", monitor);
groupOwner = (CategoryHandleImpl) workItem.getValue(myattr);


How can I get value from owner and groupOwner?

Accepted answer


permanent link
Ralph Schoon (63.5k33646) | answered Jul 23 '15, 7:54 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jul 24 '15, 3:10 a.m.
You have to cast them to the correct object. See https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ .

You can guess the type you have to cast to or you use the debugger to see it. This is also explained above together with https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ .

You can also use the search field in the blog to search for things like Contributor.
You will get an object that you have to cast to, an IContributorHandle for owner attributes you have to cast to and the resolve it, an ICathegoryHandle for type Category and a Boolean (not boolean).
Avinash Bamane selected this answer as the correct answer

Comments
Avinash Bamane commented Jul 24 '15, 1:36 a.m.

Hello Ralph,
Thanks for the quick reply. I already tried code on that blog. Please find code,
ContributorHandleImpl owner;
CategoryHandleImpl groupOwner;
//here Custom Attribute(owner) is of type Contributor
myattr = workItemCommon.findAttribute(workItem.getProjectArea(), "owner", monitor);
owner = (ContributorHandleImpl) workItem.getValue(myattr);
//here Custom Attribute(groupOwner) is of type Category                  
myattr = workItemCommon.findAttribute(workItem.getProjectArea(), "groupOwner", monitor);
groupOwner = (CategoryHandleImpl) workItem.getValue(myattr);

I am not getting, how to get values from 'owner' and 'groupOwner'.


Ralph Schoon commented Jul 24 '15, 3:13 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Read the answer above again.

Please be aware that the API uses EMF which generates the interfaces e.g. ICathegoryHandle and an implementation CategoryHandleImpl which is then implemented. You want to cast to the interface ICathegoryHandle .

As explained in https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ the handle needs to be resolved. See that post.
     

One other answer



permanent link
Avinash Bamane (20215) | answered Aug 07 '15, 10:03 a.m.
Hello All,
I was trying to develop server API, and I got answer from Ralph for this question here,
https://jazz.net/forum/questions/203295/crjzs0383e-the-rtc_sample-bundle-could-not-be-resolved

Thanks Ralph!

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.