
nz.co.senanque.pizzaorder.rules.R12 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of madura-perspectives-pizzaorder Show documentation
Show all versions of madura-perspectives-pizzaorder Show documentation
This is a rules-driven pizza configuration which lets you pick different pizza bases, toppings and sizes, except that only some combinations are allowed and the rules enforce this. The rules, UI and underlying domain objects are all delivered by this sub-application.
package nz.co.senanque.pizzaorder.rules;
import java.io.Serializable;
import nz.co.senanque.pizzaorder.instances.Customer;
import nz.co.senanque.rules.FieldReference;
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;
/**
* formula:Customer Weight metric
* {
* weight=weightKilos;}
*
*/
@Component
public class R12
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 proxyFieldweightKilos = session.getRuleProxyField(session.getMetadata(object).getProxyField("weightKilos"));
final RuleProxyField proxyFieldweight = session.getRuleProxyField(session.getMetadata(object).getProxyField("weight"));
try {
session.assign(ruleContext, ((Double) proxyFieldweightKilos.getValue()), proxyFieldweight);
} catch (UnKnownFieldValueException _x) {
return ;
}
}
public String getRuleName() {
return "R12:Weight metric";
}
public String getMessage(final RuleSession session, final ValidationObject object) {
return session.getMessage("nz.co.senanque.pizzaorder.rules.R12", new Object[] { });
}
public String toString() {
return "R12:Weight metric";
}
public String getClassName() {
return "Customer";
}
public Class getScope() {
return Customer.class;
}
public FieldReference[] listeners() {
return new FieldReference[] {new FieldReference("Customer", "Customer", "weightKilos")};
}
public FieldReference[] outputs() {
return new FieldReference[] {new FieldReference("Customer", "Customer", "weight")};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy