Search in sources :

Example 1 with SpreadsheetCompiler

use of org.drools.decisiontable.SpreadsheetCompiler in project drools-wb by kiegroup.

the class DecisionTableXLSServiceImpl method getSource.

@Override
public String getSource(final Path path) {
    InputStream inputStream = null;
    try {
        final SpreadsheetCompiler compiler = new SpreadsheetCompiler();
        inputStream = ioService.newInputStream(Paths.convert(path), StandardOpenOption.READ);
        final String drl = compiler.compile(inputStream, InputType.XLS);
        return drl;
    } catch (Exception e) {
        throw new SourceGenerationFailedException(e.getMessage());
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException ioe) {
                throw ExceptionUtilities.handleException(ioe);
            }
        }
    }
}
Also used : SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) SpreadsheetCompiler(org.drools.decisiontable.SpreadsheetCompiler) IOException(java.io.IOException) SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) InvalidFormatException(org.apache.poi.openxml4j.exceptions.InvalidFormatException) IOException(java.io.IOException) DecisionTableParseException(org.drools.template.parser.DecisionTableParseException)

Aggregations

FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvalidFormatException (org.apache.poi.openxml4j.exceptions.InvalidFormatException)1 SpreadsheetCompiler (org.drools.decisiontable.SpreadsheetCompiler)1 DecisionTableParseException (org.drools.template.parser.DecisionTableParseException)1 SourceGenerationFailedException (org.kie.workbench.common.services.shared.source.SourceGenerationFailedException)1