Search in sources :

Example 6 with M2Property

use of org.activiti.workflow.simple.alfresco.model.M2Property in project Activiti by Activiti.

the class AlfrescoBooleanPropertyConverter method convertProperty.

@Override
public void convertProperty(M2Type contentType, String formSet, Form form, FormPropertyDefinition propertyDefinition, WorkflowDefinitionConversion conversion) {
    BooleanPropertyDefinition booleanDefinition = (BooleanPropertyDefinition) propertyDefinition;
    String propertyName = getPropertyName(propertyDefinition, conversion);
    // Add to content model
    M2Property property = new M2Property();
    property.setMandatory(new M2Mandatory(booleanDefinition.isMandatory()));
    property.setName(propertyName);
    property.setPropertyType(AlfrescoConversionConstants.PROPERTY_TYPE_BOOLEAN);
    M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
    M2Aspect aspect = model.getAspect(propertyName);
    if (aspect != null) {
        // do this here
        if (aspect.getProperties().isEmpty()) {
            aspect.getProperties().add(property);
        }
        contentType.getMandatoryAspects().add(propertyName);
    } else {
        contentType.getProperties().add(property);
    }
    // Add form configuration
    form.getFormFieldVisibility().addShowFieldElement(propertyName);
    FormField formField = form.getFormAppearance().addFormField(propertyName, booleanDefinition.getName(), formSet);
    if (!booleanDefinition.isWritable()) {
        // Read-only properties should always be rendered using an info-template
        FormFieldControl control = new FormFieldControl();
        control.setTemplate(AlfrescoConversionConstants.FORM_READONLY_TEMPLATE);
        formField.setControl(control);
    }
    if (!form.isStartForm()) {
        // Add to output properties, if needed
        addOutputProperty(propertyDefinition, propertyName, contentType.getName(), conversion);
    }
}
Also used : BooleanPropertyDefinition(org.activiti.workflow.simple.definition.form.BooleanPropertyDefinition) M2Property(org.activiti.workflow.simple.alfresco.model.M2Property) FormFieldControl(org.activiti.workflow.simple.alfresco.model.config.FormFieldControl) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) M2Aspect(org.activiti.workflow.simple.alfresco.model.M2Aspect) M2Mandatory(org.activiti.workflow.simple.alfresco.model.M2Mandatory) FormField(org.activiti.workflow.simple.alfresco.model.config.FormField)

Example 7 with M2Property

use of org.activiti.workflow.simple.alfresco.model.M2Property 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

M2Model (org.activiti.workflow.simple.alfresco.model.M2Model)7 M2Property (org.activiti.workflow.simple.alfresco.model.M2Property)7 M2Mandatory (org.activiti.workflow.simple.alfresco.model.M2Mandatory)6 FormField (org.activiti.workflow.simple.alfresco.model.config.FormField)6 FormFieldControl (org.activiti.workflow.simple.alfresco.model.config.FormFieldControl)6 M2Aspect (org.activiti.workflow.simple.alfresco.model.M2Aspect)5 ArrayList (java.util.ArrayList)2 M2Constraint (org.activiti.workflow.simple.alfresco.model.M2Constraint)2 M2NamedValue (org.activiti.workflow.simple.alfresco.model.M2NamedValue)2 ListPropertyEntry (org.activiti.workflow.simple.definition.form.ListPropertyEntry)2 TextPropertyDefinition (org.activiti.workflow.simple.definition.form.TextPropertyDefinition)2 AlfrescoTransitionsPropertyDefinition (org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition)1 M2PropertyOverride (org.activiti.workflow.simple.alfresco.model.M2PropertyOverride)1 M2Type (org.activiti.workflow.simple.alfresco.model.M2Type)1 WorkflowDefinitionConversion (org.activiti.workflow.simple.converter.WorkflowDefinitionConversion)1 HumanStepDefinition (org.activiti.workflow.simple.definition.HumanStepDefinition)1 WorkflowDefinition (org.activiti.workflow.simple.definition.WorkflowDefinition)1 BooleanPropertyDefinition (org.activiti.workflow.simple.definition.form.BooleanPropertyDefinition)1 DatePropertyDefinition (org.activiti.workflow.simple.definition.form.DatePropertyDefinition)1 FormDefinition (org.activiti.workflow.simple.definition.form.FormDefinition)1