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

nz.co.senanque.customer.R2 Maven / Gradle / Ivy


package nz.co.senanque.customer;

import java.io.Serializable;
import java.util.List;
import nz.co.senanque.base.Customer;
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.ProxyField;
import nz.co.senanque.validationengine.ValidationObject;
import org.springframework.stereotype.Component;


/**
 * rule:Customer isnotknown
 * {if
 * (isNotKnown((amount)){
 * oneInvoice.amount=amount;}}
 * 
 */
@Component("nz.co.senanque.customer.R2")
public class R2
    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 proxyFieldamount = session.getRuleProxyField(session.getMetadata(object).getProxyField("amount"));
        final List proxyFieldoneInvoice_amount = session.getMetadata(object).getProxyFields("oneInvoice", "amount");
        try {
            try {
                operations.checkTrue(session.isNotKnown(proxyFieldamount));
            } catch (NotTrueException _x) {
                return ;
            }
            session.assign(ruleContext, ((Double) proxyFieldamount.getValue()), proxyFieldoneInvoice_amount);
        } catch (UnKnownFieldValueException _x) {
            return ;
        }
    }

    public String getRuleName() {
        return "nz.co.senanque.customer.R2:isnotknown";
    }

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

    public String toString() {
        return "nz.co.senanque.customer.R2:isnotknown";
    }

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

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

    public FieldReference[] listeners() {
        return new FieldReference[] {new FieldReference("Customer", "Customer", "amount")};
    }

    public FieldReference[] outputs() {
        return new FieldReference[] {new FieldReference("Invoice", "Customer", "amount")};
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy