Search in sources :

Example 1 with M2Aspect

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

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

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

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

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

the class InitializeAlfrescoModelsConversionListener method addAspectsForReusedProperties.

protected void addAspectsForReusedProperties(WorkflowDefinition workflowDefinition, M2Model model, String processId) {
    Map<String, FormPropertyDefinition> definitionMap = new HashMap<String, FormPropertyDefinition>();
    // Add start-form properties
    addDefinitionsToMap(workflowDefinition.getStartFormDefinition(), definitionMap);
    // Run through steps recursivelye, looking for properties
    addAspectsForReusedProperties(workflowDefinition.getSteps(), model, processId, definitionMap);
    // Check if the map contains values other than null, this indicates duplicate properties are found
    for (Entry<String, FormPropertyDefinition> entry : definitionMap.entrySet()) {
        if (entry.getValue() != null) {
            // Create an aspect for this property. The aspect itself will be populated when the first
            // property is converted with that name
            M2Aspect aspect = new M2Aspect();
            aspect.setName(AlfrescoConversionUtil.getQualifiedName(processId, entry.getKey()));
            model.getAspects().add(aspect);
        }
    }
}
Also used : HashMap(java.util.HashMap) FormPropertyDefinition(org.activiti.workflow.simple.definition.form.FormPropertyDefinition) M2Aspect(org.activiti.workflow.simple.alfresco.model.M2Aspect)

Aggregations

M2Aspect (org.activiti.workflow.simple.alfresco.model.M2Aspect)7 M2Model (org.activiti.workflow.simple.alfresco.model.M2Model)6 FormField (org.activiti.workflow.simple.alfresco.model.config.FormField)6 FormFieldControl (org.activiti.workflow.simple.alfresco.model.config.FormFieldControl)6 M2Mandatory (org.activiti.workflow.simple.alfresco.model.M2Mandatory)5 M2Property (org.activiti.workflow.simple.alfresco.model.M2Property)5 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)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 M2Constraint (org.activiti.workflow.simple.alfresco.model.M2Constraint)1 M2NamedValue (org.activiti.workflow.simple.alfresco.model.M2NamedValue)1 BooleanPropertyDefinition (org.activiti.workflow.simple.definition.form.BooleanPropertyDefinition)1 DatePropertyDefinition (org.activiti.workflow.simple.definition.form.DatePropertyDefinition)1 FormPropertyDefinition (org.activiti.workflow.simple.definition.form.FormPropertyDefinition)1 ListPropertyDefinition (org.activiti.workflow.simple.definition.form.ListPropertyDefinition)1 ListPropertyEntry (org.activiti.workflow.simple.definition.form.ListPropertyEntry)1 NumberPropertyDefinition (org.activiti.workflow.simple.definition.form.NumberPropertyDefinition)1 TextPropertyDefinition (org.activiti.workflow.simple.definition.form.TextPropertyDefinition)1