All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nz.co.senanque.workflow.nmcrules.R6 Maven / Gradle / Ivy

The newest version!

package nz.co.senanque.workflow.nmcrules;

import java.io.Serializable;
import nz.co.senanque.rules.FieldReference;
import nz.co.senanque.rules.NotTrueException;
import nz.co.senanque.rules.Operations;
import nz.co.senanque.rules.Rule;
import nz.co.senanque.rules.RuleContext;
import nz.co.senanque.rules.RuleProxyField;
import nz.co.senanque.rules.RuleSession;
import nz.co.senanque.rules.UnKnownFieldValueException;
import nz.co.senanque.validationengine.ValidationObject;
import nz.co.senanque.workflow.nmcinstances.NMC;
import org.springframework.stereotype.Component;


/**
 * rule:NMC p5
 * {if
 * (sameClaim&&sameAmount&&hasFunds){
 * status=approved;}}
 * 
 */
@Component("nz.co.senanque.workflow.nmcrules.R6")
public class R6
    implements Serializable, Rule
{

    private final static long serialVersionUID = 1L;

    public void evaluate(final RuleSession session, final ValidationObject object, final RuleContext ruleContext) {
        final Operations operations = session.getOperations();
        final RuleProxyField proxyFieldsameClaim = session.getRuleProxyField(session.getMetadata(object).getProxyField("sameClaim"));
        final RuleProxyField proxyFieldhasFunds = session.getRuleProxyField(session.getMetadata(object).getProxyField("hasFunds"));
        final RuleProxyField proxyFieldsameAmount = session.getRuleProxyField(session.getMetadata(object).getProxyField("sameAmount"));
        final RuleProxyField proxyFieldstatus = session.getRuleProxyField(session.getMetadata(object).getProxyField("status"));
        try {
            try {
                operations.checkTrue(operations.logicalAnd(operations.logicalAnd(((Boolean) proxyFieldhasFunds.getValue()), ((Boolean) proxyFieldsameAmount.getValue())), ((Boolean) proxyFieldsameClaim.getValue())));
            } catch (NotTrueException _x) {
                return ;
            }
            session.assign(ruleContext, "approved", proxyFieldstatus);
        } catch (UnKnownFieldValueException _x) {
            return ;
        }
    }

    public String getRuleName() {
        return "nz.co.senanque.workflow.nmcrules.R6:p5";
    }

    public String getMessage(final RuleSession session, final ValidationObject object) {
        return session.getMessage("nz.co.senanque.workflow.nmcrules.R6", new Object[] { });
    }

    public String toString() {
        return "nz.co.senanque.workflow.nmcrules.R6:p5";
    }

    public String getClassName() {
        return "NMC";
    }

    public Class getScope() {
        return NMC.class;
    }

    public FieldReference[] listeners() {
        return new FieldReference[] {new FieldReference("NMC", "NMC", "hasFunds"), new FieldReference("NMC", "NMC", "sameAmount"), new FieldReference("NMC", "NMC", "sameClaim")};
    }

    public FieldReference[] outputs() {
        return new FieldReference[] {new FieldReference("NMC", "NMC", "status")};
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy