Package org.activiti.workflow.simple.definition

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


  public void beforeStepsConversion(WorkflowDefinitionConversion conversion) {
    initializeProcess(conversion);
  }

  protected void initializeProcess(WorkflowDefinitionConversion conversion) {
    WorkflowDefinition workflowDefinition = conversion.getWorkflowDefinition();

    // Create new process
    Process process = conversion.getProcess();
    process.setId(generateProcessId(workflowDefinition));
    process.setName(workflowDefinition.getName());
    process.setDocumentation(workflowDefinition.getDescription());
   
    if (workflowDefinition.getCategory() != null) {
      conversion.getBpmnModel().setTargetNamespace(workflowDefinition.getCategory());
    }

    conversion.setProcess(process);

    // Add start-event
    StartEvent startEvent = new StartEvent();
    startEvent.setId(START_EVENT_ID);
   
    if(workflowDefinition.getStartFormDefinition() != null && workflowDefinition.getStartFormDefinition().getFormKey() != null) {
      startEvent.setFormKey(workflowDefinition.getStartFormDefinition().getFormKey());
    }
   
    process.addFlowElement(startEvent);
    conversion.setLastActivityId(startEvent.getId());
  }
View Full Code Here


  }

  @Test
  public void testWorkflowDefinitionConversion() {
    // Create definition
    WorkflowDefinition workflowDefinition = new WorkflowDefinition().name("testWorkflow")
        .description("This is a test workflow").id("the id").key("the key");

    // 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());

    // Check if parsed definition matches the original one
    assertEquals(workflowDefinition.getName(), parsedDefinition.getName());
    assertEquals(workflowDefinition.getKey(), parsedDefinition.getKey());
    assertEquals(workflowDefinition.getId(), parsedDefinition.getId());
    assertEquals(workflowDefinition.getDescription(), parsedDefinition.getDescription());
  }
View Full Code Here

    assertEquals(workflowDefinition.getDescription(), parsedDefinition.getDescription());
  }

  @Test
  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
View Full Code Here

  }
 
  @Test
  public void testChoiceConversion() {
    // Create definition
    WorkflowDefinition workflowDefinition = new WorkflowDefinition()
    .name("testWorkflow")
    .description("This is a test workflow")
    .inChoice()
      .inList()
        .addCondition("test", "==", "'hello'")
        .addCondition("test2", "==", "'world'")
        .addHumanStep("first task", "kermit")
      .endList()
      .inList()
        .addHumanStep("gonzo task", "gonzo")
      .endList()
    .endChoice();

    // 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());

    // Check if parsed definition matches the original one
    assertEquals(workflowDefinition.getName(), parsedDefinition.getName());
    assertEquals(workflowDefinition.getDescription(), parsedDefinition.getDescription());
    ChoiceStepsDefinition choiceDef = null;
    for (StepDefinition step : parsedDefinition.getSteps()) {
      if (step instanceof ChoiceStepsDefinition) {
        choiceDef = (ChoiceStepsDefinition) step;
      }
    }
    assertNotNull(choiceDef);
View Full Code Here

  }
 
  @Test
  public void testParallelConversion() {
    // Create definition
    WorkflowDefinition workflowDefinition = new WorkflowDefinition()
    .name("testWorkflow")
    .description("This is a test workflow")
    .inParallel()
      .inList()
        .addHumanStep("first task", "kermit")
        .addHumanStep("second task", "kermit")
      .endList()
      .inList()
        .addHumanStep("gonzo task", "gonzo")
      .endList()
    .endParallel();

    // 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());

    // Check if parsed definition matches the original one
    assertEquals(workflowDefinition.getName(), parsedDefinition.getName());
    assertEquals(workflowDefinition.getDescription(), parsedDefinition.getDescription());
    ParallelStepsDefinition parallelDef = null;
    for (StepDefinition step : parsedDefinition.getSteps()) {
      if (step instanceof ParallelStepsDefinition) {
        parallelDef = (ParallelStepsDefinition) step;
      }
    }
    assertNotNull(parallelDef);
View Full Code Here

          try {
           
            byte[] bpmnBytes = null;
            String filename = null;
            if (SimpleTableEditorConstants.TABLE_EDITOR_CATEGORY.equals(modelData.getCategory())) {
              WorkflowDefinition workflowDefinition = ExplorerApp.get().getSimpleWorkflowJsonConverter()
                  .readWorkflowDefinition(repositoryService.getModelEditorSource(modelData.getId()));
             
              filename = workflowDefinition.getName();
              WorkflowDefinitionConversion conversion =
                      ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
              bpmnBytes = conversion.getBpmn20Xml().getBytes("utf-8");
            } else {
              JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
View Full Code Here

      private static final long serialVersionUID = 1L;

      public void buttonClick(ClickEvent event) {
       
        // Convert to simple workflow definition
        WorkflowDefinition workflowDefinition = ExplorerApp.get().getSimpleWorkflowJsonConverter()
            .readWorkflowDefinition(model);

        // Update model name
        modelData.setName(deployModelPopupWindow.getProcessName());
        workflowDefinition.setName(deployModelPopupWindow.getProcessName());
       
        WorkflowDefinitionConversion conversion =
                ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
        conversion.convert();
       
View Full Code Here

                    "}" +
                    "" +
                    "execution.setVariable('reportData', reportData.toBytes());";
   
    // Generate bpmn model
    WorkflowDefinition workflowDefinition = new WorkflowDefinition()
      .name(processDefinition.getName() + " task duration report")
      .description(reportDescription)
      .addScriptStep(script);
   
    // Convert to BPMN 2.0 XML
View Full Code Here

    }
  }
 
  @Test
  public void testSimplestProcess() {
    WorkflowDefinition workflowDefinition = new WorkflowDefinition()
    .name("testWorkflow")
    .description("This is a test workflow");
 
    // Validate
    ProcessInstance processInstance = activitiRule.getRuntimeService().startProcessInstanceByKey(convertAndDeploy(workflowDefinition));
View Full Code Here

 
  @Test
  public void testUserTasksWithOnlyAssignees() {
    String[] assignees = new String[] {"kermit", "gonzo", "mispiggy"};
   
    WorkflowDefinition workflowDefinition = new WorkflowDefinition()
      .name("testWorkflow")
      .description("This is a test workflow")
      .addHumanStep("first task", assignees[0])
      .addHumanStep("second step", assignees[1])
      .addHumanStep("third step", assignees[2]);
View Full Code Here

TOP

Related Classes of org.activiti.workflow.simple.definition.WorkflowDefinition

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.