Package com.dtrules.session

Examples of com.dtrules.session.RuleSet


       
        RulesDirectory rd      = new RulesDirectory(
            path+"repository/",      
            "DTRules.xml");
       
        RuleSet        rs      = rd.getRuleSet("SampleProject2");
       
        IRSession      session = rs.newSession();
       
        Mapping        mapping = session.getMapping();
       
        mapping.loadData(session, path+"testfiles/"+"TestCase_001.xml");
       
View Full Code Here


            path+"repository/",      
            "DTRules.xml");
       
        // The RuleSet is built by loading the XML for the project.  This is
        // done only once, and the results cached by the RulesDirectory.
        RuleSet        rs      = rd.getRuleSet("SampleProject2");
       
        // A Session creates an instance of a Rules Set.  The Rules Engine is
        // factored so that all the Rules Engine State is built off of the
        // DTState object in the Session.  The Rules Engine is Thread safe,
        // so multiple threads can have sessions that run against the same
        // Rule Set, and the only objects unique to a session is the DTState
        // object and objects it holds.
        IRSession      session = rs.newSession();
       
        // We are going to map the data into the session with the default mapping
        // defined by the RuleSet.  Generally a Rule Set will use only one
        // mapping file.  However, you can build other mapping files.
        Mapping        mapping = session.getMapping();
