Search in sources :

Example 6 with FormPropertyDefinition

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

the class BaseStepDefinitionConverter method convertProperties.

/**
   * Converts form properties. Multiple step types can contain forms,
   * hence why it it a shared method here.
   */
protected List<FormProperty> convertProperties(FormDefinition formDefinition) {
    List<FormProperty> formProperties = new ArrayList<FormProperty>();
    for (FormPropertyDefinition propertyDefinition : formDefinition.getFormPropertyDefinitions()) {
        FormProperty formProperty = new FormProperty();
        formProperties.add(formProperty);
        formProperty.setId(propertyDefinition.getName());
        formProperty.setName(propertyDefinition.getName());
        formProperty.setRequired(propertyDefinition.isMandatory());
        String type = null;
        if (propertyDefinition instanceof NumberPropertyDefinition) {
            type = "long";
        } else if (propertyDefinition instanceof DatePropertyDefinition) {
            type = "date";
        } else if (propertyDefinition instanceof BooleanPropertyDefinition) {
            type = "boolean";
        } else if (propertyDefinition instanceof ListPropertyDefinition) {
            type = "enum";
            ListPropertyDefinition listDefinition = (ListPropertyDefinition) propertyDefinition;
            if (!listDefinition.getEntries().isEmpty()) {
                List<FormValue> formValues = new ArrayList<FormValue>(listDefinition.getEntries().size());
                for (ListPropertyEntry entry : listDefinition.getEntries()) {
                    FormValue formValue = new FormValue();
                    // We're using same value for id and name for the moment
                    formValue.setId(entry.getValue());
                    formValue.setName(entry.getName());
                    formValues.add(formValue);
                }
                formProperty.setFormValues(formValues);
            }
        } else {
            // Fallback to simple text
            type = "string";
        }
        formProperty.setType(type);
    }
    return formProperties;
}
Also used : ListPropertyEntry(org.activiti.workflow.simple.definition.form.ListPropertyEntry) BooleanPropertyDefinition(org.activiti.workflow.simple.definition.form.BooleanPropertyDefinition) FormValue(org.activiti.bpmn.model.FormValue) FormProperty(org.activiti.bpmn.model.FormProperty) ArrayList(java.util.ArrayList) FormPropertyDefinition(org.activiti.workflow.simple.definition.form.FormPropertyDefinition) NumberPropertyDefinition(org.activiti.workflow.simple.definition.form.NumberPropertyDefinition) ListPropertyDefinition(org.activiti.workflow.simple.definition.form.ListPropertyDefinition) ArrayList(java.util.ArrayList) List(java.util.List) DatePropertyDefinition(org.activiti.workflow.simple.definition.form.DatePropertyDefinition)

Aggregations

FormPropertyDefinition (org.activiti.workflow.simple.definition.form.FormPropertyDefinition)6 NumberPropertyDefinition (org.activiti.workflow.simple.definition.form.NumberPropertyDefinition)3 DatePropertyDefinition (org.activiti.workflow.simple.definition.form.DatePropertyDefinition)2 FormDefinition (org.activiti.workflow.simple.definition.form.FormDefinition)2 ListPropertyDefinition (org.activiti.workflow.simple.definition.form.ListPropertyDefinition)2 ListPropertyEntry (org.activiti.workflow.simple.definition.form.ListPropertyEntry)2 TextPropertyDefinition (org.activiti.workflow.simple.definition.form.TextPropertyDefinition)2 Item (com.vaadin.data.Item)1 CheckBox (com.vaadin.ui.CheckBox)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 FormProperty (org.activiti.bpmn.model.FormProperty)1 FormValue (org.activiti.bpmn.model.FormValue)1 AlfrescoSimpleWorkflowException (org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException)1 AlfrescoTransitionsPropertyDefinition (org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition)1 M2Aspect (org.activiti.workflow.simple.alfresco.model.M2Aspect)1