nz.co.senanque.workflow.nmcrules.R2 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 p0_1
* {if
* (!(reservationId==none)){
* hasFunds=true;}}
*
*/
@Component("nz.co.senanque.workflow.nmcrules.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 proxyFieldhasFunds = session.getRuleProxyField(session.getMetadata(object).getProxyField("hasFunds"));
final RuleProxyField proxyFieldreservationId = session.getRuleProxyField(session.getMetadata(object).getProxyField("reservationId"));
try {
try {
operations.checkTrue(operations.logicalNot(operations.eq("none", ((String) proxyFieldreservationId.getValue()))));
} catch (NotTrueException _x) {
return ;
}
session.assign(ruleContext, true, proxyFieldhasFunds);
} catch (UnKnownFieldValueException _x) {
return ;
}
}
public String getRuleName() {
return "nz.co.senanque.workflow.nmcrules.R2:p0_1";
}
public String getMessage(final RuleSession session, final ValidationObject object) {
return session.getMessage("nz.co.senanque.workflow.nmcrules.R2", new Object[] { });
}
public String toString() {
return "nz.co.senanque.workflow.nmcrules.R2:p0_1";
}
public String getClassName() {
return "NMC";
}
public Class getScope() {
return NMC.class;
}
public FieldReference[] listeners() {
return new FieldReference[] {new FieldReference("NMC", "NMC", "reservationId")};
}
public FieldReference[] outputs() {
return new FieldReference[] {new FieldReference("NMC", "NMC", "hasFunds")};
}
}