use of org.motechproject.event.MotechEvent in project motech by motech.
the class ChannelServiceImpl method sendChannelUpdatedEvent.
private void sendChannelUpdatedEvent(Channel channel) {
Map<String, Object> parameters = new HashMap<>();
parameters.put(CHANNEL_MODULE_NAME, channel.getModuleName());
eventRelay.sendEventMessage(new MotechEvent(CHANNEL_UPDATE_SUBJECT, parameters));
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class TaskDataProviderServiceImpl method addProviderImpl.
private void addProviderImpl(final TaskDataProvider provider) {
// becomes available
if (dataProviderDataService != null) {
final TaskDataProvider existing = dataProviderDataService.findByName(provider.getName());
// Only update data provider when there's actual change
if (existing != null && !existing.equals(provider)) {
LOGGER.debug("Updating a task data provider with name: {}", provider.getName());
existing.setObjects(provider.getObjects());
dataProviderDataService.update(existing);
Map<String, Object> parameters = new HashMap<>();
parameters.put(DATA_PROVIDER_NAME, provider.getName());
eventRelay.sendEventMessage(new MotechEvent(DATA_PROVIDER_UPDATE_SUBJECT, parameters));
} else if (existing == null) {
LOGGER.debug("Creating a task data provider with name: {}", provider.getName());
dataProviderDataService.create(provider);
}
} else {
LOGGER.debug("DataProviderDataService is not available, storing a task data provider with name: {} for later addition", provider.getName());
// store for later addition
providersToAdd.add(provider);
}
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class TaskActionExecutorTest method shouldRaiseEventIfActionHasSubject.
@Test
public void shouldRaiseEventIfActionHasSubject() throws ActionNotFoundException, TaskHandlerException {
TaskActionInformation actionInformation = new TaskActionInformation("action", "channel", "module", "0.1", "actionSubject");
ActionEvent actionEvent = new ActionEventBuilder().setDisplayName("Action").setSubject("actionSubject").setDescription("").setActionParameters(new TreeSet<>()).build();
when(taskService.getActionEventFor(actionInformation)).thenReturn(actionEvent);
Task task = new TaskBuilder().addAction(new TaskActionInformation("Action", "channel", "module", "0.1", "actionSubject")).build();
task.setId(11L);
Map<String, Object> metadata = new HashMap<>();
metadata.put(EventDataKeys.TASK_ID, 11L);
metadata.put(EventDataKeys.TASK_RETRY, null);
metadata.put(EventDataKeys.TASK_ACTIVITY_ID, TASK_ACTIVITY_ID);
taskActionExecutor.setBundleContext(bundleContext);
taskActionExecutor.execute(task, actionInformation, 0, new TaskContext(task, new HashMap<>(), metadata, activityService), TASK_ACTIVITY_ID);
MotechEvent raisedEvent = new MotechEvent("actionSubject", new HashMap<>(), TasksEventCallbackService.TASKS_EVENT_CALLBACK_NAME, metadata);
verify(eventRelay).sendEventMessage(raisedEvent);
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class EmailPurgerInternal method schedulePurgingJob.
public void schedulePurgingJob(String time, String multiplier) {
Map<String, Object> params = new HashMap<>();
params.put("purgeTime", time);
params.put("purgeMultiplier", multiplier);
schedulerService.safeScheduleJob(new CronSchedulableJob(new MotechEvent(PurgeEmailEventHandlerImpl.PURGE_EMAIL_SUBJECT, params), "0 0 1 * * ?"));
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class TestMotechScheduledEvent method newTest.
@Test(expected = IllegalArgumentException.class)
public void newTest() throws Exception {
MotechEvent motechEvent;
Map<String, Object> params = new HashMap<String, Object>();
params.put("JobID", uuidStr);
motechEvent = new MotechEvent(null, params);
}
Aggregations