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

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

0 votes


Accepted answer

Permanent link

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);
    }
Amit Ghatge selected this answer as the correct answer

0 votes

Comments

Thanks Ralph ! It seems manipulating the process XML is the only way to achieve it.  

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,939

Question asked: Jun 02 '19, 9:11 a.m.

Question was seen: 1,516 times

Last updated: Jun 03 '19, 4:46 a.m.

Confirmation Cancel Confirm