use of org.hisp.dhis.programrule.engine.RuleActionImplementer in project dhis2-core by dhis2.
the class TrackerRuleEngineThread method call.
@Override
public void call() {
if (sideEffectDataBundle == null) {
return;
}
Map<String, List<RuleEffect>> enrollmentRuleEffects = trackerSideEffectConverterService.toRuleEffects(sideEffectDataBundle.getEnrollmentRuleEffects());
Map<String, List<RuleEffect>> eventRuleEffects = trackerSideEffectConverterService.toRuleEffects(sideEffectDataBundle.getEventRuleEffects());
for (RuleActionImplementer ruleActionImplementer : ruleActionImplementers) {
for (Map.Entry<String, List<RuleEffect>> entry : enrollmentRuleEffects.entrySet()) {
ProgramInstance pi = sideEffectDataBundle.getProgramInstance();
pi.setProgram(sideEffectDataBundle.getProgram());
entry.getValue().stream().filter(effect -> ruleActionImplementer.accept(effect.ruleAction())).forEach(effect -> ruleActionImplementer.implement(effect, pi));
}
for (Map.Entry<String, List<RuleEffect>> entry : eventRuleEffects.entrySet()) {
ProgramStageInstance psi = sideEffectDataBundle.getProgramStageInstance();
psi.getProgramStage().setProgram(sideEffectDataBundle.getProgram());
entry.getValue().stream().filter(effect -> ruleActionImplementer.accept(effect.ruleAction())).forEach(effect -> ruleActionImplementer.implement(effect, psi));
}
}
notifier.notify(sideEffectDataBundle.getJobConfiguration(), "Tracker Rule-engine side effects completed");
}
Aggregations