How to get Contributor Value
I have one custom attribute, the type is contributor type. The problem is I can't get the value of the attribute. I have followed the code that has been provided in "https://jazz.net/forum/questions/202216/how-to-obtain-the-value-of-a-custom-contributor-field-via-a-rtc-participant-plugin" but it always capture null value even though there is a contributor assigned in that attributes. Is there anyone who can give suggestion what should I do and what happened with that?
import com.ibm.team.repository.common.IContributor; import com.ibm.team.repository.common.IContributorHandle; import com.ibm.team.repository.service.IRepositoryItemService;
IWorkItemServer workitemserver= getService(IWorkItemServer.class);IAttribute attribute = workitemserver.findAttribute(workItem.getProjectArea(), "customerExperience", monitor);IContributorHandle contributorHandle = (IContributorHandle) workItem.getValue(attribute);IContributor contributor = (IContributor) itemService.fetchItem(contributorHandle, null);
One answer
If you have to print something in Tomcat you are doing it wrong. If you don't follow the Extensions workshop https://jazz.net/library/article/1000 to be able to debug in Jetty, it is pretty much wasted time to try to help as well.
Neither do I see any tests to the instance or null or anything sanity checking code I would expect if you don't have anything better than System.out.println()
Follow the workshop and set up your environment properly.
Comments
Andy Chen
Jul 18 '17, 11:32 p.m.From a quick look at the code here, it looks like you're missing a few dependencies for
workItem in "workItem.getValue"
itemService in "itemService.fetchItem"
Are these two properly declared in your code?
Ardy Lesmana
Jul 19 '17, 1:41 a.m.Yeah I have declare it before. I can get the value of string type attributes , timestamp and enumeration. I only can’t get value if it’s contains a contributor type.
Andy Chen
Jul 19 '17, 1:58 a.m.Can you retrieve the value of other custom attributes?
Do you have other project areas to test your code on? Or is it just a single project area?
Not being able to get the subscribers might be caused by an external issue other than the API, so if possible try to check if you can get subscribers in a different project area.
Ardy Lesmana
Jul 19 '17, 2:01 a.m.Yeah, I can get the custom attributes as long as the type is not contributor or contributor list.
Andy Chen
Jul 19 '17, 2:17 a.m.The code looks ok as long as the custom attribute ID is correct.
Do the other work item API for getting contributors work?
i.e.
getCreator, getOwner & getResolver?
Ardy Lesmana
Jul 19 '17, 2:22 a.m.If I retrieve the value of built-in attributes for contributor types (Owner, Modifier, Creator, Resolver), it's working. At the first, I think maybe it's because the library but I can get the the build in contributor attributes.
Andy Chen
Jul 19 '17, 2:32 a.m.Can we check whether "customerExperience" is returning a valid attribute?
After
Try:
and see if Contributor is correctly returned
Ardy Lesmana
Jul 19 '17, 3:37 a.m.Yeah, it is return correctly,