Search in sources :

Example 1 with AbstractDataAssociation

use of org.activiti.engine.impl.bpmn.data.AbstractDataAssociation in project Activiti by Activiti.

the class AbstractExternalInvocationBpmnParseHandler method createDataOutputAssociation.

public AbstractDataAssociation createDataOutputAssociation(BpmnParse bpmnParse, DataAssociation dataAssociationElement) {
    if (StringUtils.isNotEmpty(dataAssociationElement.getSourceRef())) {
        return new MessageImplicitDataOutputAssociation(dataAssociationElement.getTargetRef(), dataAssociationElement.getSourceRef());
    } else {
        Expression transformation = bpmnParse.getExpressionManager().createExpression(dataAssociationElement.getTransformation());
        AbstractDataAssociation dataOutputAssociation = new TransformationDataOutputAssociation(null, dataAssociationElement.getTargetRef(), transformation);
        return dataOutputAssociation;
    }
}
Also used : MessageImplicitDataOutputAssociation(org.activiti.engine.impl.bpmn.webservice.MessageImplicitDataOutputAssociation) TransformationDataOutputAssociation(org.activiti.engine.impl.bpmn.data.TransformationDataOutputAssociation) AbstractDataAssociation(org.activiti.engine.impl.bpmn.data.AbstractDataAssociation) Expression(org.activiti.engine.delegate.Expression)

Example 2 with AbstractDataAssociation

use of org.activiti.engine.impl.bpmn.data.AbstractDataAssociation in project Activiti by Activiti.

the class SendTaskParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, SendTask sendTask) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, sendTask, BpmnXMLConstants.ELEMENT_TASK_SEND);
    activity.setAsync(sendTask.isAsynchronous());
    activity.setExclusive(!sendTask.isNotExclusive());
    if (StringUtils.isNotEmpty(sendTask.getType())) {
        if (sendTask.getType().equalsIgnoreCase("mail")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMailActivityBehavior(sendTask));
        } else if (sendTask.getType().equalsIgnoreCase("mule")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMuleActivityBehavior(sendTask, bpmnParse.getBpmnModel()));
        } else if (sendTask.getType().equalsIgnoreCase("camel")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCamelActivityBehavior(sendTask, bpmnParse.getBpmnModel()));
        }
    // for web service
    } else if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(sendTask.getImplementationType()) && StringUtils.isNotEmpty(sendTask.getOperationRef())) {
        if (!bpmnParse.getOperations().containsKey(sendTask.getOperationRef())) {
            logger.warn(sendTask.getOperationRef() + " does not exist for sendTask " + sendTask.getId());
        } else {
            WebServiceActivityBehavior webServiceActivityBehavior = bpmnParse.getActivityBehaviorFactory().createWebServiceActivityBehavior(sendTask);
            Operation operation = bpmnParse.getOperations().get(sendTask.getOperationRef());
            webServiceActivityBehavior.setOperation(operation);
            if (sendTask.getIoSpecification() != null) {
                IOSpecification ioSpecification = createIOSpecification(bpmnParse, sendTask.getIoSpecification());
                webServiceActivityBehavior.setIoSpecification(ioSpecification);
            }
            for (DataAssociation dataAssociationElement : sendTask.getDataInputAssociations()) {
                AbstractDataAssociation dataAssociation = createDataInputAssociation(bpmnParse, dataAssociationElement);
                webServiceActivityBehavior.addDataInputAssociation(dataAssociation);
            }
            for (DataAssociation dataAssociationElement : sendTask.getDataOutputAssociations()) {
                AbstractDataAssociation dataAssociation = createDataOutputAssociation(bpmnParse, dataAssociationElement);
                webServiceActivityBehavior.addDataOutputAssociation(dataAssociation);
            }
            activity.setActivityBehavior(webServiceActivityBehavior);
        }
    } else {
        logger.warn("One of the attributes 'type' or 'operation' is mandatory on sendTask " + sendTask.getId());
    }
}
Also used : AbstractDataAssociation(org.activiti.engine.impl.bpmn.data.AbstractDataAssociation) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) DataAssociation(org.activiti.bpmn.model.DataAssociation) AbstractDataAssociation(org.activiti.engine.impl.bpmn.data.AbstractDataAssociation) IOSpecification(org.activiti.engine.impl.bpmn.data.IOSpecification) WebServiceActivityBehavior(org.activiti.engine.impl.bpmn.behavior.WebServiceActivityBehavior) Operation(org.activiti.engine.impl.bpmn.webservice.Operation)

