Search in sources :

Example 61 with BRLActionVariableColumn

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

the class GuidedDecisionTableRHSBuilder method addLiteralColumn.

private List<BRLVariableColumn> addLiteralColumn(final LiteralValueBuilder vb) {
    final List<BRLVariableColumn> variableColumns = new ArrayList<BRLVariableColumn>();
    final BRLActionVariableColumn parameterColumn = new BRLActionVariableColumn("", DataType.TYPE_BOOLEAN);
    variableColumns.add(parameterColumn);
    // Store DRL fragment for use by GuidedDecisionTableRHSBuilder
    drlFragments.add(vb.getTemplate());
    return variableColumns;
}
Also used : BRLVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn) ArrayList(java.util.ArrayList) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 62 with BRLActionVariableColumn

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

the class GuidedDecisionTableRHSBuilder method addBRLFragmentColumn.

private List<BRLVariableColumn> addBRLFragmentColumn(final ParameterizedValueBuilder vb) {
    final List<BRLVariableColumn> variableColumns = new ArrayList<BRLVariableColumn>();
    for (String parameter : vb.getParameters()) {
        final BRLActionVariableColumn parameterColumn = new BRLActionVariableColumn(parameter, DataType.TYPE_OBJECT);
        variableColumns.add(parameterColumn);
    }
    // Store DRL fragment for use by GuidedDecisionTableRHSBuilder
    drlFragments.add(vb.getTemplate());
    return variableColumns;
}
Also used : BRLVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn) ArrayList(java.util.ArrayList) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 63 with BRLActionVariableColumn

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

the class DTCellValueWidgetFactoryTest method testGetWidgetEnumsForBRLColumn.

@Test
public void testGetWidgetEnumsForBRLColumn() throws Exception {
    BRLActionVariableColumn column = mock(BRLActionVariableColumn.class);
    doReturn("Person").when(column).getFactType();
    doReturn("name").when(column).getFactField();
    when(oracle.hasEnums("Person", "name")).thenReturn(true);
    IsWidget widget = factory.getWidget(column, cellValue);
    assertTrue(widget instanceof ListBox);
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) ListBox(org.gwtbootstrap3.client.ui.ListBox) Test(org.junit.Test)

Example 64 with BRLActionVariableColumn

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

the class DTCellValueWidgetFactoryTest method testGeTextBoxForBRLColumn.

@Test
public void testGeTextBoxForBRLColumn() throws Exception {
    BRLActionVariableColumn column = mock(BRLActionVariableColumn.class);
    doReturn("Person").when(column).getFactType();
    doReturn("name").when(column).getFactField();
    when(oracle.hasEnums("Person", "name")).thenReturn(false);
    IsWidget widget = factory.getWidget(column, cellValue);
    assertTrue(widget instanceof TextBox);
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) TextBox(org.gwtbootstrap3.client.ui.TextBox) Test(org.junit.Test)

Example 65 with BRLActionVariableColumn

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

the class GuidedDecisionTableGeneratorListenerTest method testTestNonExistentCellsFromPOI.

