use of org.drools.workbench.models.datamodel.rule.ActionFieldFunction in project drools by kiegroup.
the class RuleModelDRLPersistenceTest method testRHSSetMethodCallsMethodJava.
@Test
public void testRHSSetMethodCallsMethodJava() {
String oldValue = System.getProperty("drools.dateformat");
try {
System.setProperty("drools.dateformat", "dd-MMM-yyyy");
RuleModel m = new RuleModel();
m.name = "RHS SetMethodCallsMethod";
m.addAttribute(new RuleAttribute("dialect", "java"));
FactPattern p = new FactPattern("Person");
p.setBoundName("$p");
m.addLhsItem(p);
ActionCallMethod acm = new ActionCallMethod();
acm.setMethodName("method");
acm.setVariable("$p");
acm.addFieldValue(new ActionFieldFunction("f1", "String", DataType.TYPE_STRING));
acm.addFieldValue(new ActionFieldFunction("f2", "true", DataType.TYPE_BOOLEAN));
acm.addFieldValue(new ActionFieldFunction("f3", "31-Jan-2012", DataType.TYPE_DATE));
acm.addFieldValue(new ActionFieldFunction("f4", "100", DataType.TYPE_NUMERIC_INTEGER));
acm.addFieldValue(new ActionFieldFunction("f5", "100", DataType.TYPE_NUMERIC_BIGDECIMAL));
m.addRhsItem(acm);
String result = RuleModelDRLPersistenceImpl.getInstance().marshal(m);
assertTrue(result.indexOf("java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(\"dd-MMM-yyyy\");") != -1);
assertTrue(result.indexOf("$p.method( \"String\", true, sdf.parse(\"31-Jan-2012\"), 100, new java.math.BigDecimal(\"100\") );") != -1);
checkMarshalling(null, m);
} finally {
if (oldValue == null) {
System.clearProperty("drools.dateformat");
} else {
System.setProperty("drools.dateformat", oldValue);
}
}
}
use of org.drools.workbench.models.datamodel.rule.ActionFieldFunction in project drools-wb by kiegroup.
the class RuleModelCloneVisitor method visitActionCallMethod.
private ActionCallMethod visitActionCallMethod(ActionCallMethod acm) {
ActionCallMethod clone = new ActionCallMethod();
clone.setVariable(acm.getVariable());
clone.setState(acm.getState());
clone.setMethodName(acm.getMethodName());
for (ActionFieldValue aff : acm.getFieldValues()) {
clone.addFieldValue(cloneActionFieldFunction((ActionFieldFunction) aff));
}
return clone;
}
use of org.drools.workbench.models.datamodel.rule.ActionFieldFunction in project drools-wb by kiegroup.
the class RuleModelCloneVisitor method cloneActionFieldFunction.
private ActionFieldFunction cloneActionFieldFunction(ActionFieldFunction aff) {
ActionFieldFunction clone = new ActionFieldFunction();
clone.setField(aff.getField());
clone.setNature(aff.getNature());
clone.setType(aff.getType());
clone.setValue(aff.getValue());
clone.setMethod(aff.getMethod());
return clone;
}
use of org.drools.workbench.models.datamodel.rule.ActionFieldFunction in project drools-wb by kiegroup.
the class ActionCallMethodWidget method doLayout.
private void doLayout() {
layout.clear();
layout.setWidget(0, 0, getSetterLabel());
FlexTable inner = new FlexTable();
for (int i = 0; i < model.getFieldValues().length; i++) {
ActionFieldFunction val = model.getFieldValue(i);
inner.setWidget(i, 0, typeLabel(val.getType()));
inner.setWidget(i, 1, valueEditor(val));
}
layout.setWidget(0, 1, inner);
}
Aggregations