Example 3 with AbstractDataAssociation

use of org.activiti.engine.impl.bpmn.data.AbstractDataAssociation in project Activiti by Activiti.

the class CallActivityBehavior method execute.

public void execute(ActivityExecution execution) throws Exception {
    String processDefinitonKey = this.processDefinitonKey;
    if (processDefinitionExpression != null) {
        processDefinitonKey = (String) processDefinitionExpression.getValue(execution);
    }
    DeploymentManager deploymentManager = Context.getProcessEngineConfiguration().getDeploymentManager();
    ProcessDefinitionEntity processDefinition = null;
    if (execution.getTenantId() == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(execution.getTenantId())) {
        processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKey(processDefinitonKey);
    } else {
        processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKeyAndTenantId(processDefinitonKey, execution.getTenantId());
    }
    // Do not start a process instance if the process definition is suspended
    if (deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) {
        throw new ActivitiException("Cannot start process instance. Process definition " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended");
    }
    PvmProcessInstance subProcessInstance = execution.createSubProcessInstance(processDefinition);
    if (inheritVariables) {
        Map<String, Object> variables = execution.getVariables();
        for (Map.Entry<String, Object> entry : variables.entrySet()) {
            subProcessInstance.setVariable(entry.getKey(), entry.getValue());
        }
    }
    // copy process variables
    for (AbstractDataAssociation dataInputAssociation : dataInputAssociations) {
        Object value = null;
        if (dataInputAssociation.getSourceExpression() != null) {
            value = dataInputAssociation.getSourceExpression().getValue(execution);
        } else {
            value = execution.getVariable(dataInputAssociation.getSource());
        }
        subProcessInstance.setVariable(dataInputAssociation.getTarget(), value);
    }
    try {
        subProcessInstance.start();
    } catch (Exception e) {
        if (!ErrorPropagation.mapException(e, execution, mapExceptions, true))
            throw e;
    }
}
Also used : PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ActivitiException(org.activiti.engine.ActivitiException) AbstractDataAssociation(org.activiti.engine.impl.bpmn.data.AbstractDataAssociation) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) Map(java.util.Map) ActivitiException(org.activiti.engine.ActivitiException)

Example 4 with AbstractDataAssociation

use of org.activiti.engine.impl.bpmn.data.AbstractDataAssociation in project Activiti by Activiti.

the class CallActivityBehavior method completing.

public void completing(DelegateExecution execution, DelegateExecution subProcessInstance) throws Exception {
    // copy process variables
    for (AbstractDataAssociation dataOutputAssociation : dataOutputAssociations) {
        Object value = null;
        if (dataOutputAssociation.getSourceExpression() != null) {
            value = dataOutputAssociation.getSourceExpression().getValue(subProcessInstance);
        } else {
            value = subProcessInstance.getVariable(dataOutputAssociation.getSource());
        }
        execution.setVariable(dataOutputAssociation.getTarget(), value);
    }
}
Also used : AbstractDataAssociation(org.activiti.engine.impl.bpmn.data.AbstractDataAssociation)

Example 5 with AbstractDataAssociation

use of org.activiti.engine.impl.bpmn.data.AbstractDataAssociation in project Activiti by Activiti.

