Search in sources :

Example 1 with Form

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

the class InitializeAlfrescoModelsConversionListener method populateDefaultDetailFormConfig.

protected void populateDefaultDetailFormConfig(Configuration configuration) {
    Form form = configuration.createForm();
    // Add visibility of fields
    form.getFormFieldVisibility().addShowFieldElement(PROPERTY_WORKFLOW_DESCRIPTION);
    form.getFormFieldVisibility().addShowFieldElement(PROPERTY_WORKFLOW_DUE_DATE);
    form.getFormFieldVisibility().addShowFieldElement(PROPERTY_WORKFLOW_PRIORITY);
    form.getFormFieldVisibility().addShowFieldElement(PROPERTY_PACKAGEITEMS);
    form.getFormFieldVisibility().addShowFieldElement(PROPERTY_SEND_EMAIL_NOTIFICATIONS);
    // Add all sets to the appearance
    form.getFormAppearance().addFormSet(FORM_SET_GENERAL, FORM_SET_APPEARANCE_TITLE, FORM_SET_GENERAL_LABEL, null);
    form.getFormAppearance().addFormSet(FORM_SET_INFO, null, null, FORM_SET_TEMPLATE_2_COLUMN);
    form.getFormAppearance().addFormSet(FORM_SET_ASSIGNEE, FORM_SET_APPEARANCE_TITLE, FORM_SET_ASSIGNEE_LABEL, null);
    form.getFormAppearance().addFormSet(FORM_SET_ITEMS, FORM_SET_APPEARANCE_TITLE, FORM_SET_ITEMS_LABEL, null);
    form.getFormAppearance().addFormSet(FORM_SET_OTHER, FORM_SET_APPEARANCE_TITLE, FORM_SET_OTHER_LABEL, null);
    // Finally, add the individual fields
    FormField descriptionField = new FormField();
    descriptionField.setId(PROPERTY_WORKFLOW_DESCRIPTION);
    descriptionField.setControl(new FormFieldControl(FORM_MULTILINE_TEXT_TEMPLATE));
    descriptionField.setLabelId(FORM_WORKFLOW_DESCRIPTION_LABEL);
    form.getFormAppearance().addFormAppearanceElement(descriptionField);
    FormField dueDateField = new FormField();
    dueDateField.setId(PROPERTY_WORKFLOW_DUE_DATE);
    dueDateField.setSet(FORM_SET_INFO);
    dueDateField.setLabelId(FORM_WORKFLOW_DUE_DATE_LABEL);
    dueDateField.setControl(new FormFieldControl(FORM_DATE_TEMPLATE));
    dueDateField.getControl().getControlParameters().add(new FormFieldControlParameter(FORM_DATE_PARAM_SHOW_TIME, Boolean.FALSE.toString()));
    dueDateField.getControl().getControlParameters().add(new FormFieldControlParameter(FORM_DATE_PARAM_SUBMIT_TIME, Boolean.FALSE.toString()));
    form.getFormAppearance().addFormAppearanceElement(dueDateField);
    FormField priorityField = new FormField();
    priorityField.setSet(FORM_SET_INFO);
    priorityField.setLabelId(FORM_WORKFLOW_PRIORITY_LABEL);
    priorityField.setId(PROPERTY_WORKFLOW_PRIORITY);
    priorityField.setControl(new FormFieldControl(FORM_PRIORITY_TEMPLATE));
    form.getFormAppearance().addFormAppearanceElement(priorityField);
    form.getFormAppearance().addFormField(PROPERTY_PACKAGEITEMS, null, FORM_SET_ITEMS);
    FormField emailNotificationsField = new FormField();
    emailNotificationsField.setSet(FORM_SET_OTHER);
    emailNotificationsField.setId(PROPERTY_SEND_EMAIL_NOTIFICATIONS);
    emailNotificationsField.setControl(new FormFieldControl(FORM_EMAIL_NOTIFICATION_TEMPLATE));
    form.getFormAppearance().addFormAppearanceElement(emailNotificationsField);
}
Also used : Form(org.activiti.workflow.simple.alfresco.model.config.Form) FormFieldControl(org.activiti.workflow.simple.alfresco.model.config.FormFieldControl) FormFieldControlParameter(org.activiti.workflow.simple.alfresco.model.config.FormFieldControlParameter) FormField(org.activiti.workflow.simple.alfresco.model.config.FormField)

Example 2 with Form

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

the class InitializeAlfrescoModelsConversionListener method afterStepsConversion.

