Search in sources :

Example 1 with SourceGenerationFailedException

use of org.kie.workbench.common.services.shared.source.SourceGenerationFailedException 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)

Example 2 with SourceGenerationFailedException

use of org.kie.workbench.common.services.shared.source.SourceGenerationFailedException in project drools-wb by kiegroup.

the class GuidedRuleDSLRSourceService method getSource.

@Override
public String getSource(final Path path, final RuleModel model) throws SourceGenerationFailedException {
    try {
        final String dslr = RuleModelDRLPersistenceImpl.getInstance().marshal(model);
        final Expander expander = getDSLExpander(path);
        final String drl = expander.expand(dslr);
        return drl;
    } catch (Exception e) {
        throw new SourceGenerationFailedException(e.getMessage());
    }
}
Also used : SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) DefaultExpander(org.drools.compiler.lang.dsl.DefaultExpander) Expander(org.drools.compiler.lang.Expander) SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) IOException(java.io.IOException)

Example 3 with SourceGenerationFailedException

use of org.kie.workbench.common.services.shared.source.SourceGenerationFailedException in project drools-wb by kiegroup.

the class GuidedDecisionTableSourceService method getSource.

@Override
public String getSource(final Path path, final GuidedDecisionTable52 model) throws SourceGenerationFailedException {
    try {
        final String dslr = GuidedDTDRLPersistence.getInstance().marshal(model);
        final Expander expander = getDSLExpander(path);
        final String drl = expander.expand(dslr);
        return drl;
    } catch (Exception e) {
        throw new SourceGenerationFailedException(e.getMessage());
    }
}
Also used : SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) DefaultExpander(org.drools.compiler.lang.dsl.DefaultExpander) Expander(org.drools.compiler.lang.Expander) SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) IOException(java.io.IOException)

Example 4 with SourceGenerationFailedException

use of org.kie.workbench.common.services.shared.source.SourceGenerationFailedException in project drools-wb by kiegroup.

the class GuidedRuleTemplateSourceService method getSource.

@Override
public String getSource(final Path path, final TemplateModel model) throws SourceGenerationFailedException {
    try {
        if (model == null) {
            return "";
        } else {
            final String dslr = RuleTemplateModelDRLPersistenceImpl.getInstance().marshal(model);
            final Expander expander = getDSLExpander(path);
            final String drl = expander.expand(dslr);
            return drl;
        }
    } catch (Exception e) {
        throw new SourceGenerationFailedException(e.getMessage());
    }
}
Also used : SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) DefaultExpander(org.drools.compiler.lang.dsl.DefaultExpander) Expander(org.drools.compiler.lang.Expander) SourceGenerationFailedException(org.kie.workbench.common.services.shared.source.SourceGenerationFailedException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)4 SourceGenerationFailedException (org.kie.workbench.common.services.shared.source.SourceGenerationFailedException)4 Expander (org.drools.compiler.lang.Expander)3 DefaultExpander (org.drools.compiler.lang.dsl.DefaultExpander)3 FileInputStream (java.io.FileInputStream)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