dss/src/main/java/gov/samhsa/c2s/brms/service/RuleExecutionServiceImpl.java
StatefulKnowledgeSession createStatefulKnowledgeSession() {
        StatefulKnowledgeSession session = null;
        try {
            final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
                    .newKnowledgeBuilder();

            final String casRules = guvnorService
                    .getVersionedRulesFromPackage();

            kbuilder.add(
                    ResourceFactory.newByteArrayResource(casRules.getBytes()),
                    ResourceType.DRL);

            final KnowledgeBuilderErrors errors = kbuilder.getErrors();
            if (errors.size() > 0) {
                for (final KnowledgeBuilderError error : errors) {
                    logger.error(error.toString());
                }
            }

            final KnowledgeBase knowledgeBase = KnowledgeBaseFactory
                    .newKnowledgeBase();
            knowledgeBase.addKnowledgePackages(kbuilder.getKnowledgePackages());

            session = knowledgeBase.newStatefulKnowledgeSession();
            session.setGlobal("ruleExecutionContainer",
                    new RuleExecutionContainer());
        } catch (final Exception e) {
            logger.error(e.toString(), e);
        }
        return session;
    }
/**
     * Creates the stateful knowledge session.
     *
     * @return the stateful knowledge session
     */
Creates the stateful knowledge session.
@return the stateful knowledge session
Creates the stateful knowledge session . @return the stateful knowledge session
StatefulKnowledgeSession createStatefulKnowledgeSession() {
        StatefulKnowledgeSession session = null;
        try {
            final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
                    .newKnowledgeBuilder();
            final String casRules = guvnorService
                    .getVersionedRulesFromPackage();
            kbuilder.add(
                    ResourceFactory.newByteArrayResource(casRules.getBytes()),
                    ResourceType.DRL);
            final KnowledgeBuilderErrors errors = kbuilder.getErrors();
            if (errors.size() > 0) {
                for (final KnowledgeBuilderError error : errors) {
                    logger.error(error.toString());
                }
            }
            final KnowledgeBase knowledgeBase = KnowledgeBaseFactory
                    .newKnowledgeBase();
            knowledgeBase.addKnowledgePackages(kbuilder.getKnowledgePackages());
            session = knowledgeBase.newStatefulKnowledgeSession();
            session.setGlobal("ruleExecutionContainer",
                    new RuleExecutionContainer());
        } catch (final Exception e) {
            logger.error(e.toString(), e);
        }
        return session;
    }
StatefulKnowledgeSession createStatefulKnowledgeSession ( ) { StatefulKnowledgeSession session = null ; try { final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory . newKnowledgeBuilder ( ) ; final String casRules = guvnorService . getVersionedRulesFromPackage ( ) ; kbuilder . add ( ResourceFactory . newByteArrayResource ( casRules . getBytes ( ) ) , ResourceType . DRL ) ; final KnowledgeBuilderErrors errors = kbuilder . getErrors ( ) ; if ( errors . size ( ) > 0 ) { for ( final KnowledgeBuilderError error : errors ) { logger . error ( error . toString ( ) ) ; } } final KnowledgeBase knowledgeBase = KnowledgeBaseFactory . newKnowledgeBase ( ) ; knowledgeBase . addKnowledgePackages ( kbuilder . getKnowledgePackages ( ) ) ; session = knowledgeBase . newStatefulKnowledgeSession ( ) ; session . setGlobal ( "ruleExecutionContainer" , new RuleExecutionContainer ( ) ) ; } catch ( final Exception e ) { logger . error ( e . toString ( ) , e ) ; } return session ; }
Creates the stateful knowledge session.
Creates the stateful knowledge session .