Search in sources :

Example 16 with M2Model

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

Example 17 with M2Model

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

the class AlfrescoHumanStepDefinitionConverter method convertStepDefinition.

@Override
public UserTask convertStepDefinition(StepDefinition stepDefinition, WorkflowDefinitionConversion conversion) {
    HumanStepDefinition humanStep = (HumanStepDefinition) stepDefinition;
    validate(humanStep);
    M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
    M2Namespace modelNamespace = model.getNamespaces().get(0);
    // Let superclass handle BPMN-specific conversion
    UserTask userTask = super.convertStepDefinition(stepDefinition, conversion);
    // Clear form-properties in the BPMN file, as we use custom form-mapping in Alfresco
    userTask.getFormProperties().clear();
    userTask.setName(humanStep.getName() != null ? humanStep.getName() : humanStep.getId());
    // Create the content model for the task
    M2Type type = new M2Type();
    model.getTypes().add(type);
    type.setName(AlfrescoConversionUtil.getQualifiedName(modelNamespace.getPrefix(), humanStep.getId()));
    type.setParentName(AlfrescoConversionConstants.DEFAULT_BASE_FORM_TYPE);
    // Update task-key on the task itself
    userTask.setFormKey(type.getName());
    // Create a form-config for the task
    Module shareModule = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
    Configuration configuration = shareModule.addConfiguration(AlfrescoConversionConstants.EVALUATOR_TASK_TYPE, type.getName());
    Form formConfig = configuration.createForm();
    // Populate model and form based on FormDefinition
    formCreator.createForm(type, formConfig, humanStep.getForm(), conversion);
    // Set up property sharing using task-listeners
    addPropertySharing(humanStep, conversion, userTask);
    // is created
    if (humanStep.getAssignmentType() == HumanStepAssignmentType.USER) {
        String assignee = humanStep.getAssignment().getAssignee();
        if (assignee != null && PropertyReference.isPropertyReference(assignee)) {
            PropertyReference reference = PropertyReference.createReference(assignee);
            AlfrescoConversionUtil.getPropertyReferences(conversion).add(reference);
            userTask.setAssignee(reference.getUsernameReferenceExpression(modelNamespace.getPrefix()));
        }
    } else if (humanStep.getAssignmentType() == HumanStepAssignmentType.USERS) {
        if (humanStep.getAssignment().getCandidateUsers() != null) {
            userTask.setCandidateUsers(resolveUserPropertyReferences(humanStep.getAssignment().getCandidateUsers(), modelNamespace.getPrefix(), conversion));
        }
    } else if (humanStep.getAssignmentType() == HumanStepAssignmentType.GROUPS) {
        if (humanStep.getAssignment().getCandidateGroups() != null) {
            userTask.setCandidateGroups(resolveGroupPropertyReferences(humanStep.getAssignment().getCandidateGroups(), modelNamespace.getPrefix(), conversion));
        }
    }
    return userTask;
}
Also used : M2Namespace(org.activiti.workflow.simple.alfresco.model.M2Namespace) PropertyReference(org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference) HumanStepDefinition(org.activiti.workflow.simple.definition.HumanStepDefinition) M2Type(org.activiti.workflow.simple.alfresco.model.M2Type) Configuration(org.activiti.workflow.simple.alfresco.model.config.Configuration) Form(org.activiti.workflow.simple.alfresco.model.config.Form) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) UserTask(org.activiti.bpmn.model.UserTask) Module(org.activiti.workflow.simple.alfresco.model.config.Module)

Aggregations

M2Model (org.activiti.workflow.simple.alfresco.model.M2Model)17 M2Property (org.activiti.workflow.simple.alfresco.model.M2Property)7 FormField (org.activiti.workflow.simple.alfresco.model.config.FormField)7 FormFieldControl (org.activiti.workflow.simple.alfresco.model.config.FormFieldControl)7 M2Aspect (org.activiti.workflow.simple.alfresco.model.M2Aspect)6 M2Mandatory (org.activiti.workflow.simple.alfresco.model.M2Mandatory)6 M2Type (org.activiti.workflow.simple.alfresco.model.M2Type)6 HumanStepDefinition (org.activiti.workflow.simple.definition.HumanStepDefinition)5 PropertyReference (org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference)4 WorkflowDefinitionConversion (org.activiti.workflow.simple.converter.WorkflowDefinitionConversion)4 WorkflowDefinition (org.activiti.workflow.simple.definition.WorkflowDefinition)4 FormDefinition (org.activiti.workflow.simple.definition.form.FormDefinition)4 Test (org.junit.Test)4 FlowElement (org.activiti.bpmn.model.FlowElement)3 UserTask (org.activiti.bpmn.model.UserTask)3 M2ClassAssociation (org.activiti.workflow.simple.alfresco.model.M2ClassAssociation)3 M2Namespace (org.activiti.workflow.simple.alfresco.model.M2Namespace)3 Configuration (org.activiti.workflow.simple.alfresco.model.config.Configuration)3 Module (org.activiti.workflow.simple.alfresco.model.config.Module)3 ListPropertyEntry (org.activiti.workflow.simple.definition.form.ListPropertyEntry)3