It's all about the answers!

Ask a question

Programmatic read value of custom attributes


Antonio Bonanni (1111717) | asked Apr 11 '12, 8:15 a.m.
Hi all,

i need to read custom attributes value: i wrote some code but i get always the same error ( using working copy too ):


org.eclipse.core.runtime.AssertionFailedException: assertion failed:
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.getValue(WorkItemImpl.java:2848)
at com.ibm.team.workitem.common.internal.attributeValueProviders.FallbackProvider.getValue(FallbackProvider.java:31)
at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.getValue(AttributeImpl.java:899)


this is my code to read the value:

		IWorkItemServer workItemServer = getService(IWorkItemServer.class);

IWorkItem workingCopyItem = (IWorkItem) wi.getWorkingCopy();
parameterString += "\"workItemId:"+wi.getId()+"|";
parameterString += "project:"+workItemServer.findAttribute(workingCopyItem.getProjectArea(), "project", monitor).getValue(iac, workingCopyItem, monitor)+"|";

IAC is IAuditableCommon
monitor is ProgressMonitor

The code is in an OperationParticipant


Thanks

3 answers



permanent link
Michele Pegoraro (1.8k14119103) | answered Apr 16 '12, 5:48 a.m.
Hi,
first you have to retrieve the attribute using findAttribute method, and then you have to use IWorkItem.getValue(IAttribute) method, casting the returned value (if it is an enumeration is quite more complex).

Before the getValue maybe you want to run the IWorkItem.hasAttribute(IAttribute) in order to be sure that the work-item has the attribute you need.

Best Regards,
Michele.

permanent link
Joao Bosco Jares A. Chaves (324813) | answered Sep 09 '13, 4:39 p.m.
 I have the same issue. Any one has the solution?

permanent link
Ralph Schoon (63.5k33646) | answered Sep 10 '13, 1:36 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Sep 10 '13, 1:37 a.m.
If you use the client API this is described here: http://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/

If you use a server API, here are examples http://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/

You use the ID of the custom attribute to find the IAttribute.

Basically you find the IAttribute using the ID and then getValue() the value and cast it to a matching type.

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.