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

How to get value of a customeattribute use plain java api

 Hi all:
I am trying to develop  RTC extensions these days, I got a instance from the https://jazz.net/library/article/1000, that is a example of RTC extension developement with a very long documentation, I have done the whole example, but now I want to make a little modification to do something else, for example, put a custome attribute value to another  attribute,  I attempt to edit the run mothod of  class BuildOnStateChangeParticipant, below is a piece of run method of this class:

public void run(AdvisableOperation operation,
IProcessConfigurationElement participantConfig,
IParticipantInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {
/*
* There are several reasons not to request a build. This code is
* structured to perform the most common and fastest cases first. The
* idea is to find out as quickly as possible that you have nothing to
* do. Depending on how the participant is configured (which process
* area(s), iteration(s) or roles it affects), it could be called for
* all work item saves that occur in the using project area.
*/

/*
* First check that the operation data is work item save data.
*/
Object data = operation.getOperationData();
ISaveParameter saveParameter = null;
if (data instanceof ISaveParameter) {
saveParameter = (ISaveParameter) data;
/*
* If the state id has not changed, do not build.
*/
IWorkItem newState = (IWorkItem) saveParameter.getNewState();
Identifier<IState> newStateId = newState.getState2();
Identifier<IState> oldStateId = null;
IWorkItem oldState = (IWorkItem) saveParameter.getOldState();

I have already add a custome attribue named "test user" to the Story workitem type,  and I want to copy its value to the "Owner" build-in attribue when the state changes, how can I do this? 

0 votes



3 answers

Permanent link
Hi,
https://jazz.net/forum/questions/87341/how-to-fetch-the-workitem-built-in-custom-attribute-id-and-value discusses how to get the value of a custom attribute.

0 votes

Comments

 

 HI, thanks for your reply, I also have the a) "teamRepository" b) IItemManager c) NullProgressMonitor unresolved problem, according to you answer, I found another guy's answer that refer to the same question, It use this code:


Permanent link
 

 HI, thanks for your reply, I also have the a) "teamRepository" b) IItemManager c) NullProgressMonitor unresolved problem, according to you answer, I found another guy's answer that refer to the same question, It use this code:

IAttributeHandle handle = ...
IRepositoryItemService itemService = getService(IRepositoryItemService.class);
IAttribute attribute = (IAttribute) itemService.fetchItem(handle, IRepositoryItemService.COMPLETE);
so I have a try, but it says "The service 'net.jazz.rtcext.workitem.extensions.service.BuildOnStateChangeParticipant@1d7c1d7c' failed to find the required service 'interface com.ibm.team.repository.service.IRepositoryItemService'.  Check <prerequisites> in plugin.xml"

what is the matter?

and could you look into the code above, and give me some sample code that can fellow that

By the way I know there are client side api and server side api, what's different between them, and when I can use them?

0 votes


Permanent link
I'm not certain what is causing the prerequisites error you're getting.  My guess is that you need to add the repository as a required bundle.

The following code should be able to follow yours:
System.out.println("The attribute id: " + attribute.getIdentifier());
System.out.println("The value of the custom attribute: " + workItem.getValue(attribute));
For your question about client side and server side api, refer to this forum post that has helpful links:  https://jazz.net/forum/questions/10577/queries-regarding-clientside-and-serverside-api

0 votes

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

Question asked: Nov 15 '12, 6:22 a.m.

Question was seen: 6,226 times

Last updated: Nov 16 '12, 7:03 a.m.

Confirmation Cancel Confirm