Search in sources :

Example 1 with FormSet

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

Aggregations

AlfrescoSimpleWorkflowException (org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException)1 AlfrescoTransitionsPropertyDefinition (org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition)1 FormSet (org.activiti.workflow.simple.alfresco.model.config.FormSet)1 FormPropertyDefinition (org.activiti.workflow.simple.definition.form.FormPropertyDefinition)1 FormPropertyGroup (org.activiti.workflow.simple.definition.form.FormPropertyGroup)1