Search in sources :

Example 1 with ProgramRuleEnrollmentEvent

use of org.hisp.dhis.program.notification.event.ProgramRuleEnrollmentEvent in project dhis2-core by dhis2.

the class RuleActionSendMessageImplementer method implement.

@Override
public void implement(RuleEffect ruleEffect, ProgramInstance programInstance) {
    NotificationValidationResult result = validate(ruleEffect, programInstance);
    if (!result.isValid()) {
        return;
    }
    ProgramNotificationTemplate template = result.getTemplate();
    String key = generateKey(template, programInstance);
    publisher.publishEvent(new ProgramRuleEnrollmentEvent(this, template.getId(), programInstance));
    if (result.getLogEntry() != null) {
        return;
    }
    ExternalNotificationLogEntry entry = createLogEntry(key, template.getUid());
    entry.setNotificationTriggeredBy(NotificationTriggerEvent.PROGRAM);
    entry.setAllowMultiple(template.isSendRepeatable());
    notificationLoggingService.save(entry);
}
Also used : NotificationValidationResult(org.hisp.dhis.notification.logging.NotificationValidationResult) ProgramRuleEnrollmentEvent(org.hisp.dhis.program.notification.event.ProgramRuleEnrollmentEvent) ExternalNotificationLogEntry(org.hisp.dhis.notification.logging.ExternalNotificationLogEntry)

Aggregations

ExternalNotificationLogEntry (org.hisp.dhis.notification.logging.ExternalNotificationLogEntry)1 NotificationValidationResult (org.hisp.dhis.notification.logging.NotificationValidationResult)1 ProgramRuleEnrollmentEvent (org.hisp.dhis.program.notification.event.ProgramRuleEnrollmentEvent)1