Package org.activiti.bpmn.model

Examples of org.activiti.bpmn.model.UserTask


    return STENCIL_TASK_USER;
  }
 
  @Override
  protected void convertElementToJson(ObjectNode propertiesNode, FlowElement flowElement) {
    UserTask userTask = (UserTask) flowElement;
    String owner = userTask.getOwner();
    String assignee = userTask.getAssignee();
    String candidateUsers = convertListToCommaSeparatedString(userTask.getCandidateUsers());
    String candidateGroups = convertListToCommaSeparatedString(userTask.getCandidateGroups());
   
    if (StringUtils.isNotEmpty(owner) || StringUtils.isNotEmpty(assignee) || StringUtils.isNotEmpty(candidateUsers) || StringUtils.isNotEmpty(candidateGroups)) {
      ObjectNode assignmentNode = objectMapper.createObjectNode();
      ArrayNode itemsNode = objectMapper.createArrayNode();
     
      if (StringUtils.isNotEmpty(owner)) {
          ObjectNode assignmentItemNode = objectMapper.createObjectNode();
          assignmentItemNode.put(PROPERTY_USERTASK_ASSIGNMENT_TYPE, PROPERTY_USERTASK_OWNER);
          assignmentItemNode.put(PROPERTY_USERTASK_ASSIGNMENT_EXPRESSION, owner);
          itemsNode.add(assignmentItemNode);
        }
     
      if (StringUtils.isNotEmpty(assignee)) {
        ObjectNode assignmentItemNode = objectMapper.createObjectNode();
        assignmentItemNode.put(PROPERTY_USERTASK_ASSIGNMENT_TYPE, PROPERTY_USERTASK_ASSIGNEE);
        assignmentItemNode.put(PROPERTY_USERTASK_ASSIGNMENT_EXPRESSION, assignee);
        itemsNode.add(assignmentItemNode);
      }
     
      if (StringUtils.isNotEmpty(candidateUsers)) {
        ObjectNode assignmentItemNode = objectMapper.createObjectNode();
        assignmentItemNode.put(PROPERTY_USERTASK_ASSIGNMENT_TYPE, PROPERTY_USERTASK_CANDIDATE_USERS);
        assignmentItemNode.put(PROPERTY_USERTASK_ASSIGNMENT_EXPRESSION, candidateUsers);
        itemsNode.add(assignmentItemNode);
      }
     
      if (StringUtils.isNotEmpty(candidateGroups)) {
        ObjectNode assignmentItemNode = objectMapper.createObjectNode();
        assignmentItemNode.put(PROPERTY_USERTASK_ASSIGNMENT_TYPE, PROPERTY_USERTASK_CANDIDATE_GROUPS);
        assignmentItemNode.put(PROPERTY_USERTASK_ASSIGNMENT_EXPRESSION, candidateGroups);
        itemsNode.add(assignmentItemNode);
      }
     
      assignmentNode.put("totalCount", itemsNode.size());
      assignmentNode.put(EDITOR_PROPERTIES_GENERAL_ITEMS, itemsNode);
      propertiesNode.put(PROPERTY_USERTASK_ASSIGNMENT, assignmentNode);
     
    }
   
    if(!userTask.getCustomUserIdentityLinks().isEmpty() || !userTask.getCustomGroupIdentityLinks().isEmpty()){
      ObjectNode customIdentityLinksNode = objectMapper.createObjectNode();
        ArrayNode itemsNode = objectMapper.createArrayNode();
       
        for(String linkType : userTask.getCustomUserIdentityLinks().keySet()){
          ObjectNode identityItemNode = objectMapper.createObjectNode();
          identityItemNode.put(PROPERTY_USERTASK_IDENTITY_TYPE, "user");
          identityItemNode.put(PROPERTY_USERTASK_IDENTITY_LINK_TYPE, linkType);
          String users = convertListToCommaSeparatedString(new ArrayList<String>(userTask.getCustomUserIdentityLinks().get(linkType)));
          identityItemNode.put(PROPERTY_USERTASK_IDENTITY_LINK_EXPRESSION, users);
            itemsNode.add(identityItemNode);
        }
       
        for(String linkType : userTask.getCustomGroupIdentityLinks().keySet()){
          ObjectNode identityItemNode = objectMapper.createObjectNode();
          identityItemNode.put(PROPERTY_USERTASK_IDENTITY_TYPE, "group");
          identityItemNode.put(PROPERTY_USERTASK_IDENTITY_LINK_TYPE, linkType);
          String groups = convertListToCommaSeparatedString(new ArrayList<String>(userTask.getCustomGroupIdentityLinks().get(linkType)));
          identityItemNode.put(PROPERTY_USERTASK_IDENTITY_LINK_EXPRESSION, groups);
            itemsNode.add(identityItemNode);
        }
       
        customIdentityLinksNode.put("totalCount", itemsNode.size());
        customIdentityLinksNode.put(EDITOR_PROPERTIES_GENERAL_ITEMS, itemsNode);
        propertiesNode.put(PROPERTY_USERTASK_CUSTOM_IDENTITY_LINKS, customIdentityLinksNode);
    }
   
   
    if (userTask.getPriority() != null) {
      setPropertyValue(PROPERTY_PRIORITY, userTask.getPriority().toString(), propertiesNode);
    }
    setPropertyValue(PROPERTY_FORMKEY, userTask.getFormKey(), propertiesNode);
    setPropertyValue(PROPERTY_DUEDATE, userTask.getDueDate(), propertiesNode);
    setPropertyValue(PROPERTY_CATEGORY, userTask.getCategory(), propertiesNode);;
   
    addFormProperties(userTask.getFormProperties(), propertiesNode);
  }
