cancel
Showing results for 
Search instead for 
Did you mean: 

Adding candidate starters in Activiti Modeler

b_schnarr
Champ in-the-making
Champ in-the-making
Hello at all,

since the Activiti Modeler already contains Activiti specific elements, what effort is it to add candidate start users and candidate start groups? Because in my opinion, those are the last important elements missing in the Activiti Modeler. If those attributes were included, simple processes (without java / service logic) could directly be modeled and deployed in the Activiti Modeler without the need of importing it into Eclipse (just for adding the candidate starters).

Is this on the roadmap? What components must be altered in the Modeler? This extension would make the Activiti Modeler a bit more enterprise compliant.

Best regards
Ben
13 REPLIES 13

dave_stanley
Champ in-the-making
Champ in-the-making
I have got this working although it took a bit of messing about modifications to BpmnJsonConverter.java at line 247 insert
<code>
if (CollectionUtils.isNotEmpty(mainProcess.getCandidateStarterUsers()) || CollectionUtils.isNotEmpty(mainProcess.getCandidateStarterGroups())) {
         
            ObjectNode candidatesNode = objectMapper.createObjectNode();
            ObjectNode candidateValuesNode = objectMapper.createObjectNode();
                  
            if (CollectionUtils.isNotEmpty(mainProcess.getCandidateStarterUsers())) {
                ArrayNode candidateArrayNode = objectMapper.createArrayNode();
                for (String candidateUser : mainProcess.getCandidateStarterUsers()) {
                    ObjectNode candidateNode = objectMapper.createObjectNode();
                    candidateNode.put("value", candidateUser);
                    candidateArrayNode.add(candidateNode);
                }
                candidateValuesNode.put(PROPERTY_USERTASK_CANDIDATE_USERS, candidateArrayNode);
            }
         
            if (CollectionUtils.isNotEmpty(mainProcess.getCandidateStarterGroups())) {
                ArrayNode candidateArrayNode = objectMapper.createArrayNode();
                for (String candidateGroup : mainProcess.getCandidateStarterGroups()) {
                    ObjectNode candidateNode = objectMapper.createObjectNode();
                    candidateNode.put("value", candidateGroup);
                    candidateArrayNode.add(candidateNode);
                }
                candidateValuesNode.put(PROPERTY_USERTASK_CANDIDATE_GROUPS, candidateArrayNode);
            }
         
            candidatesNode.put("assignment", candidateValuesNode);
            propertiesNode.put(PROPERTY_PROCESS_CANDIDATE, candidatesNode);
        }
</code>
at line 518
<code>
JsonNode candidateNode = JsonConverterUtil.getProperty(PROPERTY_PROCESS_CANDIDATE, modelNode);
            if (candidateNode != null) {
                JsonNode assignmentDefNode = candidateNode.get("assignment");
                if (assignmentDefNode != null) {
                
                 process.setCandidateStarterUsers(getValueAsList(PROPERTY_USERTASK_CANDIDATE_USERS, assignmentDefNode));
                 process.setCandidateStarterGroups(getValueAsList(PROPERTY_USERTASK_CANDIDATE_GROUPS, assignmentDefNode));
                }
            }
</code>
and in StencilConstants.java
<code>final String PROPERTY_PROCESS_CANDIDATE = "process_candidates";</code>

in stencilset.json add a new package
<code>
{
    "name" : "process_candidatespackage",
    "properties" : [ {
      "id" : "process_candidates",
      "type" : "Complex",
      "title" : "Candidates",
      "value" : "",
      "description" : "Candidate Groups and Users",
      "popular" : true
    } ]
  }
</code>
then add process_candidatespackage to the propertyPackages in the BPMNDiagram Stencil
this will use the standard assignment-popup.html and associated controller, I have made some styling tweaks to these but basically unchanged apart from removing the <code>assignment.assignee</code> text input if we are dealing with a process rather than a user task.

finally and I am not overly confident with this I have removed the toJson methods from prototype.js  these were conflicting with some JSON.stringify() calls in oryx basically have included the following in app.js
<code>
if(window.Prototype) {
                delete Object.prototype.toJSON;
                delete Array.prototype.toJSON;
                delete Hash.prototype.toJSON;
                delete String.prototype.toJSON;
            }
</code>

I also noticed that oryx was serializing the properties on the canvas stencil so I have commented this out, I have not fully tested the ramifications of this but so far all is well

comented out line 9662
<code>
//if (Object.prototype.toString.call(value) === "Object") value = JSON.stringify(value);
</code>
and lines 11353 to 11357
<code>
//*
if (!(typeof value === "string") && (!prop || !prop.isList())) {
      value = JSON.stringify(value);
}
*/
</code>

hope this pushes you in the right direction

Hi Dave,

This post is long time ago, but I am facing a problem similar to this. I used your guidelines but it seems for different version (I am using Activiti Explorer 5.22). I guess that because the BpmnJsonConverter.java in 5.22 version doesn't have the getValueAsList() method. I have added the process_candidatepackage to the stencilset.json and added that package to the BPMNDiagram Stencil but it doesn't appear in the editor.

Can you explain how can the package link to the form in editor?

Thanks,

Duke.

b_schnarr
Champ in-the-making
Champ in-the-making
Wow, thanks for this detailed manual. Activiti developers, would it be possible to adopt this in the official distro?

jbarrez
Star Contributor
Star Contributor
Thanks for the detailed code! Love it.

The quickest way to get it in the codebase would be if you can test it and create a Pull Request, Benjamin. Would you be able to do so?