Search in sources :

Example 6 with DecisionTableParseException

use of org.drools.template.parser.DecisionTableParseException in project drools by kiegroup.

the class LhsBuilder method addCellValue.

public void addCellValue(int row, int column, String value) {
    this.hasValues = true;
    Integer key = new Integer(column);
    String content = this.constraints.get(key);
    if (content == null) {
        throw new DecisionTableParseException("No code snippet for CONDITION in cell " + RuleSheetParserUtil.rc2name(this.headerRow + 2, this.headerCol));
    }
    SnippetBuilder snip = new SnippetBuilder(content);
    String result = snip.build(fixValue(column, value));
    this.values.add(result);
}
Also used : DecisionTableParseException(org.drools.template.parser.DecisionTableParseException) SnippetBuilder(org.drools.template.model.SnippetBuilder)

Example 7 with DecisionTableParseException

use of org.drools.template.parser.DecisionTableParseException in project drools by kiegroup.

the class RhsBuilder method addCellValue.

public void addCellValue(int row, int column, String value) {
    hasValues = true;
    String template = (String) this.templates.get(new Integer(column));
    if (template == null) {
        throw new DecisionTableParseException("No code snippet for " + this.actionTypeCode + ", above cell " + RuleSheetParserUtil.rc2name(this.headerRow + 2, this.headerCol));
    }
    SnippetBuilder snip = new SnippetBuilder(template);
    this.values.add(snip.build(value));
}
Also used : DecisionTableParseException(org.drools.template.parser.DecisionTableParseException) SnippetBuilder(org.drools.template.model.SnippetBuilder)

Example 8 with DecisionTableParseException

use of org.drools.template.parser.DecisionTableParseException in project drools by kiegroup.

the class CsvParser method parseFile.

public void parseFile(final InputStream inStream) {
    final BufferedReader reader = new BufferedReader(new InputStreamReader(inStream, IoUtils.UTF8_CHARSET));
    try {
        startSheet();
        processRows(reader);
        finishSheet();
    } catch (final IOException e) {
        throw new DecisionTableParseException("An error occurred reading the CSV data.", e);
    }
}
Also used : DecisionTableParseException(org.drools.template.parser.DecisionTableParseException) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException)

Example 9 with DecisionTableParseException

use of org.drools.template.parser.DecisionTableParseException in project drools by kiegroup.

the class RuleWorksheetParseTest method testMissingCodeSnippetAction.

/**
 * Must have a code snippet in an action.
 */
@Test
public void testMissingCodeSnippetAction() {
    try {
        makeRuleSet();
        makeRuleTable();
        makeRow(11, "C", "A");
        makeRow(12, "foo: Foo", "Bar()");
        makeRow(13, "attr == $param");
        makeRow(15, "1", "1");
        makeRow(16, "2", "2");
        listener.finishSheet();
        Package p = listener.getRuleSet();
        DRLOutput dout = new DRLOutput();
        p.renderDRL(dout);
        String drl = dout.getDRL();
        System.out.println(drl);
        fail("should have failed");
    } catch (DecisionTableParseException e) {
        String badCell = RuleSheetParserUtil.rc2name(13, 2);
        System.err.println(e.getMessage());
        assertTrue(e.getMessage().contains(badCell));
    }
}
Also used : DRLOutput(org.drools.template.model.DRLOutput) DecisionTableParseException(org.drools.template.parser.DecisionTableParseException) Package(org.drools.template.model.Package) Test(org.junit.Test)

Example 10 with DecisionTableParseException

use of org.drools.template.parser.DecisionTableParseException in project drools by kiegroup.

the class RuleWorksheetParseTest method testSalienceOutOfRange.

@Test
public void testSalienceOutOfRange() throws Exception {
    // DROOLS-1225
    final InputStream stream = RuleWorksheetParseTest.class.getResourceAsStream("/data/SalienceOutOfRangeWorkbook.xls");
    try {
        final RuleSheetListener listener = getRuleSheetListener(stream);
        fail("should have failed");
    } catch (DecisionTableParseException e) {
    }
}
Also used : DecisionTableParseException(org.drools.template.parser.DecisionTableParseException) InputStream(java.io.InputStream) Test(org.junit.Test)

Aggregations

DecisionTableParseException (org.drools.template.parser.DecisionTableParseException)13 Test (org.junit.Test)4 Package (org.drools.template.model.Package)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 DRLOutput (org.drools.template.model.DRLOutput)2 Global (org.drools.template.model.Global)2 Rule (org.drools.template.model.Rule)2 SnippetBuilder (org.drools.template.model.SnippetBuilder)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1 Consumer (java.util.function.Consumer)1 Event (javax.enterprise.event.Event)1 IOUtils (org.apache.commons.io.IOUtils)1