Search in sources :

Example 6 with FormFieldControl

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

the class AlfrescoReferencePropertyConverter method addPriorityReference.

protected void addPriorityReference(Form form, String formSet, boolean writable) {
    String fieldName = null;
    if (form.isStartForm()) {
        fieldName = AlfrescoConversionConstants.PROPERTY_WORKFLOW_PRIORITY;
    } else {
        fieldName = AlfrescoConversionConstants.PROPERTY_PRIORITY;
    }
    form.getFormFieldVisibility().addShowFieldElement(fieldName);
    FormField priorityField = new FormField();
    priorityField.setSet(formSet);
    priorityField.setLabelId(AlfrescoConversionConstants.FORM_WORKFLOW_PRIORITY_LABEL);
    priorityField.setId(fieldName);
    if (form.isStartForm() || writable) {
        priorityField.setControl(new FormFieldControl(AlfrescoConversionConstants.FORM_PRIORITY_TEMPLATE));
    } else {
        priorityField.setControl(new FormFieldControl(AlfrescoConversionConstants.FORM_READONLY_TEMPLATE));
    }
    form.getFormAppearance().addFormAppearanceElement(priorityField);
}
Also used : FormFieldControl(org.activiti.workflow.simple.alfresco.model.config.FormFieldControl) FormField(org.activiti.workflow.simple.alfresco.model.config.FormField)

Example 7 with FormFieldControl

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

the class AlfrescoTextPropertyConverter method convertProperty.

@Override
public void convertProperty(M2Type contentType, String formSet, Form form, FormPropertyDefinition propertyDefinition, WorkflowDefinitionConversion conversion) {
    TextPropertyDefinition textDefinition = (TextPropertyDefinition) propertyDefinition;
    String propertyName = getPropertyName(textDefinition, conversion);
    // Add to content model
    M2Property property = new M2Property();
    property.setMandatory(new M2Mandatory(textDefinition.isMandatory()));
    property.setName(propertyName);
    property.setPropertyType(AlfrescoConversionConstants.PROPERTY_TYPE_TEXT);
    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, propertyDefinition.getName(), formSet);
    if (!textDefinition.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);
    } else if (textDefinition.isMultiline()) {
        // In case the property is multi-lined, use an alternative control template
        FormFieldControl control = new FormFieldControl();
        control.setTemplate(AlfrescoConversionConstants.FORM_MULTILINE_TEXT_TEMPLATE);
        formField.setControl(control);
    } else {
        FormFieldControl control = new FormFieldControl();
        control.setTemplate(AlfrescoConversionConstants.FORM_TEXT_TEMPLATE);
        formField.setControl(control);
    }
    if (!form.isStartForm()) {
        // Add to output properties, if needed
        addOutputProperty(propertyDefinition, propertyName, contentType.getName(), conversion);
    }
}
Also used : TextPropertyDefinition(org.activiti.workflow.simple.definition.form.TextPropertyDefinition) 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 8 with FormFieldControl

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

the class AlfrescoTransitionsPropertyConverter method convertProperty.

