use of org.hisp.dhis.program.notification.event.ProgramRuleStageEvent in project dhis2-core by dhis2.
the class RuleActionSendMessageImplementer method handleSingleEvent.
private void handleSingleEvent(RuleEffect ruleEffect, ProgramStageInstance programStageInstance) {
ProgramNotificationTemplate template = getNotificationTemplate(ruleEffect.ruleAction());
if (template == null) {
return;
}
publisher.publishEvent(new ProgramRuleStageEvent(this, template.getId(), programStageInstance));
}
use of org.hisp.dhis.program.notification.event.ProgramRuleStageEvent in project dhis2-core by dhis2.
the class RuleActionSendMessageImplementer method implement.
@Override
public void implement(RuleEffect ruleEffect, ProgramStageInstance programStageInstance) {
checkNotNull(programStageInstance, "ProgramStageInstance cannot be null");
NotificationValidationResult result = validate(ruleEffect, programStageInstance.getProgramInstance());
// For program without registration
if (programStageInstance.getProgramStage().getProgram().isWithoutRegistration()) {
handleSingleEvent(ruleEffect, programStageInstance);
return;
}
if (!result.isValid()) {
return;
}
ProgramInstance pi = programStageInstance.getProgramInstance();
ProgramNotificationTemplate template = result.getTemplate();
String key = generateKey(template, pi);
publisher.publishEvent(new ProgramRuleStageEvent(this, template.getId(), programStageInstance));
if (result.getLogEntry() != null) {
return;
}
ExternalNotificationLogEntry entry = createLogEntry(key, template.getUid());
entry.setNotificationTriggeredBy(NotificationTriggerEvent.PROGRAM_STAGE);
entry.setAllowMultiple(template.isSendRepeatable());
notificationLoggingService.save(entry);
}
Aggregations