Search in sources :

Example 26 with StartEvent

use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.

the class TestProcessUtil method createOneTaskProcess.

public static org.activiti.bpmn.model.Process createOneTaskProcess() {
    org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
    process.setId("oneTaskProcess");
    process.setName("The one task process");
    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);
    process.addFlowElement(new SequenceFlow("start", "theTask"));
    process.addFlowElement(new SequenceFlow("theTask", "theEnd"));
    return process;
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask) EndEvent(org.activiti.bpmn.model.EndEvent)

Example 27 with StartEvent

use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.

the class InitializeAlfrescoModelsConversionListener method afterStepsConversion.

@Override
public void afterStepsConversion(WorkflowDefinitionConversion conversion) {
    M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
    M2Namespace modelNamespace = model.getNamespaces().get(0);
    for (FlowElement flowElement : conversion.getProcess().getFlowElements()) {
        if (flowElement instanceof StartEvent) {
            StartEvent startEvent = (StartEvent) flowElement;
            if (startEvent.getFormKey() == null) {
                Module module = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
                Configuration detailsForm = module.addConfiguration(EVALUATOR_STRING_COMPARE, MessageFormat.format(EVALUATOR_CONDITION_ACTIVITI, conversion.getProcess().getId()));
                // is available
                if (conversion.getWorkflowDefinition().getStartFormDefinition() != null && !conversion.getWorkflowDefinition().getStartFormDefinition().getFormGroups().isEmpty()) {
                    // Create the content model for the start-task
                    M2Type type = new M2Type();
                    model.getTypes().add(type);
                    type.setName(AlfrescoConversionUtil.getQualifiedName(modelNamespace.getPrefix(), AlfrescoConversionConstants.START_TASK_SIMPLE_NAME));
                    type.setParentName(AlfrescoConversionConstants.DEFAULT_START_FORM_TYPE);
                    // Create a form-config for the start-task
                    Module shareModule = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
                    Configuration configuration = shareModule.addConfiguration(AlfrescoConversionConstants.EVALUATOR_TASK_TYPE, type.getName());
                    Form formConfig = configuration.createForm();
                    formConfig.setStartForm(true);
                    // Populate model and form based on FormDefinition
                    formCreator.createForm(type, formConfig, conversion.getWorkflowDefinition().getStartFormDefinition(), conversion);
                    // Use the same form-config for the workflow details
                    detailsForm.addForm(formConfig);
                    // Set formKey on start-event, referencing type
                    startEvent.setFormKey(type.getName());
                } else {
                    // Revert to the default start-form
                    startEvent.setFormKey(DEFAULT_START_FORM_TYPE);
                    // Also add form-config to the share-module for workflow detail screen, based on the default form
                    populateDefaultDetailFormConfig(detailsForm);
                }
            }
        }
    }
    // Check all elements that can contain PropertyReferences or need additional builders invoked
    List<PropertyReference> references = AlfrescoConversionUtil.getPropertyReferences(conversion);
    for (FlowElement element : conversion.getProcess().getFlowElements()) {
        if (element instanceof SequenceFlow) {
            resolvePropertyRefrencesInSequenceFlow((SequenceFlow) element, modelNamespace, references);
        } else if (element instanceof IntermediateCatchEvent) {
            resolvePropertyRefrencesInCatchEvent((IntermediateCatchEvent) element, modelNamespace, references);
        } else if (element instanceof ServiceTask) {
            resolvePropertyRefrencesInServiceTask((ServiceTask) element, modelNamespace, references);
        } else if (element instanceof UserTask) {
            addScriptListenersToUserTask((UserTask) element, conversion);
        }
    }
    // Check if all property-references reference a valid property
    if (references != null && !references.isEmpty()) {
        for (PropertyReference reference : references) {
            reference.validate(model);
        }
    }
}
Also used : M2Namespace(org.activiti.workflow.simple.alfresco.model.M2Namespace) ServiceTask(org.activiti.bpmn.model.ServiceTask) Configuration(org.activiti.workflow.simple.alfresco.model.config.Configuration) Form(org.activiti.workflow.simple.alfresco.model.config.Form) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) UserTask(org.activiti.bpmn.model.UserTask) PropertyReference(org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference) M2Type(org.activiti.workflow.simple.alfresco.model.M2Type) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) Module(org.activiti.workflow.simple.alfresco.model.config.Module)

