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

How to import workitem Templates (xml) into project area via JAVA API?

Hello everyone,

I need to import a workitem template into my project area. Has anyone experiences with that?
I've already checked the WorkItemTemplateImportWizard class, which has following code (some modifications are made):

Map<String, IWorkItemTemplateHandle> existingTemplates= new HashMap<String, IWorkItemTemplateHandle>();
List<WorkItemTemplate> newTemplates= new ArrayList<WorkItemTemplate>();
IWorkItemTemplateClient templateClient= (IWorkItemTemplateClient)repo.getClientLibrary(IWorkItemTemplateClient.class);
IWorkItemClient itemClient= (IWorkItemClient)repo.getClientLibrary(IWorkItemClient.class);
projectArea = (IProjectArea) projectArea.getWorkingCopy();
XMLTemplateParser parser= new XMLTemplateParser(projectArea, itemClient);
String xmlContent= ""<?xml version=\....."
(I wrote a simple XML into the string for testing, later on the content comes from an external xml file)
newTemplates.add((WorkItemTemplate)parser.parseTemplate(xmlContent));
List<IWorkItemTemplateHandle> templateHandles= templateClient.getTemplateHandles(projectArea, monitor);
        for (IWorkItemTemplateHandle cur : templateHandles) {
            existingTemplates.put(cur.getName(), cur);       
        }
IProcessItemService processItemService = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
processItemService.save(projectArea, monitor);


I already checked the value of the variables newTemplates and existingTemplates. "newTemplates" has all attributes of my imported template and "existingTemplates" has all attributes of my current templates. So I'm confident to get it done with your help!

After running the code, there is no error and unfortunately no new template either. It seems that I do not save the right part(?)
Any tips or hints?

Thank you in advance!
Philipp

0 votes



One answer

Permanent link
I tried following code and it works:

IWorkItemTemplate template = (WorkItemTemplate)parser.parseTemplate(xmlContent);
templateClient.importTemplate(template, false, monitor);

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
× 411

Question asked: Nov 17 '15, 8:37 a.m.

Question was seen: 3,411 times

Last updated: Nov 17 '15, 9:24 a.m.

Confirmation Cancel Confirm