@Test
public // https://issues.jboss.org/browse/GUVNOR-2188
void testTestNonExistentCellsFromPOI() {
    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("GUVNOR-2188.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
    final List<GuidedDecisionTable52> dtables = listener.getGuidedDecisionTables();
    assertNotNull(dtables);
    assertEquals(1, dtables.size());
    final GuidedDecisionTable52 dtable = dtables.get(0);
    assertEquals("IdentifyMetadataRules", dtable.getTableName());
    assertEquals(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY, dtable.getTableFormat());
    // Check expanded columns
    List<BaseColumn> columns = dtable.getExpandedColumns();
    assertNotNull(columns);
    assertEquals(7, columns.size());
    assertTrue(columns.get(0) instanceof RowNumberCol52);
    assertTrue(columns.get(1) instanceof RuleNameColumn);
    assertTrue(columns.get(2) instanceof DescriptionCol52);
    assertTrue(columns.get(3) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(4) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(5) instanceof BRLConditionVariableColumn);
    assertTrue(columns.get(6) instanceof BRLActionVariableColumn);
    // Check individual condition columns
    assertEquals(1, dtable.getConditions().size());
    assertTrue(dtable.getConditions().get(0) instanceof BRLConditionColumn);
    // Column 1
    BRLConditionColumn conditionCol0 = ((BRLConditionColumn) dtable.getConditions().get(0));
    assertEquals("Converted from ['Ingest Path', 'Court Id', 'Artifact Metadata Identified']", conditionCol0.getHeader());
    assertEquals(3, conditionCol0.getChildColumns().size());
    List<IPattern> conditionCol0definition = conditionCol0.getDefinition();
    assertEquals(1, conditionCol0definition.size());
    assertTrue(conditionCol0definition.get(0) instanceof FactPattern);
    FactPattern conditionCol0fp = (FactPattern) conditionCol0definition.get(0);
    assertEquals("IdentifyMetadataArtifact", conditionCol0fp.getFactType());
    assertEquals(3, conditionCol0fp.getNumberOfConstraints());
    assertTrue(conditionCol0fp.getConstraint(0) instanceof SingleFieldConstraint);
    final SingleFieldConstraint conditionCol0fpsfc0 = (SingleFieldConstraint) conditionCol0fp.getConstraint(0);
    assertEquals("ingestPath", conditionCol0fpsfc0.getFieldName());
    assertEquals("==", conditionCol0fpsfc0.getOperator());
    assertEquals("param1", conditionCol0fpsfc0.getValue());
    assertEquals(SingleFieldConstraint.TYPE_TEMPLATE, conditionCol0fpsfc0.getConstraintValueType());
    assertEquals(DataType.TYPE_STRING, conditionCol0fpsfc0.getFieldType());
    assertTrue(conditionCol0fp.getConstraint(1) instanceof SingleFieldConstraint);
    final SingleFieldConstraint conditionCol0fpsfc1 = (SingleFieldConstraint) conditionCol0fp.getConstraint(1);
    assertEquals("courtId", conditionCol0fpsfc1.getFieldName());
    assertEquals("==", conditionCol0fpsfc1.getOperator());
    assertEquals("param2", conditionCol0fpsfc1.getValue());
    assertEquals(SingleFieldConstraint.TYPE_TEMPLATE, conditionCol0fpsfc1.getConstraintValueType());
    assertEquals(DataType.TYPE_STRING, conditionCol0fpsfc1.getFieldType());
    assertTrue(conditionCol0fp.getConstraint(2) instanceof SingleFieldConstraint);
    final SingleFieldConstraint conditionCol0fpsfc2 = (SingleFieldConstraint) conditionCol0fp.getConstraint(2);
    assertEquals("artifactMetadataIdentified", conditionCol0fpsfc2.getFieldName());
    assertEquals("==", conditionCol0fpsfc2.getOperator());
    assertEquals("param3", conditionCol0fpsfc2.getValue());
    assertEquals(SingleFieldConstraint.TYPE_TEMPLATE, conditionCol0fpsfc2.getConstraintValueType());
    assertEquals(DataType.TYPE_STRING, conditionCol0fpsfc2.getFieldType());
    // Column 1 - Variable 1
    BRLConditionVariableColumn conditionCol0param0 = conditionCol0.getChildColumns().get(0);
    assertEquals("param1", conditionCol0param0.getVarName());
    assertEquals("Ingest Path", conditionCol0param0.getHeader());
    assertEquals(DataType.TYPE_STRING, conditionCol0param0.getFieldType());
    assertEquals("IdentifyMetadataArtifact", conditionCol0param0.getFactType());
    assertEquals("ingestPath", conditionCol0param0.getFactField());
    // Column 1 - Variable 2
    BRLConditionVariableColumn conditionCol0param1 = conditionCol0.getChildColumns().get(1);
    assertEquals("param2", conditionCol0param1.getVarName());
    assertEquals("Court Id", conditionCol0param1.getHeader());
    assertEquals(DataType.TYPE_STRING, conditionCol0param1.getFieldType());
    assertEquals("IdentifyMetadataArtifact", conditionCol0param1.getFactType());
    assertEquals("courtId", conditionCol0param1.getFactField());
    // Column 1 - Variable 3
    BRLConditionVariableColumn conditionCol0param2 = conditionCol0.getChildColumns().get(2);
    assertEquals("param3", conditionCol0param2.getVarName());
    assertEquals("Artifact Metadata Identified", conditionCol0param2.getHeader());
    assertEquals(DataType.TYPE_STRING, conditionCol0param2.getFieldType());
    assertEquals("IdentifyMetadataArtifact", conditionCol0param2.getFactType());
    assertEquals("artifactMetadataIdentified", conditionCol0param2.getFactField());
    // Check individual action columns
    assertEquals(1, dtable.getActionCols().size());
    assertTrue(dtable.getActionCols().get(0) instanceof BRLActionColumn);
    // Column 2
    BRLActionColumn actionCol0 = ((BRLActionColumn) dtable.getActionCols().get(0));
    assertEquals("Converted from ['Identify Metadata Required']", actionCol0.getHeader());
    assertEquals(1, actionCol0.getChildColumns().size());
    List<IAction> actionCol0definition = actionCol0.getDefinition();
    assertEquals(1, actionCol0definition.size());
    assertTrue(actionCol0definition.get(0) instanceof ActionSetField);
    ActionSetField actionCol0asf = (ActionSetField) actionCol0definition.get(0);
    assertEquals("fact1", actionCol0asf.getVariable());
    assertEquals(1, actionCol0asf.getFieldValues().length);
    ActionFieldValue actionCol0asf_afv0 = actionCol0asf.getFieldValues()[0];
    assertEquals("identifiedMetadataRequired", actionCol0asf_afv0.getField());
    assertEquals("param4", actionCol0asf_afv0.getValue());
    assertEquals(FieldNatureType.TYPE_TEMPLATE, actionCol0asf_afv0.getNature());
    assertEquals(DataType.TYPE_STRING, actionCol0asf_afv0.getType());
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) IPattern(org.drools.workbench.models.datamodel.rule.IPattern) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ArrayList(java.util.ArrayList) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ExcelParser(org.drools.decisiontable.parser.xls.ExcelParser) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) IAction(org.drools.workbench.models.datamodel.rule.IAction) InputStream(java.io.InputStream) IOException(java.io.IOException) ConversionResult(org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult) ActionSetField(org.drools.workbench.models.datamodel.rule.ActionSetField) DataListener(org.drools.template.parser.DataListener) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) RuleNameColumn(org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Aggregations

BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)72 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)56 Test (org.junit.Test)41 ArrayList (java.util.ArrayList)28 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)28 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)23 IAction (org.drools.workbench.models.datamodel.rule.IAction)20 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)20 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)19 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)18 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)18 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)17 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)16 ActionInsertFact (org.drools.workbench.models.datamodel.rule.ActionInsertFact)13 RuleNameColumn (org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn)13 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)12 InputStream (java.io.InputStream)11 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)11 ConversionResult (org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult)11 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)11