Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get value from Custom Attribute?

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?

0 votes


Accepted answer

Permanent link
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

1 vote

Comments

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'.

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
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!

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jul 23 '15, 7:46 a.m.

Question was seen: 3,687 times

Last updated: Aug 07 '15, 10:03 a.m.

Confirmation Cancel Confirm