How to read the value of an attribute of a workitem with Plain Java API?
![]()
Denes Elo (15●1●9)
| asked Aug 10 '17, 8:33 a.m.
edited Aug 10 '17, 8:57 a.m. by Ralph Schoon (62.7k●3●36●43) The workitem has some attributes: Type, Tags, Task Completion, Severity, Status... I need from these the value of Status (smallstring) . I get the identifier of the Status it is internalState.
workItem = copy.getWorkItem(); I don't know why I get this Exception: java.lang.IllegalStateException: Attempting to get unset feature: Creator at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.getCreator(WorkItemImpl.java:1362) at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.eGet(WorkItemImpl.java:2338) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1021) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1013) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1008) at com.ibm.team.workitem.common.internal.PropertyUtil.get(PropertyUtil.java:105) at com.ibm.team.workitem.common.internal.PropertyUtil.get(PropertyUtil.java:109) at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.getValue(WorkItemImpl.java:2897) at Sample.analyzeItem(Sample.java:146) at Sample.analyzeReference(Sample.java:103) at Sample.run(Sample.java:91) at Sample.main(Sample.java:38) The exception thrown when i call the getValue() function. If somebody know the problem please show some example code! Thanks your help!! |
Accepted answer
![]() Hi,
if (workItem.hasCustomAttribute(customString)){ Object value = workItem.getValue(customString); if (value instanceof String) { String attributeValue = (String) value; // do something with the value } } code fragment from the article. Denes Elo selected this answer as the correct answer
Comments Thanks! I opened the SMALL_PROFILE, now I open with FULL_PROFILE and everything works fine.
|