How to set preconditions programatically ?
Hi,
I am trying to set preconditions & follow up actions programatically using plain java API. Manually what we do is create a new configuration and then for save operation we set some preconditions & follow up actions. What i want to achieve is to create a new configuration for save work item operation (using plain java api). So do you guys know how can i achieve it ? I couldn't find any java documentation/API to create a new configuration for save work item operation
Thanks
Accepted answer
Amit, there is no documented API for this. You basically have to manipulate the process configuration XML file and save it.
This is an example how this can be done. Note that this is potentially dangerous.
IProcessClientService processClient = (IProcessClientService) teamRepository .getClientLibrary(IProcessClientService.class);URI uri = URI.create(projectAreaName.replaceAll(" ", "%20")); IProjectArea projectArea = (IProjectArea) processClient .findProcessArea(uri, null, monitor); if (projectArea == null) { System.out.println("Project area not found."); return false; } projectArea = (IProjectArea) projectArea.getWorkingCopy(); // Set to share process // setProcessToSahred(projectArea); // setShareProcess(thisProjectArea, projectAreaSharingItsProcess) Map<String, IContent> pd = projectArea.getProcessData(); IContent content = (IContent) pd .get(ProcessContentKeys.PROCESS_SPECIFICATION_KEY); if (content != null) { String processConfig = createStringFromContent(teamRepository, content, monitor); String newProcessConfig = processConfig.replace( "this-is-a-fake-url", "http://localhost/index.html"); IContent newContent = createContentFromString(teamRepository, newProcessConfig, monitor); pd.put(ProcessContentKeys.PROCESS_SPECIFICATION_KEY, newContent); IProcessItemService processItemService = (IProcessItemService) teamRepository .getClientLibrary(IProcessItemService.class); processItemService.save(projectArea, monitor); }