Search in sources :

Example 11 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl 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 12 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.

the class SignalEventDefinitionParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, SignalEventDefinition signalDefinition) {
    Signal signal = null;
    if (bpmnParse.getBpmnModel().containsSignalId(signalDefinition.getSignalRef())) {
        signal = bpmnParse.getBpmnModel().getSignal(signalDefinition.getSignalRef());
        String signalName = signal.getName();
        signalDefinition.setSignalRef(signalName);
    }
    if (signal == null) {
        return;
    }
    ActivityImpl activity = bpmnParse.getCurrentActivity();
    if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
        activity.setProperty("type", "signalStartEvent");
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
        eventSubscriptionDeclaration.setActivityId(activity.getId());
        eventSubscriptionDeclaration.setStartEvent(true);
        addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, bpmnParse.getCurrentScope());
    } else if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
        activity.setProperty("type", "intermediateSignalCatch");
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
        if (signal.getScope() != null) {
            eventSubscriptionDeclaration.setConfiguration(signal.getScope());
        }
        if (getPrecedingEventBasedGateway(bpmnParse, (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) != null) {
            eventSubscriptionDeclaration.setActivityId(activity.getId());
            addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity.getParent());
        } else {
            activity.setScope(true);
            addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity);
        }
    } else if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent) {
        ThrowEvent throwEvent = (ThrowEvent) bpmnParse.getCurrentFlowElement();
        activity.setProperty("type", "intermediateSignalThrow");
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
        eventSubscriptionDeclaration.setAsync(signalDefinition.isAsync());
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowSignalEventActivityBehavior(throwEvent, signal, eventSubscriptionDeclaration));
    } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
        BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
        boolean interrupting = boundaryEvent.isCancelActivity();
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
        activity.setProperty("type", "boundarySignal");
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
        eventSubscriptionDeclaration.setActivityId(activity.getId());
        if (signal.getScope() != null) {
            eventSubscriptionDeclaration.setConfiguration(signal.getScope());
        }
        addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity.getParent());
        if (activity.getParent() instanceof ActivityImpl) {
            ((ActivityImpl) activity.getParent()).setScope(true);
        }
    }
}
Also used : ThrowEvent(org.activiti.bpmn.model.ThrowEvent) Signal(org.activiti.bpmn.model.Signal) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) StartEvent(org.activiti.bpmn.model.StartEvent) EventSubscriptionDeclaration(org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration)

Example 13 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.

the class CallActivityParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, CallActivity callActivity) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, callActivity, BpmnXMLConstants.ELEMENT_CALL_ACTIVITY);
    activity.setScope(true);
    activity.setAsync(callActivity.isAsynchronous());
    activity.setExclusive(!callActivity.isNotExclusive());
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCallActivityBehavior(callActivity));
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Example 14 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.

the class CompensateEventDefinitionParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, CompensateEventDefinition eventDefinition) {
    ScopeImpl scope = bpmnParse.getCurrentScope();
    if (StringUtils.isNotEmpty(eventDefinition.getActivityRef())) {
        if (scope.findActivity(eventDefinition.getActivityRef()) == null) {
            logger.warn("Invalid attribute value for 'activityRef': no activity with id '" + eventDefinition.getActivityRef() + "' in current scope " + scope.getId());
        }
    }
    org.activiti.engine.impl.bpmn.parser.CompensateEventDefinition compensateEventDefinition = new org.activiti.engine.impl.bpmn.parser.CompensateEventDefinition();
    compensateEventDefinition.setActivityRef(eventDefinition.getActivityRef());
    compensateEventDefinition.setWaitForCompletion(eventDefinition.isWaitForCompletion());
    ActivityImpl activity = bpmnParse.getCurrentActivity();
    if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent) {
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowCompensationEventActivityBehavior((ThrowEvent) bpmnParse.getCurrentFlowElement(), compensateEventDefinition));
    } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
        BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
        boolean interrupting = boundaryEvent.isCancelActivity();
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
        activity.setProperty("type", "compensationBoundaryCatch");
    } else {
    // What to do?
    }
}
Also used : ThrowEvent(org.activiti.bpmn.model.ThrowEvent) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl) CompensateEventDefinition(org.activiti.bpmn.model.CompensateEventDefinition)

Example 15 with ActivityImpl

use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.

the class EventBasedGatewayParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, EventGateway gateway) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, gateway, BpmnXMLConstants.ELEMENT_GATEWAY_EVENT);
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createEventBasedGatewayActivityBehavior(gateway));
    activity.setAsync(gateway.isAsynchronous());
    activity.setExclusive(!gateway.isNotExclusive());
    activity.setScope(true);
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Aggregations

ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)82 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)15 ActivitiException (org.activiti.engine.ActivitiException)14 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)11 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)9 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)7 TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)7 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)6 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)6 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 EventDefinition (org.activiti.bpmn.model.EventDefinition)4 StartEvent (org.activiti.bpmn.model.StartEvent)4 IOSpecification (org.activiti.engine.impl.bpmn.data.IOSpecification)4 ActivityBehavior (org.activiti.engine.impl.pvm.delegate.ActivityBehavior)4 BpmnModel (org.activiti.bpmn.model.BpmnModel)3 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)3 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)3 PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)3