Examples of HumanStepDefinition


Examples of org.activiti.workflow.simple.definition.HumanStepDefinition

  public List<HumanStepDefinition> getSteps() {
    List<HumanStepDefinition> steps = new ArrayList<HumanStepDefinition>();
    for (Object itemId : getItemIds()) {
      Item item = getItem(itemId);

      HumanStepDefinition humanStepDefinition = new HumanStepDefinition();
     
      String name = (String) item.getItemProperty(ID_NAME).getValue();
      if (name != null && name.length() > 0) {
        humanStepDefinition.setName(name);
      }
     
      String assignee = (String) ((ComboBox) item.getItemProperty(ID_ASSIGNEE).getValue()).getValue();
      if (assignee != null && assignee.length() > 0) {
        humanStepDefinition.setAssignee(assignee);
      }
     
      String groups = (String) ((ComboBox) item.getItemProperty("groups").getValue()).getValue();
      List<String> candidateGroups = new ArrayList<String>();
      if (groups != null && groups.length() > 0) {
        for (String group : groups.split(",")) {
          candidateGroups.add(group.trim());
        }
      }
      humanStepDefinition.setCandidateGroups(candidateGroups);

      String description = (String) ((TextField) item.getItemProperty(ID_DESCRIPTION).getValue()).getValue();
      if (description != null && description.length() > 0) {
        humanStepDefinition.setDescription(description);
      }
     
      humanStepDefinition.setStartsWithPrevious((boolean) ((CheckBox) item.getItemProperty(ID_START_WITH_PREVIOUS).getValue()).booleanValue());
     
      FormDefinition formDefinition = taskFormModel.getForm(itemId);
      humanStepDefinition.setForm(formDefinition);

      steps.add(humanStepDefinition);
    }
    return steps;
  }
View Full Code Here

Examples of org.activiti.workflow.simple.definition.HumanStepDefinition

  public void testHumanStepConversion() {
    WorkflowDefinition workflowDefinition = new WorkflowDefinition().name("testWorkflow").addHumanStep("step1", "fred")
        .addHumanStepForGroup("step2", Collections.singletonList("group")).addHumanStepForWorkflowInitiator("step3");

    // Add form to last step
    HumanStepDefinition stepWithForm = new HumanStepDefinition();
    stepWithForm.setName("step4");
    stepWithForm.setDescription("Step description");
   
    workflowDefinition.getSteps().add(stepWithForm);
    FormDefinition formDefinition = new FormDefinition();
    stepWithForm.setForm(formDefinition);
    formDefinition.setFormKey("123");
   
    TextPropertyDefinition textProp = new TextPropertyDefinition();
    textProp.setMandatory(true);
    textProp.setName("textProp");
    textProp.setWritable(false);
    formDefinition.addFormProperty(textProp);
    textProp.getParameters().put("custom-parameter", "This is a test");
   
    NumberPropertyDefinition numberProp = new NumberPropertyDefinition();
    numberProp.setMandatory(true);
    numberProp.setName("numberProp");
    numberProp.setWritable(false);
    formDefinition.addFormProperty(numberProp);
   
    ReferencePropertyDefinition reference = new ReferencePropertyDefinition();
    reference.setMandatory(true);
    reference.setName("referenceProp");
    reference.setWritable(false);
    reference.setType("referencedType");
    formDefinition.addFormProperty(reference);
   
    ListPropertyDefinition itemType = new ListPropertyDefinition();
    itemType.setMandatory(true);
    itemType.setName("referenceProp");
    itemType.setWritable(false);
    itemType.addEntry(new ListPropertyEntry("1", "Item 1"));
    itemType.addEntry(new ListPropertyEntry("2", "Item 2"));
    formDefinition.addFormProperty(itemType);
   
    // Write result to byte-array
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Writer writer = new OutputStreamWriter(baos);
    converter.writeWorkflowDefinition(workflowDefinition, writer);
   
    // Parse definition based on written JSON
    WorkflowDefinition parsedDefinition = converter.readWorkflowDefinition(baos.toByteArray());
    assertEquals(workflowDefinition.getSteps().size(), parsedDefinition.getSteps().size());

    int index = 0;
    for(StepDefinition stepDefinition : parsedDefinition.getSteps()) {
      assertTrue(stepDefinition instanceof HumanStepDefinition);
      HumanStepDefinition humanStep = (HumanStepDefinition) stepDefinition;
      HumanStepDefinition originalStep = (HumanStepDefinition) workflowDefinition.getSteps().get(index);
     
      // Check general human-step fields
      assertEquals(originalStep.getAssignee(), humanStep.getAssignee());
      assertEquals(originalStep.getAssignmentType(), humanStep.getAssignmentType());
      assertEquals(originalStep.getCandidateGroups(), humanStep.getCandidateGroups());
      assertEquals(originalStep.getCandidateUsers(), humanStep.getCandidateUsers());
      assertEquals(originalStep.getName(), humanStep.getName());
      assertEquals(originalStep.getDescription(), humanStep.getDescription());
     
      if(originalStep.getForm() != null) {
        // Encountered step with form attached to it, should be last step
        assertEquals(3, index);
        assertEquals("123", humanStep.getForm().getFormKey());
        assertEquals(originalStep.getForm().getFormPropertyDefinitions().size(),
            humanStep.getForm().getFormPropertyDefinitions().size());
       
        // Check form-fields, generic fields
        for(int i=0; i<originalStep.getForm().getFormPropertyDefinitions().size(); i++) {
          FormPropertyDefinition origDef = originalStep.getForm().getFormPropertyDefinitions().get(i);
          FormPropertyDefinition parsedDef = humanStep.getForm().getFormPropertyDefinitions().get(i);
         
          assertEquals(origDef.getName(), parsedDef.getName());
          assertEquals(origDef.isMandatory(), parsedDef.isMandatory());
          assertEquals(origDef.isWritable(), parsedDef.isWritable());
View Full Code Here

Examples of org.activiti.workflow.simple.definition.HumanStepDefinition

  }
 
  protected void loadTaskRows(StepDefinitionContainer<?> container, TaskTable taskTable) {
    for (StepDefinition stepDefinition : container.getSteps()) {
      if (stepDefinition instanceof HumanStepDefinition) {
        HumanStepDefinition humanStepDefinition = (HumanStepDefinition) stepDefinition;
        taskTable.addTaskRow(humanStepDefinition);
      } else if (stepDefinition instanceof StepDefinitionContainer<?>) {
        loadTaskRows((StepDefinitionContainer<?>) stepDefinition, taskTable);
      }
    }
View Full Code Here

Examples of org.activiti.workflow.simple.definition.HumanStepDefinition

        workflow.setDescription(description);
      }
     
      List<HumanStepDefinition> steps = taskTable.getSteps();
      for (int i=0; i<steps.size(); i++) {
        HumanStepDefinition currentStep = steps.get(i);
       
        // Check if we have a parallel block
        int nextIndex = i+1;
        ParallelStepsDefinition parallelStepsDefinition = null;
        while (nextIndex < steps.size() && steps.get(nextIndex).isStartsWithPrevious()) {
View Full Code Here

Examples of org.activiti.workflow.simple.definition.HumanStepDefinition

    if(id == null) {
      id = AlfrescoConversionUtil.getValidIdString(stepDefinition.getName());
    }
   
    // Break down the review into separate steps and convert those instead
    HumanStepDefinition reviewTask = new HumanStepDefinition();
    reviewTask.setName(stepDefinition.getName());
    reviewTask.setDescription("Review task");

    // Clone the review-form and add custom transitions property
    FormDefinition finalForm = null;
    if (stepDefinition.getForm() != null) {
      finalForm = stepDefinition.getForm().clone();
    } else {
      finalForm = new FormDefinition();
    }
    finalForm.addFormProperty(createTransitionsProperty());
    reviewTask.setForm(finalForm);
   
   
    // Assignment
    if(stepDefinition.getAssignmentType() == HumanStepAssignmentType.USER) {
      reviewTask.setAssignee(new PropertyReference(stepDefinition.getAssignmentPropertyName()).getPlaceholder());
    }
   
    // Add a script-task that initializes the correct variables for the review
    ScriptServiceTaskBuilder builder = new ScriptServiceTaskBuilder();
    builder.setExecutionVariable(getCountVariableName(id, namespacePrefix), "0");
View Full Code Here

Examples of org.activiti.workflow.simple.definition.HumanStepDefinition

    return HumanStepDefinition.class;
  }

  @Override
  public UserTask convertStepDefinition(StepDefinition stepDefinition, WorkflowDefinitionConversion conversion) {
    HumanStepDefinition humanStep = (HumanStepDefinition) stepDefinition;
    validate(humanStep);
   
    M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
    M2Namespace modelNamespace = model.getNamespaces().get(0);
   
    // Let superclass handle BPMN-specific conversion
    UserTask userTask = super.convertStepDefinition(stepDefinition, conversion);
   
    // Clear form-properties in the BPMN file, as we use custom form-mapping in Alfresco
    userTask.getFormProperties().clear();
   
    userTask.setName(humanStep.getName() != null ? humanStep.getName() : humanStep.getId());
   
    // Create the content model for the task
    M2Type type = new M2Type();
    model.getTypes().add(type);
    type.setName(AlfrescoConversionUtil.getQualifiedName(modelNamespace.getPrefix(),
        humanStep.getId()));
    type.setParentName(AlfrescoConversionConstants.DEFAULT_BASE_FORM_TYPE);
   
    // Update task-key on the task itself
    userTask.setFormKey(type.getName());
   
    // Create a form-config for the task
    Module shareModule = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
    Configuration configuration = shareModule.addConfiguration(AlfrescoConversionConstants.EVALUATOR_TASK_TYPE
        , type.getName());
    Form formConfig = configuration.createForm();
   
    // Populate model and form based on FormDefinition
    formCreator.createForm(type, formConfig, humanStep.getForm(), conversion);
   
    // Set up property sharing using task-listeners
    addPropertySharing(humanStep, conversion, userTask);
   
    // Special handling for assignee that reference form-properties, before BPMN
    // is created
    if (humanStep.getAssignmentType() == HumanStepAssignmentType.USER) {
      String assignee = humanStep.getAssignment().getAssignee();

      if (assignee != null && PropertyReference.isPropertyReference(assignee)) {
        PropertyReference reference = PropertyReference.createReference(assignee);
        AlfrescoConversionUtil.getPropertyReferences(conversion).add(reference);
        userTask.setAssignee(reference.getUsernameReferenceExpression(modelNamespace.getPrefix()));
      }
    } else if (humanStep.getAssignmentType() == HumanStepAssignmentType.USERS) {
      if(humanStep.getAssignment().getCandidateUsers() != null) {
        userTask.setCandidateUsers(resolveUserPropertyReferences(humanStep.getAssignment().getCandidateUsers(), modelNamespace.getPrefix(), conversion));
      }
    } else if (humanStep.getAssignmentType() == HumanStepAssignmentType.GROUPS) {
      if(humanStep.getAssignment().getCandidateGroups() != null) {
        userTask.setCandidateGroups(resolveGroupPropertyReferences(humanStep.getAssignment().getCandidateGroups(), modelNamespace.getPrefix(), conversion));
      }
    }
   
    return userTask;
  }
View Full Code Here

Examples of org.activiti.workflow.simple.definition.HumanStepDefinition

  @Test
  public void testTaskListenerForIncomingProperties() throws Exception {
    WorkflowDefinition definition = new WorkflowDefinition();
    definition.setId("process");
   
    HumanStepDefinition humanStep = new HumanStepDefinition();
    humanStep.setId("step1");
    FormDefinition form = new FormDefinition();
    form.setFormKey("myform");
    humanStep.setForm(form);
   
    definition.addStep(humanStep);
   
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
View Full Code Here

Examples of org.activiti.workflow.simple.definition.HumanStepDefinition

  @Test
  public void testTaskListenerForOutgoingProperties() throws Exception {
    WorkflowDefinition definition = new WorkflowDefinition();
    definition.setId("process");
   
    HumanStepDefinition humanStep = new HumanStepDefinition();
    humanStep.setId("step1");
    FormDefinition form = new FormDefinition();
   
    humanStep.setForm(form);
   
    TextPropertyDefinition text = new TextPropertyDefinition();
    text.setName("my text");
   
    text.getParameters().put(AlfrescoConversionConstants.PARAMETER_ADD_PROPERTY_TO_OUTPUT, true);
View Full Code Here

Examples of org.activiti.workflow.simple.definition.HumanStepDefinition

   * Check artifact export.
   */
  @Test
  public void testExportArtifacts() throws Exception {
    WorkflowDefinition definition = new WorkflowDefinition();
    HumanStepDefinition humanStep = new HumanStepDefinition();
    humanStep.setAssignee("fred");
    humanStep.setId("step 1");
    FormDefinition form = new FormDefinition();
    form.setFormKey("wf:activitiAdhoc");
    humanStep.setForm(form);
   
    definition.addStep(humanStep);
   
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
View Full Code Here

Examples of org.activiti.workflow.simple.definition.HumanStepDefinition

  public void testHumanStepBasicFormField() throws Exception {
    // TODO: finish test once all types are present
    WorkflowDefinition definition = new WorkflowDefinition();
    definition.setId("process");
   
    HumanStepDefinition humanStep = new HumanStepDefinition();
    humanStep.setId("step1");
    FormDefinition form = new FormDefinition();
    humanStep.setForm(form);
   
    FormPropertyGroup group = new FormPropertyGroup();
    group.setId("group");
    group.setTitle("My group");
    humanStep.getForm().addFormPropertyGroup(group);
   
    // Add simple text
    TextPropertyDefinition textProperty = new TextPropertyDefinition();
    textProperty.setName("text");
    textProperty.setMandatory(true);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.