How to get filed Against value of WorkItem?
![]()
vivek chaudhari (13●4●6)
| asked Jun 21 '12, 11:34 a.m.
retagged Jun 21 '12, 11:39 a.m. by David Olsen (523●7)
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
|
Accepted answer
![]()
Ralph Schoon (63.3k●3●36●46)
| answered Jun 25 '12, 9:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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
|
2 other answers
![]()
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.
|
![]() Could you show me your complete code with your solution?
Best regards
|
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.