Example 28 with StartEvent

use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.

the class HumanStepDefinitionConverter method createUserTask.

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;
}
Also used : UserTask(org.activiti.bpmn.model.UserTask) StartEvent(org.activiti.bpmn.model.StartEvent) FormDefinition(org.activiti.workflow.simple.definition.form.FormDefinition)

Example 29 with StartEvent

use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.

the class WorkflowDefinitionConversionTest method testEmptyWorkflowDefinitionConversion.

/**
	 * Check if all required artifacts are created when converting an empty workflow-definition.
	 */
@Test
public void testEmptyWorkflowDefinitionConversion() {
    WorkflowDefinition definition = new WorkflowDefinition();
    definition.setDescription("This is the description");
    definition.setId("workflowdefinition");
    definition.setName("My workflow definition");
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
    BpmnModel bpmnModel = conversion.getBpmnModel();
    assertNotNull(bpmnModel);
    Process process = bpmnModel.getMainProcess();
    assertNotNull(process);
    assertEquals("This is the description", process.getDocumentation());
    assertEquals("My workflow definition", process.getName());
    assertEquals("workflowdefinition", process.getId());
    // Default start-task key should be used, as no custom startform-config is present
    boolean startTaskFound = false;
    for (FlowElement element : process.getFlowElements()) {
        if (element instanceof StartEvent) {
            assertEquals("bpm:startTask", ((StartEvent) element).getFormKey());
            startTaskFound = true;
        }
    }
    assertTrue(startTaskFound);
    // Check presence of content-model
    M2Model contentModel = AlfrescoConversionUtil.getContentModel(conversion);
    assertNotNull(contentModel);
    // Check presence of form-config and default workflow-details
    Module module = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
    assertNotNull(module);
    assertEquals(1L, module.getConfigurations().size());
    Configuration config = module.getConfigurations().get(0);
    assertEquals(1L, config.getForms().size());
    assertEquals("activiti$workflowdefinition", config.getCondition());
    assertEquals(AlfrescoConversionConstants.EVALUATOR_STRING_COMPARE, config.getEvaluator());
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) Configuration(org.activiti.workflow.simple.alfresco.model.config.Configuration) FlowElement(org.activiti.bpmn.model.FlowElement) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) StartEvent(org.activiti.bpmn.model.StartEvent) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) Process(org.activiti.bpmn.model.Process) Module(org.activiti.workflow.simple.alfresco.model.config.Module) BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.Test)

Example 30 with StartEvent

use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.

the class StartEventJsonConverter method convertElementToJson.

protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
    StartEvent startEvent = (StartEvent) baseElement;
    if (StringUtils.isNotEmpty(startEvent.getInitiator())) {
        propertiesNode.put(PROPERTY_NONE_STARTEVENT_INITIATOR, startEvent.getInitiator());
    }
    if (StringUtils.isNotEmpty(startEvent.getFormKey())) {
        propertiesNode.put(PROPERTY_FORMKEY, startEvent.getFormKey());
    }
    addFormProperties(startEvent.getFormProperties(), propertiesNode);
    addEventProperties(startEvent, propertiesNode);
}
Also used : StartEvent(org.activiti.bpmn.model.StartEvent)

Aggregations

StartEvent (org.activiti.bpmn.model.StartEvent)35 UserTask (org.activiti.bpmn.model.UserTask)18 FlowElement (org.activiti.bpmn.model.FlowElement)14 SubProcess (org.activiti.bpmn.model.SubProcess)8 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)7 BpmnModel (org.activiti.bpmn.model.BpmnModel)7 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)7 EndEvent (org.activiti.bpmn.model.EndEvent)6 FormProperty (org.activiti.bpmn.model.FormProperty)6 HashMap (java.util.HashMap)5 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)5 ValuedDataObject (org.activiti.bpmn.model.ValuedDataObject)5 ArrayList (java.util.ArrayList)4 FormValue (org.activiti.bpmn.model.FormValue)4 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)4 AlfrescoStartEvent (org.activiti.bpmn.model.alfresco.AlfrescoStartEvent)4 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)4 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)3 Process (org.activiti.bpmn.model.Process)3 Date (java.util.Date)2