@Override
public void convertProperty(M2Type contentType, String formSet, Form form, FormPropertyDefinition propertyDefinition, WorkflowDefinitionConversion conversion) {
    AlfrescoTransitionsPropertyDefinition def = (AlfrescoTransitionsPropertyDefinition) propertyDefinition;
    String propertyName = contentType.getName() + AlfrescoConversionConstants.PROPERTY_TRANSITIONS_SUFFIX;
    // Add to content model
    M2Property property = new M2Property();
    property.setMandatory(new M2Mandatory(def.isMandatory()));
    property.setName(propertyName);
    property.setPropertyType(AlfrescoConversionConstants.PROPERTY_TYPE_TEXT);
    M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
    contentType.getProperties().add(property);
    // Create constraint for the values
    if (def.getTransitions() != null && !def.getTransitions().isEmpty()) {
        M2Constraint valueConstraint = new M2Constraint();
        valueConstraint.setType(AlfrescoConversionConstants.CONTENT_MODEL_CONSTRAINT_TYPE_LIST);
        valueConstraint.setName(propertyName + AlfrescoConversionConstants.CONTENT_MODEL_CONSTRAINT_TYPE_LIST.toLowerCase());
        List<String> values = new ArrayList<String>(def.getTransitions().size());
        for (ListPropertyEntry entry : def.getTransitions()) {
            values.add(entry.getValue());
        }
        valueConstraint.getParameters().add(new M2NamedValue(AlfrescoConversionConstants.CONTENT_MODEL_CONSTRAINT_ALLOWED_VALUES, null, values));
        // Add constraint to the root model instead of the type itself and reference it from within the property
        // for readability and reuse of the model
        model.getConstraints().add(valueConstraint);
        M2Constraint reference = new M2Constraint();
        reference.setRef(valueConstraint.getName());
        property.getConstraints().add(reference);
    }
    // Add a pointer to the transition-property as well, using an override
    M2PropertyOverride override = new M2PropertyOverride();
    override.setDefaultValue(AlfrescoConversionUtil.getUrlQualifiedPropertyName(propertyName, model.getNamespaces().get(0)));
    override.setName(AlfrescoConversionConstants.PROPERTY_OUTCOME_PROPERTY_NAME);
    contentType.getPropertyOverrides().add(override);
    // Add the transition-set
    form.getFormAppearance().addFormSet(AlfrescoConversionConstants.FORM_SET_RESPONSE, null, null, null);
    form.getFormFieldVisibility().addShowFieldElement(propertyName);
    FormField transitionsFormField = new FormField();
    transitionsFormField.setId(propertyName);
    transitionsFormField.setSet(AlfrescoConversionConstants.FORM_SET_RESPONSE);
    transitionsFormField.setControl(new FormFieldControl(AlfrescoConversionConstants.FORM_TRANSITIONS_TEMPLATE));
    form.getFormAppearance().addFormAppearanceElement(transitionsFormField);
}
Also used : ListPropertyEntry(org.activiti.workflow.simple.definition.form.ListPropertyEntry) M2Property(org.activiti.workflow.simple.alfresco.model.M2Property) AlfrescoTransitionsPropertyDefinition(org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) ArrayList(java.util.ArrayList) M2Constraint(org.activiti.workflow.simple.alfresco.model.M2Constraint) M2PropertyOverride(org.activiti.workflow.simple.alfresco.model.M2PropertyOverride) M2NamedValue(org.activiti.workflow.simple.alfresco.model.M2NamedValue) FormFieldControl(org.activiti.workflow.simple.alfresco.model.config.FormFieldControl) M2Mandatory(org.activiti.workflow.simple.alfresco.model.M2Mandatory) FormField(org.activiti.workflow.simple.alfresco.model.config.FormField) M2PropertyOverride(org.activiti.workflow.simple.alfresco.model.M2PropertyOverride)

Example 9 with FormFieldControl

use of org.activiti.workflow.simple.alfresco.model.config.FormFieldControl 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 10 with FormFieldControl

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

the class InitializeAlfrescoModelsConversionListener method populateDefaultDetailFormConfig.

