use of org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity in project Activiti by Activiti.
the class BpmnDeployer method addSignalEventSubscriptions.
@SuppressWarnings("unchecked")
protected void addSignalEventSubscriptions(ProcessDefinitionEntity processDefinition) {
List<EventSubscriptionDeclaration> eventDefinitions = (List<EventSubscriptionDeclaration>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION);
if (eventDefinitions != null) {
for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) {
if (eventDefinition.getEventType().equals("signal") && eventDefinition.isStartEvent()) {
SignalEventSubscriptionEntity subscriptionEntity = new SignalEventSubscriptionEntity();
subscriptionEntity.setEventName(eventDefinition.getEventName());
subscriptionEntity.setActivityId(eventDefinition.getActivityId());
subscriptionEntity.setProcessDefinitionId(processDefinition.getId());
if (processDefinition.getTenantId() != null) {
subscriptionEntity.setTenantId(processDefinition.getTenantId());
}
subscriptionEntity.insert();
}
}
}
}
use of org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity 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.SignalEventSubscriptionEntity in project Activiti by Activiti.
the class ActivityEventsTest method testActivitySignalBoundaryEventsOnUserTask.
@Deployment
public void testActivitySignalBoundaryEventsOnUserTask() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalOnUserTask");
assertNotNull(processInstance);
Execution executionWithSignal = runtimeService.createExecutionQuery().activityId("userTask").singleResult();
assertNotNull(executionWithSignal);
runtimeService.signalEventReceived("signalName");
assertEquals(1, listener.getEventsReceived().size());
// Next, an signal-event is expected, as a result of the message
assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiActivityCancelledEvent);
ActivitiActivityCancelledEvent signalEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ACTIVITY_CANCELLED, signalEvent.getType());
assertEquals("userTask", signalEvent.getActivityId());
assertEquals(executionWithSignal.getId(), signalEvent.getExecutionId());
assertEquals(executionWithSignal.getProcessInstanceId(), signalEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
assertNotNull(signalEvent.getCause());
assertTrue(signalEvent.getCause() instanceof SignalEventSubscriptionEntity);
SignalEventSubscriptionEntity cause = (SignalEventSubscriptionEntity) signalEvent.getCause();
assertEquals("signalName", cause.getEventName());
}
use of org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity 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