protected Work updateValue(Work value) {
   Work work = new WorkImpl();
   work.setName(value.getName());
   for (Map.Entry<String, Text> entry : texts.entrySet()) {
     String text = entry.getValue().getText();
     work.setParameter(entry.getKey(), "".equals(text) ? null : text);
   }
   work.setParameterDefinitions(value.getParameterDefinitions());
   return work;
 }
Example #2
0
  private RuleFlowProcess getWorkItemProcess(String processId, String workName) {
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId(processId);

    List<Variable> variables = new ArrayList<Variable>();
    Variable variable = new Variable();
    variable.setName("UserName");
    variable.setType(new StringDataType());
    variables.add(variable);
    variable = new Variable();
    variable.setName("Person");
    variable.setType(new ObjectDataType(Person.class.getName()));
    variables.add(variable);
    variable = new Variable();
    variable.setName("MyObject");
    variable.setType(new ObjectDataType());
    variables.add(variable);
    variable = new Variable();
    variable.setName("Number");
    variable.setType(new IntegerDataType());
    variables.add(variable);
    process.getVariableScope().setVariables(variables);

    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);

    WorkItemNode workItemNode = new WorkItemNode();
    workItemNode.setName("workItemNode");
    workItemNode.setId(2);
    workItemNode.addInMapping("Comment", "Person.name");
    workItemNode.addInMapping("Attachment", "MyObject");
    workItemNode.addOutMapping("Result", "MyObject");
    workItemNode.addOutMapping("Result.length()", "Number");
    Work work = new WorkImpl();
    work.setName(workName);
    Set<ParameterDefinition> parameterDefinitions = new HashSet<ParameterDefinition>();
    ParameterDefinition parameterDefinition =
        new ParameterDefinitionImpl("ActorId", new StringDataType());
    parameterDefinitions.add(parameterDefinition);
    parameterDefinition = new ParameterDefinitionImpl("Content", new StringDataType());
    parameterDefinitions.add(parameterDefinition);
    parameterDefinition = new ParameterDefinitionImpl("Comment", new StringDataType());
    parameterDefinitions.add(parameterDefinition);
    work.setParameterDefinitions(parameterDefinitions);
    work.setParameter("ActorId", "#{UserName}");
    work.setParameter("Content", "#{Person.name}");
    workItemNode.setWork(work);

    EndNode endNode = new EndNode();
    endNode.setName("End");
    endNode.setId(3);

    connect(startNode, workItemNode);
    connect(workItemNode, endNode);

    process.addNode(startNode);
    process.addNode(workItemNode);
    process.addNode(endNode);

    return process;
  }