How to get Work Item found in attribute value?
![](http://jazz.net/_images/myphoto/cf5f428c6dd010c78f55d7f0e0ad2009.jpg)
Accepted answer
![](http://jazz.net/_images/myphoto/cf5f428c6dd010c78f55d7f0e0ad2009.jpg)
int id = new Integer(idString).intValue();
IWorkItem workItem = workItemClient.findWorkItemById(id,
IWorkItem.SMALL_PROFILE, null);
IAttribute foundIn = workItemClient.findAttribute(projectArea,
IWorkItem.FOUND_IN_PROPERTY, null);
if (workItem.hasAttribute(foundIn)){
IDeliverableHandle foundInValueHandle = (IDeliverableHandle) workItem.getValue(foundIn);
IDeliverable foundInValue = (IDeliverable)teamRepository.itemManager().fetchCompleteItem(foundInValueHandle, IItemManager.REFRESH, null);
System.out.println("Found In "+ foundInValue.getName() );
}
System.out.println("Accessed work item: " + workItem.getId() + ".");
4 other answers
![](http://jazz.net/_images/myphoto/cf5f428c6dd010c78f55d7f0e0ad2009.jpg)
Comments
![](http://jazz.net/_images/myphoto/a48ec80e50c4a4d3c224fc4544492744.jpg)
When I try https://server_port/ccm/oslc/workitems/workitem_number.xml?oslc_cm.properties=rtc_cm:foundIn I get page cannot be displayed.
When I try s://server_port/ccm/oslc/workitems/ or s://server_port/ccm/oslc/ I get The requested resource () is not available.
Do I need to do something to turn on OSLC services or should it be on by default? I experimenting with the standard Windows 7 RTC download.
![](http://jazz.net/_images/myphoto/cf5f428c6dd010c78f55d7f0e0ad2009.jpg)
Comments
![](http://jazz.net/_images/myphoto/e88a078db92393ce98a2c98da8c35e46.jpg)
Also if you just put,
![](http://jazz.net/_images/myphoto/a48ec80e50c4a4d3c224fc4544492744.jpg)
That works! Thanks. I'm new to OSLC so I didn't realize you could post the work item number.xml to get it to work.
The first statement didn't list the actual foundIn value. But the 502.xml displaying all properties did. I need to figure out how to list the value of a property.
I've spent a fair amount of time using the Reportable REST API to extract work item information I need for another application. (For example, list certain fields - including some parent and child values - for all work items in a particular project, state, and planned for.)
How would using OSLC for that compare to using the Reportable REST API? Is there a clear advantage to one over the other?
Here is what I am doing with REST:
(I'll list it in the next comment:)
![](http://jazz.net/_images/myphoto/a48ec80e50c4a4d3c224fc4544492744.jpg)
![](http://jazz.net/_images/myphoto/a48ec80e50c4a4d3c224fc4544492744.jpg)
<server>:<port>/ ccm/rpt/repository/workitem?fields=workitem/workItem[projectArea/name='MiCSES 2' and (state/id=53 or state/id=2 or state/id=51 or state/id=5)]/(children[type/id='source_code_ci_-_micses']/(id|stringExtensions[key='MICSES_Source_File_CI_Name']/value|bigDecimalExtensions[key='MICSES_Source_file_CI_Version_dec']/value|parent/(id|state/name|target/name)))
![](http://jazz.net/_images/myphoto/cf5f428c6dd010c78f55d7f0e0ad2009.jpg)
I get the error while running your code:
com.sun.proxy.$Proxy26 cannot be cast to com.ibm.team.workitem.api.common.IDeliverable
Could you help?
Comments
![](http://jazz.net/_images/myphoto/e5e63d5878217b64611c1df9401b7cd3.jpg)
-
Don't post new questions on questions that are already answered and accepted
- Create a new question
- Create a question, that has actually data that others could work on
![](http://jazz.net/_images/myphoto/e5e63d5878217b64611c1df9401b7cd3.jpg)
You obviously try to cast something to something, that can't be casted that way.
![](http://jazz.net/_images/myphoto/5deb243200c57dfffcbbac6a44815613.jpg)
Hi Ralph
I could identify the error. Actually I was not able to use IDeliverable, instead I used Deliverable Class (without "I") and I could retrieve foundIn attribute. Check my code:
IAttribute attribute = workItemClient.findAttribute(projectAreaHandle,identifier, iProgressMonitor);
Object value = workItem.getValue(attribute);
if (value instanceof IDeliverableHandle){
IDeliverableHandle foundInValueHandle = (IDeliverableHandle) workItem.getValue(attribute);
Deliverable foundInValue = (Deliverable)teamRepository.itemManager().fetchCompleteItem(foundInValueHandle, IItemManager.REFRESH, null);
System.ou.println(foundInValue.getName());
}
Thank you!
![](http://jazz.net/_images/myphoto/e5e63d5878217b64611c1df9401b7cd3.jpg)
Looks good.