It's all about the answers!

Ask a question

How can I get the Project Area name for the work item within a ServerSide Participant?


Susan Hanson (1.6k2186193) | asked May 29 '14, 8:29 p.m.
edited May 29 '14, 8:32 p.m.
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.



Comments
1
sam detweiler commented May 29 '14, 10:03 p.m.

Should work. Another way is to get the project area handles once, and then compare with the workitem relative data. 


What else will you use the project area object for? 


Susan Hanson commented May 30 '14, 8:10 a.m.

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!


sam detweiler commented May 30 '14, 8:21 a.m.

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.


sam detweiler commented May 30 '14, 8:27 a.m.

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.


sam detweiler commented May 30 '14, 8:30 a.m.

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.

Be the first one to answer this question!


Register or to post your answer.