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();
}
}
}
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();
}
}
}
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;
}
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);
}
}
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();
}
Aggregations