Search in sources :

Example 6 with M2Aspect

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

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

the class AlfrescoReferencePropertyConverter method addAssociation.

protected void addAssociation(Form form, String formSet, ReferencePropertyDefinition referenceDefinition, M2Type contentType, WorkflowDefinitionConversion conversion) {
    M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
    // Check if model contains an aspect for the property
    String propertyName = getPropertyName(referenceDefinition, conversion);
    M2ClassAssociation association = new M2ClassAssociation();
    association.setName(propertyName);
    association.setTitle(referenceDefinition.getName());
    M2AssociationSource source = new M2AssociationSource();
    source.setMany(false);
    source.setMandatory(true);
    M2AssociationTarget target = new M2AssociationTarget();
    target.setClassName(referenceDefinition.getType());
    target.setMandatory(referenceDefinition.isMandatory());
    // Determine whether or not it's allowed to select multiple targets
    boolean isTargetMany = extractBooleanFromParameters(referenceDefinition.getParameters(), AlfrescoConversionConstants.PARAMETER_REFERENCE_MANY, false);
    target.setMany(isTargetMany);
    association.setTarget(target);
    association.setSource(source);
    M2Aspect aspect = model.getAspect(propertyName);
    if (aspect != null) {
        if (aspect.getAssociations().isEmpty()) {
            aspect.getAssociations().add(association);
        }
        contentType.getMandatoryAspects().add(propertyName);
    } else {
        contentType.getAssociations().add(association);
    }
    // Add field to form
    form.getFormFieldVisibility().addShowFieldElement(propertyName);
    FormField field = new FormField();
    form.getFormAppearance().addFormAppearanceElement(field);
    field.setId(propertyName);
    field.setSet(formSet);
    // of the normal document picker, starting from the default location
    if (AlfrescoConversionConstants.CONTENT_TYPE_CONTENT.equals(referenceDefinition.getType())) {
        FormFieldControl control = new FormFieldControl(AlfrescoConversionConstants.FORM_PACKAGE_ITEMS_TEMPLATE);
        control.addControlParameter(AlfrescoConversionConstants.FORM_PACKAGE_ITEMS_PARAM_ROOTNODE, AlfrescoConversionConstants.FORM_PACKAGE_ITEMS_PARAM_ROOTNODE_DEFAULT);
        field.setControl(control);
        // Since we use the "package" template, we need to set the special action-parameters. This might
        // impact the general package actions, but it's the bes we can do without custom coding/template
        addOrAlterPackageItemActions(contentType, true, true);
    }
    // Wire in variable output to process, if needed
    addOutputProperty(referenceDefinition, propertyName, contentType.getName(), conversion);
}
Also used : M2AssociationTarget(org.activiti.workflow.simple.alfresco.model.M2AssociationTarget) FormFieldControl(org.activiti.workflow.simple.alfresco.model.config.FormFieldControl) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) M2AssociationSource(org.activiti.workflow.simple.alfresco.model.M2AssociationSource) M2Aspect(org.activiti.workflow.simple.alfresco.model.M2Aspect) FormField(org.activiti.workflow.simple.alfresco.model.config.FormField) M2ClassAssociation(org.activiti.workflow.simple.alfresco.model.M2ClassAssociation)

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