View Full Code Here

    /**
     * Updates the Decision Table XML specified in the RuleSet with the Decision Tables as
     * currently held in memory. 
     */
    public void saveDecisionTables(RSession session, String rulesetname) throws RulesException {
        RuleSet       rs       = rulesDirectory.getRuleSet(RName.getRName(rulesetname));
        String        filepath = rs.getFilepath();
        String        filename = rs.getDT_XMLName();
       
        OutputStream out;
        try {
            out = new FileOutputStream(filepath+filename);
        } catch (FileNotFoundException e) {
View Full Code Here

    public static void main(String args[]){
        String path = "C:\\eclipse\\workspace\\EB_POC\\new_york_EB\\xml\\";
        String file = path + "DTRules.xml";   
   
        RulesDirectory    rd      = new RulesDirectory("",file);
        RuleSet           rs      = rd.getRuleSet(RName.getRName("ebdemo"));
        RSession          session;
        try {
            OutputStream  out     = new FileOutputStream("c:\\temp\\dt.xml");
                          session = new RSession(rs);
            RulesAdminService admin   = new RulesAdminService(session, rd);
View Full Code Here

            System.out.println(e1.toString());
        }
    }

    public void saveEDD(RSession session, String rulesetname) throws RulesException {
        RuleSet       rs       = rulesDirectory.getRuleSet(RName.getRName(rulesetname));
        EntityFactory ef       = session.getEntityFactory();
        String        filepath = rs.getFilepath();
        String        filename = rs.getEDD_XMLName();
       
        OutputStream out;
        try {
            out = new FileOutputStream(filepath+filename);
        } catch (FileNotFoundException e) {
View Full Code Here

            OutputStream   outDTStream  = new FileOutputStream(ruleSet.getFilepath()+"/"+ruleSet.getDT_XMLName());
           
            dtcompiler.compile(inDTStream, outDTStream);
                       
            RulesDirectory  rd  = new RulesDirectory(path, rulesDirectoryXML);
            RuleSet         rs  = rd.getRuleSet(RName.getRName(ruleset));
            EntityFactory   ef  = rs.newSession().getEntityFactory();
            IREntity        dt  = ef.getDecisiontables();
            Iterator<RName> idt = ef.getDecisionTableRNameIterator();
           
            while(idt.hasNext()){
                RDecisionTable t = (RDecisionTable) dt.get(idt.next());
                t.build(session.getState());
                List<ICompilerError> errs = t.compile();
                for (ICompilerError error : errs){
                    dtcompiler.logError(
                            t.getName().stringValue(),
                            t.getFilename(),
                            "validity check",
                            error.getMessage(),
                            0,
                            "In the "+error.getErrorType().name()+" row "+error.getIndex()+"\r\n"+error.getSource());
                }
                Coordinate err_RowCol = t.validate();
                if(!t.isCompiled()  || err_RowCol!=null){
                    int column = 0;
                    int row    = 0;
                    if(err_RowCol!=null){
                        row    = err_RowCol.getRow();
                        column = err_RowCol.getCol();
                    }
                    dtcompiler.logError(
                            t.getName().stringValue(),
                            t.getFilename(),
                            "validity check",
                            "Decision Table did not compile",
                            0,
                            "A problem may have been found on row "+row+" and column "+column);
                }
            }
           
            dtcompiler.printErrors(err, NumErrorsToReport);
            err.println("Total Errors Found: "+dtcompiler.getErrors().size());
            if(dtcompiler.getErrors().size() == 0){
                rd  = new RulesDirectory(path, rulesDirectoryXML);
                rs  = rd.getRuleSet(RName.getRName(ruleset));
                PrintStream btables = new PrintStream(rs.getWorkingdirectory()+"balanced.txt");
                rs.newSession().printBalancedTables(btables);
                RulesAdminService admin = new RulesAdminService(rs.newSession(),rd);
                List tables = admin.getDecisionTables(rs.getName());
                for(Object table : tables){
                   RDecisionTable dtable = admin.getDecisionTable(rs.getName(),(String)table);
                   dtable.check(System.out);
                }
            }
        } catch (Exception e) {
            err.print(e);
View Full Code Here

     * @param filename  File name for the mapping file generated
     * @throws Exception
     */
    @Deprecated
    public void generateMap(String mapping, String filename) throws Exception {
        RuleSet        rs   = getRuleSet();
        IMapGenerator   mgen = new MapGenerator();          
        mgen.generateMapping(
                mapping,
                rs.getFilepath()+rs.getEDD_XMLName(),
                rs.getWorkingdirectory()+"map.xml");
    }
View Full Code Here

     * @param filename  File name for the mapping file generated
     * @throws Exception
     */
    public void generateMap(int version, String mapping, String filename) throws Exception {
        filename = filename.trim();
        RuleSet        rs   = getRuleSet();
        IMapGenerator   mgen;
        if(version == 1){
            mgen = new MapGenerator();
        }else{
            mgen = new MapGenerator2();
        }
        if(!filename.toLowerCase().endsWith(".xml")){
            filename += ".xml";
        }
        mgen.generateMapping(
                mapping,
                rs.getFilepath()+rs.getEDD_XMLName(),
                rs.getWorkingdirectory()+filename);
    }
View Full Code Here

            file = args[0];
        }
       
        try {
            RulesDirectory rd       = new RulesDirectory(path,file);
            RuleSet        rs       = rd.getRuleSet(RName.getRName("ebdemo"));
            IRSession      session  = rs.newSession();
            DecisionTableTypeTest test;
           
            test = new DecisionTableTypeTest(session,rs);
            test.dt.setType(RDecisionTable.Type.FIRST);
            test.dt.build(session.getState());
View Full Code Here

            OutputStream   outDTStream  = new FileOutputStream(ruleSet.getFilepath()+"/"+ruleSet.getDT_XMLName());
           
            dtcompiler.compile(inDTStream, outDTStream);
                       
            RulesDirectory  rd  = new RulesDirectory(path, rulesDirectoryXML);
            RuleSet         rs  = rd.getRuleSet(RName.getRName(ruleset));
            EntityFactory   ef  = rs.newSession().getEntityFactory();
            IREntity        dt  = ef.getDecisiontables();
            Iterator<RName> idt = ef.getDecisionTableRNameIterator();
           
            while(idt.hasNext()){
                RDecisionTable t = (RDecisionTable) dt.get(idt.next());
                t.build(session.getState());
                List<IDecisionTableError> errs = t.compile();
                for (IDecisionTableError error : errs){
                    dtcompiler.logError(
                            t.getName().stringValue(),
                            t.getFilename(),
                            "validity check",
                            error.getMessage(),
                            0,
                            "In the "+error.getErrorType().name()+" row "+error.getIndex()+"\r\n"+error.getSource());
                }
                Coordinate err_RowCol = t.validate();
                if(!t.isCompiled()  || err_RowCol!=null){
                    int column = 0;
                    int row    = 0;
                    if(err_RowCol!=null){
                        row    = err_RowCol.getRow();
                        column = err_RowCol.getCol();
                    }
                    dtcompiler.logError(
                            t.getName().stringValue(),
                            t.getFilename(),
                            "validity check",
                            "Decision Table did not compile",
                            0,
                            "A problem may have been found on row "+row+" and column "+column);
                }
            }
           
            if(verbose) {
                dtcompiler.printErrors(err, NumErrorsToReport);
                err.println("Total Errors Found: "+dtcompiler.getErrors().size());
            }
            if(dtcompiler.getErrors().size() == 0){
                rd  = new RulesDirectory(path, rulesDirectoryXML);
                rs  = rd.getRuleSet(RName.getRName(ruleset));
                PrintStream btables = new PrintStream(rs.getWorkingdirectory()+"balanced.txt");
                rs.newSession().printBalancedTables(btables);

                if(verbose) {
                    RulesAdminService admin = new RulesAdminService(rs.newSession(),rd);
                    List<?> tables = admin.getDecisionTables(rs.getName());
                    for(Object table : tables){
                       RDecisionTable dtable = admin.getDecisionTable(rs.getName(),(String)table);
                       dtable.check(ostream);
                    }
                }
               
            }
View Full Code Here

TOP

Related Classes of com.dtrules.session.RuleSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.