plain java snippet work item
![]()
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.setCategory(category); workItem.setCreator(repo.loggedInContributor()); workItem.setOwner(repo.loggedInContributor()); workItem.setHTMLSummary(XMLString.createFromPlainText("Example work item")); IDetailedStatus s = wc.save(null); if(! s.isOK()) { throw new TeamRepositoryException("Error saving work item", s.getException()); } } finally { service.getWorkItemWorkingCopyManager().disconnect(workItem); } workItem = (IWorkItem) repo.itemManager().fetchCompleteItem(workItem, IItemManager.DEFAULT, monitor); monitor.subTask("Created a work item " + workItem.getId()); return workItem; } |
One answer
![]()
Thanks for posting your code to create a new work-item:
IWorkItemType workItemType = service.findWorkItemType(projectArea, "defect", monitor);
which is a different code compares to https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation:
WorkItemInitialization operation= new WorkItemInitialization(summary, category);
It helps us! :)
You can retrieve an existing project area by its name:
String name = ...;Cheers. |
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.