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

How to get IContributor objects from a WorkItem

 Hi everyone,
I have a custom WorkItem with custom attributes which contain contributors (users).
Each attribute is a role.
Now I want to detect when you change which users get added to which attribute(role) via an server extension.
I have the new and the old state of the workitem.

My question is now: How do I access the contributors in those attributes?

Thanks

0 votes



One answer

Permanent link
You get the value of the attribute like for any attribute. What you get back can be casted to something. IContributor or IContributorHandle. It is easy enough to use instanceof and debugging to see what you get.
Note, you always want to use the interface and not the implementation class.

There are multiple examples here https://rsjazz.wordpress.com/ . I am pretty sure I provided the links already.
Start here: https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/ . Understanding and Using the RTC Java Client API explains what you just ask. And https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ explains it a bit deeper. https://rsjazz.wordpress.com/2015/11/03/a-rtc-workitem-command-line-version-3-0/ has code to get and set these attributes and also list attributes of this kind.

getValue returns an object so

	if (!(value instanceof IContributorHandle)) {
		throw new WorkItemCommandLineException(
				"Convert Contributor - Incompatible Type Exception: "
						+ value.toString());
	}
	IContributor contributor = (IContributor) getTeamRepository()
			.itemManager().fetchCompleteItem((IContributorHandle) value,
					IItemManager.DEFAULT, getMonitor());

0 votes

Comments

 Thanks for your reply.

I already tried using getValue(IAttribute), but I can't seem to get from my attribute id to an IAttribute. How do I?

 Oh and yes I looked at https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ but I don't have a workItemClient or a fProjectArea

You can get the teamRepository using getOrigin(). You can get the project area from the IWorkItem. You can get the client libraries or common services (IWorkItemCommon) based on that information, depending on the context you are in, which you don't explain. This all allows to find and look up the IAttribute.

https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ is a good summary if you use the client api.

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,954
× 369

Question asked: Aug 17 '16, 7:43 a.m.

Question was seen: 3,410 times

Last updated: Aug 18 '16, 3:47 a.m.

Confirmation Cancel Confirm