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

How to get filed Against value of WorkItem?

I am new to RTC plugin development. This is my first plugin creation.

Basically I want to find filedAgainst value when workItem gets saved.

Below is sample code which I am working on and It is not intended to use in my work.

/*
* 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();
if (oldState != null) // New work item check.
oldStateId = oldState.getState2();
if ((newStateId != null) && !(newStateId.equals(oldStateId))) {
/*
* If the work item is not of the proper type, do not build.
* Note that the work item type and state are hard coded, as is
* the build definition id. We will change that later. That is
* when we will start using the participantConfig parameter.
*/
String newType = newState.getWorkItemType();
//new -- This is where i want to find the value of Category but I don't seems to get proper values
System.out.println(newState.getCategory());
System.out.println(IWorkItem.CATEGORY_PROPERTY);
System.out.println(newState.getCategory().getItemType().getName());
System.out.println(newState.getCategory().equals("Test Project 1"));
//new-end
if (newType.equals("com.ibm.team.apt.workItemType.story")) {
/*
* Finally, if the new state is the target state, build.
*/
if (newState.getState2().getStringIdentifier().equals(
"com.ibm.team.apt.story.tested")) {
build("our.integration.build");
}
}
}


//new -- This is where i want to find the value of Category but I don't seems to get proper values
System.out.println(newState.getCategory());
System.out.println(IWorkItem.CATEGORY_PROPERTY);
System.out.println(newState.getCategory().getItemType().getName());
System.out.println(newState.getCategory().equals("Test Project 1"));
//new-end

I tried above statements but I didn't get any proper string representation of filedAgainst value..

Can someone please help? I am using RTC 3101

0 votes


Accepted answer

Permanent link
The API often returns object handles instead of the full object
–To get the object from an IHandle use a resolve operation provided by the Services/Client libraries. Objects might not be resolvable due to permissions
•IAuditableCommon.resolveAuditable(handle, profile, monitor)
•IAuditableCommon.resolveAuditablesPermissionAware(handles, profile, monitor)
•ITeamrepository.itemManager().fetchCompleteItem(itemHandle, flags, monitor)

Profiles are used to deterine how much data needs to be loaded when resolving a handle
–General profiles: ItemProfile.createFullProfile(IProjectArea.ITEM_TYPE)
–Special profiles: IWorkItem.SMALL_PROFILE, IQueryDescriptor.FULL_PROFILE
–On the client Flags are IItemManager.DEFAULT (cached), IItemManager.REFRESH (refresh cache)

Sometimes it is necessary to find the team repository containing an object; use getOrigin()
–ITeamRepository repo = (ITeamRepository) iItem.getOrigin();
vivek chaudhari selected this answer as the correct answer

0 votes


2 other answers

Permanent link
The Jazz has the concept of Item Handle and Item.
All that is stored in the Jazz Repository are Items.
The Item handle has the basic information (not all) required to fetch the complete item.
In your case the newState.getCategory() will get you the Item handle for the Category not the Category Item.
Check the SDK for an API to resolve the ItemHandle to Item.

1 vote


Permanent link

 Could you show me your complete code with your solution?

Best regards

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
× 10,938
× 369

Question asked: Jun 21 '12, 11:34 a.m.

Question was seen: 7,167 times

Last updated: Jan 04 '19, 5:51 a.m.

Confirmation Cancel Confirm