Search in sources :

Example 31 with EventSubscriptionEntity

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

the class EventSubscriptionQueryTest method testQueryByEventName.

public void testQueryByEventName() {
    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();
            MessageEventSubscriptionEntity messageEventSubscriptionEntity3 = new MessageEventSubscriptionEntity();
            messageEventSubscriptionEntity3.setEventName("messageName2");
            messageEventSubscriptionEntity3.insert();
            return null;
        }
    });
    List<EventSubscriptionEntity> list = newEventSubscriptionQuery().eventName("messageName").list();
    assertEquals(2, list.size());
    list = newEventSubscriptionQuery().eventName("messageName2").list();
    assertEquals(1, list.size());
    cleanDb();
}
Also used : CommandContext(org.activiti.engine.impl.interceptor.CommandContext) 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)

Example 32 with EventSubscriptionEntity

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

the class SignalController method getSignals.

@RequestMapping(method = GET)
public ResponseEntity<Resources<Resource<SignalInfo>>> getSignals(@PathVariable("id") String id) {
    Request request = getRequest(id);
    if (request == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
    List<SignalInfo> signals = new ArrayList<>();
    Task task = taskService.createTaskQuery().processInstanceBusinessKey(request.getRequestId()).active().singleResult();
    if (task == null) {
        return new ResponseEntity<>(new Resources<>(Collections.emptyList()), HttpStatus.OK);
    }
    // Query the signals that are subscribed to by the current process instance.
    // TODO this is a non-public API, is there a supported way of doing this?
    CommandExecutor executor = ((ProcessEngineConfigurationImpl) ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration()).getCommandExecutor();
    EventSubscriptionQueryImpl query = new EventSubscriptionQueryImpl(executor);
    for (EventSubscriptionEntity signal : query.processInstanceId(task.getProcessInstanceId()).list()) {
        signals.add(new SignalInfo(signal.getEventName()));
    }
    Resources<Resource<SignalInfo>> resources = Resources.wrap(signals);
    for (Resource<SignalInfo> resource : resources) {
        resource.add(linkTo(methodOn(SignalController.class).getSignal(id, resource.getContent().getName())).withSelfRel());
    }
    return new ResponseEntity<>(resources, HttpStatus.OK);
}
Also used : Task(org.activiti.engine.task.Task) Request(cern.modesti.request.Request) CommandExecutor(org.activiti.engine.impl.interceptor.CommandExecutor) Resource(org.springframework.hateoas.Resource) ResponseEntity(org.springframework.http.ResponseEntity) EventSubscriptionQueryImpl(org.activiti.engine.impl.EventSubscriptionQueryImpl) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) EventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 33 with EventSubscriptionEntity

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

the class RequestLinks method getSignalLinks.

public List<Link> getSignalLinks(Request request) {
    List<Link> links = new ArrayList<>();
    Task task = taskService.createTaskQuery().processInstanceBusinessKey(request.getRequestId()).active().singleResult();
    if (task != null) {
        // Query the signals that are subscribed to by the current process instance.
        // TODO this is a non-public API, is there a supported way of doing this?
        CommandExecutor executor = ((ProcessEngineConfigurationImpl) ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration()).getCommandExecutor();
        EventSubscriptionQueryImpl query = new EventSubscriptionQueryImpl(executor);
        List<EventSubscriptionEntity> signals = query.processInstanceId(task.getProcessInstanceId()).list();
        for (EventSubscriptionEntity signal : signals) {
            links.add(linkTo(SignalController.class, request.getRequestId()).slash(signal.getEventName()).withRel("signals"));
        }
    }
    return links;
}
Also used : Task(org.activiti.engine.task.Task) ArrayList(java.util.ArrayList) CommandExecutor(org.activiti.engine.impl.interceptor.CommandExecutor) EventSubscriptionQueryImpl(org.activiti.engine.impl.EventSubscriptionQueryImpl) SignalController(cern.modesti.workflow.signal.SignalController) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) Link(org.springframework.hateoas.Link) 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