nz.co.senanque.performance.R6 Maven / Gradle / Ivy
package nz.co.senanque.performance;
import java.io.Serializable;
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.ValidationObject;
import org.springframework.stereotype.Component;
/**
* rule:Customer set customerType to read-only, activate and required
* {if
* (name==aaaab){
* readonly((customerType);
* activate((customerType);
* require((customerType);
* exclude((customerType,C);}}
*
*/
@Component("nz.co.senanque.performance.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 proxyFieldcustomerType = session.getRuleProxyField(session.getMetadata(object).getProxyField("customerType"));
final RuleProxyField proxyFieldname = session.getRuleProxyField(session.getMetadata(object).getProxyField("name"));
try {
try {
operations.checkTrue(operations.eq("aaaab", ((String) proxyFieldname.getValue())));
} catch (NotTrueException _x) {
return ;
}
session.readonly(ruleContext, proxyFieldcustomerType);
session.activate(ruleContext, proxyFieldcustomerType);
session.require(ruleContext, proxyFieldcustomerType);
session.exclude(ruleContext, "C", proxyFieldcustomerType);
} catch (UnKnownFieldValueException _x) {
return ;
}
}
public String getRuleName() {
return "nz.co.senanque.performance.R6:set customerType to read-only, activate and required";
}
public String getMessage(final RuleSession session, final ValidationObject object) {
return session.getMessage("nz.co.senanque.performance.R6", new Object[] { });
}
public String toString() {
return "nz.co.senanque.performance.R6:set customerType to read-only, activate and required";
}
public String getClassName() {
return "Customer";
}
public Class getScope() {
return Customer.class;
}
public FieldReference[] listeners() {
return new FieldReference[] {new FieldReference("Customer", "Customer", "name")};
}
public FieldReference[] outputs() {
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy