Package org.eclipse.bpmn2

Examples of org.eclipse.bpmn2.UserTask


    public void testPoolUnmarshalling() throws Exception {
        Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
        Definitions definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("pool.json"), "").getContents().get(0));
        assertTrue(definitions.getRootElements().size() == 1);
        assertTrue(definitions.getRootElements().get(0) instanceof Process);
        Process process = getRootProcess(definitions);
        assertEquals("pool", process.getName());
        assertEquals(ProcessType.PRIVATE, process.getProcessType());
        assertTrue(process.isIsClosed());
        definitions.eResource().save(System.out, Collections.emptyMap());
    }
View Full Code Here


    public void testLaneUnmarshalling() throws Exception {
        Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
        Definitions definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("pool.json"), "").getContents().get(0));
        assertTrue(definitions.getRootElements().size() == 1);
        assertTrue(definitions.getRootElements().get(0) instanceof Process);
        Process process = getRootProcess(definitions);
        assertTrue(process.getLaneSets().size() == 1);
        assertTrue(process.getLaneSets().get(0).getLanes().size() == 1);
        Lane l = process.getLaneSets().get(0).getLanes().get(0);
        assertEquals("my first lane", l.getName());
        definitions.eResource().save(System.out, Collections.emptyMap());
    }
View Full Code Here

            if (result == null)
                result = defaultCase(theEObject);
            return result;
        }
        case Bpmn2Package.USER_TASK: {
            UserTask userTask = (UserTask) theEObject;
            T result = caseUserTask(userTask);
            if (result == null)
                result = caseTask(userTask);
            if (result == null)
                result = caseActivity(userTask);
View Full Code Here

    for (FlowElement flowElement : flowElements) {
      if (flowElement instanceof StartEvent) {
        if (((StartEvent) flowElement).getOutgoing().size() == 1) {
          SequenceFlow sequenceFlow = (((StartEvent) flowElement).getOutgoing()).get(0);
          if (sequenceFlow.getTargetRef() instanceof UserTask) {
            UserTask userTask = (UserTask) sequenceFlow.getTargetRef();
            for (ExtensionAttributeValue extensionAttributeValue : userTask.getExtensionValues()) {
              FeatureMap extensionElements = extensionAttributeValue.getValue();
              for (Entry entry : extensionElements) {
                if (entry.getValue() instanceof TaskCommand) {
                  TaskCommand taskCommand = (TaskCommand) entry.getValue();
                  taskCommands.add(taskCommand);
View Full Code Here

   * @param flowElements
   */
  public static void allUserTaskNodeHaveTaskAssignment(List<FlowElement> flowElements,StringBuffer sb) {
    for (FlowElement flowElement : flowElements) {
      if (flowElement instanceof UserTask) {
        UserTask userTask = (UserTask) flowElement;
        if (userTask.getResources().size() < 1) {
          sb.append(userTask.getId() + "节点没有设置任务分配;" + "");
        }
        LoopCharacteristics loopCharacteristics = userTask.getLoopCharacteristics();

        if (loopCharacteristics instanceof MultiInstanceLoopCharacteristics) {

          for (ExtensionAttributeValue extensionAttributeValue : userTask.getExtensionValues()) {
            FeatureMap extensionElements = extensionAttributeValue.getValue();

            for (Entry entry : extensionElements) {
              if (entry.getValue() instanceof TaskCommand) {
                TaskCommand taskCommand = (TaskCommand) entry.getValue();
View Full Code Here

   */
  public static void taskAssignmentHasOneDuzhan(List<FlowElement> flowElements,StringBuffer sb) {
    List<HumanPerformer> humanPerformers = new ArrayList<HumanPerformer>();
    for (FlowElement flowElement : flowElements) {
      if (flowElement instanceof UserTask) {
        UserTask userTask = (UserTask) flowElement;
        for (ResourceRole resourceRole : userTask.getResources()) {
          if (resourceRole.getClass().getSimpleName().equals("HumanPerformerImpl")) {
            HumanPerformer humanPerformer = (HumanPerformer) resourceRole;
            humanPerformers.add(humanPerformer);
          }
        }
View Full Code Here

   *
   * @param flowElement
   */
  private static void verifyFormIsNull(FlowElement flowElement,StringBuffer sb) {
    if (flowElement instanceof UserTask) {
      UserTask userTask = (UserTask) flowElement;

      for (ExtensionAttributeValue extensionAttributeValue : userTask.getExtensionValues()) {
        FeatureMap extensionElements = extensionAttributeValue.getValue();

        for (Entry entry : extensionElements) {
          if (entry.getValue() instanceof FormUri) {
            FormUri formUri = (FormUri) entry.getValue();
            if (formUri.getExpression().getValue() != null || !(formUri.getExpression().getValue().equals(""))) {
              return;
            }
          }

        }
      }
      sb.append(userTask.getId() + "节点没有设置表单;" + "");
    }
  }
View Full Code Here

    TaskCommandInst taskCommand = getTaskCommandInst();
   

    List<TaskInstance> taskInstanceQueryTos = (new GetRollBackTaskCmd(this.taskId)).execute(commandContext);
   
    UserTask userTask=(UserTask)taskInstance.getToken().getFlowNode();
   

   
    ExecutionContext executionContext = getExecutionContext();

    Object expressionValue = null;
    if (taskCommand != null && taskCommand.getExpression() != null) {
      try {

        expressionValue = ExpressionMgmt.execute(taskCommand.getExpression(), executionContext);

      } catch (Exception e) {
        throw new FixFlowException(taskInstance.getToken().getFlowNode().getName()+ " 节点,用户命令表达式执行异常!", e);
      }
    }
    String rollBackNodeId = null;
    if (expressionValue != null && !expressionValue.equals("")) {
      rollBackNodeId = expressionValue.toString();
    } else {
      throw new FixFlowException("没有在表达式中指定退回节点!");
    }

    TaskInstance taskInstanceQueryRollBack = null;

    for (TaskInstance taskInstanceQueryTo : taskInstanceQueryTos) {
      if (taskInstanceQueryTo.getNodeId().equals(rollBackNodeId)) {
        taskInstanceQueryRollBack = taskInstanceQueryTo;
        break;
      }
    }
    if (taskInstanceQueryRollBack == null) {
      throw new FixFlowException(userTask.getId() + " 节点的退回命令上退回节点设置错误!");
    }

    String taskId = this.taskId;
    String taskComment = this.taskComment;
View Full Code Here

      setPropertyValue(PROPERTY_FORMURI_VIEW, userTask.getFormUriView(), propertiesNode);
    }
 
    @Override
    protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
      UserTask task = Bpmn2Factory.eINSTANCE.createUserTask();// UserTask();
      //任务主题
      JsonNode processSubject = JsonConverterUtil.getProperty(PROPERTY_USERTASK_SUBJECT, elementNode);
      if(processSubject != null && StringUtils.isNotEmpty(processSubject.asText())) {
        TaskSubject taskSubject = FixFlowFactory.eINSTANCE.createTaskSubject();
        Expression subjectExpression = FixFlowFactory.eINSTANCE.createExpression();
        subjectExpression.setName(processSubject.asText());
        subjectExpression.setValue(processSubject.asText());
        taskSubject.setExpression(subjectExpression);
        taskSubject.setId("TaskSubject_1");
        BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__TASK_SUBJECT, taskSubject);
      }
     
      //任务类型
      JsonNode taskTypeNode = getProperty(PROPERTY_USERTASK_TASKTYPE, elementNode);
      if(taskTypeNode != null){
        BpmnModelUtil.addExtensionAttribute(task, FixFlowPackage.Literals.DOCUMENT_ROOT__TASK_TYPE, taskTypeNode.asText());
      }
     
      //任务优先级
      JsonNode taskPriorityNode = getProperty(PROPERTY_PRIORITY, elementNode);
      if(taskPriorityNode != null){
        TaskPriority taskPriority = FixFlowFactory.eINSTANCE.createTaskPriority();
        Expression taskPriorityExpression = FixFlowFactory.eINSTANCE.createExpression();
        taskPriorityExpression.setName(taskPriorityNode.asText());
        taskPriorityExpression.setValue(taskPriorityNode.asText());
        taskPriority.setExpression(taskPriorityExpression);
        BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__TASK_PRIORITY, taskPriority);
      }
     
      //任务命令
      JsonNode taskCommandNode = getProperty(PROPERTY_TASKCOMMAND, elementNode);
      if(taskCommandNode != null){
        JsonNode itemsNode = taskCommandNode.get(EDITOR_PROPERTIES_GENERAL_ITEMS);
        if(itemsNode !=null){
          Iterator<JsonNode> taskcommandIterator = itemsNode.getElements();
          while(taskcommandIterator.hasNext()) {
            JsonNode taskCommandItemNode = taskcommandIterator.next();
            TaskCommand taskCommand = FixFlowFactory.eINSTANCE.createTaskCommand();
            String commandName = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_NAME).asText();
            String commandId = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_ID).asText();
            String commandType = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_TYPE).asText();
            String isSaveData = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_IS_SAVEDATA).asText();
            String isSimulation =  taskCommandItemNode.get(PROPERTY_TASKCOMMAND_IS_SIMULATION_RUN).asText();
            String isVerify = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_IS_VERIFICATION).asText();
            String paraExpression = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_PARA_EXPRESSION).asText();
            String expression = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_EXPRESSION).asText();
             
            taskCommand.setCommandType(commandType);
            taskCommand.setId(commandId);
            taskCommand.setName(commandName);
            taskCommand.setIsSimulationRun(isSimulation);
            taskCommand.setIsSaveData(isSaveData);
            taskCommand.setIsVerification(isVerify);
            //执行表达式
            Expression expression2 = FixFlowFactory.eINSTANCE.createExpression();
            expression2.setName(expression);
            expression2.setValue(expression);
            taskCommand.setExpression(expression2);
            //参数表达式
            Expression expression3 = FixFlowFactory.eINSTANCE.createExpression();
            expression3.setName(paraExpression);
            expression3.setValue(paraExpression);
            taskCommand.setParameterExpression(expression3);
            BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__TASK_COMMAND, taskCommand);
          }
        }
      }
     
      //默认表单
      JsonNode usertaskFormUri = JsonConverterUtil.getProperty(PROPERTY_FORMURI, elementNode);
      if(usertaskFormUri != null && StringUtil.isNotEmpty(usertaskFormUri.asText())){
        FormUri formUri = FixFlowFactory.eINSTANCE.createFormUri();
        Expression expression = FixFlowFactory.eINSTANCE.createExpression();
        expression.setName(usertaskFormUri.asText());
        expression.setValue(usertaskFormUri.asText());
        formUri.setExpression(expression);
        BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__FORM_URI, formUri);
      }
      //浏览表单
      JsonNode usertaskFormUriView = JsonConverterUtil.getProperty(PROPERTY_FORMURI_VIEW, elementNode);
      if(usertaskFormUriView != null && StringUtil.isNotEmpty(usertaskFormUriView.asText())){
        FormUriView formUri = FixFlowFactory.eINSTANCE.createFormUriView();
        Expression expression = FixFlowFactory.eINSTANCE.createExpression();
        expression.setName(usertaskFormUriView.asText());
        expression.setValue(usertaskFormUriView.asText());
        formUri.setExpression(expression);
        BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__FORM_URI_VIEW, formUri);
      }
      //分配策略
      JsonNode policyTypeNode = getProperty(PROPERTY_USERTASK_POLICYTYPE, elementNode);
      if(policyTypeNode != null){
        AssignPolicyType assignPolicyType = FixFlowFactory.eINSTANCE.createAssignPolicyType();
        assignPolicyType.setId(policyTypeNode.asText());
        String expressionBody = getPropertyValueAsString(PROPERTY_USERTASK_ASSIGNEXPRESSION, elementNode);
        if(StringUtil.isNotEmpty(expressionBody)){
          Expression policyExpression = FixFlowFactory.eINSTANCE.createExpression();
          policyExpression.setValue(expressionBody);
          policyExpression.setName(expressionBody);
          assignPolicyType.setExpression(policyExpression);
        }
        BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__ASSIGN_POLICY_TYPE, assignPolicyType);
      }
      //转换处理人
      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.getElements();
          while (assignmentIterator.hasNext()) {
            JsonNode assignmentItemNode = assignmentIterator.next();
            PotentialOwner potentialOwner = Bpmn2Factory.eINSTANCE.createPotentialOwner();
            String resourceType = assignmentItemNode.get(PROPERTY_USERTASK_RESOURCE_TYPE).asText();
            String includeExclusion = "INCLUDE";
            String isContainSub = assignmentItemNode.get(PROPERTY_USERTASK_RESOURCE_IS_CONTAINSSUB).asText();
            String resourceName = assignmentItemNode.get(PROPERTY_USERTASK_RESOURCE_NAME).asText();
            String expressionBody = assignmentItemNode.get(PROPERTY_USERTASK_RESOURCE_EXPRESSION).asText();
           
            BpmnModelUtil.addExtensionAttribute(potentialOwner, FixFlowPackage.Literals.DOCUMENT_ROOT__RESOURCE_TYPE, resourceType);
            BpmnModelUtil.addExtensionAttribute(potentialOwner, FixFlowPackage.Literals.DOCUMENT_ROOT__INCLUDE_EXCLUSION, includeExclusion);
            BpmnModelUtil.addExtensionAttribute(potentialOwner, FixFlowPackage.Literals.DOCUMENT_ROOT__IS_CONTAINS_SUB, isContainSub);
            ResourceAssignmentExpression resourceAssignmentExpression = Bpmn2Factory.eINSTANCE.createResourceAssignmentExpression();
            potentialOwner.setName(resourceName);
            FormalExpression formalExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
            formalExpression.setBody(expressionBody);
            formalExpression.setId(expressionBody);
            resourceAssignmentExpression.setExpression(formalExpression);
            potentialOwner.setResourceAssignmentExpression(resourceAssignmentExpression);
            task.getResources().add(potentialOwner);
          }
        }
      }
      return task;
    }
View Full Code Here

      super(fp, "User Task", "Task performed by human");
    }

    @Override
    protected Task createFlowElement(ICreateContext context) {
      UserTask task = ModelHandler.FACTORY.createUserTask();
      task.setName("User Task");
      return task;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.bpmn2.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.