@Test public void testLHSBindings() { GuidedDTDRLPersistence p = new GuidedDTDRLPersistence(); String[] row = new String[]{"1", "desc", "mike", "33 + 1", "age > 6"}; String[][] data = new String[1][]; data[0] = row; List<BaseColumn> allColumns = new ArrayList<BaseColumn>(); List<CompositeColumn<? extends BaseColumn>> allPatterns = new ArrayList<CompositeColumn<? extends BaseColumn>>(); allColumns.add(new RowNumberCol52()); allColumns.add(new DescriptionCol52()); Pattern52 p1 = new Pattern52(); p1.setBoundName("p1"); p1.setFactType("Person"); allPatterns.add(p1); ConditionCol52 col = new ConditionCol52(); col.setFactField("name"); col.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL); col.setOperator("=="); col.setBinding("$name"); p1.getChildColumns().add(col); allColumns.add(col); ConditionCol52 col2 = new ConditionCol52(); col2.setFactField("age"); col2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_RET_VALUE); col2.setOperator("<"); col2.setBinding("$age"); p1.getChildColumns().add(col2); allColumns.add(col2); ConditionCol52 col3 = new ConditionCol52(); col3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_PREDICATE); col3.setBinding("$name"); p1.getChildColumns().add(col3); allColumns.add(col3); List<DTCellValue52> rowData = DataUtilities.makeDataRowList(row); TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider(allColumns, rowData); RuleModel rm = new RuleModel(); p.doConditions(allColumns, allPatterns, rowDataProvider, rowData, DataUtilities.makeDataLists(data), rm); assertEquals(1, rm.lhs.length); assertEquals("Person", ((FactPattern) rm.lhs[0]).getFactType()); assertEquals("p1", ((FactPattern) rm.lhs[0]).getBoundName()); FactPattern person = (FactPattern) rm.lhs[0]; assertEquals(3, person.getConstraintList().getConstraints().length); SingleFieldConstraint cons = (SingleFieldConstraint) person.getConstraint(0); assertEquals(BaseSingleFieldConstraint.TYPE_LITERAL, cons.getConstraintValueType()); assertEquals("name", cons.getFieldName()); assertEquals("==", cons.getOperator()); assertEquals("mike", cons.getValue()); assertEquals("$name", cons.getFieldBinding()); cons = (SingleFieldConstraint) person.getConstraint(1); assertEquals(BaseSingleFieldConstraint.TYPE_RET_VALUE, cons.getConstraintValueType()); assertEquals("age", cons.getFieldName()); assertEquals("<", cons.getOperator()); assertEquals("33 + 1", cons.getValue()); assertEquals("$age", cons.getFieldBinding()); cons = (SingleFieldConstraint) person.getConstraint(2); assertEquals(BaseSingleFieldConstraint.TYPE_PREDICATE, cons.getConstraintValueType()); assertEquals("age > 6", cons.getValue()); assertNull(cons.getFieldBinding()); }
void doConditions(List<BaseColumn> allColumns, List<CompositeColumn<? extends BaseColumn>> conditionPatterns, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, List<List<DTCellValue52>> data, RuleModel rm) { List<IPattern> patterns = new ArrayList<IPattern>(); for (CompositeColumn<?> cc : conditionPatterns) { if (cc instanceof LimitedEntryBRLConditionColumn) { doCondition(allColumns, (LimitedEntryBRLConditionColumn) cc, patterns, rowDataProvider, row, rm); } else if (cc instanceof BRLConditionColumn) { doCondition(allColumns, (BRLConditionColumn) cc, patterns, rowDataProvider, row, rm); } else if (cc instanceof Pattern52) { doCondition(allColumns, (Pattern52) cc, patterns, row, data, rm); } } rm.lhs = patterns.toArray(new IPattern[patterns.size()]); }
GuidedDTDRLPersistence { void doConditions(List<BaseColumn> allColumns, List<CompositeColumn<? extends BaseColumn>> conditionPatterns, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, List<List<DTCellValue52>> data, RuleModel rm) { List<IPattern> patterns = new ArrayList<IPattern>(); for (CompositeColumn<?> cc : conditionPatterns) { if (cc instanceof LimitedEntryBRLConditionColumn) { doCondition(allColumns, (LimitedEntryBRLConditionColumn) cc, patterns, rowDataProvider, row, rm); } else if (cc instanceof BRLConditionColumn) { doCondition(allColumns, (BRLConditionColumn) cc, patterns, rowDataProvider, row, rm); } else if (cc instanceof Pattern52) { doCondition(allColumns, (Pattern52) cc, patterns, row, data, rm); } } rm.lhs = patterns.toArray(new IPattern[patterns.size()]); } }
GuidedDTDRLPersistence { void doConditions(List<BaseColumn> allColumns, List<CompositeColumn<? extends BaseColumn>> conditionPatterns, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, List<List<DTCellValue52>> data, RuleModel rm) { List<IPattern> patterns = new ArrayList<IPattern>(); for (CompositeColumn<?> cc : conditionPatterns) { if (cc instanceof LimitedEntryBRLConditionColumn) { doCondition(allColumns, (LimitedEntryBRLConditionColumn) cc, patterns, rowDataProvider, row, rm); } else if (cc instanceof BRLConditionColumn) { doCondition(allColumns, (BRLConditionColumn) cc, patterns, rowDataProvider, row, rm); } else if (cc instanceof Pattern52) { doCondition(allColumns, (Pattern52) cc, patterns, row, data, rm); } } rm.lhs = patterns.toArray(new IPattern[patterns.size()]); }  }
GuidedDTDRLPersistence { void doConditions(List<BaseColumn> allColumns, List<CompositeColumn<? extends BaseColumn>> conditionPatterns, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, List<List<DTCellValue52>> data, RuleModel rm) { List<IPattern> patterns = new ArrayList<IPattern>(); for (CompositeColumn<?> cc : conditionPatterns) { if (cc instanceof LimitedEntryBRLConditionColumn) { doCondition(allColumns, (LimitedEntryBRLConditionColumn) cc, patterns, rowDataProvider, row, rm); } else if (cc instanceof BRLConditionColumn) { doCondition(allColumns, (BRLConditionColumn) cc, patterns, rowDataProvider, row, rm); } else if (cc instanceof Pattern52) { doCondition(allColumns, (Pattern52) cc, patterns, row, data, rm); } } rm.lhs = patterns.toArray(new IPattern[patterns.size()]); }  static GuidedDTDRLPersistence getInstance(); String marshal(final GuidedDecisionTable52 originalDTable); }
GuidedDTDRLPersistence { void doConditions(List<BaseColumn> allColumns, List<CompositeColumn<? extends BaseColumn>> conditionPatterns, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, List<List<DTCellValue52>> data, RuleModel rm) { List<IPattern> patterns = new ArrayList<IPattern>(); for (CompositeColumn<?> cc : conditionPatterns) { if (cc instanceof LimitedEntryBRLConditionColumn) { doCondition(allColumns, (LimitedEntryBRLConditionColumn) cc, patterns, rowDataProvider, row, rm); } else if (cc instanceof BRLConditionColumn) { doCondition(allColumns, (BRLConditionColumn) cc, patterns, rowDataProvider, row, rm); } else if (cc instanceof Pattern52) { doCondition(allColumns, (Pattern52) cc, patterns, row, data, rm); } } rm.lhs = patterns.toArray(new IPattern[patterns.size()]); }  static GuidedDTDRLPersistence getInstance(); String marshal(final GuidedDecisionTable52 originalDTable);  }