How to retrieve complex custom attribute of a Workitem.
We have custom workitems in RTC and custom attributes attached to those workitems.
We are using this piece of code:
IAttribute attribute2 = workItemClient.findAttribute(projectArea,"deployment.component", null);
We get the object and if we print it we have
"com.ibm.team.scm.common.internal.impl.ComponentHandleImpl@ead0ead (stateId: <unset>, itemId: [UUID _LlT-wBEPEeKQ4PpX4404og], origin: com.ibm.team.repository.client.internal.TeamRepository@128c128c, immutable: true)"
How can we cast this object to a component?
|
One answer
Ralph Schoon (63.6k●3●36●46)
| answered Oct 09 '12, 9:57 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Oct 09 '12, 9:59 a.m.
Canberk,
you will always get an object back if you get a value. You have to find out which type the object is. This is fairly simple during debugging. See for example how to get enumeration variables http://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/ The code in the other answer is absolutely correct and the usual way to resolve work items, and get attributes by their ID and use that to get the value. The cast is also typical. There is - as far as I can tell - no built in type for components. So it is either a string or something completely custom. In the first case you should be able to cast it to String and in the latter, you are in the best position to tell which type it actually is. |
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.
Comments
Hi canberk,
whats the type of "deployment.component" attribute?
Type is an "Item".
Also those codes were for the Plain Java Library. I also need to convert "findByAttribute" method to server side. How can I achieve that?
IAttribute attribute2 = workItemClient.findAttribute(projectArea,"deployment.component", null); This is not working for Server Side plugin as it's using client side codes. I couldnt find the server side method for fetching attributes
more information given by Canberk,
I created an attribute where I can set a "component". The reason I do that is for my release management. People will search workitems and find what other works re in progress on a specific component. So when I receive the value from getvalue(IAttribute) method, I receive a object which contains the component information.
So I need to cast this object to a Component and receive its name somehow. Thank you for the help but that doesnt help me :(