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

How to get list of severities using Java API?

Hello I would like to set the severity for my work item.

Here is my code:



ITeamAreaHandle teamAreaHandle = Snippet3.createProject(repo, "Snippet 5");
ITeamArea teamArea = (ITeamArea) repo.itemManager().fetchCompleteItem(teamAreaHandle, IItemManager.DEFAULT, monitor);
IProjectAreaHandle projectArea = teamArea.getProjectArea();
IWorkItemClient service = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
IWorkItemType workItemType = service.findWorkItemType(projectArea, "defect", monitor);
IWorkItemHandle handle = service.getWorkItemWorkingCopyManager().connectNew(workItemType, monitor);
WorkItemWorkingCopy wc = service.getWorkItemWorkingCopyManager().getWorkingCopy(handle);
IWorkItem workItem = wc.getWorkItem();
List<ICategory> findCategories= service.findCategories(projectArea, ICategory.FULL_PROFILE, monitor);
ICategory category = findCategories.get(0);
workItem.setCategory(category);
workItem.setCreator(repo.loggedInContributor());
workItem.setSeverity(arg0);
IDetailedStatus s = wc.save(null);


But I have no idea how can I fetch list of severities available. Any ideas?

0 votes



One answer

Permanent link

IProcessClientService processClient =
(IProcessClientService) repository.getClientLibrary(IProcessClientService.class);
URI uri = URI.create("My Project".replaceAll(" ", "%20"));
IProjectArea projectArea =
(IProjectArea) processClient.findProcessArea(uri, null, monitor);
IProjectAreaHandle projectAreaHandle = projectArea.getProjectArea();

IWorkItemClient workItemClient =
(IWorkItemClient) repository.getClientLibrary(IWorkItemClient.class);
IAttribute severityAttribtute =
workItemClient.findAttribute(projectAreaHandle, IWorkItem.SEVERITY_PROPERTY, monitor);
IEnumeration<? extends ILiteral> severities =
workItemClient.resolveEnumeration((IAttributeHandle) severityAttribtute.getItemHandle(), monitor);

ILiteral majorSeverity = null;
for(ILiteral severity : severities.getEnumerationLiterals()) {
if(severity.getName().equals("Major")) {
majorSeverity = severity;
break;
}
}

IWorkItem workItem = ...
IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();
wcm.connect((IWorkItemHandle) workItem.getItemHandle(), IWorkItem.FULL_PROFILE, monitor);
WorkItemWorkingCopy workingCopy = wcm.getWorkingCopy((IWorkItemHandle) workItem.getItemHandle());
IWorkItem workItemCopy = workingCopy.getWorkItem();
workItemCopy.setValue(severityAttribtute, majorSeverity.getIdentifier2().getStringIdentifier());
workingCopy.save(monitor);



Hello I would like to set the severity for my work item.

Here is my code:



ITeamAreaHandle teamAreaHandle = Snippet3.createProject(repo, "Snippet 5");
ITeamArea teamArea = (ITeamArea) repo.itemManager().fetchCompleteItem(teamAreaHandle, IItemManager.DEFAULT, monitor);
IProjectAreaHandle projectArea = teamArea.getProjectArea();
IWorkItemClient service = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
IWorkItemType workItemType = service.findWorkItemType(projectArea, "defect", monitor);
IWorkItemHandle handle = service.getWorkItemWorkingCopyManager().connectNew(workItemType, monitor);
WorkItemWorkingCopy wc = service.getWorkItemWorkingCopyManager().getWorkingCopy(handle);
IWorkItem workItem = wc.getWorkItem();
List<ICategory> findCategories= service.findCategories(projectArea, ICategory.FULL_PROFILE, monitor);
ICategory category = findCategories.get(0);
workItem.setCategory(category);
workItem.setCreator(repo.loggedInContributor());
workItem.setSeverity(arg0);
IDetailedStatus s = wc.save(null);


But I have no idea how can I fetch list of severities available. Any ideas?

1 vote

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

Question asked: Dec 15 '11, 3:45 a.m.

Question was seen: 5,740 times

Last updated: Dec 15 '11, 3:45 a.m.

Confirmation Cancel Confirm