Search in sources :

Example 6 with SignalEventSubscriptionEntity

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();
            }
        }
    }
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) EventSubscriptionDeclaration(org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration) SignalEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity)

Example 7 with SignalEventSubscriptionEntity

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;
}
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 8 with SignalEventSubscriptionEntity

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());
}
Also used : Execution(org.activiti.engine.runtime.Execution) ActivitiActivityCancelledEvent(org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) SignalEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity) Deployment(org.activiti.engine.test.Deployment)

Example 9 with SignalEventSubscriptionEntity

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

SignalEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity)9 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)4 EventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)3 MessageEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity)3 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)2 ActivitiActivityCancelledEvent (org.activiti.engine.delegate.event.ActivitiActivityCancelledEvent)2 Execution (org.activiti.engine.runtime.Execution)2 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)2 Deployment (org.activiti.engine.test.Deployment)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ActivitiException (org.activiti.engine.ActivitiException)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 EventSubscriptionDeclaration (org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration)1 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)1 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1