protected StatefulKnowledgeSession initNewKnowledgeSession() { StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession(); for ( int i = 0; i < columnList.length; i++ ) { session.insert( columnList[i] ); } session.fireAllRules(); return session; }
public void execute() throws Exception { if ( kbase != null ) { StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession(); for ( Row row : rowList ) { session.insert( row ); } session.fireAllRules(); Collection<Object> oList = session.getObjects( new ObjectFilter() { @Override public boolean accept( Object o ) { if ( o instanceof Row && !( (Row) o ).isExternalSource() ) { return true; } return false; } } ); for ( Object o : oList ) { resultList.add( (Row) o ); } session.dispose(); } }
public void initializeRules() { // To ensure the plugin classloader use for dependency resolution ClassLoader orig = Thread.currentThread().getContextClassLoader(); ClassLoader loader = getClass().getClassLoader(); Thread.currentThread().setContextClassLoader( loader ); Resource ruleSet = null; if ( ruleString != null ) { ruleSet = ResourceFactory.newReaderResource( new StringReader( ruleString ) ); } else { ruleSet = ResourceFactory.newFileResource( ruleFilePath ); } kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add( ruleSet, ResourceType.DRL ); if ( kbuilder.hasErrors() ) { System.out.println( kbuilder.getErrors().toString() ); throw new RuntimeException( BaseMessages.getString( PKG, "RulesData.Error.CompileDRL" ) ); } Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages(); kbase = KnowledgeBaseFactory.newKnowledgeBase(); // Cache the knowledge base as its creation is intensive kbase.addKnowledgePackages( pkgs ); // reset classloader back to original Thread.currentThread().setContextClassLoader( orig ); }
/** * Create a new KnowledgeBase using the given KnowledgeBaseConfiguration * @return * The KnowledgeBase */ public static KnowledgeBase newKnowledgeBase(KnowledgeBaseConfiguration conf) { return getKnowledgeBaseFactoryService().newKnowledgeBase( conf ); }
/** * Create a KnowledgeSessionConfiguration on which properties can be set. * @return * The KnowledgeSessionConfiguration. */ public static KnowledgeSessionConfiguration newKnowledgeSessionConfiguration() { return getKnowledgeBaseFactoryService().newKnowledgeSessionConfiguration(); }
/** * Create a KnowledgeBaseConfiguration on which properties can be set. * @return * The KnowledgeBaseConfiguration. */ public static KnowledgeBaseConfiguration newKnowledgeBaseConfiguration() { return getKnowledgeBaseFactoryService().newKnowledgeBaseConfiguration(); }
/** * Get the SystemEventListener * @return */ public static SystemEventListener getSystemEventListener() { return getSystemEventListenerService().getSystemEventListener(); }
/** * Set the SystemEventListener * * @param listener */ public static void setSystemEventListener(SystemEventListener listener) { getSystemEventListenerService().setSystemEventListener( listener ); }
public void initializeRules() { // To ensure the plugin classloader use for dependency resolution ClassLoader orig = Thread.currentThread().getContextClassLoader(); ClassLoader loader = getClass().getClassLoader(); Thread.currentThread().setContextClassLoader( loader ); Resource ruleSet = null; if ( ruleString != null ) { ruleSet = ResourceFactory.newReaderResource( new StringReader( ruleString ) ); } else { ruleSet = ResourceFactory.newFileResource( ruleFilePath ); } kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add( ruleSet, ResourceType.DRL ); if ( kbuilder.hasErrors() ) { System.out.println( kbuilder.getErrors().toString() ); throw new RuntimeException( BaseMessages.getString( PKG, "RulesData.Error.CompileDRL" ) ); } Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages(); kbase = KnowledgeBaseFactory.newKnowledgeBase(); // Cache the knowledge base as its creation is intensive kbase.addKnowledgePackages( pkgs ); // reset classloader back to original Thread.currentThread().setContextClassLoader( orig ); }
/** * Create a new KnowledgeBase using the default KnowledgeBaseConfiguration * @return * The KnowledgeBase */ public static KnowledgeBase newKnowledgeBase() { return getKnowledgeBaseFactoryService().newKnowledgeBase(); }
/** * Create a KnowledgeSessionConfiguration on which properties can be set. * @return * The KnowledgeSessionConfiguration. */ public static KnowledgeSessionConfiguration newKnowledgeSessionConfiguration(Properties properties) { return getKnowledgeBaseFactoryService().newKnowledgeSessionConfiguration( properties ); }
/** * Create a KnowledgeBaseConfiguration on which properties can be set. * @return * The KnowledgeBaseConfiguration. */ public static KnowledgeBaseConfiguration newKnowledgeBaseConfiguration() { return getKnowledgeBaseFactoryService().newKnowledgeBaseConfiguration(); }
/** * Get the SystemEventListener * @return */ public static SystemEventListener getSystemEventListener() { return getSystemEventListenerService().getSystemEventListener(); }
/** * Set the SystemEventListener * * @param listener */ public static void setSystemEventListener(SystemEventListener listener) { getSystemEventListenerService().setSystemEventListener( listener ); }
/** * Create a new KnowledgeBase using the given KnowledgeBaseConfiguration * @return * The KnowledgeBase */ public static KnowledgeBase newKnowledgeBase(KnowledgeBaseConfiguration conf) { return getKnowledgeBaseFactoryService().newKnowledgeBase( conf ); }
/** * Create a KnowledgeSessionConfiguration on which properties can be set. * @return * The KnowledgeSessionConfiguration. */ public static KnowledgeSessionConfiguration newKnowledgeSessionConfiguration(Properties properties) { return getKnowledgeBaseFactoryService().newKnowledgeSessionConfiguration( properties ); }
/** * Create a KnowledgeBaseConfiguration on which properties can be set. Use * the given properties file and ClassLoader - either of which can be null. * @return * The KnowledgeBaseConfiguration. */ public static KnowledgeBaseConfiguration newKnowledgeBaseConfiguration(Properties properties, ClassLoader... classLoaders) { return getKnowledgeBaseFactoryService().newKnowledgeBaseConfiguration( properties, classLoaders ); }
/** * Create a new KnowledgeBase using the default KnowledgeBaseConfiguration * @return * The KnowledgeBase */ public static KnowledgeBase newKnowledgeBase() { return getKnowledgeBaseFactoryService().newKnowledgeBase(); }
/** * Create a KnowledgeSessionConfiguration on which properties can be set. * @return * The KnowledgeSessionConfiguration. */ public static KnowledgeSessionConfiguration newKnowledgeSessionConfiguration(Properties properties) { return getKnowledgeBaseFactoryService().newKnowledgeSessionConfiguration( properties ); }
/** * Create a KnowledgeSessionConfiguration on which properties can be set. * @return * The KnowledgeSessionConfiguration. */ public static KnowledgeSessionConfiguration newKnowledgeSessionConfiguration() { return getKnowledgeBaseFactoryService().newKnowledgeSessionConfiguration(); }