It's all about the answers!

Ask a question

plain java snippet work item

xx xx (461616) | asked Nov 02 '10, 12:52 p.m.
in plain java ,snippet5. java creates a work item.But

I don't want to create a new project area in jazz platform , it is not important the code is java or egl. the code is first create a project area ,then create work item. i wanna create work item in existing project areas in Jazz platform.

The code like this ;

public static IWorkItemHandle createWorkItem(ITeamRepository repo, IProgressMonitor monitor) throws TeamRepositoryException {
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();
try {
List<ICategory> findCategories= service.findCategories(projectArea, ICategory.FULL_PROFILE, monitor);
ICategory category = findCategories.get(0);
workItem.setHTMLSummary(XMLString.createFromPlainText("Example work item"));
IDetailedStatus s =;
if(! s.isOK()) {
throw new TeamRepositoryException("Error saving work item", s.getException());
} finally {
workItem = (IWorkItem) repo.itemManager().fetchCompleteItem(workItem, IItemManager.DEFAULT, monitor);
monitor.subTask("Created a work item " + workItem.getId());
return workItem;

One answer

permanent link
SEC Servizi (97122854) | answered Jun 04 '13, 4:52 a.m.
edited Jun 04 '13, 4:58 a.m.
Thanks for posting your code to create a new work-item:
IWorkItemType workItemType = service.findWorkItemType(projectArea, "defect", monitor); 
IWorkItemHandle handle = service.getWorkItemWorkingCopyManager().connectNew(workItemType, monitor); 
WorkItemInitialization operation= new WorkItemInitialization(summary, category);
IWorkItemHandle handle=, null);
It helps us! :)

You can retrieve an existing project area by its name:
String name = ...;
IProcessClientService processClient = (IProcessClientService) repo.getClientLibrary(IProcessClientService.class);
URI uri = URI.create(name.replaceAll(" ", "%20"));
IProjectArea prjArea = (IProjectArea) processClient.findProcessArea(uri, null, null);

Your answer

Register or to post your answer.