How to get Affected By Defect in Java API
Hello Team,
I am trying to get the list of Affected By Defect logs using Java API, Though there is no direct parameter for Affected By Defect in WorkItemEndPoints
I am using the following code, but isItemReference() is not returning true
How can i fetch the logs details, Thanks for help!!
for(IReference ir: ((ISaveParameter) data).getNewReferences().getReferences(ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.AFFECTED_BY_DEFECT).getTargetEndPointDescriptor()))
{
if(ir.isItemReference())
{
IWorkItem r;
try {
r = iac.resolveAuditable((IWorkItemHandle)ir.resolve(),IWorkItem.FULL_PROFILE, null);
WorkflowInfo y =wfm.getWorkflowInfo(r, monitor);
String targetWItype = r.getWorkItemType();
String targetStateName = y.getStateName(r.getState2());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Accepted answer
Because it is not a WorkItem to Work Item Link and it is likely not an ItemReference either.
The link type should be com.ibm.team.workitem.common.model.WorkItemLinkTypes.AFFECTED_BY_DEFECT
and the endpoint should be ILinkTypeRegistry.INSTANCE.getLinkType(
WorkItemLinkTypes.AFFECTED_BY_DEFECT)
.getTargetEndPointDescriptor());
You will get an URI and will have to use REST/OSLC to access the details.
The link type should be com.ibm.team.workitem.common.model.WorkItemLinkTypes.AFFECTED_BY_DEFECT
and the endpoint should be ILinkTypeRegistry.INSTANCE.getLinkType(
WorkItemLinkTypes.AFFECTED_BY_DEFECT)
.getTargetEndPointDescriptor());
You will get an URI and will have to use REST/OSLC to access the details.
Comments
Hello Ralph,
Thanks for the suggestion.
Is there any sample code to use REST/OSLC?
Thanks.
I am not an OSLC guy, there have ben numerous answers on this forum, so it might be beneficial to search. Also the RTC server uses REST/OSLC, so it might be an idea to search how it does that in the source. Tedios, I know, but that would be my first approach. Maybe als interesting: https://jazz.net/forum/questions/214885/use-current-user-session-to-login-another-project-through-rtc-plugin/215303 maybe these internal interfaces provide a hint?
Comments
Jayshri Burde
Nov 15 '17, 8:06 a.m.Hello Pankaj