Search in sources :

Example 1 with DescrBuildWarning

use of org.drools.compiler.compiler.DescrBuildWarning in project drools by kiegroup.

the class KnowledgeBuilderImpl method dumpGeneratedRule.

private void dumpGeneratedRule(PackageDescr descr, String resName, String src) {
    File dumpDir = this.configuration.getDumpDir();
    if (dumpDir != null) {
        try {
            String dirName = dumpDir.getCanonicalPath().endsWith("/") ? dumpDir.getCanonicalPath() : dumpDir.getCanonicalPath() + "/";
            String outputPath = dirName + resName + ".drl";
            try (FileOutputStream fos = new FileOutputStream(outputPath)) {
                fos.write(src.getBytes());
            } catch (IOException iox) {
                this.addBuilderResult(new DescrBuildWarning(null, descr, descr.getResource(), "Unable to write generated rules the dump directory: " + outputPath));
            }
        } catch (IOException e) {
            this.addBuilderResult(new DescrBuildWarning(null, descr, descr.getResource(), "Unable to access the dump directory"));
        }
    }
}
Also used : DescrBuildWarning(org.drools.compiler.compiler.DescrBuildWarning) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) DSLMappingFile(org.drools.compiler.lang.dsl.DSLMappingFile) DSLTokenizedMappingFile(org.drools.compiler.lang.dsl.DSLTokenizedMappingFile) File(java.io.File)

Aggregations

File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 DescrBuildWarning (org.drools.compiler.compiler.DescrBuildWarning)1 DSLMappingFile (org.drools.compiler.lang.dsl.DSLMappingFile)1 DSLTokenizedMappingFile (org.drools.compiler.lang.dsl.DSLTokenizedMappingFile)1