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