void refreshColumnsPage() { refreshAttributesPanelEvent.fire(new RefreshAttributesPanelEvent(this, model.getAttributeCols())); refreshMetaDataPanelEvent.fire(new RefreshMetaDataPanelEvent(this, model.getMetadataCols())); refreshConditionsPanelEvent.fire(new RefreshConditionsPanelEvent(this, model.getConditions())); refreshActionsPanelEvent.fire(new RefreshActionsPanelEvent(this, model.getActionCols())); }
private void removeCommaSeparatedValues(final BaseColumn column) { final int columnIndex = this.model.getExpandedColumns().indexOf(column); for (List<DTCellValue52> row : this.model.getData()) { final DTCellValue52 dcv = row.get(columnIndex); cellUtilities.removeCommaSeparatedValue(dcv); } }
@Before public void setUp() throws Exception { dtable = new GuidedDecisionTable52(); dtable.setTableName( "Resolved hit policy table" ); dtable.setHitPolicy( GuidedDecisionTable52.HitPolicy.RESOLVED_HIT ); dtable.setData( DataUtilities.makeDataLists( new Object[][]{ new Object[]{1, "desc-row1"}, new Object[]{2, "desc-row2"}, new Object[]{3, "desc-row3"} } ) ); }
@Override public boolean hasColumnDefinitions() { final boolean hasAttributeCols = model.getAttributeCols().size() > 0; final boolean hasMetadataCols = model.getMetadataCols().size() > 0; final boolean hasConditionCols = model.getConditionsCount() > 0; final boolean hasActionCols = model.getActionCols().size() > 0; return hasAttributeCols || hasConditionCols || hasActionCols || hasMetadataCols; }
public GuidedDecisionTableModelVisitor(final GuidedDecisionTable52 model) { this.model = PortablePreconditions.checkNotNull("model", model); this.packageName = model.getPackageName(); this.imports = model.getImports(); }
public static GuidedDecisionTable52 makeTableWithAttributeCol(final String packageName, final Collection<Import> imports, final String tableName) { final GuidedDecisionTable52 dt = new GuidedDecisionTable52(); dt.setPackageName(packageName); dt.getImports().getImports().addAll(imports); dt.setTableName(tableName); AttributeCol52 attr = new AttributeCol52(); attr.setAttribute("ruleflow-group"); dt.getAttributeCols().add(attr); dt.setData(DataUtilities.makeDataLists(new String[][]{ new String[]{"1", "desc", "myRuleFlowGroup"} })); return dt; }
public LimitedGuidedDecisionTableBuilder(final String packageName, final Collection<Import> imports, final String tableName) { table.setPackageName(packageName); table.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY); table.getImports().getImports().addAll(imports); table.setTableName(tableName); }
public static GuidedDecisionTable52 makeTableWithActionCol(final String packageName, final Collection<Import> imports, final String tableName) { final GuidedDecisionTable52 dt = new GuidedDecisionTable52(); dt.setPackageName(packageName); dt.getImports().getImports().addAll(imports); dt.setTableName(tableName); ActionInsertFactCol52 ins = new ActionInsertFactCol52(); ins.setBoundName("$i"); ins.setFactType("Applicant"); ins.setFactField("age"); ins.setType(DataType.TYPE_NUMERIC_INTEGER); dt.getActionCols().add(ins); dt.setData(DataUtilities.makeDataLists(new String[][]{ new String[]{"1", "desc", "33"} })); return dt; }
protected OptionalInt findLastIndexOfActionSetFieldColumn(final ActionSetFieldCol52 column) { final String binding = column.getBoundName(); final List<ActionCol52> relatedColumns = new ArrayList<>(); relatedColumns.addAll(model.getActionCols().stream() .filter(c -> c instanceof ActionSetFieldCol52) .map(c -> (ActionSetFieldCol52) c) .filter(c -> c.getBoundName().equals(binding)) .collect(Collectors.toList())); return relatedColumns.stream().mapToInt(c -> model.getActionCols().indexOf(c)).max(); }
@Test public void testLimitedEntryAttributes() { GuidedDecisionTable52 dt = new GuidedDecisionTable52(); dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY); dt.setTableName("limited-entry"); AttributeCol52 attr = new AttributeCol52(); attr.setAttribute("salience"); dt.getAttributeCols().add(attr); dt.setData(DataUtilities.makeDataLists(new String[][]{ new String[]{"1", "desc", "100"}, new String[]{"2", "desc", "200"} })); GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance(); String drl = p.marshal(dt); assertTrue(drl.indexOf("salience 100") > -1); assertTrue(drl.indexOf("salience 200") > -1); }
protected void addPattern(Pattern52 pattern) { if (!table.getConditions().contains(pattern)) { table.getConditions().add(pattern); } }
@Test public void testLimitedEntryMetadata() { GuidedDecisionTable52 dt = new GuidedDecisionTable52(); dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY); dt.setTableName("limited-entry"); MetadataCol52 md = new MetadataCol52(); md.setMetadata("metadata"); dt.getMetadataCols().add(md); dt.setData(DataUtilities.makeDataLists(new String[][]{ new String[]{"1", "desc", "md1"}, new String[]{"2", "desc", "md2"} })); GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance(); String drl = p.marshal(dt); assertTrue(drl.indexOf("@metadata(md1)") > -1); assertTrue(drl.indexOf("@metadata(md2)") > -1); }
@Override public void delete(final ColumnMetaData metaData) throws VetoException { //Check operation is supported if (!handlesDelete(metaData)) { return; } final LimitedEntryBRLConditionColumn column = (LimitedEntryBRLConditionColumn) metaData.getColumn(); final int columnIndex = model.getExpandedColumns().indexOf(column); model.getConditions().remove(column); synchroniseDeleteColumn(columnIndex); }
void initialiseModels() { initialiseLegacyColumnDataTypes(); final List<BaseColumn> modelColumns = model.getExpandedColumns(); for (BaseColumn column : modelColumns) { initialiseColumn(column); } for (List<DTCellValue52> row : model.getData()) { initialiseRow(modelColumns, row); } setOriginalHashCode(model.hashCode()); }
@Test public void testOnDecisionTableSelectedEventWithMultipleRowsSelectedAndItHasEditableColumns() { model.getConditions().add(makePattern52()); model.getData().add(makeDTCellValue52List()); model.getData().add(makeDTCellValue52List()); uiModel.selectCells(0, 2, 1, 2); builder.onDecisionTableSelectedEvent(new DecisionTableSelectedEvent(dtPresenter)); assertTrue(builder.miAppendRow.getMenuItem().isEnabled()); assertFalse(builder.miInsertRowAbove.getMenuItem().isEnabled()); assertFalse(builder.miInsertRowBelow.getMenuItem().isEnabled()); assertTrue(builder.miInsertColumn.getMenuItem().isEnabled()); }
@Override public void delete(final ColumnMetaData metaData) throws VetoException { //Check operation is supported if (!handlesDelete(metaData)) { return; } final LimitedEntryBRLActionColumn column = (LimitedEntryBRLActionColumn) metaData.getColumn(); final int columnIndex = model.getExpandedColumns().indexOf(column); model.getActionCols().remove(column); synchroniseDeleteColumn(columnIndex); }
private void mockPatterns() { final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class); final List<CompositeColumn<?>> patterns = Collections.singletonList(fakePattern()); final List<ActionCol52> actions = Arrays.asList(fakeActionCol(), fakeActionCol()); when(model.getConditions()).thenReturn(patterns); when(model.getActionCols()).thenReturn(actions); when(presenter.getModel()).thenReturn(model); }
@Before public void setUp() throws Exception { dtable = new GuidedDecisionTable52(); dtable.setTableName( "Rule order table" ); dtable.setHitPolicy( GuidedDecisionTable52.HitPolicy.RULE_ORDER ); }
protected void removeActionColumn(final int columnDataIndex, final int columnActionIndex) { table52.getActionCols() .remove(columnActionIndex); for (final List<DTCellValue52> row : table52.getData()) { row.remove(columnDataIndex); } updateManager.deleteColumns(columnDataIndex, 1); }
@Before public void setUp() throws Exception { model = new GuidedDecisionTable52(); actionSetFieldsPage.model = model; }