It's all about the answers!

Ask a question

Server Side Link Advisor - Validates Link and gets data from Linked WorkItem


Ryan McFadden (191318) | asked May 02 '18, 7:52 p.m.

I am attempting to write a server-side advisor using the 6.0.3 version of RTC with the server-sdk.

I have two workItems that have a Parent/Child relationship.  The advisor has two tasks:

1) Prevent the child from being saved unless it has been linked to a Parent of the correct workItem type.

2) Retrieve the WorkItem ID and the Owner of the Parent work item and populate these values into custom attributes of the Child Work Item. 

I am able to accomplish the first task, but am unable to determine how to resolve the link to get the ID and the Owner from the parent work item.

my class extends AbstractService.

my run method is as follows:

@Override
public void run(AdvisableOperation operation, IProcessConfigurationElement advisorConfiguration,
                            IAdvisorInfoCollector collector, IProgressMonitor monitor) throws TeamRepositoryException {

   SaveParameter save = (SaveParameter)operation.getOperationData();

   IAuditable auditable = save.getNewState();

   if (auditable instanceof IWorkItem)
   {

      IWorkItem workItem = (IWorkItem)auditable;
      IWorkItemReferences references = save.getNewReferences();

      Boolean parentFound = false;
      String parentWILinkID = ILinkTypeRegistry.INSTANCE.getLinkType (WorkItemLinkTypes.PARENT_WORK_ITEM).getLinkTypeId();

      for(IEndPointDescriptor endpoint: references.getTypes())
      {

         String endPointLinkID = endpoint.getLinkType().getLinkTypeId();
         if (endpoint.isTarget()) //only concerned with the Target Endpoint to retrieve data and work item type
         {
             if ( endPointLinkID.equals(parentWILinkID) )
             {
               parentFound = true;

               // This is where I am stuck.
               // I can get the UUID from the endpoint object here but how do I resolve that to the Parent Work Item to get at the attribute data?
             }
         }
      }

      if (!parentFound)
      {
         IAdvisorInfo errorInfo = collector.createProblemInfo("Parent Not Found", "Link Advisor Service", "ERROR");
      }
   }
}

One answer



permanent link
Ryan McFadden (191318) | answered May 03 '18, 12:28 p.m.

Ok so to answer my own question:

https://rsjazz.wordpress.com/2012/12/14/do-not-modify-the-triggering-element-in-an-operationadvisor/

The advisor construct was never intended to update anything, only prevent the user from doing something that they are not allowed to do. 

The action of taking the ID and Owner values of the parent to the child work item will have to be done in a participant.

Your answer


Register or to post 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.