Search in sources :

Example 11 with HumanStepDefinition

use of org.activiti.workflow.simple.definition.HumanStepDefinition in project Activiti by Activiti.

the class WorkflowDefinitionConversionTest method testTransitionProperty.

@Test
public void testTransitionProperty() throws Exception {
    WorkflowDefinition definition = new WorkflowDefinition();
    definition.setId("process");
    HumanStepDefinition humanStep = new HumanStepDefinition();
    humanStep.setId("step1");
    FormDefinition form = new FormDefinition();
    humanStep.setForm(form);
    AlfrescoTransitionsPropertyDefinition transition = new AlfrescoTransitionsPropertyDefinition();
    transition.addEntry(new ListPropertyEntry("One", "One"));
    transition.addEntry(new ListPropertyEntry("Two", "Two"));
    humanStep.getForm().addFormProperty(transition);
    definition.addStep(humanStep);
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
    M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
    assertEquals(1L, model.getTypes().size());
    M2Type taskType = model.getTypes().get(0);
    assertEquals(1L, taskType.getPropertyOverrides().size());
    assertEquals("bpm:outcomePropertyName", taskType.getPropertyOverrides().get(0).getName());
    assertTrue(taskType.getPropertyOverrides().get(0).getDefaultValue().contains("step1transitions"));
    assertEquals(1L, taskType.getProperties().size());
    assertEquals(1L, model.getConstraints().size());
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) HumanStepDefinition(org.activiti.workflow.simple.definition.HumanStepDefinition) ListPropertyEntry(org.activiti.workflow.simple.definition.form.ListPropertyEntry) M2Type(org.activiti.workflow.simple.alfresco.model.M2Type) AlfrescoTransitionsPropertyDefinition(org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) FormDefinition(org.activiti.workflow.simple.definition.form.FormDefinition) Test(org.junit.Test)

Example 12 with HumanStepDefinition

use of org.activiti.workflow.simple.definition.HumanStepDefinition in project Activiti by Activiti.

the class AlfrescoHumanStepDefinitionConverter method convertStepDefinition.

@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);
    // 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;
}
Also used : M2Namespace(org.activiti.workflow.simple.alfresco.model.M2Namespace) PropertyReference(org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference) HumanStepDefinition(org.activiti.workflow.simple.definition.HumanStepDefinition) M2Type(org.activiti.workflow.simple.alfresco.model.M2Type) Configuration(org.activiti.workflow.simple.alfresco.model.config.Configuration) Form(org.activiti.workflow.simple.alfresco.model.config.Form) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) UserTask(org.activiti.bpmn.model.UserTask) Module(org.activiti.workflow.simple.alfresco.model.config.Module)

Aggregations

HumanStepDefinition (org.activiti.workflow.simple.definition.HumanStepDefinition)12 FormDefinition (org.activiti.workflow.simple.definition.form.FormDefinition)9 WorkflowDefinition (org.activiti.workflow.simple.definition.WorkflowDefinition)8 Test (org.junit.Test)7 WorkflowDefinitionConversion (org.activiti.workflow.simple.converter.WorkflowDefinitionConversion)6 M2Model (org.activiti.workflow.simple.alfresco.model.M2Model)5 M2Type (org.activiti.workflow.simple.alfresco.model.M2Type)5 UserTask (org.activiti.bpmn.model.UserTask)4 FlowElement (org.activiti.bpmn.model.FlowElement)3 ListStepDefinition (org.activiti.workflow.simple.definition.ListStepDefinition)3 StepDefinition (org.activiti.workflow.simple.definition.StepDefinition)3 FormPropertyGroup (org.activiti.workflow.simple.definition.form.FormPropertyGroup)3 TextPropertyDefinition (org.activiti.workflow.simple.definition.form.TextPropertyDefinition)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Process (org.activiti.bpmn.model.Process)2 PropertyReference (org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference)2 M2ClassAssociation (org.activiti.workflow.simple.alfresco.model.M2ClassAssociation)2 ListConditionStepDefinition (org.activiti.workflow.simple.definition.ListConditionStepDefinition)2 ListPropertyEntry (org.activiti.workflow.simple.definition.form.ListPropertyEntry)2 ReferencePropertyDefinition (org.activiti.workflow.simple.definition.form.ReferencePropertyDefinition)2