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