Search in sources :

Example 6 with PropertyReference

use of org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference in project Activiti by Activiti.

the class InitializeAlfrescoModelsConversionListener method beforeStepsConversion.

@Override
public void beforeStepsConversion(WorkflowDefinitionConversion conversion) {
    String processId = null;
    if (conversion.getWorkflowDefinition().getId() != null) {
        processId = AlfrescoConversionUtil.getValidIdString(conversion.getWorkflowDefinition().getId());
    } else {
        processId = generateUniqueProcessId(conversion);
    }
    M2Model model = addContentModel(conversion, processId);
    addExtension(conversion, processId);
    // In case the same property definitions are used across multiple forms, we need to identify this
    // up-front and create an aspect for this that can be shared due to the fact that you cannot define the same
    // property twice in a the same content-model namespace
    addAspectsForReusedProperties(conversion.getWorkflowDefinition(), model, processId);
    // Add list of property references
    conversion.setArtifact(ARTIFACT_PROPERTY_REFERENCES, new ArrayList<PropertyReference>());
}
Also used : PropertyReference(org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference) M2Model(org.activiti.workflow.simple.alfresco.model.M2Model)

Example 7 with PropertyReference

use of org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference 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

PropertyReference (org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference)7 M2Model (org.activiti.workflow.simple.alfresco.model.M2Model)4 UserTask (org.activiti.bpmn.model.UserTask)3 M2Type (org.activiti.workflow.simple.alfresco.model.M2Type)3 ArrayList (java.util.ArrayList)2 FlowElement (org.activiti.bpmn.model.FlowElement)2 ServiceTask (org.activiti.bpmn.model.ServiceTask)2 M2Namespace (org.activiti.workflow.simple.alfresco.model.M2Namespace)2 Configuration (org.activiti.workflow.simple.alfresco.model.config.Configuration)2 Form (org.activiti.workflow.simple.alfresco.model.config.Form)2 Module (org.activiti.workflow.simple.alfresco.model.config.Module)2 HumanStepDefinition (org.activiti.workflow.simple.definition.HumanStepDefinition)2 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)1 MultiInstanceLoopCharacteristics (org.activiti.bpmn.model.MultiInstanceLoopCharacteristics)1 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)1 StartEvent (org.activiti.bpmn.model.StartEvent)1 AlfrescoSimpleWorkflowException (org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException)1 ScriptServiceTaskBuilder (org.activiti.workflow.simple.alfresco.conversion.script.ScriptServiceTaskBuilder)1 ScriptTaskListenerBuilder (org.activiti.workflow.simple.alfresco.conversion.script.ScriptTaskListenerBuilder)1 M2AssociationSource (org.activiti.workflow.simple.alfresco.model.M2AssociationSource)1