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

How to get the "Filed Against" value from RTCJavaP

I need to get the "Filed Against" value from RTC by using java plain api. I wrote following code:


IAttribute component= workItemClient.findAttribute(projectAreaHandle, IWorkItem.CATEGORY_PROPERTY, monitor);


Identifier<ILiteral> component1= (com.ibm.team.workitem.common.model.Identifier<ILiteral>)workItem.getValue(component);

IEnumeration<ILiteral> componentEnumeratoin = (IEnumeration<ILiteral>)workItemClient.resolveEnumeration(component, monitor);

ILiteral component2 = componentEnumeratoin.findEnumerationLiteral(component1);


This does not work, is there someone can help on this? Thanks a lot!

0 votes


Accepted answer

Permanent link

 I would suggest to look here: https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/

Ralph Schoon selected this answer as the correct answer

0 votes


4 other answers

Permanent link

  Object data=arg0.getOperationData();

ISaveParameter param=null;
if (data instanceof ISaveParameter) {
param = (ISaveParameter) data;
}
IWorkItem workItem= newstate(data);
IAuditableCommon iAuditableCommon = (param).getSaveOperationParameter().getAuditableCommon();
IWorkItemCommon workItemCommon =iAuditableCommon.getPeer(IWorkItemCommon.class);

ICategoryHandle iCategoryHandle = workItem.getCategory();

0 votes

Comments

Thanks, unfortunately that is server API and uses a deprecated call. 

instead of getPeer() you should use getService from AbstractService which you extend.


Permanent link
I need to check the existing value of "Filed Against" value and then set it to new value.
Appriciate any suggessions or Piece of code.


Thanks in Advance
Radhika Bandari


public static void main(String[] args) {
TeamPlatform.startup();
try {
IProgressMonitor monitor = new SysoutProgressMonitor();
ITeamRepository repo = Snippet1.login(monitor);

// update workItem values
updateWorkItem(repo, 69, monitor);

} catch (TeamRepositoryException e) {
System.out.println("Unable to login: " + e.getMessage());
} finally {
TeamPlatform.shutdown();
}
}

public static IWorkItemHandle updateWorkItem(ITeamRepository repo, int workItemId, IProgressMonitor monitor) throws TeamRepositoryException {

IItemManager itm = repo.itemManager();

IWorkItemClient service = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
IWorkItem workItem = service.findWorkItemById(workItemId, IWorkItem.FULL_PROFILE, monitor);
//get existing category value.
ICategory category = (ICategory) itm.fetchCompleteItem(workItem.getCategory(), IItemManager.DEFAULT, monitor);
System.out.println("This is category: " + category.getName());
// ready new category value.
List<String> path= Arrays.asList("JUnit/Tests".split("/"));
ICategoryHandle newCategoryHandle = service.findCategoryByNamePath(workItem.getProjectArea(), path, monitor);

IWorkItemWorkingCopyManager wcm = service.getWorkItemWorkingCopyManager();

wcm.connect(workItem, IWorkItem.FULL_PROFILE, monitor);

try {
WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItem);

// set new category value.
wc.getWorkItem().setCategory(newCategoryHandle);

//String actionName = "com.ibm.team.workitem.defectWorkflow.action.startWorking";
String actionName = "modify";
wc.setWorkflowAction(actionName);

System.out.println(wc.getWorkflowAction());

IDetailedStatus s = wc.save(monitor);
if (!s.isOK()) {
throw new TeamRepositoryException("Error saving work item", s.getException());
}

} finally {
wcm.disconnect(workItem);
}

return workItem;
}

0 votes


Permanent link
I need to check the existing value of "Filed Against" value and then set it to new value.
Appriciate any suggessions or Piece of code.


Thanks in Advance
Radhika Bandari

0 votes


Permanent link
here is customizing code about plain jave api support by ibm.
how to get category name about workitemId

IProgressMonitor monitor = new SysoutProgressMonitor();
ITeamRepository repo = Snippet1.login(monitor);

IItemManager itm = repo.itemManager();

IWorkItemClient service = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
IWorkItem workItem = service.findWorkItemById(workItemId, IWorkItem.FULL_PROFILE, monitor);


ICategory category = (ICategory) itm.fetchCompleteItem(workItem.getCategory(), IItemManager.DEFAULT, monitor);
System.out.println("This is category: " + category.getName());

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,925

Question asked: Oct 12 '11, 5:19 a.m.

Question was seen: 8,524 times

Last updated: May 24 '19, 9:08 a.m.

Confirmation Cancel Confirm