It's all about the answers!

Ask a question

How to get the "Filed Against" value from RTCJavaP


Yun Li (1154) | asked Oct 12 '11, 5:19 a.m.
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!

Accepted answer


permanent link
Ralph Schoon (61.4k33643) | answered May 24 '19, 9:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Ralph Schoon selected this answer as the correct answer

4 other answers



permanent link
yongkwan kim (2111) | answered Oct 13 '11, 1:09 a.m.
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());

permanent link
radhika bandari (10675) | answered Nov 07 '11, 6:39 a.m.
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

permanent link
yongkwan kim (2111) | answered Nov 07 '11, 8:29 p.m.
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;
}

permanent link
AMEYA KALE (172) | answered May 24 '19, 8:12 a.m.

  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();


Comments
Ralph Schoon commented May 24 '19, 9:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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

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

Your answer


Register or to post your answer.