nz.co.senanque.workflow.nmcrules.R5 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 p4
* {if
* (hasFunds==true){
* readonly((claimId);
* readonly((memberId);
* readonly((memberType);
* readonly((requestedAmount);}}
*
*/
@Component("nz.co.senanque.workflow.nmcrules.R5")
public class R5
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 proxyFieldclaimId = session.getRuleProxyField(session.getMetadata(object).getProxyField("claimId"));
final RuleProxyField proxyFieldmemberId = session.getRuleProxyField(session.getMetadata(object).getProxyField("memberId"));
final RuleProxyField proxyFieldrequestedAmount = session.getRuleProxyField(session.getMetadata(object).getProxyField("requestedAmount"));
final RuleProxyField proxyFieldmemberType = session.getRuleProxyField(session.getMetadata(object).getProxyField("memberType"));
try {
try {
operations.checkTrue(operations.eq(true, ((Boolean) proxyFieldhasFunds.getValue())));
} catch (NotTrueException _x) {
return ;
}
session.readonly(ruleContext, proxyFieldclaimId);
session.readonly(ruleContext, proxyFieldmemberId);
session.readonly(ruleContext, proxyFieldmemberType);
session.readonly(ruleContext, proxyFieldrequestedAmount);
} catch (UnKnownFieldValueException _x) {
return ;
}
}
public String getRuleName() {
return "nz.co.senanque.workflow.nmcrules.R5:p4";
}
public String getMessage(final RuleSession session, final ValidationObject object) {
return session.getMessage("nz.co.senanque.workflow.nmcrules.R5", new Object[] { });
}
public String toString() {
return "nz.co.senanque.workflow.nmcrules.R5:p4";
}
public String getClassName() {
return "NMC";
}
public Class getScope() {
return NMC.class;
}
public FieldReference[] listeners() {
return new FieldReference[] {new FieldReference("NMC", "NMC", "hasFunds")};
}
public FieldReference[] outputs() {
return null;
}
}