Package org.activiti.bpmn.model

Examples of org.activiti.bpmn.model.UserTask


  public Class< ? extends StepDefinition> getHandledClass() {
    return HumanStepDefinition.class;
  }
 
  protected UserTask createProcessArtifact(HumanStepDefinition stepDefinition, WorkflowDefinitionConversion conversion) {
    UserTask userTask = createUserTask(stepDefinition, conversion);
    addFlowElement(conversion, userTask, true);
   
    return userTask;
  }
View Full Code Here


  protected UserTask createUserTask(HumanStepDefinition humanStepDefinition, WorkflowDefinitionConversion conversion) {
   
    // TODO: validate and throw exception on missing properties
   
    UserTask userTask = new UserTask();
    userTask.setId(conversion.getUniqueNumberedId(ConversionConstants.USER_TASK_ID_PREFIX));
    userTask.setName(humanStepDefinition.getName());
    userTask.setDocumentation(humanStepDefinition.getDescription());

    // Initiator
    if (humanStepDefinition.getAssignmentType() == HumanStepAssignmentType.INITIATOR) {
      userTask.setAssignee(getInitiatorExpression());

      // Add the initiator variable declaration to the start event
      for (StartEvent startEvent : conversion.getProcess().findFlowElementsOfType(StartEvent.class)) {
        startEvent.setInitiator(getInitiatorVariable());
      }
     
    // Assignee 
    } else if (humanStepDefinition.getAssignmentType() == HumanStepAssignmentType.USER) {
      userTask.setAssignee(humanStepDefinition.getAssignee());
    }

    // Candidate Users
    if (humanStepDefinition.getAssignmentType() == HumanStepAssignmentType.USERS || humanStepDefinition.getAssignmentType() == HumanStepAssignmentType.MIXED) {
      userTask.setCandidateUsers(humanStepDefinition.getCandidateUsers());
    }

    // Candidate groups
    if (humanStepDefinition.getAssignmentType() == HumanStepAssignmentType.GROUPS || humanStepDefinition.getAssignmentType() == HumanStepAssignmentType.MIXED) {
      userTask.setCandidateGroups(humanStepDefinition.getCandidateGroups());
    }
   
    // Form
    if (humanStepDefinition.getForm() != null) {
     
      FormDefinition formDefinition = humanStepDefinition.getForm();
     
      // Form properties
      userTask.setFormProperties(convertProperties(formDefinition));
     
      if(formDefinition.getFormKey() != null) {
        userTask.setFormKey(formDefinition.getFormKey());
      }
    }

    return userTask;
  }
View Full Code Here

 
  @Override
  @SuppressWarnings("unchecked")
  protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
    String formKey = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_FORM_FORMKEY);
    UserTask userTask = null;
    if (StringUtils.isNotEmpty(formKey)) {
      if (model.getUserTaskFormTypes() != null && model.getUserTaskFormTypes().contains(formKey)) {
        userTask = new AlfrescoUserTask();
      }
    }
    if (userTask == null) {
      userTask = new UserTask();
    }
    BpmnXMLUtil.addXMLLocation(userTask, xtr);
    userTask.setDueDate(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_DUEDATE));
    userTask.setCategory(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_CATEGORY));
    userTask.setFormKey(formKey);
    userTask.setAssignee(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_ASSIGNEE));
    userTask.setOwner(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_OWNER));
    userTask.setPriority(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_PRIORITY));
   
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_CANDIDATEUSERS))) {
      String expression = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_CANDIDATEUSERS);
      userTask.getCandidateUsers().addAll(parseDelimitedList(expression));
    }
   
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_CANDIDATEGROUPS))) {
      String expression = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_CANDIDATEGROUPS);
      userTask.getCandidateGroups().addAll(parseDelimitedList(expression));
    }

    BpmnXMLUtil.addCustomAttributes(xtr, userTask, defaultElementAttributes,
        defaultActivityAttributes, defaultUserTaskAttributes);
