Search in sources :

Example 26 with EventSubscriptionEntity

use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity in project Activiti by Activiti.

the class BpmnDeployer method removeExistingMessageEventSubscriptions.

protected void removeExistingMessageEventSubscriptions(ProcessDefinitionEntity processDefinition, ProcessDefinitionEntity latestProcessDefinition) {
    if (latestProcessDefinition != null) {
        CommandContext commandContext = Context.getCommandContext();
        List<EventSubscriptionEntity> subscriptionsToDisable = commandContext.getEventSubscriptionEntityManager().findEventSubscriptionsByTypeAndProcessDefinitionId(MessageEventHandler.EVENT_HANDLER_TYPE, latestProcessDefinition.getId(), latestProcessDefinition.getTenantId());
        for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsToDisable) {
            eventSubscriptionEntity.delete();
        }
    }
}
Also used : CommandContext(org.activiti.engine.impl.interceptor.CommandContext) SignalEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity) MessageEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity) EventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 27 with EventSubscriptionEntity

use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity in project Activiti by Activiti.

the class BpmnDeployer method removeExistingSignalEventSubScription.

protected void removeExistingSignalEventSubScription(ProcessDefinitionEntity processDefinition, ProcessDefinitionEntity latestProcessDefinition) {
    if (latestProcessDefinition != null) {
        CommandContext commandContext = Context.getCommandContext();
        List<EventSubscriptionEntity> subscriptionsToDisable = commandContext.getEventSubscriptionEntityManager().findEventSubscriptionsByTypeAndProcessDefinitionId(SignalEventHandler.EVENT_HANDLER_TYPE, latestProcessDefinition.getId(), latestProcessDefinition.getTenantId());
        for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsToDisable) {
            eventSubscriptionEntity.delete();
        }
    }
}
Also used : CommandContext(org.activiti.engine.impl.interceptor.CommandContext) SignalEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity) MessageEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity) EventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 28 with EventSubscriptionEntity

use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity in project Activiti by Activiti.

the class EventSubscriptionDeclaration method prepareEventSubscriptionEntity.

public EventSubscriptionEntity prepareEventSubscriptionEntity(ExecutionEntity execution) {
    EventSubscriptionEntity eventSubscriptionEntity = null;
    if (eventType.equals("message")) {
        eventSubscriptionEntity = new MessageEventSubscriptionEntity(execution);
    } else if (eventType.equals("signal")) {
        eventSubscriptionEntity = new SignalEventSubscriptionEntity(execution);
    } else {
        throw new ActivitiIllegalArgumentException("Found event definition of unknown type: " + eventType);
    }
    eventSubscriptionEntity.setEventName(eventName);
    if (activityId != null) {
        ActivityImpl activity = execution.getProcessDefinition().findActivity(activityId);
        eventSubscriptionEntity.setActivity(activity);
    }
    if (configuration != null) {
        eventSubscriptionEntity.setConfiguration(configuration);
    }
    return eventSubscriptionEntity;
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) MessageEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity) MessageEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity) SignalEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity) EventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity) SignalEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity)

Example 29 with EventSubscriptionEntity

use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity in project Activiti by Activiti.

the class ScopeUtil method throwCompensationEvent.

/**
   * we create a separate execution for each compensation handler invocation. 
   */
public static void throwCompensationEvent(List<CompensateEventSubscriptionEntity> eventSubscriptions, ActivityExecution execution, boolean async) {
    // first spawn the compensating executions
    for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
        ExecutionEntity compensatingExecution = null;
        // and holds snapshot data).
        if (eventSubscription.getConfiguration() != null) {
            compensatingExecution = Context.getCommandContext().getExecutionEntityManager().findExecutionById(eventSubscription.getConfiguration());
            // move the compensating execution under this execution:
            compensatingExecution.setParent((InterpretableExecution) execution);
            compensatingExecution.setEventScope(false);
        } else {
            compensatingExecution = (ExecutionEntity) execution.createExecution();
            eventSubscription.setConfiguration(compensatingExecution.getId());
        }
        compensatingExecution.setConcurrent(true);
    }
    // signal compensation events in reverse order of their 'created' timestamp
    Collections.sort(eventSubscriptions, new Comparator<EventSubscriptionEntity>() {

        public int compare(EventSubscriptionEntity o1, EventSubscriptionEntity o2) {
            return o2.getCreated().compareTo(o1.getCreated());
        }
    });
    for (CompensateEventSubscriptionEntity compensateEventSubscriptionEntity : eventSubscriptions) {
        compensateEventSubscriptionEntity.eventReceived(null, async);
    }
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) CompensateEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.CompensateEventSubscriptionEntity) CompensateEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.CompensateEventSubscriptionEntity) EventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 30 with EventSubscriptionEntity

use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity in project Activiti by Activiti.

the class EventSubscriptionQueryTest method testQueryByEventType.

public void testQueryByEventType() {
    processEngineConfiguration.getCommandExecutor().execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            MessageEventSubscriptionEntity messageEventSubscriptionEntity1 = new MessageEventSubscriptionEntity();
            messageEventSubscriptionEntity1.setEventName("messageName");
            messageEventSubscriptionEntity1.insert();
            MessageEventSubscriptionEntity messageEventSubscriptionEntity2 = new MessageEventSubscriptionEntity();
            messageEventSubscriptionEntity2.setEventName("messageName");
            messageEventSubscriptionEntity2.insert();
            SignalEventSubscriptionEntity signalEventSubscriptionEntity3 = new SignalEventSubscriptionEntity();
            signalEventSubscriptionEntity3.setEventName("messageName2");
            signalEventSubscriptionEntity3.insert();
            return null;
        }
    });
    List<EventSubscriptionEntity> list = newEventSubscriptionQuery().eventType("signal").list();
    assertEquals(1, list.size());
    list = newEventSubscriptionQuery().eventType("message").list();
    assertEquals(2, list.size());
    cleanDb();
}
Also used : CommandContext(org.activiti.engine.impl.interceptor.CommandContext) MessageEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity) SignalEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity) MessageEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity) SignalEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity) EventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)

Aggregations

EventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)33 MessageEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity)15 SignalEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity)13 EventSubscriptionEntityManager (org.activiti.engine.impl.persistence.entity.EventSubscriptionEntityManager)11 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)9 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)9 Task (org.activiti.engine.task.Task)6 Deployment (org.activiti.engine.test.Deployment)6 EventSubscriptionQueryImpl (org.activiti.engine.impl.EventSubscriptionQueryImpl)5 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)5 CompensateEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.CompensateEventSubscriptionEntity)4 Execution (org.activiti.engine.runtime.Execution)4 ArrayList (java.util.ArrayList)3 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)3 ActivitiException (org.activiti.engine.ActivitiException)3 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)3 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)2 CommandExecutor (org.activiti.engine.impl.interceptor.CommandExecutor)2 ExecutionEntityManager (org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)2 Request (cern.modesti.request.Request)1