operation advisor precondition link
I am working on a server side OperationAdvisor,trying to precondition.
I try to get detailed info of related workitem.
Here is I'm trying code.
Object data = operation.getOperationData();
if (data instanceof ISaveParameter) {
ISaveParameter param = (ISaveParameter) data;
IAuditable auditable = param.getNewState();
if (auditable instanceof IWorkItem) {
IWorkItem sourceworkItem = (IWorkItem) auditable;
IWorkItemReferences iwr = ((ISaveParameter) data).getNewReferences();
List<IEndPointDescriptor> epdl = iwr.getTypes();
ILinkType lt = epdl.get(0).getLinkType();
IAdvisorInfo problem = collector.createProblemInfo(
"Hello World!", "This work item is of type: " + lt.getLinkTypeId() + " " + epdl.get(0).getDisplayName()
+ sourceworkItem.getWorkItemType(),
PROBLEM_TYPE);
collector.addInfo(problem);
}
}
It works successfully, but in addition
- I try to get related workItem identifier(id -)
- I want to control whether related workitem has a parent work item ?
I try on https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=182769&&tab=links
But I can't. Server rtc 3.0.1, client rtc 3.0 sdk
Thanks
I try to get detailed info of related workitem.
Here is I'm trying code.
Object data = operation.getOperationData();
if (data instanceof ISaveParameter) {
ISaveParameter param = (ISaveParameter) data;
IAuditable auditable = param.getNewState();
if (auditable instanceof IWorkItem) {
IWorkItem sourceworkItem = (IWorkItem) auditable;
IWorkItemReferences iwr = ((ISaveParameter) data).getNewReferences();
List<IEndPointDescriptor> epdl = iwr.getTypes();
ILinkType lt = epdl.get(0).getLinkType();
IAdvisorInfo problem = collector.createProblemInfo(
"Hello World!", "This work item is of type: " + lt.getLinkTypeId() + " " + epdl.get(0).getDisplayName()
+ sourceworkItem.getWorkItemType(),
PROBLEM_TYPE);
collector.addInfo(problem);
}
}
It works successfully, but in addition
- I try to get related workItem identifier(id -)
- I want to control whether related workitem has a parent work item ?
I try on https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=182769&&tab=links
But I can't. Server rtc 3.0.1, client rtc 3.0 sdk
Thanks
6 answers
sorry, don't quite understand the question..
- I try to get related workItem identifier(id -)
in my code which u reference, you get the referenced workitem
and then its id (I put it in the error message)
- I want to control whether related workitem has a parent work item ?
control, or know?
once u have the workitem, then you would have to start over, and get its list of references, and check the link for parent, and.....
so, like this
IWorkItemReferences resolveWorkItemReferences(IWorkItemHandle workItem, org.eclipse.core.runtime.IProgressMonitor monitor)
see the javadoc provided with 3.0.1.1.. downloadable separately
sam
- I try to get related workItem identifier(id -)
in my code which u reference, you get the referenced workitem
// get the item, and it SHOULD always be a workitem
IWorkItem r = iac.resolveAuditable((IWorkItemHandle)wir.get(j).resolve(),IWorkItem.FULL_PROFILE, null);
and then its id (I put it in the error message)
"Workitem "+ r.getId()+ " is not Resolved"
- I want to control whether related workitem has a parent work item ?
control, or know?
once u have the workitem, then you would have to start over, and get its list of references, and check the link for parent, and.....
so, like this
IWorkItemReferences resolveWorkItemReferences(IWorkItemHandle workItem, org.eclipse.core.runtime.IProgressMonitor monitor)
see the javadoc provided with 3.0.1.1.. downloadable separately
sam
Yes, I try to get referenced workitem id. I got it by r.getId() as you said.
and next I want to know whether related workitem has a parent?
IWorkItemServer workItemService = getService(IWorkItemServer.class);
IWorkItemReferences references = workItemService .resolveWorkItemReferences(currentworkitem, null);
List<IEndPointDescriptor> epdl = iwr.getTypes();
epdl.get(0).getId()
But I can't get referenced parent info. Is this right way?
Thanks
and next I want to know whether related workitem has a parent?
IWorkItemServer workItemService = getService(IWorkItemServer.class);
IWorkItemReferences references = workItemService .resolveWorkItemReferences(currentworkitem, null);
List<IEndPointDescriptor> epdl = iwr.getTypes();
epdl.get(0).getId()
But I can't get referenced parent info. Is this right way?
Thanks
sorry, don't quite understand the question..
- I try to get related workItem identifier(id -)
in my code which u reference, you get the referenced workitem
// get the item, and it SHOULD always be a workitem
IWorkItem r = iac.resolveAuditable((IWorkItemHandle)wir.get(j).resolve(),IWorkItem.FULL_PROFILE, null);
and then its id (I put it in the error message)
"Workitem "+ r.getId()+ " is not Resolved"
- I want to control whether related workitem has a parent work item ?
control, or know?
once u have the workitem, then you would have to start over, and get its list of references, and check the link for parent, and.....
so, like this
IWorkItemReferences resolveWorkItemReferences(IWorkItemHandle workItem, org.eclipse.core.runtime.IProgressMonitor monitor)
see the javadoc provided with 3.0.1.1.. downloadable separately
sam
the javadoc says you can call resolveWorkItemReferences directly from a workitem
IWorkItemReferences targetWIreferences = currentworkitem.resolveWorkItemReferences(referencedworkitemHandle, null);
>and next I want to know whether related workitem has a parent?
then you have to loop thru the references same as the first pass..
Sam
IWorkItemReferences targetWIreferences = currentworkitem.resolveWorkItemReferences(referencedworkitemHandle, null);
>and next I want to know whether related workitem has a parent?
then you have to loop thru the references same as the first pass..
Sam
I looked at javadoc ,Iworkitem doesn't have resolveWorkItemReferences. IWorkItemServer or workitemClient has resolveWorkItemReferences. I tried like
IWorkItemServer workItemServer = getService(IWorkItemServer.class);
IWorkItemReferences references= workItemServer.resolveWorkItemReferences(workitem, null);
List<IEndPointDescriptor> epdl2 = references.getTypes();
Internal Error. Unable to instantiate advisor HelloWorldAdvisor.prohibitSave.
CRJAZ6010E:An exception occurred creating extension.
IWorkItemServer workItemServer = getService(IWorkItemServer.class);
IWorkItemReferences references= workItemServer.resolveWorkItemReferences(workitem, null);
List<IEndPointDescriptor> epdl2 = references.getTypes();
Internal Error. Unable to instantiate advisor HelloWorldAdvisor.prohibitSave.
CRJAZ6010E:An exception occurred creating extension.
the javadoc says you can call resolveWorkItemReferences directly from a workitem
IWorkItemReferences targetWIreferences = currentworkitem.resolveWorkItemReferences(referencedworkitemHandle, null);
>and next I want to know whether related workitem has a parent?
then you have to loop thru the references same as the first pass..
Sam
I'm not sure if I understand the question correctly.
In order to resolve parent reference into WorkItem you can use something like this:
WhererelatedWorkItem would be the parent (if exists) of your workitem. Note that you can change WorkItemEndPoints.PARENT_WORK_ITEM to any endpoint type you want. But you also have to change a little bit the code, as an WorkItem can only have one Parent, the code works fine, but for endpoints like Children, you have to put relatedWorkItem into a List.
In order to resolve parent reference into WorkItem you can use something like this:
try {
IItemHandle referencedItem = null;
IWorkItem relatedWorkItem = null;
IWorkItemServer workItemServer = getService(IWorkItemServer.class);
IRepositoryItemService repositoryItemService = getService(IRepositoryItemService.class);
IWorkItemReferences references = workItemServer.resolveWorkItemReferences(workItem, null);
List<IReference> parentRef = references.getReferences(WorkItemEndPoints.PARENT_WORK_ITEM);
if (parentRef!=null && parentRef.size()>0) {
for (IReference reference : parentRef) {
if (reference.isItemReference()) {
referencedItem = ((IItemReference) parentRef.get(0)).getReferencedItem();
if (referencedItem instanceof IWorkItemHandle) {
relatedWorkItem = (IWorkItem) repositoryItemService.fetchItem(referencedItem, null);
}
}
}
}
} catch (TeamRepositoryException e1) {
e1.printStackTrace();
}
Where