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?
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
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).
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).