View Full Code Here


  private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("writeReportTask");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("writeReportTask", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertEquals("writeReportTask", userTask.getId());
    assertEquals("Fazer relatório", userTask.getName());
  }
View Full Code Here

    addFormProperties(userTask.getFormProperties(), propertiesNode);
  }
 
  @Override
  protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
    UserTask task = new UserTask();
    task.setPriority(getPropertyValueAsString(PROPERTY_PRIORITY, elementNode));
    task.setFormKey(getPropertyValueAsString(PROPERTY_FORMKEY, elementNode));
    task.setDueDate(getPropertyValueAsString(PROPERTY_DUEDATE, elementNode));
    task.setCategory(getPropertyValueAsString(PROPERTY_CATEGORY, elementNode));
   
    JsonNode assignmentNode = getProperty(PROPERTY_USERTASK_ASSIGNMENT, elementNode);
    if (assignmentNode != null) {
      JsonNode itemsNode = assignmentNode.get(EDITOR_PROPERTIES_GENERAL_ITEMS);
      if (itemsNode != null) {
        Iterator<JsonNode> assignmentIterator = itemsNode.elements();
        while (assignmentIterator.hasNext()) {
          JsonNode assignmentItemNode = assignmentIterator.next();
          if (assignmentItemNode.get(PROPERTY_USERTASK_ASSIGNMENT_TYPE) != null &&
              assignmentItemNode.get(PROPERTY_USERTASK_ASSIGNMENT_EXPRESSION) != null) {
           
            String assignmentType = assignmentItemNode.get(PROPERTY_USERTASK_ASSIGNMENT_TYPE).asText();
            if (PROPERTY_USERTASK_ASSIGNEE.equals(assignmentType)) {
              task.setAssignee(assignmentItemNode.get(PROPERTY_USERTASK_ASSIGNMENT_EXPRESSION).asText());
            } else if (PROPERTY_USERTASK_OWNER.equals(assignmentType)) {
              task.setOwner(assignmentItemNode.get(PROPERTY_USERTASK_ASSIGNMENT_EXPRESSION).asText());
            } else if (PROPERTY_USERTASK_CANDIDATE_USERS.equals(assignmentType)) {
              task.setCandidateUsers(getValueAsList(PROPERTY_USERTASK_ASSIGNMENT_EXPRESSION, assignmentItemNode));
            } else if (PROPERTY_USERTASK_CANDIDATE_GROUPS.equals(assignmentType)) {
              task.setCandidateGroups(getValueAsList(PROPERTY_USERTASK_ASSIGNMENT_EXPRESSION, assignmentItemNode));
            }
          }
        }
      }
    }
   
    JsonNode customIdentityLinksNode = getProperty(PROPERTY_USERTASK_CUSTOM_IDENTITY_LINKS, elementNode);
    if (customIdentityLinksNode != null) {
      JsonNode itemsNode = customIdentityLinksNode.get(EDITOR_PROPERTIES_GENERAL_ITEMS);
      if (itemsNode != null) {
        Iterator<JsonNode> customIdentityLinksIterator = itemsNode.elements();
        while (customIdentityLinksIterator.hasNext()) {
          JsonNode customIdentityLinksItemNode = customIdentityLinksIterator.next();
          if (customIdentityLinksItemNode.get(PROPERTY_USERTASK_IDENTITY_TYPE) != null && customIdentityLinksItemNode.get(PROPERTY_USERTASK_IDENTITY_LINK_TYPE) != null
              && customIdentityLinksItemNode.get(PROPERTY_USERTASK_IDENTITY_LINK_EXPRESSION) != null) {
           
           String identityType = customIdentityLinksItemNode.get(PROPERTY_USERTASK_IDENTITY_TYPE).asText();
           String identityLinkType = customIdentityLinksItemNode.get(PROPERTY_USERTASK_IDENTITY_LINK_TYPE).asText();
          
           List<String> identitiesList = getValueAsList(PROPERTY_USERTASK_IDENTITY_LINK_EXPRESSION, customIdentityLinksItemNode);
          
           if ("user".equals(identityType)) {
             Set<String> users = task.getCustomUserIdentityLinks().get(identityLinkType);
             if(users == null){
               users = new HashSet<String>();
               task.getCustomUserIdentityLinks().put(identityLinkType, users);
             }
             users.addAll(identitiesList);
           }else if ("group".equals(identityType)) {
             Set<String> groups = task.getCustomGroupIdentityLinks().get(identityLinkType);
             if(groups == null){
               groups = new HashSet<String>();
               task.getCustomGroupIdentityLinks().put(identityLinkType, groups);
             }
             groups.addAll(identitiesList);
           }
          }
        }
View Full Code Here

  
    flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("userTask1", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertEquals("kermit", userTask.getAssignee());
   
    flowElement = model.getMainProcess().getFlowElement("subprocess1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess1", flowElement.getId());
View Full Code Here

    FlowElement flowElement = model.getMainProcess().getFlowElement("usertask");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("usertask", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertEquals("usertask", userTask.getId());
    assertEquals("User Task", userTask.getName());
   
    Map<String, List<ExtensionAttribute>> attributesMap = userTask.getAttributes();
    assertNotNull(attributesMap);
    assertEquals(2, attributesMap.size());

    attributes = attributesMap.get("id");
    assertNotNull(attributes);
View Full Code Here

  private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("usertask");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("usertask", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertEquals("usertask", userTask.getId());
    assertEquals("User task", userTask.getName());
    assertEquals("testKey", userTask.getFormKey());
    assertEquals("40", userTask.getPriority());
    assertEquals("2012-11-01", userTask.getDueDate());
   
    assertEquals("kermit", userTask.getAssignee());
    assertEquals(2, userTask.getCandidateUsers().size());
    assertTrue(userTask.getCandidateUsers().contains("kermit"));
    assertTrue(userTask.getCandidateUsers().contains("fozzie"));
    assertEquals(2, userTask.getCandidateGroups().size());
    assertTrue(userTask.getCandidateGroups().contains("management"));
    assertTrue(userTask.getCandidateGroups().contains("sales"));
   
    assertEquals(1, userTask.getCustomUserIdentityLinks().size());
    assertEquals(2, userTask.getCustomGroupIdentityLinks().size());
    assertTrue(userTask.getCustomUserIdentityLinks().get("businessAdministrator").contains("kermit"));
    assertTrue(userTask.getCustomGroupIdentityLinks().get("manager").contains("management"));
    assertTrue(userTask.getCustomGroupIdentityLinks().get("businessAdministrator").contains("management"));
   
   
    List<FormProperty> formProperties = userTask.getFormProperties();
    assertEquals(3, formProperties.size());
    FormProperty formProperty = formProperties.get(0);
    assertEquals("formId", formProperty.getId());
    assertEquals("formName", formProperty.getName());
    assertEquals("string", formProperty.getType());
    assertEquals("variable", formProperty.getVariable());
    assertEquals("${expression}", formProperty.getExpression());
    formProperty = formProperties.get(1);
    assertEquals("formId2", formProperty.getId());
    assertEquals("anotherName", formProperty.getName());
    assertEquals("long", formProperty.getType());
    assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
    assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
    formProperty = formProperties.get(2);
    assertEquals("formId3", formProperty.getId());
    assertEquals("enumName", formProperty.getName());
    assertEquals("enum", formProperty.getType());
    assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
    assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
    assertEquals(2, formProperty.getFormValues().size());
   
    List<ActivitiListener> listeners = userTask.getTaskListeners();
    assertEquals(3, listeners.size());
    ActivitiListener listener = listeners.get(0);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
    assertEquals("org.test.TestClass", listener.getImplementation());
    assertEquals("create", listener.getEvent());
    listener = listeners.get(1);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${someExpression}", listener.getImplementation());
    assertEquals("assignment", listener.getEvent());
    listener = listeners.get(2);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${someDelegateExpression}", listener.getImplementation());
    assertEquals("complete", listener.getEvent());
   
    List<ActivitiListener> executionListeners = userTask.getExecutionListeners();
    assertEquals(1, executionListeners.size());
    ActivitiListener executionListener = executionListeners.get(0);
    assertEquals("end", executionListener.getEvent());
   
  }
View Full Code Here

    // See feedback-step.png in the resource folder to get a graphical understanding of the conversion below
   
    Map<String, BaseElement> processElements = new HashMap<String, BaseElement>();
   
    // The first user task, responsible for configuring the feedback
    UserTask selectPeopleUserTask = createSelectPeopleUserTask(feedbackStepDefinition, conversion, processElements);
   
    // Parallel gateways (forking/joining)
    ParallelGateway fork = createForkParallelGateway(conversion, processElements);
    addSequenceFlow(conversion, selectPeopleUserTask, fork);
   
    // Gather feedback user task for the initiator of the feedback step
    UserTask gatherFeedbackUserTask = createGatherFeedbackUserTask(feedbackStepDefinition, conversion, processElements);
    addSequenceFlow(conversion, fork, gatherFeedbackUserTask);
   
    // Global signal event
    Signal signal = createSignalDeclaration(conversion);
   
    // Signal throw event after the gather feedback task
    ThrowEvent signalThrowEvent = createSignalThrow(conversion, signal);
    addSequenceFlow(conversion, gatherFeedbackUserTask, signalThrowEvent);
   
    // Povide feedback step
    UserTask feedbackTask = createFeedbackUserTask(feedbackStepDefinition, conversion, processElements);
    addSequenceFlow(conversion, fork, feedbackTask);
   
    // Boundary signal catch to shut down all tasks if the 'gather feedback' task is completed
    BoundaryEvent boundarySignalCatch = createBoundarySignalCatch(conversion, signal, feedbackTask);
   
View Full Code Here

    return processElements;
  }

  protected UserTask createSelectPeopleUserTask(FeedbackStepDefinition feedbackStepDefinition, WorkflowDefinitionConversion conversion,
          Map<String, BaseElement> processElements) {
    UserTask selectPeopleUserTask = new UserTask();
    selectPeopleUserTask.setId(conversion.getUniqueNumberedId(ConversionConstants.USER_TASK_ID_PREFIX));
    selectPeopleUserTask.setName(getSelectPeopleTaskName());
    selectPeopleUserTask.setAssignee(feedbackStepDefinition.getFeedbackInitiator());
    addFlowElement(conversion, selectPeopleUserTask, true);
    processElements.put(SELECT_PEOPLE_USER_TASK, selectPeopleUserTask);
   
    // TODO: work out form such that it can be used in Activiti Explorer, ie. add correct form properties
    // The following is just a a bit of a dummy form property
    FormProperty feedbackProvidersProperty = new FormProperty();
    feedbackProvidersProperty.setId(VARIABLE_FEEDBACK_PROVIDERS);
    feedbackProvidersProperty.setName("Who needs to provide feedback?");
    feedbackProvidersProperty.setRequired(true);
    feedbackProvidersProperty.setType("string"); // TODO: we need some kind of 'people' property type here
   
    selectPeopleUserTask.setFormProperties(Arrays.asList(feedbackProvidersProperty));
   
    // When the list of feedback providers is fixed up front, we need to add a script listener
    // that injects these variables into the process (instead of having it provided by the end user in a form)
    if (feedbackStepDefinition.getFeedbackProviders() != null && !feedbackStepDefinition.getFeedbackProviders()
                                                                                        .isEmpty()) {
      if (selectPeopleUserTask.getTaskListeners() == null)
      {
        selectPeopleUserTask.setTaskListeners(new ArrayList<ActivitiListener>());
      }
     
      ActivitiListener taskListener = new ActivitiListener();
      taskListener.setEvent("complete");
      taskListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
      taskListener.setImplementation("org.activiti.engine.impl.bpmn.listener.ScriptTaskListener");
     
      FieldExtension languageField = new FieldExtension();
      languageField.setFieldName("language");
      languageField.setStringValue("JavaScript");
     
      FieldExtension scriptField = new FieldExtension();
      scriptField.setFieldName("script");
     
      StringBuilder script = new StringBuilder();
      if (JvmUtil.isJDK8()) {
        script.append("load(\"nashorn:mozilla_compat.js\");");
      }
      script.append("importPackage (java.util); var feedbackProviders = new ArrayList();" + System.getProperty("line.separator"));
      for (String feedbackProvider : feedbackStepDefinition.getFeedbackProviders()) {
        script.append("feedbackProviders.add('" + feedbackProvider + "');" + System.getProperty("line.separator"));
      }
      script.append("task.getExecution().setVariable('" + VARIABLE_FEEDBACK_PROVIDERS + "', feedbackProviders);" + System.getProperty("line.separator"));
      scriptField.setStringValue(script.toString());

      taskListener.setFieldExtensions(Arrays.asList(languageField, scriptField));
     
      selectPeopleUserTask.getTaskListeners().add(taskListener);
    }
   
   
    return selectPeopleUserTask;
  }
View Full Code Here

    return fork;
  }

  protected UserTask createGatherFeedbackUserTask(FeedbackStepDefinition feedbackStepDefinition, WorkflowDefinitionConversion conversion,
          Map<String, BaseElement> processElements) {
    UserTask gatherFeedbackUserTask = new UserTask();
    gatherFeedbackUserTask.setId(conversion.getUniqueNumberedId(ConversionConstants.USER_TASK_ID_PREFIX));
    gatherFeedbackUserTask.setName(getGatherFeedbackTaskName());
    gatherFeedbackUserTask.setAssignee(feedbackStepDefinition.getFeedbackInitiator());
    addFlowElement(conversion, gatherFeedbackUserTask);
    processElements.put(SELECT_PEOPLE_USER_TASK, gatherFeedbackUserTask);
    return gatherFeedbackUserTask;
  }
View Full Code Here

    return join;
  }

  protected UserTask createFeedbackUserTask(FeedbackStepDefinition feedbackStepDefinition, WorkflowDefinitionConversion conversion,
          Map<String, BaseElement> processElements) {
    UserTask feedbackTask = new UserTask();
    feedbackTask.setId(conversion.getUniqueNumberedId(ConversionConstants.USER_TASK_ID_PREFIX));
    feedbackTask.setName(getProvideFeedbackTaskName());
    feedbackTask.setAssignee("${" + VARIABLE_FEEDBACK_PROVIDER + "}");
   
    MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = new MultiInstanceLoopCharacteristics();
    multiInstanceLoopCharacteristics.setSequential(false);
    multiInstanceLoopCharacteristics.setInputDataItem(VARIABLE_FEEDBACK_PROVIDERS);
    multiInstanceLoopCharacteristics.setElementVariable(VARIABLE_FEEDBACK_PROVIDER);
    feedbackTask.setLoopCharacteristics(multiInstanceLoopCharacteristics);
   
    addFlowElement(conversion, feedbackTask);
    processElements.put(FEEDBACK_USER_TASK, feedbackTask);
    return feedbackTask;
  }
View Full Code Here

TOP

Related Classes of org.activiti.bpmn.model.UserTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.