nz.co.senanque.functions.R2 Maven / Gradle / Ivy
package nz.co.senanque.functions;
import java.io.Serializable;
import java.util.Date;
import nz.co.senanque.base.Invoice;
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:Invoice invoice days
* {
* days=daysSince((date);}
*
*/
@Component("nz.co.senanque.functions.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 proxyFielddays = session.getRuleProxyField(session.getMetadata(object).getProxyField("days"));
final RuleProxyField proxyFielddate = session.getRuleProxyField(session.getMetadata(object).getProxyField("date"));
try {
session.assign(ruleContext, operations.daysSince(((Date) proxyFielddate.getValue())), proxyFielddays);
} catch (UnKnownFieldValueException _x) {
return ;
}
}
public String getRuleName() {
return "nz.co.senanque.functions.R2:invoice days";
}
public String getMessage(final RuleSession session, final ValidationObject object) {
return session.getMessage("nz.co.senanque.functions.R2", new Object[] { });
}
public String toString() {
return "nz.co.senanque.functions.R2:invoice days";
}
public String getClassName() {
return "Invoice";
}
public Class getScope() {
return Invoice.class;
}
public FieldReference[] listeners() {
return new FieldReference[] {new FieldReference("Invoice", "Invoice", "date")};
}
public FieldReference[] outputs() {
return new FieldReference[] {new FieldReference("Invoice", "Invoice", "days")};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy