Search in sources :

Example 21 with ActivityImpl

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

the class CompensationEventHandler method handleEvent.

public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {
    String configuration = eventSubscription.getConfiguration();
    if (configuration == null) {
        throw new ActivitiException("Compensating execution not set for compensate event subscription with id " + eventSubscription.getId());
    }
    ExecutionEntity compensatingExecution = commandContext.getExecutionEntityManager().findExecutionById(configuration);
    ActivityImpl compensationHandler = eventSubscription.getActivity();
    if ((compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION) == null || !(Boolean) compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION)) && compensationHandler.isScope()) {
        // descend into scope:
        List<CompensateEventSubscriptionEntity> eventsForThisScope = compensatingExecution.getCompensateEventSubscriptions();
        ScopeUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);
    } else {
        try {
            if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
                commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createActivityEvent(ActivitiEventType.ACTIVITY_COMPENSATE, compensationHandler.getId(), (String) compensationHandler.getProperty("name"), compensatingExecution.getId(), compensatingExecution.getProcessInstanceId(), compensatingExecution.getProcessDefinitionId(), (String) compensatingExecution.getActivity().getProperties().get("type"), compensatingExecution.getActivity().getActivityBehavior().getClass().getCanonicalName()));
            }
            compensatingExecution.setActivity(compensationHandler);
            // executing the atomic operation makes sure activity start events are fired
            compensatingExecution.performOperation(AtomicOperation.ACTIVITY_START);
        } catch (Exception e) {
            throw new ActivitiException("Error while handling compensation event " + eventSubscription, e);
        }
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) CompensateEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.CompensateEventSubscriptionEntity) ActivitiException(org.activiti.engine.ActivitiException)

Example 22 with ActivityImpl

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

the class FlowNodeHistoryParseHandler method parse.

public void parse(BpmnParse bpmnParse, BaseElement element) {
    ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(element.getId());
    if (element instanceof BoundaryEvent) {
        // A boundary-event never receives an activity start-event
        activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, ACTIVITY_INSTANCE_START_LISTENER, 0);
        activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, ACTIVITI_INSTANCE_END_LISTENER, 1);
    } else {
        activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_START, ACTIVITY_INSTANCE_START_LISTENER, 0);
        activity.addExecutionListener(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_END, ACTIVITI_INSTANCE_END_LISTENER);
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent)

Example 23 with ActivityImpl

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

the class TimerStartEventJobHandler method startProcessInstanceWithInitialActivity.

protected void startProcessInstanceWithInitialActivity(JobEntity job, String configuration, DeploymentManager deploymentManager, CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = deploymentManager.findDeployedProcessDefinitionById(job.getProcessDefinitionId());
    String activityId = getActivityIdFromConfiguration(configuration);
    ActivityImpl startActivity = processDefinition.findActivity(activityId);
    if (!deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) {
        dispatchTimerFiredEvent(job, commandContext);
        ExecutionEntity processInstance = processDefinition.createProcessInstance(null, startActivity);
        processInstance.start();
    } else {
        log.debug("Ignoring timer of suspended process definition {}", processDefinition.getId());
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 24 with ActivityImpl

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

the class CustomSequenceFlowBpmnParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, SequenceFlow flow) {
    // Do the regular stuff
    super.executeParse(bpmnParse, flow);
    // Add extension element conditions
    Map<String, List<ExtensionElement>> extensionElements = flow.getExtensionElements();
    if (extensionElements.containsKey("activiti_custom_condition")) {
        List<ExtensionElement> conditionsElements = extensionElements.get("activiti_custom_condition");
        CustomSetConditionsExecutionListener customFlowListener = new CustomSetConditionsExecutionListener();
        customFlowListener.setFlowId(flow.getId());
        for (ExtensionElement conditionElement : conditionsElements) {
            customFlowListener.addCondition(conditionElement.getElementText());
        }
        ActivityImpl activity = findActivity(bpmnParse, flow.getSourceRef());
        activity.addExecutionListener("start", customFlowListener);
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ExtensionElement(org.activiti.bpmn.model.ExtensionElement) List(java.util.List)

Example 25 with ActivityImpl

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

the class TerminateEndEventActivityBehavior method execute.

public void execute(ActivityExecution execution) throws Exception {
    ActivityImpl terminateEndEventActivity = (ActivityImpl) execution.getActivity();
    if (terminateAll) {
        ActivityExecution processInstanceExecution = findRootProcessInstanceExecution((ExecutionEntity) execution);
        terminateProcessInstanceExecution(execution, terminateEndEventActivity, processInstanceExecution);
    } else {
        ActivityExecution scopeExecution = ScopeUtil.findScopeExecution(execution);
        if (scopeExecution != null) {
            terminateExecution(execution, terminateEndEventActivity, scopeExecution);
        }
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution)

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