Search in sources :

Example 1 with FormField

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

the class AlfrescoDatePropertyConverter method convertProperty.

@Override
public void convertProperty(M2Type contentType, String formSet, Form form, FormPropertyDefinition propertyDefinition, WorkflowDefinitionConversion conversion) {
    DatePropertyDefinition dateDefinition = (DatePropertyDefinition) propertyDefinition;
    String propertyName = getPropertyName(propertyDefinition, conversion);
    // Add to content model
    M2Property property = new M2Property();
    property.setMandatory(new M2Mandatory(dateDefinition.isMandatory()));
    property.setName(propertyName);
    if (dateDefinition.isShowTime()) {
        property.setPropertyType(AlfrescoConversionConstants.PROPERTY_TYPE_DATETIME);
    } else {
        property.setPropertyType(AlfrescoConversionConstants.PROPERTY_TYPE_DATE);
    }
    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, dateDefinition.getName(), formSet);
    if (dateDefinition.isWritable()) {
        // Use custom date-control
        FormFieldControl control = new FormFieldControl();
        control.setTemplate(AlfrescoConversionConstants.FORM_DATE_TEMPLATE);
        control.addControlParameter(AlfrescoConversionConstants.FORM_DATE_PARAM_SHOW_TIME, Boolean.toString(dateDefinition.isShowTime()));
        control.addControlParameter(AlfrescoConversionConstants.FORM_DATE_PARAM_SUBMIT_TIME, Boolean.toString(dateDefinition.isShowTime()));
        formField.setControl(control);
    } else {
        // 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 : 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) DatePropertyDefinition(org.activiti.workflow.simple.definition.form.DatePropertyDefinition) 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 2 with FormField

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

the class AlfrescoListPropertyConverter method convertProperty.

@Override
public void convertProperty(M2Type contentType, String formSet, Form form, FormPropertyDefinition propertyDefinition, WorkflowDefinitionConversion conversion) {
    ListPropertyDefinition dateDefinition = (ListPropertyDefinition) propertyDefinition;
    String propertyName = getPropertyName(propertyDefinition, conversion);
    // Add to content model
    M2Property property = new M2Property();
    property.setMandatory(new M2Mandatory(dateDefinition.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);
    }
    // Create constraint for the values
    if (dateDefinition.getEntries() != null && !dateDefinition.getEntries().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>(dateDefinition.getEntries().size());
        for (ListPropertyEntry entry : dateDefinition.getEntries()) {
            // TODO: i18n file using labels in properties-file, a part of deployment?
            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 form configuration
    form.getFormFieldVisibility().addShowFieldElement(propertyName);
    FormField formField = form.getFormAppearance().addFormField(propertyName, propertyDefinition.getName(), formSet);
    // Read-only properties should always be rendered using an info-template
    if (!dateDefinition.isWritable()) {
        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 : ListPropertyEntry(org.activiti.workflow.simple.definition.form.ListPropertyEntry) M2Property(org.activiti.workflow.simple.alfresco.model.M2Property) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) ArrayList(java.util.ArrayList) M2Constraint(org.activiti.workflow.simple.alfresco.model.M2Constraint) M2NamedValue(org.activiti.workflow.simple.alfresco.model.M2NamedValue) FormFieldControl(org.activiti.workflow.simple.alfresco.model.config.FormFieldControl) ListPropertyDefinition(org.activiti.workflow.simple.definition.form.ListPropertyDefinition) 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 3 with FormField

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

the class AlfrescoNumberPropertyConverter method convertProperty.

@Override
public void convertProperty(M2Type contentType, String formSet, Form form, FormPropertyDefinition propertyDefinition, WorkflowDefinitionConversion conversion) {
    NumberPropertyDefinition numberPropertyDefinition = (NumberPropertyDefinition) propertyDefinition;
    String propertyName = getPropertyName(propertyDefinition, conversion);
    // Add to content model
    M2Property property = new M2Property();
    property.setMandatory(new M2Mandatory(numberPropertyDefinition.isMandatory()));
    property.setName(propertyName);
    property.setPropertyType(AlfrescoConversionConstants.PROPERTY_TYPE_DOUBLE);
    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 (numberPropertyDefinition.isWritable()) {
        // Use custom date-control
        FormFieldControl control = new FormFieldControl();
        control.setTemplate(AlfrescoConversionConstants.FORM_NUMBER_TEMPLATE);
        formField.setControl(control);
    } else {
        // 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 : NumberPropertyDefinition(org.activiti.workflow.simple.definition.form.NumberPropertyDefinition) 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 4 with FormField

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

the class AlfrescoReferencePropertyConverter method addCommentReference.

protected void addCommentReference(Form form, String formSet) {
    form.getFormFieldVisibility().addShowFieldElement(AlfrescoConversionConstants.PROPERTY_COMMENT);
    FormField commentField = new FormField();
    commentField.setId(AlfrescoConversionConstants.PROPERTY_COMMENT);
    commentField.setLabelId(AlfrescoConversionConstants.FORM_COMMENT_LABEL);
    commentField.setSet(formSet);
    commentField.setControl(new FormFieldControl(AlfrescoConversionConstants.FORM_MULTILINE_TEXT_TEMPLATE));
    form.getFormAppearance().addFormAppearanceElement(commentField);
}
Also used : FormFieldControl(org.activiti.workflow.simple.alfresco.model.config.FormFieldControl) FormField(org.activiti.workflow.simple.alfresco.model.config.FormField)

Example 5 with FormField

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

the class AlfrescoReferencePropertyConverter method addFieldReference.

protected void addFieldReference(Form form, String formSet, ReferencePropertyDefinition definition, M2Type contentType, WorkflowDefinitionConversion conversion) {
    if (form.isStartForm()) {
        throw new AlfrescoSimpleWorkflowException("Field references cannot be used on start-forms");
    }
    // Check if model contains an aspect for the property
    String propertyName = getPropertyName(definition, conversion);
    // Add property-reference to the context to be validated
    PropertyReference reference = new PropertyReference(definition.getName());
    AlfrescoConversionUtil.getPropertyReferences(conversion).add(reference);
    // Add aspect to content-type
    contentType.getMandatoryAspects().add(propertyName);
    // Add read-only field to form
    form.getFormFieldVisibility().addShowFieldElement(propertyName);
    FormField field = new FormField();
    form.getFormAppearance().addFormAppearanceElement(field);
    field.setId(propertyName);
    field.setLabelId(definition.getName());
    field.setSet(formSet);
    field.setControl(new FormFieldControl(AlfrescoConversionConstants.FORM_READONLY_TEMPLATE));
}
Also used : PropertyReference(org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference) FormFieldControl(org.activiti.workflow.simple.alfresco.model.config.FormFieldControl) AlfrescoSimpleWorkflowException(org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException) 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