Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Work Item References within server side Operation Advisor

Hello,

I am trying to write a server side operation advisor for Work Item save that needs to access the parent and child references of the saved work item. I have figured out how to access the references from a plain java application, but am having problems determining how to get a hold of the objects I need while running on the server as an operation advisor. My code will need to find the referenced Work Items and load them in memory to access their types and some field values. Can anyone point me to some example code that would help shed some light on this?

Thank you,

Jamie Berry.

0 votes



5 answers

Permanent link
Okay, I have found out how to get the Work Item References from within server side Operation Advisor:

ISaveParameter saveParameter = (ISaveParameter) data;

IWorkItemReferences references = saveParameter.getNewReferences();


Now I am having trouble fetching the items that are referenced in order to determine their work item type and their ID. I have some client side code that uses ProviderFactory objects, but I can't seem to get it to translate to server side code. I will keep looking, but if anyone has any pointers, I would greatly appreciate it.

0 votes


Permanent link
I found out how to fetch the items, thanks to some pointers I found in this post: http://jazz.net/forums/viewtopic.php?t=10966

I was missing the part of having to list the services required for the advisor in order to gain access to the IRepositoryItemService (which can be used to fetch an item).

Now I am having trouble fetching the items that are referenced in order to determine their work item type and their ID. I have some client side code that uses ProviderFactory objects, but I can't seem to get it to translate to server side code. I will keep looking, but if anyone has any pointers, I would greatly appreciate it.

0 votes


Permanent link
Here is the code that will fetch all related work items.
For Parent Use the constant : WorkItemEndPoints.PARENT_WORK_ITEM
For Child Use the constant : WorkItemEndPoints.CHILD_WORK_ITEM
---------------------------------------------------------------------------------------------------------
List<IReference>   relatedRefs = ((ISaveParameter) data).getNewReferences()
                        .getReferences(WorkItemEndPoints.RELATED_WORK_ITEM);

for (IReference ref : relatedRefs) {
                if (ref.resolve() instanceof IWorkItemHandle) {
                    if (ref.isItemReference()) {
                        referencedItem = ((IItemReference) ref).getReferencedItem();
                        relatedworkItem = (IWorkItem) repositoryItemService
                                .fetchItem(referencedItem, null);
}
}
}

0 votes


Permanent link

This topic is exactly what I am trying to do.   The link to the forum is broken and the code shown here doesn't compile. 

0 votes


Permanent link

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941

Question asked: Oct 15 '10, 6:28 p.m.

Question was seen: 6,442 times

Last updated: May 02 '18, 4:55 p.m.

Confirmation Cancel Confirm