protected void populateDefaultDetailFormConfig(Configuration configuration) {
    Form form = configuration.createForm();
    // Add visibility of fields
    form.getFormFieldVisibility().addShowFieldElement(PROPERTY_WORKFLOW_DESCRIPTION);
    form.getFormFieldVisibility().addShowFieldElement(PROPERTY_WORKFLOW_DUE_DATE);
    form.getFormFieldVisibility().addShowFieldElement(PROPERTY_WORKFLOW_PRIORITY);
    form.getFormFieldVisibility().addShowFieldElement(PROPERTY_PACKAGEITEMS);
    form.getFormFieldVisibility().addShowFieldElement(PROPERTY_SEND_EMAIL_NOTIFICATIONS);
    // Add all sets to the appearance
    form.getFormAppearance().addFormSet(FORM_SET_GENERAL, FORM_SET_APPEARANCE_TITLE, FORM_SET_GENERAL_LABEL, null);
    form.getFormAppearance().addFormSet(FORM_SET_INFO, null, null, FORM_SET_TEMPLATE_2_COLUMN);
    form.getFormAppearance().addFormSet(FORM_SET_ASSIGNEE, FORM_SET_APPEARANCE_TITLE, FORM_SET_ASSIGNEE_LABEL, null);
    form.getFormAppearance().addFormSet(FORM_SET_ITEMS, FORM_SET_APPEARANCE_TITLE, FORM_SET_ITEMS_LABEL, null);
    form.getFormAppearance().addFormSet(FORM_SET_OTHER, FORM_SET_APPEARANCE_TITLE, FORM_SET_OTHER_LABEL, null);
    // Finally, add the individual fields
    FormField descriptionField = new FormField();
    descriptionField.setId(PROPERTY_WORKFLOW_DESCRIPTION);
    descriptionField.setControl(new FormFieldControl(FORM_MULTILINE_TEXT_TEMPLATE));
    descriptionField.setLabelId(FORM_WORKFLOW_DESCRIPTION_LABEL);
    form.getFormAppearance().addFormAppearanceElement(descriptionField);
    FormField dueDateField = new FormField();
    dueDateField.setId(PROPERTY_WORKFLOW_DUE_DATE);
    dueDateField.setSet(FORM_SET_INFO);
    dueDateField.setLabelId(FORM_WORKFLOW_DUE_DATE_LABEL);
    dueDateField.setControl(new FormFieldControl(FORM_DATE_TEMPLATE));
    dueDateField.getControl().getControlParameters().add(new FormFieldControlParameter(FORM_DATE_PARAM_SHOW_TIME, Boolean.FALSE.toString()));
    dueDateField.getControl().getControlParameters().add(new FormFieldControlParameter(FORM_DATE_PARAM_SUBMIT_TIME, Boolean.FALSE.toString()));
    form.getFormAppearance().addFormAppearanceElement(dueDateField);
    FormField priorityField = new FormField();
    priorityField.setSet(FORM_SET_INFO);
    priorityField.setLabelId(FORM_WORKFLOW_PRIORITY_LABEL);
    priorityField.setId(PROPERTY_WORKFLOW_PRIORITY);
    priorityField.setControl(new FormFieldControl(FORM_PRIORITY_TEMPLATE));
    form.getFormAppearance().addFormAppearanceElement(priorityField);
    form.getFormAppearance().addFormField(PROPERTY_PACKAGEITEMS, null, FORM_SET_ITEMS);
    FormField emailNotificationsField = new FormField();
    emailNotificationsField.setSet(FORM_SET_OTHER);
    emailNotificationsField.setId(PROPERTY_SEND_EMAIL_NOTIFICATIONS);
    emailNotificationsField.setControl(new FormFieldControl(FORM_EMAIL_NOTIFICATION_TEMPLATE));
    form.getFormAppearance().addFormAppearanceElement(emailNotificationsField);
}
Also used : Form(org.activiti.workflow.simple.alfresco.model.config.Form) FormFieldControl(org.activiti.workflow.simple.alfresco.model.config.FormFieldControl) FormFieldControlParameter(org.activiti.workflow.simple.alfresco.model.config.FormFieldControlParameter) FormField(org.activiti.workflow.simple.alfresco.model.config.FormField)

Aggregations

FormField (org.activiti.workflow.simple.alfresco.model.config.FormField)14 FormFieldControl (org.activiti.workflow.simple.alfresco.model.config.FormFieldControl)14 M2Model (org.activiti.workflow.simple.alfresco.model.M2Model)7 M2Aspect (org.activiti.workflow.simple.alfresco.model.M2Aspect)6 M2Mandatory (org.activiti.workflow.simple.alfresco.model.M2Mandatory)6 M2Property (org.activiti.workflow.simple.alfresco.model.M2Property)6 ArrayList (java.util.ArrayList)2 M2Constraint (org.activiti.workflow.simple.alfresco.model.M2Constraint)2 M2NamedValue (org.activiti.workflow.simple.alfresco.model.M2NamedValue)2 M2PropertyOverride (org.activiti.workflow.simple.alfresco.model.M2PropertyOverride)2 FormFieldControlParameter (org.activiti.workflow.simple.alfresco.model.config.FormFieldControlParameter)2 ListPropertyEntry (org.activiti.workflow.simple.definition.form.ListPropertyEntry)2 AlfrescoSimpleWorkflowException (org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException)1 PropertyReference (org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference)1 AlfrescoTransitionsPropertyDefinition (org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition)1 M2AssociationSource (org.activiti.workflow.simple.alfresco.model.M2AssociationSource)1 M2AssociationTarget (org.activiti.workflow.simple.alfresco.model.M2AssociationTarget)1 M2ClassAssociation (org.activiti.workflow.simple.alfresco.model.M2ClassAssociation)1 Form (org.activiti.workflow.simple.alfresco.model.config.Form)1 BooleanPropertyDefinition (org.activiti.workflow.simple.definition.form.BooleanPropertyDefinition)1