public void addPackageFromXml( final Resource resource ) throws DroolsParserException, IOException { this.resource = resource; addPackage( xmlToPackageDescr(resource) ); this.resource = null; }
public void addPackageFromPMML(Resource resource, ResourceType type, ResourceConfiguration configuration) throws Exception { PMMLCompiler compiler = getPMMLCompiler(); if ( compiler != null ) { if ( compiler.getResults().isEmpty() ) { this.resource = resource; PackageDescr descr = pmmlModelToPackageDescr(compiler, resource); if ( descr != null ) { addPackage( descr ); } this.resource = null; } else { this.results.addAll( compiler.getResults() ); } compiler.clearResults(); } else { addPackageForExternalType( resource, type, configuration ); } }
public void addPackageFromDecisionTable( Resource resource, ResourceConfiguration configuration ) throws DroolsParserException, IOException { this.resource = resource; addPackage( decisionTableToPackageDescr(resource, configuration) ); this.resource = null; }
public void addPackageFromDrl( Resource resource ) throws DroolsParserException, IOException { this.resource = resource; addPackage( drlToPackageDescr(resource) ); this.resource = null; }
public void addPackageFromDslr( final Resource resource ) throws DroolsParserException, IOException { this.resource = resource; addPackage( dslrToPackageDescr(resource) ); this.resource = null; }
private PackageBuilder readRules() throws DroolsParserException, IOException { PackageBuilder packageBuilder = new PackageBuilder(); PackageBuilder intermPackageBuilder = null; listOfReader = dynamicRuleReader(); // Here goes your application code for(Reader reader : listOfReader){ try{ intermPackageBuilder = new PackageBuilder(); intermPackageBuilder.addPackage(reader); assertNoRuleErrors(intermPackageBuilder); // This is the core step. // Above line throws an exception, every time a rules fails. You can persist this exception for production debugging packageBuilder.addPackage(reader); }catch(DroolsParserException | IOException e){ logger.error("Rules contain error, so skip adding them to the Package Builder"); } } return packageBuilder; }
public void addPackageFromBrl( final Resource resource ) throws DroolsParserException { this.resource = resource; try { addPackage( brlToPackageDescr(resource) ); } catch (Exception e) { throw new DroolsParserException( e ); } finally { this.resource = null; } }
for( KnowledgePackage kpkg : pkgs ) { overrideReSource( ((KnowledgePackageImp)kpkg).pkg, resource ); addPackage(((KnowledgePackageImp) kpkg).pkg); addPackage( kpkg.pkg ); } else if( object instanceof Package ) { addPackage( pkg ); } else if( object instanceof Package[] ) { for( Package pkg : pkgs ) { overrideReSource( pkg, resource ); addPackage( pkg );
/** * Load a rule package from DRL source and associate all loaded artifacts * with the given resource. * * @param reader * @param sourceResource the source resource for the read artifacts * @throws DroolsParserException * @throws IOException */ public void addPackageFromDrl( final Reader reader, final Resource sourceResource ) throws DroolsParserException, IOException { this.resource = sourceResource; final DrlParser parser = new DrlParser(); final PackageDescr pkg = parser.parse( reader ); this.results.addAll( parser.getErrors() ); if (pkg == null) { this.results.add( new ParserError( sourceResource, "Parser returned a null Package", 0, 0 ) ); } if (!parser.hasErrors()) { addPackage( pkg ); } this.resource = null; }
/** * Load a rule package from DRL source using the supplied DSL configuration. * * @param source * The source of the rules. * @param dsl * The source of the domain specific language configuration. * @throws DroolsParserException * @throws IOException */ public void addPackageFromDrl( final Reader source, final Reader dsl ) throws DroolsParserException, IOException { this.resource = new ReaderResource( source, ResourceType.DSLR ); final DrlParser parser = new DrlParser(); final PackageDescr pkg = parser.parse( source, dsl ); this.results.addAll( parser.getErrors() ); if (!parser.hasErrors()) { addPackage( pkg ); } this.resource = null; }
pkgBuilder.addPackage( new PackageDescr( pkgName ) ); pkgReg = pkgBuilder.getPackageRegistry( pkgName );
builder.addPackage( packageDescr ); final Package pkg = builder.getPackage();
pkgBuilder.addPackage(new PackageDescr(packageName)); pkgReg = pkgBuilder.getPackageRegistry(packageName);
/** * Load a rule package from XML source. * * @param reader * @throws DroolsParserException * @throws IOException */ public void addPackageFromXml( final Reader reader ) throws DroolsParserException, IOException { this.resource = new ReaderResource( reader, ResourceType.XDRL ); final XmlPackageReader xmlReader = new XmlPackageReader( this.configuration.getSemanticModules() ); xmlReader.getParser().setClassLoader( this.rootClassLoader ); try { xmlReader.read( reader ); } catch (final SAXException e) { throw new DroolsParserException( e.toString(), e.getCause() ); } addPackage( xmlReader.getPackageDescr() ); this.resource = null; }