How can I get the Project Area name for the work item within a ServerSide Participant?
![]()
I'm trying to have a single WorkItemSave participant be able to work on multiple project areas on the same server (it is a singleton). The two project areas are slightly different in their attribute IDs and work item type IDs.
My first major check needs to be "which project area is this work item in" so that I can then use the proper literals for the IDs. However, I haven't had alot of luck getting the project area name *easily*. I have this code, but not sure if a) it will work well and b) if there is a better/cheaper way: IProjectAreaHandle ipah = newWorkItemData.getProjectArea(); IRepositoryItemService itemService = getService(IRepositoryItemService.class); IProjectArea ipa = (IProjectArea)itemService.fetchItem(ipah, null); String projectName = ipa.getName(); Any ideas? Thanks in advance. |
Be the first one to answer this question!
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.
Comments
Should work. Another way is to get the project area handles once, and then compare with the workitem relative data.
Nothing :-) Basically I will have common methods for doing the "work" but the determination of if the work needs done needs to be done based on project area, for example (really bad pseudocode):
if (project area A) {
if (workitemtype.equals("technicaldebt") {
doWork("targetRelease")
}
}
else if (project area B) {
if (workitemtype.equals("com.ibm.workitemtype.technicaldebt") {
doWork("edition","release");
}
}
so the work item type ids are changing (we needed to do some standardization) and the attribute IDs are changing in some cases.
So since it is a singleton, I could have a static variable loaded the first time which contains the project area handle for the 2 project areas, and then compare just the handles ... interesting thought.
Thanks!
and if you used arraylist for the project area uuid and literals,
then you could use indexing
supportedprojectslist.indexOf(workitem.getProjectArea().getItemId())
if the index is >=0 its one of yours, else its something else.
if supportedprojectslist.size==0, then you have to initialize it.
all fast operations. as most of the project areas won't be yours.
and, if you went ahead and used the name string approach, I would recommend not to load the entire project area object, but only the name field, to reduce the database overhead.
and
So since it is a singleton, I could have a static variable loaded the first time
since its java you can have a static variable accessed by all instances. doesn't matter on the singleton point.