Search in sources :

Example 1 with FormPropertyGroup

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

the class AlfrescoFormCreator method createForm.

public void createForm(M2Type contentType, Form formConfig, FormDefinition formDefinition, WorkflowDefinitionConversion conversion) {
    if (formDefinition != null && formDefinition.getFormGroups() != null) {
        for (FormPropertyGroup group : formDefinition.getFormGroups()) {
            // Create a group in the form-config
            String groupId = null;
            if (group.getId() != null) {
                groupId = AlfrescoConversionUtil.getValidIdString(group.getId());
            } else {
                groupId = AlfrescoConversionUtil.getValidIdString(group.getTitle());
            }
            FormSet formSet = formConfig.getFormAppearance().addFormSet(groupId, getAppearanceForGroup(group), group.getTitle(), getTemplateForGroup(group));
            // Convert all properties
            AlfrescoFormPropertyConverter converter = null;
            for (FormPropertyDefinition property : group.getFormPropertyDefinitions()) {
                converter = propertyConverters.get(property.getClass());
                if (converter == null) {
                    throw new AlfrescoSimpleWorkflowException("Unsupported property type: " + property.getClass().getName());
                }
                converter.convertProperty(contentType, formSet.getId(), formConfig, property, conversion);
            }
        }
    }
    if (formDefinition != null && formDefinition.getFormPropertyDefinitions() != null && !formDefinition.getFormPropertyDefinitions().isEmpty()) {
        for (FormPropertyDefinition def : formDefinition.getFormPropertyDefinitions()) {
            if (def instanceof AlfrescoTransitionsPropertyDefinition) {
                AlfrescoFormPropertyConverter converter = propertyConverters.get(def.getClass());
                if (converter != null) {
                    converter.convertProperty(contentType, null, formConfig, def, conversion);
                }
            }
        }
    }
    // Finally, add default "transitions" if not already added to the model
    if (formConfig.getFormAppearance().getFormSet(AlfrescoConversionConstants.FORM_SET_RESPONSE) == null) {
        formConfig.getFormAppearance().addFormSet(AlfrescoConversionConstants.FORM_SET_RESPONSE, null, null, null);
        formConfig.getFormFieldVisibility().addShowFieldElement(AlfrescoConversionConstants.FORM_FIELD_TRANSITIONS);
        formConfig.getFormAppearance().addFormField(AlfrescoConversionConstants.FORM_FIELD_TRANSITIONS, null, AlfrescoConversionConstants.FORM_SET_RESPONSE);
    }
}
Also used : AlfrescoTransitionsPropertyDefinition(org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition) FormPropertyGroup(org.activiti.workflow.simple.definition.form.FormPropertyGroup) FormSet(org.activiti.workflow.simple.alfresco.model.config.FormSet) FormPropertyDefinition(org.activiti.workflow.simple.definition.form.FormPropertyDefinition) AlfrescoSimpleWorkflowException(org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException)

Example 2 with FormPropertyGroup

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

the class WorkflowDefinitionConversionTest method testCustomReference.

/**
	 * Test if a custom reference (eg. type=cm:person) is turned into an association on the
	 * model.
	 */
@Test
public void testCustomReference() 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
    ReferencePropertyDefinition textProperty = new ReferencePropertyDefinition();
    textProperty.setName("person");
    textProperty.setMandatory(true);
    textProperty.setType("cm:person");
    group.addFormProperty(textProperty);
    definition.addStep(humanStep);
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
    // Check content-model
    M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
    assertNotNull(model);
    M2Type type = model.getTypes().get(0);
    assertNotNull(type);
    // Simple text
    M2ClassAssociation association = getAssociationFromType("person", type);
    assertEquals("cm:person", association.getTarget().getClassName());
    assertTrue(association.getTarget().isMandatory());
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) HumanStepDefinition(org.activiti.workflow.simple.definition.HumanStepDefinition) M2Type(org.activiti.workflow.simple.alfresco.model.M2Type) ReferencePropertyDefinition(org.activiti.workflow.simple.definition.form.ReferencePropertyDefinition) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) FormPropertyGroup(org.activiti.workflow.simple.definition.form.FormPropertyGroup) FormDefinition(org.activiti.workflow.simple.definition.form.FormDefinition) M2ClassAssociation(org.activiti.workflow.simple.alfresco.model.M2ClassAssociation) Test(org.junit.Test)

