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 |
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 |
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 sorry, don't quite understand the question.. |
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 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. the javadoc says you can call resolveWorkItemReferences directly from a workitem |
yes, sorry, most of the xCommon class interfaces are shared between server and client.. this one is not.. IWorkitemCommon.
anyhow.. you don't really need it, as the operation advisor has access to the AuditableCommon class and methods.. 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:
Where |
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.