Search in sources :

Example 1 with M2PropertyOverride

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

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

the class AlfrescoReferencePropertyConverter method addOrAlterPackageItemActions.

protected void addOrAlterPackageItemActions(M2Type contentType, boolean allowAdd, boolean allowRemove) {
    if (allowAdd) {
        M2PropertyOverride addOverride = contentType.getPropertyOverride(AlfrescoConversionConstants.PROPERTY_PACKAGEITEMS_ACTION_GROUP);
        if (addOverride == null) {
            addOverride = new M2PropertyOverride();
            addOverride.setName(AlfrescoConversionConstants.PROPERTY_PACKAGEITEMS_ACTION_GROUP);
            contentType.getPropertyOverrides().add(addOverride);
        }
        addOverride.setDefaultValue(AlfrescoConversionConstants.PROPERTY_PACKAGEITEMS_ACTION_GROUP_ADD);
    }
    M2PropertyOverride removeOverride = contentType.getPropertyOverride(AlfrescoConversionConstants.PROPERTY_PACKAGEITEMS_ITEM_ACTION_GROUP);
    if (removeOverride == null) {
        removeOverride = new M2PropertyOverride();
        removeOverride.setName(AlfrescoConversionConstants.PROPERTY_PACKAGEITEMS_ITEM_ACTION_GROUP);
        contentType.getPropertyOverrides().add(removeOverride);
    }
    if (allowRemove) {
        removeOverride.setDefaultValue(AlfrescoConversionConstants.PROPERTY_PACKAGEITEMS_ITEM_ACTION_GROUP_REMOVE);
    } else {
        removeOverride.setDefaultValue(AlfrescoConversionConstants.PROPERTY_PACKAGEITEMS_ITEM_ACTION_GROUP_EDIT);
    }
}
Also used : M2PropertyOverride(org.activiti.workflow.simple.alfresco.model.M2PropertyOverride)

Example 3 with M2PropertyOverride

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

the class AlfrescoReferencePropertyConverter method addEmailNotificationReference.

protected void addEmailNotificationReference(Form form, String formSet, M2Type type, ReferencePropertyDefinition def) {
    // Only relevant on a start-form
    if (form.isStartForm()) {
        boolean forced = extractBooleanFromParameters(def.getParameters(), AlfrescoConversionConstants.PARAMETER_FORCE_NOTOFICATIONS, false);
        if (forced) {
            // Notifications are needed, add an override to the model
            if (type.getPropertyOverride(AlfrescoConversionConstants.PROPERTY_SEND_EMAIL_NOTIFICATIONS) == null) {
                M2PropertyOverride override = new M2PropertyOverride();
                override.setName(AlfrescoConversionConstants.PROPERTY_SEND_EMAIL_NOTIFICATIONS);
                override.setDefaultValue(Boolean.TRUE.toString());
                type.getPropertyOverrides().add(override);
            }
        } else {
            // Render a control to select whether notifications are needed or not
            form.getFormFieldVisibility().addShowFieldElement(AlfrescoConversionConstants.PROPERTY_SEND_EMAIL_NOTIFICATIONS);
            FormField formField = form.getFormAppearance().addFormField(AlfrescoConversionConstants.PROPERTY_SEND_EMAIL_NOTIFICATIONS, null, formSet);
            formField.setControl(new FormFieldControl(AlfrescoConversionConstants.FORM_EMAIL_NOTIFICATION_TEMPLATE));
            form.getFormAppearance().addFormAppearanceElement(formField);
        }
    }
}
Also used : M2PropertyOverride(org.activiti.workflow.simple.alfresco.model.M2PropertyOverride) FormFieldControl(org.activiti.workflow.simple.alfresco.model.config.FormFieldControl) FormField(org.activiti.workflow.simple.alfresco.model.config.FormField)

Aggregations

M2PropertyOverride (org.activiti.workflow.simple.alfresco.model.M2PropertyOverride)3 FormField (org.activiti.workflow.simple.alfresco.model.config.FormField)2 FormFieldControl (org.activiti.workflow.simple.alfresco.model.config.FormFieldControl)2 ArrayList (java.util.ArrayList)1 AlfrescoTransitionsPropertyDefinition (org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition)1 M2Constraint (org.activiti.workflow.simple.alfresco.model.M2Constraint)1 M2Mandatory (org.activiti.workflow.simple.alfresco.model.M2Mandatory)1 M2Model (org.activiti.workflow.simple.alfresco.model.M2Model)1 M2NamedValue (org.activiti.workflow.simple.alfresco.model.M2NamedValue)1 M2Property (org.activiti.workflow.simple.alfresco.model.M2Property)1 ListPropertyEntry (org.activiti.workflow.simple.definition.form.ListPropertyEntry)1