public void execute() { model.addRhsItem(new ActionInsertFact(item), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex()))); hide(); } });
public void execute() { model.addRhsItem(new ActionInsertFact(item), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex()))); hide(); } });
@Test public void emptyActionFieldList() { final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[]{field1}, new ActionInsertFact()); assertEquals(1, result.length); assertEquals(field1, result[0]); }
@Test public void emptyActionFieldList() { final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[]{field1}, new ActionInsertFact()); assertEquals(1, result.length); assertEquals(field1, result[0]); }
@Test public void filtering() { when(field1.getName()).thenReturn("field1"); when(field2.getName()).thenReturn("field2"); final ActionFieldList afl = new ActionInsertFact(); final ActionFieldValue afv = new ActionFieldValue(); afv.setField("field1"); afl.addFieldValue(afv); final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[]{field1, field2}, afl); assertEquals(1, result.length); assertEquals(field2, result[0]); } }
@Test public void filtering() { when(field1.getName()).thenReturn("field1"); when(field2.getName()).thenReturn("field2"); final ActionFieldList afl = new ActionInsertFact(); final ActionFieldValue afv = new ActionFieldValue(); afv.setField("field1"); afl.addFieldValue(afv); final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[]{field1, field2}, afl); assertEquals(1, result.length); assertEquals(field2, result[0]); } }
private void addBrlInsertActionToModel(final GuidedDecisionTable52 model, final String factType, final String field) { final BRLActionColumn brlAction = new BRLActionColumn(); final ActionInsertFact aif = new ActionInsertFact(factType); final ActionFieldValue afv = new ActionFieldValue(field, "$var", DataType.TYPE_STRING); afv.setNature(FieldNatureType.TYPE_VARIABLE); aif.addFieldValue(afv); brlAction.setDefinition(Collections.singletonList(aif)); BRLActionVariableColumn variableColumn = new BRLActionVariableColumn("$var", DataType.TYPE_STRING, factType, field); brlAction.getChildColumns().add(variableColumn); model.getActionCols().add(brlAction); }
private void doAction(List<LabelledAction> actions, ActionWorkItemInsertFactCol52 ac, String cell) { if (Boolean.TRUE.equals(Boolean.parseBoolean(cell))) { LabelledAction a = findByLabelledAction(actions, ac.getBoundName()); if (a == null) { a = new LabelledAction(); a.boundName = ac.getBoundName(); if (!ac.isInsertLogical()) { ActionInsertFact ins = new ActionInsertFact(ac.getFactType()); ins.setBoundName(ac.getBoundName()); a.action = ins; } else { ActionInsertLogicalFact ins = new ActionInsertLogicalFact(ac.getFactType()); ins.setBoundName(ac.getBoundName()); a.action = ins; } actions.add(a); } ActionInsertFact ins = (ActionInsertFact) a.action; ActionWorkItemFieldValue val = new ActionWorkItemFieldValue(ac.getFactField(), ac.getType(), ac.getWorkItemName(), ac.getWorkItemResultParameterName(), ac.getParameterClassName()); ins.addFieldValue(val); } }
private void setupBRLActionColumn() { final BRLActionColumn brl = new BRLActionColumn(); final ActionInsertFact ifc1 = new ActionInsertFact(); ifc1.setFactType("Person"); ifc1.setBoundName("$a"); final ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("name"); afv1.setValue("f1"); ifc1.addFieldValue(afv1); final ActionFieldValue afv2 = new ActionFieldValue(); afv2.setNature(FieldNatureType.TYPE_TEMPLATE); afv2.setField("age"); afv2.setValue("f2"); ifc1.addFieldValue(afv2); brl.getDefinition().add(ifc1); brl.getChildColumns().add(new BRLActionVariableColumn("f1", DataType.TYPE_STRING)); brl.getChildColumns().add(new BRLActionVariableColumn("f2", DataType.TYPE_NUMERIC_INTEGER)); model.getActionCols().add(brl); when(dmo.getFieldType(eq("Person"), eq("name"))).thenReturn(DataType.TYPE_STRING); when(dmo.getFieldType(eq("Person"), eq("age"))).thenReturn(DataType.TYPE_NUMERIC_INTEGER); } }
private void doAction(List<LabelledAction> actions, ActionInsertFactCol52 ac, String cell) { LabelledAction a = findByLabelledAction(actions, ac.getBoundName()); if (a == null) { a = new LabelledAction(); a.boundName = ac.getBoundName(); if (!ac.isInsertLogical()) { ActionInsertFact ins = new ActionInsertFact(ac.getFactType()); ins.setBoundName(ac.getBoundName()); a.action = ins; } else { ActionInsertLogicalFact ins = new ActionInsertLogicalFact(ac.getFactType()); ins.setBoundName(ac.getBoundName()); a.action = ins; } actions.add(a); } ActionInsertFact ins = (ActionInsertFact) a.action; ActionFieldValue val = new ActionFieldValue(ac.getFactField(), cell, ac.getType()); ins.addFieldValue(val); }
private ActionInsertFact visitActionFieldList(ActionInsertFact afl) { ActionInsertFact clone = new ActionInsertFact(); clone.setFactType(afl.getFactType()); clone.setBoundName(afl.getBoundName()); for (ActionFieldValue afv : afl.getFieldValues()) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField(afv.getField()); afvClone.setNature(afv.getNature()); afvClone.setType(afv.getType()); afvClone.setValue(afv.getValue()); clone.addFieldValue(afvClone); } return clone; }
private ActionInsertFact visitActionFieldList(ActionInsertFact afl) { ActionInsertFact clone = new ActionInsertFact(); clone.setFactType(afl.getFactType()); clone.setBoundName(afl.getBoundName()); for (ActionFieldValue afv : afl.getFieldValues()) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField(afv.getField()); afvClone.setNature(afv.getNature()); afvClone.setType(afv.getType()); afvClone.setValue(afv.getValue()); clone.addFieldValue(afvClone); } return clone; }
@Test public void testBasics() { final RuleTemplateModelPersistence p = RuleTemplateModelXMLPersistenceImpl.getInstance(); final TemplateModel m = new TemplateModel(); m.addLhsItem(new FactPattern("Person")); m.addLhsItem(new FactPattern("Accident")); m.addAttribute(new RuleAttribute("no-loop", "true")); m.addRhsItem(new ActionInsertFact("Report")); ActionGlobalCollectionAdd ag = new ActionGlobalCollectionAdd(); ag.setFactName("x"); ag.setGlobalName("g"); m.addRhsItem(ag); m.name = "my rule"; final String xml = p.marshal(m); System.out.println(xml); assertTrue(xml.indexOf("Person") > -1); assertTrue(xml.indexOf("Accident") > -1); assertTrue(xml.indexOf("no-loop") > -1); assertTrue(xml.indexOf("org.kie") == -1); assertTrue(xml.indexOf("addToGlobal") > -1); RuleModel rm_ = RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal(xml); assertEquals(2, rm_.rhs.length); }
final ActionInsertFact aif = new ActionInsertFact(); aif.setFactType("Fact"); aif.addFieldValue(new ActionFieldValue() {{
final ActionInsertFact aif = new ActionInsertFact(); aif.setFactType("Fact"); aif.addFieldValue(new ActionFieldValue() {{
ActionInsertFact actionInsertFact = new ActionInsertFact(); actionInsertFact.setFactType("Applicant"); ActionFieldValue actionFieldValue = new ActionFieldValue("age", "123", "Integer");
m.addLhsItem(fp); ActionInsertFact aif = new ActionInsertFact("Present"); aif.setBoundName("f0"); ActionFieldValue afv0 = new ActionFieldValue();
m.addLhsItem(fp); ActionInsertFact aif = new ActionInsertFact("Present"); aif.setBoundName("f0"); ActionFieldValue afv0 = new ActionFieldValue();
m.addLhsItem(fp); ActionInsertFact aif = new ActionInsertFact("Present"); aif.setBoundName("f0"); ActionFieldValue afv0 = new ActionFieldValue();
m.addLhsItem(fp); ActionInsertFact aif = new ActionInsertFact("Present"); aif.setBoundName("f0"); ActionFieldValue afv0 = new ActionFieldValue();