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

How to retrieve complex custom attribute of a Workitem.

We have  custom workitems in RTC and custom attributes attached to those workitems.
We are trying to retrieve a custom attribute's value by using JAVA API. We can retrieve the value of custom attributes like Timestamp,string etc. But when iit comes to retrieve the value of a complex attribute which holds a component as Item,it's hard to retrieve the value. 

We are using this piece of code:

IAttribute attribute2 = workItemClient.findAttribute(projectArea,"deployment.component", null);
Object obj2 = workItem2.getValue(attribute2);

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?

0 votes

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 :(



One answer

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

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
× 11,052
× 416

Question asked: Oct 08 '12, 6:58 a.m.

Question was seen: 6,419 times

Last updated: Oct 09 '12, 9:59 a.m.

Confirmation Cancel Confirm