@Override
public void afterStepsConversion(WorkflowDefinitionConversion conversion) {
    M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
    M2Namespace modelNamespace = model.getNamespaces().get(0);
    for (FlowElement flowElement : conversion.getProcess().getFlowElements()) {
        if (flowElement instanceof StartEvent) {
            StartEvent startEvent = (StartEvent) flowElement;
            if (startEvent.getFormKey() == null) {
                Module module = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
                Configuration detailsForm = module.addConfiguration(EVALUATOR_STRING_COMPARE, MessageFormat.format(EVALUATOR_CONDITION_ACTIVITI, conversion.getProcess().getId()));
                // is available
                if (conversion.getWorkflowDefinition().getStartFormDefinition() != null && !conversion.getWorkflowDefinition().getStartFormDefinition().getFormGroups().isEmpty()) {
                    // Create the content model for the start-task
                    M2Type type = new M2Type();
                    model.getTypes().add(type);
                    type.setName(AlfrescoConversionUtil.getQualifiedName(modelNamespace.getPrefix(), AlfrescoConversionConstants.START_TASK_SIMPLE_NAME));
                    type.setParentName(AlfrescoConversionConstants.DEFAULT_START_FORM_TYPE);
                    // Create a form-config for the start-task
                    Module shareModule = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
                    Configuration configuration = shareModule.addConfiguration(AlfrescoConversionConstants.EVALUATOR_TASK_TYPE, type.getName());
                    Form formConfig = configuration.createForm();
                    formConfig.setStartForm(true);
                    // Populate model and form based on FormDefinition
                    formCreator.createForm(type, formConfig, conversion.getWorkflowDefinition().getStartFormDefinition(), conversion);
                    // Use the same form-config for the workflow details
                    detailsForm.addForm(formConfig);
                    // Set formKey on start-event, referencing type
                    startEvent.setFormKey(type.getName());
                } else {
                    // Revert to the default start-form
                    startEvent.setFormKey(DEFAULT_START_FORM_TYPE);
                    // Also add form-config to the share-module for workflow detail screen, based on the default form
                    populateDefaultDetailFormConfig(detailsForm);
                }
            }
        }
    }
    // Check all elements that can contain PropertyReferences or need additional builders invoked
    List<PropertyReference> references = AlfrescoConversionUtil.getPropertyReferences(conversion);
    for (FlowElement element : conversion.getProcess().getFlowElements()) {
        if (element instanceof SequenceFlow) {
            resolvePropertyRefrencesInSequenceFlow((SequenceFlow) element, modelNamespace, references);
        } else if (element instanceof IntermediateCatchEvent) {
            resolvePropertyRefrencesInCatchEvent((IntermediateCatchEvent) element, modelNamespace, references);
        } else if (element instanceof ServiceTask) {
            resolvePropertyRefrencesInServiceTask((ServiceTask) element, modelNamespace, references);
        } else if (element instanceof UserTask) {
            addScriptListenersToUserTask((UserTask) element, conversion);
        }
    }
    // Check if all property-references reference a valid property
    if (references != null && !references.isEmpty()) {
        for (PropertyReference reference : references) {
            reference.validate(model);
        }
    }
}
Also used : M2Namespace(org.activiti.workflow.simple.alfresco.model.M2Namespace) ServiceTask(org.activiti.bpmn.model.ServiceTask) Configuration(org.activiti.workflow.simple.alfresco.model.config.Configuration) Form(org.activiti.workflow.simple.alfresco.model.config.Form) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) UserTask(org.activiti.bpmn.model.UserTask) PropertyReference(org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference) M2Type(org.activiti.workflow.simple.alfresco.model.M2Type) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) Module(org.activiti.workflow.simple.alfresco.model.config.Module)

Example 3 with Form

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

Form (org.activiti.workflow.simple.alfresco.model.config.Form)3 UserTask (org.activiti.bpmn.model.UserTask)2 PropertyReference (org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference)2 M2Model (org.activiti.workflow.simple.alfresco.model.M2Model)2 M2Namespace (org.activiti.workflow.simple.alfresco.model.M2Namespace)2 M2Type (org.activiti.workflow.simple.alfresco.model.M2Type)2 Configuration (org.activiti.workflow.simple.alfresco.model.config.Configuration)2 Module (org.activiti.workflow.simple.alfresco.model.config.Module)2 FlowElement (org.activiti.bpmn.model.FlowElement)1 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)1 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)1 ServiceTask (org.activiti.bpmn.model.ServiceTask)1 StartEvent (org.activiti.bpmn.model.StartEvent)1 FormField (org.activiti.workflow.simple.alfresco.model.config.FormField)1 FormFieldControl (org.activiti.workflow.simple.alfresco.model.config.FormFieldControl)1 FormFieldControlParameter (org.activiti.workflow.simple.alfresco.model.config.FormFieldControlParameter)1 HumanStepDefinition (org.activiti.workflow.simple.definition.HumanStepDefinition)1