Examples of IRSession


Examples of com.dtrules.session.IRSession

                state.find(table).execute(state);
            }catch(NullPointerException e){
                throw new RulesException("undefined", "PerformCatchError",
                        "The table '"+table.stringValue()+"' is undefined");
            }catch(RulesException e){
                IRSession     session       = state.getSession();
                EntityFactory ef            = session.getEntityFactory();  
                IREntity      errorEntity   = ef.findRefEntity(error).clone(session).rEntityValue();
                state.entitypush(errorEntity);
               
                // If any of the following puts fail (because the given entity doesn't define them), then
                // simply carry on your merry way.  The user can define these fields if they need them,
View Full Code Here

Examples of com.dtrules.session.IRSession

                state.find(table).execute(state);
            }catch(NullPointerException e){
                throw new RulesException("undefined", "PerformCatchError",
                        "The table '"+table.stringValue()+"' is undefined");
            }catch(RulesException e){
                IRSession     session       = state.getSession();
                EntityFactory ef            = session.getEntityFactory();  
                IREntity      errorEntity   = ef.findRefEntity(error).clone(session).rEntityValue();
                state.entitypush(errorEntity);
               
                // If any of the following puts fail (because the given entity doesn't define them), then
                // simply carry on your merry way.  The user can define these fields if they need them,
View Full Code Here

Examples of com.dtrules.session.IRSession

             
              out        = new PrintStream     (getOutputDirectory()+root+"_results.xml");
              if(Trace()){
                tracefile  = new FileOutputStream(getOutputDirectory()+root+"_trace.xml");
              }
              IRSession      session    = rs.newSession();
              DTState        state      = session.getState();
              state.setOutput(tracefile, out);
              if(Trace()){
                  state.setState(DTState.DEBUG | DTState.TRACE | DTState.VERBOSE);
                  state.traceStart();
              }
              // Get the XML mapping for the rule set, and load a set of data into the EDD
                 
              loadData(session, path, dataset);
             
              if(Verbose()){
                  datamap.print(new FileOutputStream(getOutputDirectory()+root+"_datamap.xml"));
                 
                  entityfile = new FileOutputStream(getOutputDirectory()+root+"_entities_before.xml");
                  RArray entitystack = new RArray(0,false,false);
                  for(int i=0; i< session.getState().edepth()-2; i++){
                      entitystack.add(session.getState().entityfetch(i));
                  }
                  session.printEntityReport(new XMLPrinter(entityfile), false, session.getState(), "entitystack", entitystack);
              }
             
              // Once the data is loaded, execute the rules.
              RulesException ex = null;
              try{
                  executeDecisionTables(session);
              }catch(RulesException e){
                  ex = e;
              }
             
              // Then if asked, dump the entities.
              if(Verbose()){
                  entityfile = new FileOutputStream(getOutputDirectory()+root+"_entities_after.xml");
                  RArray entitystack = new RArray(0,false,false);
                  for(int i=0; i< session.getState().edepth()-2; i++){
                      entitystack.add(session.getState().entityfetch(i));
                  }
                  session.printEntityReport(new XMLPrinter(entityfile), false, session.getState(), "entitystack", entitystack);
               }
             
              if(ex!=null)throw ex;
             
              // Print the report
              try{
                 printReport(dfcnt, session, out);
              }catch(Throwable e){
                 if(!Console()){                    // If we are going to the console, assume the same
                                                    // error will get thrown, so don't print twice.   
                     System.out.println(e.toString());
                 }
              }
             
              // If asked, print the report again to the console.
              if(Console()){
                  try{
                      printReport(dfcnt, session,System.out);
                  }catch(Throwable e){
                      System.out.println(e.toString());
                   }
              }

            
             
              if(Trace()){
                  session.getState().traceEnd();
              }
            
          } catch ( Exception ex ) {
              System.out.print("<-ERR  ");
              if(Console()){
View Full Code Here

Examples of com.dtrules.session.IRSession

                state.find(table).execute(state);
            }catch(NullPointerException e){
                throw new RulesException("undefined", "PerformCatchError",
                        "The table '"+table.stringValue()+"' is undefined");
            }catch(RulesException e){
                IRSession     session       = state.getSession();
                EntityFactory ef            = session.getEntityFactory();  
                IREntity      errorEntity   = ef.findRefEntity(error).clone(session).rEntityValue();
                state.entitypush(errorEntity);
               
                // If any of the following puts fail (because the given entity doesn't define them), then
                // simply carry on your merry way.  The user can define these fields if they need them,
View Full Code Here

Examples of com.dtrules.session.IRSession

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

Examples of com.dtrules.session.IRSession

    static int testcntfailed   = 0;
       
    public static void main(String args[]){
       
        String          file    = "c:\\eclipse\\workspace\\DTRules\\com.dtrules.testfiles\\DTRules.xml";
        IRSession       session;
        DTState         state;
        RulesDirectory  rd;
        RuleSet         rs;
       
        try {
            rd      = new RulesDirectory("",file);
            rs      = rd.getRuleSet(RName.getRName("test",true));
            session = rs.newSession();
            state   = session.getState();
        } catch (RulesException e1) {
            System.out.println("Failed to initialize the Rules Engine");
            return;
        }
       
        for(int i=0;i<tests.length;i+=2){
            try{
               session.execute(tests[i]);
               String result = state.datapop().stringValue();
               if(tests[i+1].equals(result.trim())){
                   state.debug("test: << "+tests[i]+" >> expected: "+tests[i+1]+" --passed\n");
               }else{
                   state.debug("test: << "+tests[i]+" >> expected: "+tests[i+1]+" result:"+result+" --FAILED\n");
View Full Code Here

Examples of com.dtrules.session.IRSession

   
    public void writeDecisionTables(String tables, String fields[], boolean ascending, int limit){
        try {
            RulesDirectory    rd    = new RulesDirectory(getPath(),getRulesDirectoryFile());
            RuleSet           rs    = rd.getRuleSet(getRuleSetName());
            IRSession         s     = rs.newSession();
            RulesAdminService admin = new RulesAdminService(s);
           
            Rules2Excel r2e = new Rules2Excel();
           
            r2e.writeExcel(admin, rs, tables, fields, ascending, limit);
View Full Code Here

Examples of com.dtrules.session.IRSession

            out        = new PrintStream     (getOutputDirectory()+number+root+"_results.xml");
              if(Trace()){
                  tracefile  = new FileOutputStream(getOutputDirectory()+number+root+"_trace.xml");
              }
              IRSession      session    = rs.newSession();
              DTState        state      = session.getState();
              state.setOutput(tracefile, out);
              if(Trace()){
                  state.setState(DTState.DEBUG | DTState.TRACE);
                  if(Verbose()){
                      state.setState(DTState.VERBOSE);
                  }
                  state.traceStart();
              }
              // Get the XML mapping for the rule set, and load a set of data into the EDD
                 
              loadData(session, path, dataset);
             
              if(Verbose()){
                if(harnessVersion() < 2){
                     datamap.print(new FileOutputStream(getOutputDirectory()+number+root+"_datamap.xml"));
                }else{
                 autoDataMap.printDataLoadXML(new FileOutputStream(getOutputDirectory()+number+root+"_datamap.xml"));
                }
                  entityfile = new FileOutputStream(getOutputDirectory()+number+root+"_entities_before.xml");
                  RArray entitystack = new RArray(0,false,false);
                  for(int i=0; i< session.getState().edepth()-2; i++){
                      entitystack.add(session.getState().entityfetch(i));
                  }
                  session.printEntityReport(new XMLPrinter(entityfile), false, false, session.getState(), "entitystack", entitystack);
              }
             
              // Once the data is loaded, execute the rules.
              RulesException ex = null;
              try{
                  executeDecisionTables(session);
              }catch(RulesException e){
                  ex = e;
              }
             
              // Then if asked, dump the entities.
              if(Verbose()){
                  entityfile = new FileOutputStream(getOutputDirectory()+number+root+"_entities_after.xml");
                  RArray entitystack = new RArray(0,false,false);
                  for(int i=0; i< session.getState().edepth()-2; i++){
                      entitystack.add(session.getState().entityfetch(i));
                  }
                  session.printEntityReport(new XMLPrinter(entityfile),false, false, session.getState(), "entitystack", entitystack);
               }
             
              if(ex!=null)throw ex;
             
              // Print the report
              try{
                 printReport(dfcnt, session, out);
              }catch(Throwable e){
                 if(!Console()){                    // If we are going to the console, assume the same
                                                    // error will get thrown, so don't print twice.   
                     System.out.println(e.toString());
                 }
              }
             
              // If asked, print the report again to the console.
              if(Console()){
                  try{
                      printReport(dfcnt, session,System.out);
                  }catch(Throwable e){
                      System.out.println(e.toString());
                   }
              }

            
             
              if(Trace()){
                  session.getState().traceEnd();
              }
            
          } catch ( Exception ex ) {
              System.out.print("<-ERR  ");
              if(Console()){
View Full Code Here

Examples of com.dtrules.session.IRSession

     */
    @SuppressWarnings("unchecked")
    public void compile(int NumErrorsToReport, PrintStream err) {
       
        try {
            IRSession session    = new RSession(ruleSet);
            Class  compilerClass = ruleSet.getDefaultCompiler();
            if(compilerClass == null){
              throw new RulesException("undefined", "Excel2XML", "No default compiler has been found." +
                  "  We cannot convert and compile the XML without one");
            }
            ICompiler defaultCompiler = (ICompiler) compilerClass.newInstance();
            defaultCompiler.setSession(session);

            ICompiler      compiler     = defaultCompiler;
                           dtcompiler   = new DTCompiler(compiler);
           
            InputStream    inDTStream   = new FileInputStream(ruleSet.getFilepath()+"/"+UDTFilename);
            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(),
View Full Code Here

Examples of com.dtrules.session.IRSession

                state.find(table).execute(state);
            }catch(NullPointerException e){
                throw new RulesException("undefined", "PerformCatchError",
                        "The table '"+table.stringValue()+"' is undefined");
            }catch(RulesException e){
                IRSession     session       = state.getSession();
                EntityFactory ef            = session.getEntityFactory();  
                IREntity      errorEntity   = ef.findRefEntity(error).clone(session).rEntityValue();
                state.entitypush(errorEntity);
               
                // If any of the following puts fail (because the given entity doesn't define them), then
                // simply carry on your merry way.  The user can define these fields if they need them,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.