use of org.hisp.dhis.program.notification.ProgramNotificationTemplate in project dhis2-core by dhis2.
the class ProgramNotificationTemplateObjectBundleHook method preCreate.
@Override
public <T extends IdentifiableObject> void preCreate(T object, ObjectBundle bundle) {
if (!ProgramNotificationTemplate.class.isInstance(object))
return;
ProgramNotificationTemplate template = (ProgramNotificationTemplate) object;
preProcess(template);
}
use of org.hisp.dhis.program.notification.ProgramNotificationTemplate in project dhis2-core by dhis2.
the class ProgramNotificationTemplateObjectBundleHook method postUpdate.
@Override
public <T extends IdentifiableObject> void postUpdate(T persistedObject, ObjectBundle bundle) {
if (!ProgramNotificationTemplate.class.isInstance(persistedObject))
return;
ProgramNotificationTemplate template = (ProgramNotificationTemplate) persistedObject;
postProcess(template);
}
use of org.hisp.dhis.program.notification.ProgramNotificationTemplate in project dhis2-core by dhis2.
the class ProgramNotificationTemplateObjectBundleHook method postCreate.
@Override
public <T extends IdentifiableObject> void postCreate(T persistedObject, ObjectBundle bundle) {
if (!ProgramNotificationTemplate.class.isInstance(persistedObject))
return;
ProgramNotificationTemplate template = (ProgramNotificationTemplate) persistedObject;
postProcess(template);
}
use of org.hisp.dhis.program.notification.ProgramNotificationTemplate in project dhis2-core by dhis2.
the class ProgramStageInstanceStoreTest method testGetWithScheduledNotifications.
@Test
void testGetWithScheduledNotifications() {
ProgramNotificationTemplate a1 = createProgramNotificationTemplate("a1", -1, SCHEDULED_DAYS_DUE_DATE, ProgramNotificationRecipient.TRACKED_ENTITY_INSTANCE), a2 = createProgramNotificationTemplate("a2", -2, SCHEDULED_DAYS_DUE_DATE, ProgramNotificationRecipient.TRACKED_ENTITY_INSTANCE), a3 = createProgramNotificationTemplate("a3", 1, SCHEDULED_DAYS_DUE_DATE, ProgramNotificationRecipient.TRACKED_ENTITY_INSTANCE), b1 = createProgramNotificationTemplate("b1", -1, SCHEDULED_DAYS_DUE_DATE, ProgramNotificationRecipient.TRACKED_ENTITY_INSTANCE), b2 = createProgramNotificationTemplate("b2", -2, SCHEDULED_DAYS_DUE_DATE, ProgramNotificationRecipient.TRACKED_ENTITY_INSTANCE), b3 = createProgramNotificationTemplate("b3", 1, SCHEDULED_DAYS_DUE_DATE, ProgramNotificationRecipient.TRACKED_ENTITY_INSTANCE), c1 = createProgramNotificationTemplate("c1", -1, SCHEDULED_DAYS_DUE_DATE, ProgramNotificationRecipient.TRACKED_ENTITY_INSTANCE), c2 = createProgramNotificationTemplate("c2", -2, SCHEDULED_DAYS_DUE_DATE, ProgramNotificationRecipient.TRACKED_ENTITY_INSTANCE), c3 = createProgramNotificationTemplate("c3", 1, SCHEDULED_DAYS_DUE_DATE, ProgramNotificationRecipient.TRACKED_ENTITY_INSTANCE);
programNotificationStore.save(a1);
programNotificationStore.save(a2);
programNotificationStore.save(a3);
programNotificationStore.save(b1);
programNotificationStore.save(b2);
programNotificationStore.save(b3);
programNotificationStore.save(c1);
programNotificationStore.save(c2);
programNotificationStore.save(c3);
// Stage
stageA.setNotificationTemplates(Sets.newHashSet(a1, a2, a3));
programStageService.updateProgramStage(stageA);
stageB.setNotificationTemplates(Sets.newHashSet(b1, b2, b3));
programStageService.updateProgramStage(stageB);
stageC.setNotificationTemplates(Sets.newHashSet(c1, c2, c3));
programStageService.updateProgramStage(stageC);
// Dates
Calendar cal = Calendar.getInstance();
PeriodType.clearTimeOfDay(cal);
// 2016-01-10 -> "today"
Date today = cal.getTime();
// 2016-01-11
cal.add(Calendar.DATE, 1);
Date tomorrow = cal.getTime();
// 2016-01-09
cal.add(Calendar.DATE, -2);
Date yesterday = cal.getTime();
// Events
ProgramStageInstance eventA = new ProgramStageInstance(programInstanceA, stageA);
eventA.setDueDate(tomorrow);
programStageInstanceStore.save(eventA);
ProgramStageInstance eventB = new ProgramStageInstance(programInstanceB, stageB);
eventB.setDueDate(today);
programStageInstanceStore.save(eventB);
ProgramStageInstance eventC = new ProgramStageInstance(programInstanceB, stageC);
eventC.setDueDate(yesterday);
programStageInstanceStore.save(eventC);
// Queries
List<ProgramStageInstance> results;
// A
results = programStageInstanceStore.getWithScheduledNotifications(a1, today);
assertEquals(1, results.size());
assertEquals(eventA, results.get(0));
results = programStageInstanceStore.getWithScheduledNotifications(a2, today);
assertEquals(0, results.size());
results = programStageInstanceStore.getWithScheduledNotifications(a3, today);
assertEquals(0, results.size());
// B
results = programStageInstanceStore.getWithScheduledNotifications(b1, today);
assertEquals(0, results.size());
results = programStageInstanceStore.getWithScheduledNotifications(b2, today);
assertEquals(0, results.size());
results = programStageInstanceStore.getWithScheduledNotifications(b3, today);
assertEquals(0, results.size());
// C
results = programStageInstanceStore.getWithScheduledNotifications(c1, today);
assertEquals(0, results.size());
results = programStageInstanceStore.getWithScheduledNotifications(c2, today);
assertEquals(0, results.size());
results = programStageInstanceStore.getWithScheduledNotifications(c3, today);
assertEquals(1, results.size());
assertEquals(eventC, results.get(0));
}
use of org.hisp.dhis.program.notification.ProgramNotificationTemplate in project dhis2-core by dhis2.
the class ProgramRuleEntityMapperServiceTest method setProgramRuleAction.
private ProgramRuleAction setProgramRuleAction(ProgramRuleAction programRuleActionA, ProgramRuleActionType type, String content, String data) {
programRuleActionA.setProgramRuleActionType(type);
if (type == ProgramRuleActionType.ASSIGN) {
programRuleActionA.setContent(content);
programRuleActionA.setData(data);
}
if (type == ProgramRuleActionType.DISPLAYTEXT) {
programRuleActionA.setLocation("feedback");
programRuleActionA.setContent("content");
programRuleActionA.setData("true");
}
if (type == ProgramRuleActionType.SENDMESSAGE) {
ProgramNotificationTemplate notificationTemplate = new ProgramNotificationTemplate();
notificationTemplate.setUid("uid0");
programRuleActionA.setTemplateUid(notificationTemplate.getUid());
}
return programRuleActionA;
}
Aggregations