Example 3 with FormPropertyGroup

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

the class WorkflowDefinitionConversionTest method testTaskListenerForOutgoingProperties.

@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);
    FormPropertyGroup group = new FormPropertyGroup();
    group.setId("group");
    form.getFormGroups().add(group);
    group.getFormPropertyDefinitions().add(text);
    definition.addStep(humanStep);
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
    Process process = conversion.getProcess();
    assertNotNull(process);
    boolean listenerFound = false;
    for (FlowElement flowElement : process.getFlowElements()) {
        if (flowElement instanceof UserTask) {
            UserTask task = (UserTask) flowElement;
            assertNotNull(task.getTaskListeners());
            assertEquals(2L, task.getTaskListeners().size());
            assertEquals("create", task.getTaskListeners().get(0).getEvent());
            assertEquals("complete", task.getTaskListeners().get(1).getEvent());
            listenerFound = true;
        }
    }
    assertTrue(listenerFound);
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) HumanStepDefinition(org.activiti.workflow.simple.definition.HumanStepDefinition) TextPropertyDefinition(org.activiti.workflow.simple.definition.form.TextPropertyDefinition) FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) FormPropertyGroup(org.activiti.workflow.simple.definition.form.FormPropertyGroup) Process(org.activiti.bpmn.model.Process) FormDefinition(org.activiti.workflow.simple.definition.form.FormDefinition) Test(org.junit.Test)

Example 4 with FormPropertyGroup

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

the class WorkflowDefinitionConversionTest method testHumanStepBasicFormField.

/**
	 * Test basic form-fields (text, number, date, list, ...)
	 */
@Test
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);
    group.addFormProperty(textProperty);
    definition.addStep(humanStep);
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
    // Check content-model
    M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
    assertNotNull(model);
    M2Type type = model.getTypes().get(0);
    assertNotNull(type);
    // Simple text
    M2Property property = getPropertyFromType("text", type);
    assertEquals("d:text", property.getPropertyType());
    assertEquals(Boolean.TRUE, property.getMandatory().isMandatory());
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) HumanStepDefinition(org.activiti.workflow.simple.definition.HumanStepDefinition) M2Type(org.activiti.workflow.simple.alfresco.model.M2Type) TextPropertyDefinition(org.activiti.workflow.simple.definition.form.TextPropertyDefinition) M2Property(org.activiti.workflow.simple.alfresco.model.M2Property) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) FormPropertyGroup(org.activiti.workflow.simple.definition.form.FormPropertyGroup) FormDefinition(org.activiti.workflow.simple.definition.form.FormDefinition) Test(org.junit.Test)

Aggregations

FormPropertyGroup (org.activiti.workflow.simple.definition.form.FormPropertyGroup)4 WorkflowDefinitionConversion (org.activiti.workflow.simple.converter.WorkflowDefinitionConversion)3 HumanStepDefinition (org.activiti.workflow.simple.definition.HumanStepDefinition)3 WorkflowDefinition (org.activiti.workflow.simple.definition.WorkflowDefinition)3 FormDefinition (org.activiti.workflow.simple.definition.form.FormDefinition)3 Test (org.junit.Test)3 M2Model (org.activiti.workflow.simple.alfresco.model.M2Model)2 M2Type (org.activiti.workflow.simple.alfresco.model.M2Type)2 TextPropertyDefinition (org.activiti.workflow.simple.definition.form.TextPropertyDefinition)2 FlowElement (org.activiti.bpmn.model.FlowElement)1 Process (org.activiti.bpmn.model.Process)1 UserTask (org.activiti.bpmn.model.UserTask)1 AlfrescoSimpleWorkflowException (org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException)1 AlfrescoTransitionsPropertyDefinition (org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition)1 M2ClassAssociation (org.activiti.workflow.simple.alfresco.model.M2ClassAssociation)1 M2Property (org.activiti.workflow.simple.alfresco.model.M2Property)1 FormSet (org.activiti.workflow.simple.alfresco.model.config.FormSet)1 FormPropertyDefinition (org.activiti.workflow.simple.definition.form.FormPropertyDefinition)1 ReferencePropertyDefinition (org.activiti.workflow.simple.definition.form.ReferencePropertyDefinition)1