Search in sources :

Example 16 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.

the class GuidedDecisionTableGeneratorListenerTest method testEmptyCells.

@Test
public // https://bugzilla.redhat.com/show_bug.cgi?id=1256623
void testEmptyCells() {
    final ConversionResult result = new ConversionResult();
    final List<DataListener> listeners = new ArrayList<DataListener>();
    final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result, dmo);
    listeners.add(listener);
    // Convert
    final ExcelParser parser = new ExcelParser(listeners);
    final InputStream is = this.getClass().getResourceAsStream("EmptySpreadsheetCells.xls");
    try {
        parser.parseFile(is);
    } finally {
        try {
            is.close();
        } catch (IOException ioe) {
            fail(ioe.getMessage());
        }
    }
    // Check conversion results
    assertEquals(0, result.getMessages().size());
    // Check basics
    List<GuidedDecisionTable52> dtables = listener.getGuidedDecisionTables();
    assertNotNull(dtables);
    assertEquals(1, dtables.size());
    final GuidedDecisionTable52 dtable = dtables.get(0);
    assertEquals("ExceptionPrivateCar", dtable.getTableName());
    assertEquals(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY, dtable.getTableFormat());
    // Check expanded columns
    List<BaseColumn> columns = dtable.getExpandedColumns();
    assertNotNull(columns);
    assertEquals(20, columns.size());
    assertTrue(columns.get(0) instanceof RowNumberCol52);
    assertTrue(columns.get(1) instanceof DescriptionCol52);
    assertTrue(columns.get(2) instanceof AttributeCol52);
    assertTrue(columns.get(3) instanceof AttributeCol52);
    assertTrue(columns.get(4) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(5) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(6) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(7) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(8) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(9) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(10) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(11) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(12) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(13) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(14) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(15) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(16) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(17) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(18) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(19) instanceof BRLActionVariableColumn);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) ConversionResult(org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ExcelParser(org.drools.decisiontable.parser.xls.ExcelParser) DataListener(org.drools.template.parser.DataListener) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 17 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.

the class GuidedDecisionTableGeneratorListenerTest method testAttributes.

@Test
public void testAttributes() {
    final ConversionResult result = new ConversionResult();
    final List<DataListener> listeners = new ArrayList<DataListener>();
    final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result, dmo);
    listeners.add(listener);
    // Convert
    final ExcelParser parser = new ExcelParser(listeners);
    final InputStream is = this.getClass().getResourceAsStream("Attributes.xls");
    try {
        parser.parseFile(is);
    } finally {
        try {
            is.close();
        } catch (IOException ioe) {
            fail(ioe.getMessage());
        }
    }
    // Check conversion results
    assertEquals(0, result.getMessages().size());
    // Check basics
    List<GuidedDecisionTable52> dtables = listener.getGuidedDecisionTables();
    assertNotNull(dtables);
    assertEquals(1, dtables.size());
    GuidedDecisionTable52 dtable = dtables.get(0);
    assertEquals("AttributesTest", dtable.getTableName());
    assertEquals(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY, dtable.getTableFormat());
    // Check expanded columns
    List<BaseColumn> columns = dtable.getExpandedColumns();
    assertNotNull(columns);
    assertEquals(12, columns.size());
    assertTrue(columns.get(0) instanceof RowNumberCol52);
    assertTrue(columns.get(1) instanceof DescriptionCol52);
    assertTrue(columns.get(2) instanceof AttributeCol52);
    assertTrue(columns.get(3) instanceof AttributeCol52);
    assertTrue(columns.get(4) instanceof AttributeCol52);
    assertTrue(columns.get(5) instanceof AttributeCol52);
    assertTrue(columns.get(6) instanceof AttributeCol52);
    assertTrue(columns.get(7) instanceof AttributeCol52);
    assertTrue(columns.get(8) instanceof AttributeCol52);
    assertTrue(columns.get(9) instanceof AttributeCol52);
    assertTrue(columns.get(10) instanceof AttributeCol52);
    assertTrue(columns.get(11) instanceof AttributeCol52);
    // Check individual attributes
    AttributeCol52 attrCol2 = ((AttributeCol52) columns.get(2));
    assertEquals(GuidedDecisionTable52.SALIENCE_ATTR, attrCol2.getAttribute());
    assertFalse(attrCol2.isUseRowNumber());
    assertFalse(attrCol2.isReverseOrder());
    AttributeCol52 attrCol3 = ((AttributeCol52) columns.get(3));
    assertEquals(GuidedDecisionTable52.ACTIVATION_GROUP_ATTR, attrCol3.getAttribute());
    AttributeCol52 attrCol4 = ((AttributeCol52) columns.get(4));
    assertEquals(GuidedDecisionTable52.DURATION_ATTR, attrCol4.getAttribute());
    AttributeCol52 attrCol5 = ((AttributeCol52) columns.get(5));
    assertEquals(GuidedDecisionTable52.TIMER_ATTR, attrCol5.getAttribute());
    AttributeCol52 attrCol6 = ((AttributeCol52) columns.get(6));
    assertEquals(GuidedDecisionTable52.CALENDARS_ATTR, attrCol6.getAttribute());
    AttributeCol52 attrCol7 = ((AttributeCol52) columns.get(7));
    assertEquals(GuidedDecisionTable52.NO_LOOP_ATTR, attrCol7.getAttribute());
    AttributeCol52 attrCol8 = ((AttributeCol52) columns.get(8));
    assertEquals(GuidedDecisionTable52.LOCK_ON_ACTIVE_ATTR, attrCol8.getAttribute());
    AttributeCol52 attrCol9 = ((AttributeCol52) columns.get(9));
    assertEquals(GuidedDecisionTable52.AUTO_FOCUS_ATTR, attrCol9.getAttribute());
    AttributeCol52 attrCol10 = ((AttributeCol52) columns.get(10));
    assertEquals(GuidedDecisionTable52.AGENDA_GROUP_ATTR, attrCol10.getAttribute());
    AttributeCol52 attrCol11 = ((AttributeCol52) columns.get(11));
    assertEquals(GuidedDecisionTable52.RULEFLOW_GROUP_ATTR, attrCol11.getAttribute());
    // Check data
    assertEquals(2, dtable.getData().size());
    assertTrue(isRowEquivalent(new Object[] { 1, "Specific rule 1", 1, "g1", 100l, "T1", "CAL1", true, true, true, "AG1", "RFG1" }, dtable.getData().get(0)));
    assertTrue(isRowEquivalent(new Object[] { 2, "Specific rule 2", 2, "g2", 200l, "T2", "CAL2", false, false, false, "AG2", "RFG2" }, dtable.getData().get(1)));
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) ConversionResult(org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ExcelParser(org.drools.decisiontable.parser.xls.ExcelParser) DataListener(org.drools.template.parser.DataListener) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 18 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.

the class GuidedDecisionTableGeneratorListenerTest method testSalienceWarnings.

@Test
public void testSalienceWarnings() {
    final ConversionResult result = new ConversionResult();
    final List<DataListener> listeners = new ArrayList<DataListener>();
    final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result, dmo);
    listeners.add(listener);
    // Convert
    final ExcelParser parser = new ExcelParser(listeners);
    final InputStream is = this.getClass().getResourceAsStream("SalienceWarnings.xls");
    try {
        parser.parseFile(is);
    } finally {
        try {
            is.close();
        } catch (IOException ioe) {
            fail(ioe.getMessage());
        }
    }
    // Check conversion results
    assertEquals(2, result.getMessages().size());
    assertEquals(ConversionMessageType.WARNING, result.getMessages().get(0).getMessageType());
    assertFalse(result.getMessages().get(0).getMessage().indexOf("Priority is not an integer literal, in cell C7") == -1);
    assertEquals(ConversionMessageType.WARNING, result.getMessages().get(1).getMessageType());
    assertFalse(result.getMessages().get(1).getMessage().indexOf("Priority is not an integer literal, in cell C8") == -1);
    // Check basics
    List<GuidedDecisionTable52> dtables = listener.getGuidedDecisionTables();
    assertNotNull(dtables);
    assertEquals(1, dtables.size());
    GuidedDecisionTable52 dtable = dtables.get(0);
    assertEquals("SalienceWarningsTest", dtable.getTableName());
    assertEquals(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY, dtable.getTableFormat());
    // Check expanded columns
    List<BaseColumn> columns = dtable.getExpandedColumns();
    assertNotNull(columns);
    assertEquals(3, columns.size());
    assertTrue(columns.get(0) instanceof RowNumberCol52);
    assertTrue(columns.get(1) instanceof DescriptionCol52);
    assertTrue(columns.get(2) instanceof AttributeCol52);
    // Check attribute column
    AttributeCol52 attrCol2 = ((AttributeCol52) columns.get(2));
    assertEquals(GuidedDecisionTable52.SALIENCE_ATTR, attrCol2.getAttribute());
    assertFalse(attrCol2.isUseRowNumber());
    assertFalse(attrCol2.isReverseOrder());
    // Check data
    assertEquals(2, dtable.getData().size());
    assertTrue(isRowEquivalent(new Object[] { 1, "Rule 1", 0 }, dtable.getData().get(0)));
    assertTrue(isRowEquivalent(new Object[] { 2, "Rule 2", 0 }, dtable.getData().get(1)));
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) ConversionResult(org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ExcelParser(org.drools.decisiontable.parser.xls.ExcelParser) DataListener(org.drools.template.parser.DataListener) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 19 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.

the class GuidedDecisionTableActivationGroupBuilder method populateDecisionTable.

@Override
public void populateDecisionTable(final GuidedDecisionTable52 dtable, final int maxRowCount) {
    final AttributeCol52 column = new AttributeCol52();
    column.setAttribute(GuidedDecisionTable52.ACTIVATION_GROUP_ATTR);
    dtable.getAttributeCols().add(column);
    if (this.values.size() < maxRowCount) {
        for (int iRow = this.values.size(); iRow < maxRowCount; iRow++) {
            this.values.add(new DTCellValue52(""));
        }
    }
    addColumnData(dtable, column);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 20 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.

the class GuidedDecisionTableAgendaGroupBuilder method populateDecisionTable.

@Override
public void populateDecisionTable(final GuidedDecisionTable52 dtable, final int maxRowCount) {
    final AttributeCol52 column = new AttributeCol52();
    column.setAttribute(GuidedDecisionTable52.AGENDA_GROUP_ATTR);
    dtable.getAttributeCols().add(column);
    if (this.values.size() < maxRowCount) {
        for (int iRow = this.values.size(); iRow < maxRowCount; iRow++) {
            this.values.add(new DTCellValue52(""));
        }
    }
    addColumnData(dtable, column);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Aggregations

AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)86 Test (org.junit.Test)55 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)30 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)20 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)14 ArrayList (java.util.ArrayList)12 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)12 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)10 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)10 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)9 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)8 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)8 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)7 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 ExcelParser (org.drools.decisiontable.parser.xls.ExcelParser)6 DataListener (org.drools.template.parser.DataListener)6 ConversionResult (org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult)6 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)5 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)5