Search in sources :

Example 1 with RuleActionAssign

use of org.hisp.dhis.rules.models.RuleActionAssign in project dhis2-core by dhis2.

the class RuleActionAssignValueImplementer method assignValue.

private void assignValue(RuleEffect ruleEffect, ProgramInstance programInstance) {
    if (programInstance == null) {
        log.info("No value assigned by AssignValue action");
        return;
    }
    String value = ruleEffect.data();
    RuleActionAssign assign = (RuleActionAssign) ruleEffect.ruleAction();
    String variable = assign.field();
    Matcher matcher = PATTERN.matcher(variable);
    while (matcher.find()) {
        variable = matcher.group(0).trim();
    }
    log.info("Assigning: " + variable + " with value: " + value);
    if (!variableMap.containsKey(programInstance.getUid())) {
        variableMap.put(programInstance.getUid(), new HashMap<>());
    }
    variableMap.get(programInstance.getUid()).put(variable, value);
}
Also used : Matcher(java.util.regex.Matcher) RuleActionAssign(org.hisp.dhis.rules.models.RuleActionAssign)

Aggregations

Matcher (java.util.regex.Matcher)1 RuleActionAssign (org.hisp.dhis.rules.models.RuleActionAssign)1