@Test public void testRHS() { GuidedDTDRLPersistence p = new GuidedDTDRLPersistence(); String[] row = new String[]{"1", "desc", "a", "a condition", "actionsetfield1", "actionupdatefield2", "retract", "actioninsertfact1", "actioninsertfact2"}; List<BaseColumn> allColumns = new ArrayList<BaseColumn>(); allColumns.add(new RowNumberCol52()); allColumns.add(new DescriptionCol52()); allColumns.add(new MetadataCol52()); allColumns.add(new ConditionCol52()); List<ActionCol52> cols = new ArrayList<ActionCol52>(); ActionSetFieldCol52 asf1 = new ActionSetFieldCol52(); asf1.setBoundName("a"); asf1.setFactField("field1"); asf1.setType(DataType.TYPE_STRING); cols.add(asf1); ActionSetFieldCol52 asf2 = new ActionSetFieldCol52(); asf2.setBoundName("a"); asf2.setFactField("field2"); asf2.setUpdate(true); asf2.setType(DataType.TYPE_NUMERIC_INTEGER); cols.add(asf2); ActionRetractFactCol52 ret = new ActionRetractFactCol52(); cols.add(ret); ActionInsertFactCol52 ins1 = new ActionInsertFactCol52(); ins1.setBoundName("ins"); ins1.setFactType("Cheese"); ins1.setFactField("price"); ins1.setType(DataType.TYPE_NUMERIC_INTEGER); cols.add(ins1); ActionInsertFactCol52 ins2 = new ActionInsertFactCol52(); ins2.setBoundName("ins"); ins2.setFactType("Cheese"); ins2.setFactField("type"); ins2.setType(DataType.TYPE_NUMERIC_INTEGER); cols.add(ins2); RuleModel rm = new RuleModel(); allColumns.addAll(cols); List<DTCellValue52> rowData = DataUtilities.makeDataRowList(row); TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider(allColumns, rowData); p.doActions(allColumns, cols, rowDataProvider, rowData, rm); assertEquals(4, rm.rhs.length); ActionSetField a1 = (ActionSetField) rm.rhs[0]; assertEquals("a", a1.getVariable()); assertEquals(1, a1.getFieldValues().length); assertEquals("field1", a1.getFieldValues()[0].getField()); assertEquals("actionsetfield1", a1.getFieldValues()[0].getValue()); assertEquals(DataType.TYPE_STRING, a1.getFieldValues()[0].getType()); ActionSetField a2 = (ActionSetField) rm.rhs[1]; assertEquals("a", a2.getVariable()); assertEquals(1, a2.getFieldValues().length); assertEquals("field2", a2.getFieldValues()[0].getField()); assertEquals("actionupdatefield2", a2.getFieldValues()[0].getValue()); assertEquals(DataType.TYPE_NUMERIC_INTEGER, a2.getFieldValues()[0].getType()); ActionRetractFact a3 = (ActionRetractFact) rm.rhs[2]; assertEquals("retract", a3.getVariableName()); ActionInsertFact a4 = (ActionInsertFact) rm.rhs[3]; assertEquals("Cheese", a4.getFactType()); assertEquals(2, a4.getFieldValues().length); assertEquals("price", a4.getFieldValues()[0].getField()); assertEquals("actioninsertfact1", a4.getFieldValues()[0].getValue()); assertEquals(DataType.TYPE_NUMERIC_INTEGER, a4.getFieldValues()[0].getType()); assertEquals("type", a4.getFieldValues()[1].getField()); assertEquals("actioninsertfact2", a4.getFieldValues()[1].getValue()); assertEquals(DataType.TYPE_NUMERIC_INTEGER, a4.getFieldValues()[1].getType()); }
void doActions(List<BaseColumn> allColumns, List<ActionCol52> actionCols, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, RuleModel rm) { List<LabelledAction> actions = new ArrayList<LabelledAction>(); for (ActionCol52 c : actionCols) { if (c instanceof LimitedEntryBRLActionColumn) { doAction(allColumns, (LimitedEntryBRLActionColumn) c, actions, rowDataProvider, row, rm); } else if (c instanceof BRLActionColumn) { doAction(allColumns, (BRLActionColumn) c, actions, rowDataProvider, row, rm); } else { int index = allColumns.indexOf(c); DTCellValue52 dcv = row.get(index); String cell = ""; if (c instanceof LimitedEntryCol) { if (dcv.getBooleanValue() == true) { LimitedEntryCol lec = (LimitedEntryCol) c; cell = GuidedDTDRLUtilities.convertDTCellValueToString(lec.getValue()); } } else { cell = GuidedDTDRLUtilities.convertDTCellValueToString(dcv); } if (validCell(cell, dcv.getDataType())) { if (c instanceof ActionWorkItemInsertFactCol52) { doAction(actions, (ActionWorkItemInsertFactCol52) c, cell); } else if (c instanceof ActionInsertFactCol52) { doAction(actions, (ActionInsertFactCol52) c, cell); } else if (c instanceof ActionWorkItemSetFieldCol52) { doAction(actions, (ActionWorkItemSetFieldCol52) c, cell); } else if (c instanceof ActionSetFieldCol52) { doAction(actions, (ActionSetFieldCol52) c, cell); } else if (c instanceof ActionRetractFactCol52) { doAction(actions, cell); } else if (c instanceof ActionWorkItemCol52) { doAction(actions, (ActionWorkItemCol52) c, cell); } } } } rm.rhs = new IAction[actions.size()]; for (int i = 0; i < rm.rhs.length; i++) { rm.rhs[i] = actions.get(i).action; } }
GuidedDTDRLPersistence { void doActions(List<BaseColumn> allColumns, List<ActionCol52> actionCols, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, RuleModel rm) { List<LabelledAction> actions = new ArrayList<LabelledAction>(); for (ActionCol52 c : actionCols) { if (c instanceof LimitedEntryBRLActionColumn) { doAction(allColumns, (LimitedEntryBRLActionColumn) c, actions, rowDataProvider, row, rm); } else if (c instanceof BRLActionColumn) { doAction(allColumns, (BRLActionColumn) c, actions, rowDataProvider, row, rm); } else { int index = allColumns.indexOf(c); DTCellValue52 dcv = row.get(index); String cell = ""; if (c instanceof LimitedEntryCol) { if (dcv.getBooleanValue() == true) { LimitedEntryCol lec = (LimitedEntryCol) c; cell = GuidedDTDRLUtilities.convertDTCellValueToString(lec.getValue()); } } else { cell = GuidedDTDRLUtilities.convertDTCellValueToString(dcv); } if (validCell(cell, dcv.getDataType())) { if (c instanceof ActionWorkItemInsertFactCol52) { doAction(actions, (ActionWorkItemInsertFactCol52) c, cell); } else if (c instanceof ActionInsertFactCol52) { doAction(actions, (ActionInsertFactCol52) c, cell); } else if (c instanceof ActionWorkItemSetFieldCol52) { doAction(actions, (ActionWorkItemSetFieldCol52) c, cell); } else if (c instanceof ActionSetFieldCol52) { doAction(actions, (ActionSetFieldCol52) c, cell); } else if (c instanceof ActionRetractFactCol52) { doAction(actions, cell); } else if (c instanceof ActionWorkItemCol52) { doAction(actions, (ActionWorkItemCol52) c, cell); } } } } rm.rhs = new IAction[actions.size()]; for (int i = 0; i < rm.rhs.length; i++) { rm.rhs[i] = actions.get(i).action; } } }
GuidedDTDRLPersistence { void doActions(List<BaseColumn> allColumns, List<ActionCol52> actionCols, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, RuleModel rm) { List<LabelledAction> actions = new ArrayList<LabelledAction>(); for (ActionCol52 c : actionCols) { if (c instanceof LimitedEntryBRLActionColumn) { doAction(allColumns, (LimitedEntryBRLActionColumn) c, actions, rowDataProvider, row, rm); } else if (c instanceof BRLActionColumn) { doAction(allColumns, (BRLActionColumn) c, actions, rowDataProvider, row, rm); } else { int index = allColumns.indexOf(c); DTCellValue52 dcv = row.get(index); String cell = ""; if (c instanceof LimitedEntryCol) { if (dcv.getBooleanValue() == true) { LimitedEntryCol lec = (LimitedEntryCol) c; cell = GuidedDTDRLUtilities.convertDTCellValueToString(lec.getValue()); } } else { cell = GuidedDTDRLUtilities.convertDTCellValueToString(dcv); } if (validCell(cell, dcv.getDataType())) { if (c instanceof ActionWorkItemInsertFactCol52) { doAction(actions, (ActionWorkItemInsertFactCol52) c, cell); } else if (c instanceof ActionInsertFactCol52) { doAction(actions, (ActionInsertFactCol52) c, cell); } else if (c instanceof ActionWorkItemSetFieldCol52) { doAction(actions, (ActionWorkItemSetFieldCol52) c, cell); } else if (c instanceof ActionSetFieldCol52) { doAction(actions, (ActionSetFieldCol52) c, cell); } else if (c instanceof ActionRetractFactCol52) { doAction(actions, cell); } else if (c instanceof ActionWorkItemCol52) { doAction(actions, (ActionWorkItemCol52) c, cell); } } } } rm.rhs = new IAction[actions.size()]; for (int i = 0; i < rm.rhs.length; i++) { rm.rhs[i] = actions.get(i).action; } }  }
GuidedDTDRLPersistence { void doActions(List<BaseColumn> allColumns, List<ActionCol52> actionCols, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, RuleModel rm) { List<LabelledAction> actions = new ArrayList<LabelledAction>(); for (ActionCol52 c : actionCols) { if (c instanceof LimitedEntryBRLActionColumn) { doAction(allColumns, (LimitedEntryBRLActionColumn) c, actions, rowDataProvider, row, rm); } else if (c instanceof BRLActionColumn) { doAction(allColumns, (BRLActionColumn) c, actions, rowDataProvider, row, rm); } else { int index = allColumns.indexOf(c); DTCellValue52 dcv = row.get(index); String cell = ""; if (c instanceof LimitedEntryCol) { if (dcv.getBooleanValue() == true) { LimitedEntryCol lec = (LimitedEntryCol) c; cell = GuidedDTDRLUtilities.convertDTCellValueToString(lec.getValue()); } } else { cell = GuidedDTDRLUtilities.convertDTCellValueToString(dcv); } if (validCell(cell, dcv.getDataType())) { if (c instanceof ActionWorkItemInsertFactCol52) { doAction(actions, (ActionWorkItemInsertFactCol52) c, cell); } else if (c instanceof ActionInsertFactCol52) { doAction(actions, (ActionInsertFactCol52) c, cell); } else if (c instanceof ActionWorkItemSetFieldCol52) { doAction(actions, (ActionWorkItemSetFieldCol52) c, cell); } else if (c instanceof ActionSetFieldCol52) { doAction(actions, (ActionSetFieldCol52) c, cell); } else if (c instanceof ActionRetractFactCol52) { doAction(actions, cell); } else if (c instanceof ActionWorkItemCol52) { doAction(actions, (ActionWorkItemCol52) c, cell); } } } } rm.rhs = new IAction[actions.size()]; for (int i = 0; i < rm.rhs.length; i++) { rm.rhs[i] = actions.get(i).action; } }  static GuidedDTDRLPersistence getInstance(); String marshal(final GuidedDecisionTable52 originalDTable); }
GuidedDTDRLPersistence { void doActions(List<BaseColumn> allColumns, List<ActionCol52> actionCols, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, RuleModel rm) { List<LabelledAction> actions = new ArrayList<LabelledAction>(); for (ActionCol52 c : actionCols) { if (c instanceof LimitedEntryBRLActionColumn) { doAction(allColumns, (LimitedEntryBRLActionColumn) c, actions, rowDataProvider, row, rm); } else if (c instanceof BRLActionColumn) { doAction(allColumns, (BRLActionColumn) c, actions, rowDataProvider, row, rm); } else { int index = allColumns.indexOf(c); DTCellValue52 dcv = row.get(index); String cell = ""; if (c instanceof LimitedEntryCol) { if (dcv.getBooleanValue() == true) { LimitedEntryCol lec = (LimitedEntryCol) c; cell = GuidedDTDRLUtilities.convertDTCellValueToString(lec.getValue()); } } else { cell = GuidedDTDRLUtilities.convertDTCellValueToString(dcv); } if (validCell(cell, dcv.getDataType())) { if (c instanceof ActionWorkItemInsertFactCol52) { doAction(actions, (ActionWorkItemInsertFactCol52) c, cell); } else if (c instanceof ActionInsertFactCol52) { doAction(actions, (ActionInsertFactCol52) c, cell); } else if (c instanceof ActionWorkItemSetFieldCol52) { doAction(actions, (ActionWorkItemSetFieldCol52) c, cell); } else if (c instanceof ActionSetFieldCol52) { doAction(actions, (ActionSetFieldCol52) c, cell); } else if (c instanceof ActionRetractFactCol52) { doAction(actions, cell); } else if (c instanceof ActionWorkItemCol52) { doAction(actions, (ActionWorkItemCol52) c, cell); } } } } rm.rhs = new IAction[actions.size()]; for (int i = 0; i < rm.rhs.length; i++) { rm.rhs[i] = actions.get(i).action; } }  static GuidedDTDRLPersistence getInstance(); String marshal(final GuidedDecisionTable52 originalDTable);  }