Search in sources :

Example 1 with SYSTEM_PROGRAM_RULE_SERVER_EXECUTION

use of org.hisp.dhis.external.conf.ConfigurationKey.SYSTEM_PROGRAM_RULE_SERVER_EXECUTION in project dhis2-core by dhis2.

the class DefaultProgramRuleEngineService method evaluateEnrollmentAndRunEffects.

@Override
@Transactional
public List<RuleEffect> evaluateEnrollmentAndRunEffects(long enrollment) {
    if (config.isDisabled(SYSTEM_PROGRAM_RULE_SERVER_EXECUTION)) {
        return Lists.newArrayList();
    }
    ProgramInstance programInstance = programInstanceService.getProgramInstance(enrollment);
    if (programInstance == null) {
        return Lists.newArrayList();
    }
    List<RuleEffect> ruleEffects = programRuleEngine.evaluate(programInstance, programInstance.getProgramStageInstances());
    for (RuleEffect effect : ruleEffects) {
        ruleActionImplementers.stream().filter(i -> i.accept(effect.ruleAction())).forEach(i -> {
            log.debug(String.format("Invoking action implementer: %s", i.getClass().getSimpleName()));
            i.implement(effect, programInstance);
        });
    }
    return ruleEffects;
}
Also used : DhisConfigurationProvider(org.hisp.dhis.external.conf.DhisConfigurationProvider) SYSTEM_PROGRAM_RULE_SERVER_EXECUTION(org.hisp.dhis.external.conf.ConfigurationKey.SYSTEM_PROGRAM_RULE_SERVER_EXECUTION) RuleEffect(org.hisp.dhis.rules.models.RuleEffect) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance) Program(org.hisp.dhis.program.Program) ProgramStageInstanceService(org.hisp.dhis.program.ProgramStageInstanceService) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Lists(com.google.common.collect.Lists) Service(org.springframework.stereotype.Service) ProgramInstance(org.hisp.dhis.program.ProgramInstance) ProgramInstanceService(org.hisp.dhis.program.ProgramInstanceService) Qualifier(org.springframework.beans.factory.annotation.Qualifier) RuleValidationResult(org.hisp.dhis.rules.models.RuleValidationResult) ProgramService(org.hisp.dhis.program.ProgramService) Transactional(org.springframework.transaction.annotation.Transactional) RuleEffect(org.hisp.dhis.rules.models.RuleEffect) ProgramInstance(org.hisp.dhis.program.ProgramInstance) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Lists (com.google.common.collect.Lists)1 List (java.util.List)1 Slf4j (lombok.extern.slf4j.Slf4j)1 SYSTEM_PROGRAM_RULE_SERVER_EXECUTION (org.hisp.dhis.external.conf.ConfigurationKey.SYSTEM_PROGRAM_RULE_SERVER_EXECUTION)1 DhisConfigurationProvider (org.hisp.dhis.external.conf.DhisConfigurationProvider)1 Program (org.hisp.dhis.program.Program)1 ProgramInstance (org.hisp.dhis.program.ProgramInstance)1 ProgramInstanceService (org.hisp.dhis.program.ProgramInstanceService)1 ProgramService (org.hisp.dhis.program.ProgramService)1 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)1 ProgramStageInstanceService (org.hisp.dhis.program.ProgramStageInstanceService)1 RuleEffect (org.hisp.dhis.rules.models.RuleEffect)1 RuleValidationResult (org.hisp.dhis.rules.models.RuleValidationResult)1 Qualifier (org.springframework.beans.factory.annotation.Qualifier)1 Service (org.springframework.stereotype.Service)1 Transactional (org.springframework.transaction.annotation.Transactional)1