private void addActionSetField(String itemText, int position) { this.model.addRhsItem(new ActionSetField(itemText), position); }
private void addActionSetField(String itemText, int position) { this.model.addRhsItem(new ActionSetField(itemText), position); }
private ActionSetField visitActionFieldList(ActionSetField afl) { ActionSetField clone = new ActionSetField(); clone.setVariable(afl.getVariable()); for (ActionFieldValue afv : afl.getFieldValues()) { clone.addFieldValue(cloneActionFieldValue(afv)); } return clone; }
private ActionSetField visitActionFieldList(ActionSetField afl) { ActionSetField clone = new ActionSetField(); clone.setVariable(afl.getVariable()); for (ActionFieldValue afv : afl.getFieldValues()) { clone.addFieldValue(cloneActionFieldValue(afv)); } return clone; }
ActionSetField action = new ActionSetField(entry.getKey()); addSettersToAction(entry.getValue(), action,
a.boundName = sf.getBoundName(); if (!sf.isUpdate()) { a.action = new ActionSetField(sf.getBoundName()); } else { a.action = new ActionUpdateField(sf.getBoundName());
private void doAction(List<LabelledAction> actions, ActionSetFieldCol52 sf, String cell) { LabelledAction a = findByLabelledAction(actions, sf.getBoundName(), sf.isUpdate()); if (a == null) { a = new LabelledAction(); a.boundName = sf.getBoundName(); a.isUpdate = sf.isUpdate(); if (!sf.isUpdate()) { a.action = new ActionSetField(sf.getBoundName()); } else { a.action = new ActionUpdateField(sf.getBoundName()); } actions.add(a); } else if (sf.isUpdate() && !(a.action instanceof ActionUpdateField)) { // lets swap it out for an update as the user has asked for it. ActionSetField old = (ActionSetField) a.action; ActionUpdateField update = new ActionUpdateField(sf.getBoundName()); update.setFieldValues(old.getFieldValues()); a.action = update; } ActionSetField asf = (ActionSetField) a.action; ActionFieldValue val = new ActionFieldValue(sf.getFactField(), cell, sf.getType()); asf.addFieldValue(val); }
private ActionSetField clone(final ActionSetField action) { if (action instanceof ActionUpdateField) { final ActionUpdateField auf = (ActionUpdateField) action; final ActionUpdateField clone = new ActionUpdateField(auf.getVariable()); clone.setFieldValues(auf.getFieldValues()); return clone; } else if (action instanceof ActionCallMethod) { final ActionCallMethod acm = (ActionCallMethod) action; final ActionCallMethod clone = new ActionCallMethod(acm.getVariable()); clone.setState(acm.getState()); clone.setMethodName(acm.getMethodName()); clone.setFieldValues(acm.getFieldValues()); return clone; } else if (action instanceof ActionSetField) { final ActionSetField clone = new ActionSetField(action.getVariable()); clone.setFieldValues(action.getFieldValues()); return clone; } else { return action; } } }
ifc2.addFieldValue(afv2); final ActionSetField asf = new ActionSetField(); asf.setVariable("$a"); asf.addFieldValue(new ActionFieldValue("age",
ifc2.addFieldValue(afv2); final ActionSetField asf = new ActionSetField(); asf.setVariable("$a"); asf.addFieldValue(new ActionFieldValue("age",
@Test public void testActionUpdateFactZeroValues() { TemplateModel m = new TemplateModel(); m.name = "r1"; FactPattern fp = new FactPattern("Person"); fp.setBoundName("$p"); m.addLhsItem(fp); ActionSetField asf = new ActionSetField("$p"); ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_TEMPLATE); afv0.setField("field1"); afv0.setValue("$f1"); asf.addFieldValue(afv0); ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("field2"); afv1.setValue("$f2"); asf.addFieldValue(afv1); m.addRhsItem(asf); String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "$p : Person()\n" + "then\n" + "end"; m.addRow(new String[]{null, null}); checkMarshall(expected, m); }
@Test public void testActionUpdateFactFirstValue() { TemplateModel m = new TemplateModel(); m.name = "r1"; FactPattern fp = new FactPattern("Person"); fp.setBoundName("$p"); m.addLhsItem(fp); ActionSetField asf = new ActionSetField("$p"); ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_TEMPLATE); afv0.setField("field1"); afv0.setValue("$f1"); asf.addFieldValue(afv0); ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("field2"); afv1.setValue("$f2"); asf.addFieldValue(afv1); m.addRhsItem(asf); String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "$p : Person()\n" + "then\n" + "$p.setField1(\"foo\");\n" + "end"; m.addRow(new String[]{"foo", null}); checkMarshall(expected, m); }
@Test public void testActionUpdateFactSecondValue() { TemplateModel m = new TemplateModel(); m.name = "r1"; FactPattern fp = new FactPattern("Person"); fp.setBoundName("$p"); m.addLhsItem(fp); ActionSetField asf = new ActionSetField("$p"); ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_TEMPLATE); afv0.setField("field1"); afv0.setValue("$f1"); asf.addFieldValue(afv0); ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("field2"); afv1.setValue("$f2"); asf.addFieldValue(afv1); m.addRhsItem(asf); String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "$p : Person()\n" + "then\n" + "$p.setField2(\"bar\");\n" + "end"; m.addRow(new String[]{null, "bar"}); checkMarshall(expected, m); }
m.addLhsItem(fp); ActionSetField asf = new ActionSetField("$p"); ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_TEMPLATE);
final ActionSetField asf = new ActionSetField(); asf.setVariable("$a"); asf.addFieldValue(new ActionFieldValue("age",
m.addRhsItem(fr); ActionSetField asf = new ActionSetField("$p"); ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_TEMPLATE);
model.addRhsItem( auf ); ActionSetField asf = new ActionSetField(); asf.setVariable( "$var" ); asf.addFieldValue( buildActionFieldValue() );