View Full Code Here

  }
 
  @Override
  @SuppressWarnings("unchecked")
  protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
    UserTask userTask = (UserTask) element;
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_ASSIGNEE, userTask.getAssignee(), xtw);
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_OWNER, userTask.getOwner(), xtw);
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CANDIDATEUSERS, convertToDelimitedString(userTask.getCandidateUsers()), xtw);
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CANDIDATEGROUPS, convertToDelimitedString(userTask.getCandidateGroups()), xtw);
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_DUEDATE, userTask.getDueDate(), xtw);
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CATEGORY, userTask.getCategory(), xtw);
    writeQualifiedAttribute(ATTRIBUTE_FORM_FORMKEY, userTask.getFormKey(), xtw);
    if (userTask.getPriority() != null) {
      writeQualifiedAttribute(ATTRIBUTE_TASK_USER_PRIORITY, userTask.getPriority().toString(), xtw);
    }
    // write custom attributes
    BpmnXMLUtil.writeCustomAttributes(userTask.getAttributes().values(), xtw, defaultElementAttributes,
        defaultActivityAttributes, defaultUserTaskAttributes);
  }
View Full Code Here

        defaultActivityAttributes, defaultUserTaskAttributes);
  }
 
  @Override
  protected boolean writeExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception {
    UserTask userTask = (UserTask) element;
    didWriteExtensionStartElement = writeFormProperties(userTask, didWriteExtensionStartElement, xtw);
    didWriteExtensionStartElement = writeCustomIdentities(element, didWriteExtensionStartElement, xtw);
    return didWriteExtensionStartElement;
  }
View Full Code Here

    didWriteExtensionStartElement = writeCustomIdentities(element, didWriteExtensionStartElement, xtw);
    return didWriteExtensionStartElement;
  }
 
  protected boolean writeCustomIdentities(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception {
    UserTask userTask = (UserTask) element;
    if(userTask.getCustomUserIdentityLinks().isEmpty() && userTask.getCustomGroupIdentityLinks().isEmpty())
      return didWriteExtensionStartElement;
     
     
        if (didWriteExtensionStartElement == false) {
              xtw.writeStartElement(ELEMENT_EXTENSIONS);
              didWriteExtensionStartElement = true;
            }
        Set<String> identityLinkTypes = new HashSet<String>();
        identityLinkTypes.addAll(userTask.getCustomUserIdentityLinks().keySet());
        identityLinkTypes.addAll(userTask.getCustomGroupIdentityLinks().keySet());
        for (String identityType : identityLinkTypes) {
          writeCustomIdentities(userTask, identityType, userTask.getCustomUserIdentityLinks().get(identityType), userTask.getCustomGroupIdentityLinks().get(identityType), xtw);
        }
     
      return didWriteExtensionStartElement;
    }
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

    StartEvent startEvent = startEvents.get(0);
    assertEquals(1, startEvent.getOutgoingFlows().size());
    assertEquals(0, startEvent.getIncomingFlows().size());
   
    String nextElementId = startEvent.getOutgoingFlows().get(0).getTargetRef();
    UserTask userTask = (UserTask) process.getFlowElement(nextElementId);
    assertEquals("First Task", userTask.getName());
   
    assertEquals(1, userTask.getOutgoingFlows().size());
    assertEquals(1, userTask.getIncomingFlows().size());
    nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef();
    ParallelGateway parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId);
    assertEquals(2, parallelGateway.getOutgoingFlows().size());
   
    nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef();
    assertEquals(1, parallelGateway.getIncomingFlows().size());
    userTask = (UserTask) process.getFlowElement(nextElementId);
    assertEquals(1, userTask.getOutgoingFlows().size());
   
    nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef();
    parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId);
    assertEquals(1, parallelGateway.getOutgoingFlows().size());
    assertEquals(2, parallelGateway.getIncomingFlows().size());
   
    nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef();
View Full Code Here

    StartEvent startEvent = new StartEvent();
    startEvent.setId("start");
    process.addFlowElement(startEvent);

    UserTask userTask = new UserTask();
    userTask.setName("The Task");
    userTask.setId("theTask");
    userTask.setAssignee("kermit");
    process.addFlowElement(userTask);

    EndEvent endEvent = new EndEvent();
    endEvent.setId("theEnd");
    process.addFlowElement(endEvent);
View Full Code Here

    StartEvent startEvent = new StartEvent();
    startEvent.setId("start");
    process.addFlowElement(startEvent);

    UserTask userTask = new UserTask();
    userTask.setName("The First Task");
    userTask.setId("task1");
    userTask.setAssignee("kermit");
    process.addFlowElement(userTask);

    UserTask userTask2 = new UserTask();
    userTask2.setName("The Second Task");
    userTask2.setId("task2");
    userTask2.setAssignee("kermit");
    process.addFlowElement(userTask2);

    EndEvent endEvent = new EndEvent();
    endEvent.setId("theEnd");
    process.addFlowElement(endEvent);
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.