the class ServiceTaskParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, ServiceTask serviceTask) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, serviceTask, BpmnXMLConstants.ELEMENT_TASK_SERVICE);
    activity.setAsync(serviceTask.isAsynchronous());
    activity.setFailedJobRetryTimeCycleValue(serviceTask.getFailedJobRetryTimeCycleValue());
    activity.setExclusive(!serviceTask.isNotExclusive());
    // Email, Mule and Shell service tasks
    if (StringUtils.isNotEmpty(serviceTask.getType())) {
        if (serviceTask.getType().equalsIgnoreCase("mail")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMailActivityBehavior(serviceTask));
        } else if (serviceTask.getType().equalsIgnoreCase("mule")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMuleActivityBehavior(serviceTask, bpmnParse.getBpmnModel()));
        } else if (serviceTask.getType().equalsIgnoreCase("camel")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCamelActivityBehavior(serviceTask, bpmnParse.getBpmnModel()));
        } else if (serviceTask.getType().equalsIgnoreCase("shell")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createShellActivityBehavior(serviceTask));
        } else {
            logger.warn("Invalid service task type: '" + serviceTask.getType() + "' " + " for service task " + serviceTask.getId());
        }
    // activiti:class
    } else if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(serviceTask.getImplementationType())) {
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createClassDelegateServiceTask(serviceTask));
    // activiti:delegateExpression
    } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(serviceTask.getImplementationType())) {
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createServiceTaskDelegateExpressionActivityBehavior(serviceTask));
    // activiti:expression      
    } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(serviceTask.getImplementationType())) {
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createServiceTaskExpressionActivityBehavior(serviceTask));
    // Webservice   
    } else if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(serviceTask.getImplementationType()) && StringUtils.isNotEmpty(serviceTask.getOperationRef())) {
        if (!bpmnParse.getOperations().containsKey(serviceTask.getOperationRef())) {
            logger.warn(serviceTask.getOperationRef() + " does not exist for service task " + serviceTask.getId());
        } else {
            WebServiceActivityBehavior webServiceActivityBehavior = bpmnParse.getActivityBehaviorFactory().createWebServiceActivityBehavior(serviceTask);
            webServiceActivityBehavior.setOperation(bpmnParse.getOperations().get(serviceTask.getOperationRef()));
            if (serviceTask.getIoSpecification() != null) {
                IOSpecification ioSpecification = createIOSpecification(bpmnParse, serviceTask.getIoSpecification());
                webServiceActivityBehavior.setIoSpecification(ioSpecification);
            }
            for (DataAssociation dataAssociationElement : serviceTask.getDataInputAssociations()) {
                AbstractDataAssociation dataAssociation = createDataInputAssociation(bpmnParse, dataAssociationElement);
                webServiceActivityBehavior.addDataInputAssociation(dataAssociation);
            }
            for (DataAssociation dataAssociationElement : serviceTask.getDataOutputAssociations()) {
                AbstractDataAssociation dataAssociation = createDataOutputAssociation(bpmnParse, dataAssociationElement);
                webServiceActivityBehavior.addDataOutputAssociation(dataAssociation);
            }
            activity.setActivityBehavior(webServiceActivityBehavior);
        }
    } else {
        logger.warn("One of the attributes 'class', 'delegateExpression', 'type', 'operation', or 'expression' is mandatory on serviceTask " + serviceTask.getId());
    }
}
Also used : AbstractDataAssociation(org.activiti.engine.impl.bpmn.data.AbstractDataAssociation) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) DataAssociation(org.activiti.bpmn.model.DataAssociation) AbstractDataAssociation(org.activiti.engine.impl.bpmn.data.AbstractDataAssociation) IOSpecification(org.activiti.engine.impl.bpmn.data.IOSpecification) WebServiceActivityBehavior(org.activiti.engine.impl.bpmn.behavior.WebServiceActivityBehavior)

Aggregations

AbstractDataAssociation (org.activiti.engine.impl.bpmn.data.AbstractDataAssociation)8 DataAssociation (org.activiti.bpmn.model.DataAssociation)4 Expression (org.activiti.engine.delegate.Expression)2 WebServiceActivityBehavior (org.activiti.engine.impl.bpmn.behavior.WebServiceActivityBehavior)2 IOSpecification (org.activiti.engine.impl.bpmn.data.IOSpecification)2 TransformationDataOutputAssociation (org.activiti.engine.impl.bpmn.data.TransformationDataOutputAssociation)2 MessageImplicitDataOutputAssociation (org.activiti.engine.impl.bpmn.webservice.MessageImplicitDataOutputAssociation)2 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)2 Map (java.util.Map)1 ActivitiException (org.activiti.engine.ActivitiException)1 Operation (org.activiti.engine.impl.bpmn.webservice.Operation)1 ExpressionManager (org.activiti.engine.impl.el.ExpressionManager)1 DeploymentManager (org.activiti.engine.impl.persistence.deploy.DeploymentManager)1 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)1 PvmProcessInstance (org.activiti.engine.impl.pvm.PvmProcessInstance)1