Search in sources :

Example 1 with IOSpecification

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

the class AbstractBpmnParseHandler method createIOSpecification.

protected IOSpecification createIOSpecification(BpmnParse bpmnParse, org.activiti.bpmn.model.IOSpecification specificationModel) {
    IOSpecification ioSpecification = new IOSpecification();
    for (DataSpec dataInputElement : specificationModel.getDataInputs()) {
        ItemDefinition itemDefinition = bpmnParse.getItemDefinitions().get(dataInputElement.getItemSubjectRef());
        Data dataInput = new Data(bpmnParse.getTargetNamespace() + ":" + dataInputElement.getId(), dataInputElement.getId(), itemDefinition);
        ioSpecification.addInput(dataInput);
    }
    for (DataSpec dataOutputElement : specificationModel.getDataOutputs()) {
        ItemDefinition itemDefinition = bpmnParse.getItemDefinitions().get(dataOutputElement.getItemSubjectRef());
        Data dataOutput = new Data(bpmnParse.getTargetNamespace() + ":" + dataOutputElement.getId(), dataOutputElement.getId(), itemDefinition);
        ioSpecification.addOutput(dataOutput);
    }
    for (String dataInputRef : specificationModel.getDataInputRefs()) {
        DataRef dataRef = new DataRef(dataInputRef);
        ioSpecification.addInputRef(dataRef);
    }
    for (String dataOutputRef : specificationModel.getDataOutputRefs()) {
        DataRef dataRef = new DataRef(dataOutputRef);
        ioSpecification.addOutputRef(dataRef);
    }
    return ioSpecification;
}
Also used : DataRef(org.activiti.engine.impl.bpmn.data.DataRef) IOSpecification(org.activiti.engine.impl.bpmn.data.IOSpecification) ItemDefinition(org.activiti.engine.impl.bpmn.data.ItemDefinition) DataSpec(org.activiti.bpmn.model.DataSpec) Data(org.activiti.engine.impl.bpmn.data.Data)

Example 2 with IOSpecification

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

the class TransactionParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, Transaction transaction) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, transaction, BpmnXMLConstants.ELEMENT_TRANSACTION);
    activity.setAsync(transaction.isAsynchronous());
    activity.setExclusive(!transaction.isNotExclusive());
    activity.setScope(true);
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createTransactionActivityBehavior(transaction));
    bpmnParse.setCurrentScope(activity);
    bpmnParse.processFlowElements(transaction.getFlowElements());
    processArtifacts(bpmnParse, transaction.getArtifacts(), activity);
    bpmnParse.removeCurrentScope();
    if (transaction.getIoSpecification() != null) {
        IOSpecification ioSpecification = createIOSpecification(bpmnParse, transaction.getIoSpecification());
        activity.setIoSpecification(ioSpecification);
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) IOSpecification(org.activiti.engine.impl.bpmn.data.IOSpecification)

Example 3 with IOSpecification

use of org.activiti.engine.impl.bpmn.data.IOSpecification 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 4 with IOSpecification

use of org.activiti.engine.impl.bpmn.data.IOSpecification 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)

Example 5 with IOSpecification

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

the class SubProcessParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, SubProcess subProcess) {
    ActivityImpl activity = createActivityOnScope(bpmnParse, subProcess, BpmnXMLConstants.ELEMENT_SUBPROCESS, bpmnParse.getCurrentScope());
    activity.setAsync(subProcess.isAsynchronous());
    activity.setExclusive(!subProcess.isNotExclusive());
    boolean triggeredByEvent = false;
    if (subProcess instanceof EventSubProcess) {
        triggeredByEvent = true;
    }
    activity.setProperty("triggeredByEvent", triggeredByEvent);
    // event subprocesses are not scopes
    activity.setScope(!triggeredByEvent);
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createSubprocActivityBehavior(subProcess));
    bpmnParse.setCurrentScope(activity);
    bpmnParse.setCurrentSubProcess(subProcess);
    bpmnParse.processFlowElements(subProcess.getFlowElements());
    processArtifacts(bpmnParse, subProcess.getArtifacts(), activity);
    // no data objects for event subprocesses
    if (!(subProcess instanceof EventSubProcess)) {
        // parse out any data objects from the template in order to set up the necessary process variables
        Map<String, Object> variables = processDataObjects(bpmnParse, subProcess.getDataObjects(), activity);
        activity.setVariables(variables);
    }
    bpmnParse.removeCurrentScope();
    bpmnParse.removeCurrentSubProcess();
    if (subProcess.getIoSpecification() != null) {
        IOSpecification ioSpecification = createIOSpecification(bpmnParse, subProcess.getIoSpecification());
        activity.setIoSpecification(ioSpecification);
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) IOSpecification(org.activiti.engine.impl.bpmn.data.IOSpecification) EventSubProcess(org.activiti.bpmn.model.EventSubProcess)

Aggregations

IOSpecification (org.activiti.engine.impl.bpmn.data.IOSpecification)5 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)4 DataAssociation (org.activiti.bpmn.model.DataAssociation)2 WebServiceActivityBehavior (org.activiti.engine.impl.bpmn.behavior.WebServiceActivityBehavior)2 AbstractDataAssociation (org.activiti.engine.impl.bpmn.data.AbstractDataAssociation)2 DataSpec (org.activiti.bpmn.model.DataSpec)1 EventSubProcess (org.activiti.bpmn.model.EventSubProcess)1 Data (org.activiti.engine.impl.bpmn.data.Data)1 DataRef (org.activiti.engine.impl.bpmn.data.DataRef)1 ItemDefinition (org.activiti.engine.impl.bpmn.data.ItemDefinition)1 Operation (org.activiti.engine.impl.bpmn.webservice.Operation)1