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.
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.
5 answers
Okay, I have found out how to get the Work Item References from within server side Operation Advisor:
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.
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.
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).
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.
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);
}
}
}
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);
}
}
}
- https://rsjazz.wordpress.com/2012/11/27/resolve-parent-if-all-children-are-resolved-participant/
- https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/
-
https://rsjazz.wordpress.com/2012/09/20/the-rtc-workitem-server-link-api-linking-to-work-items-and-other-elements/