Examples of IRSession


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(false);
           
            r2e.writeExcel(admin, rs, tables, fields, ascending, limit);
View Full Code Here

Examples of com.dtrules.session.IRSession

            out        = new PrintStream     (getOutputDirectory(rs)+number+root+"_results.xml");
              if(Trace()){
                  tracefile  = new FileOutputStream(getOutputDirectory(rs)+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(rs)+number+root+"_datamap.xml"));
                }else{
                 autoDataMap.printDataLoadXML(new FileOutputStream(getOutputDirectory(rs)+number+root+"_datamap.xml"));
                }
                  entityfile = new FileOutputStream(getOutputDirectory(rs)+number+root+"_entities_before.xml");
                  RArray entitystack = RArray.newArray(session,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(rs)+number+root+"_entities_after.xml");
                  RArray entitystack = RArray.newArray(session,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.   
                     ostream.println(e.toString());
                 }
              }
             
              // If asked, print the report again to the console.
              if(Console()){
                  try{
                      printReport(dfcnt, session,ostream);
                  }catch(Throwable e){
                      ostream.println(e.toString());
                   }
              }

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

Examples of com.dtrules.session.IRSession

     * @return
     * @throws RulesException
     */
    static private IRObject compile(RuleSet ruleset, SimpleTokenizer tokenizer, String v, boolean executable, int depth) throws RulesException {       
       try{
         IRSession session  = ruleset.newSession();
           RArray   result    = RArray.newArray(session,true,executable);
           Token    token;   
       while((token=tokenizer.nextToken())!=null){
         if(token.getType()== Token.Type.STRING) {
                          IRObject rs = RString.newRString(token.strValue);
View Full Code Here

Examples of com.dtrules.session.IRSession

        }
    }
   
    @SuppressWarnings("unchecked")
  private void initTables() throws RulesException {
        IRSession session = rs.newSession();
        RulesAdminService admin = new RulesAdminService(session,rs.getRulesDirectory());
        List tables = admin.getDecisionTables(rs.getName());
       
        for(Object table : tables){
            RDecisionTable dt = admin.getDecisionTable(rs.getName(),(String)table);
View Full Code Here

Examples of com.dtrules.session.IRSession

        RulesDirectory rd = new RulesDirectory(
                System.getProperty("user.dir") + "/../sampleprojects/CHIP/",
                "DTRules.xml");

        RuleSet   rs = rd.getRuleSet("CHIP");
        IRSession s  = trace.setState(rs, t);
       
        if (s == null) {
            System.out.println("Could not build a session.");
            return;
        }
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();
           
            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

Examples of com.dtrules.session.IRSession

     
        String          path    = System.getProperty("user.dir")+"/";
        String          config  = "DTRules_eBooks.xml";
        RulesDirectory  rd      = new RulesDirectory(path, config);
                        rs      = rd.getRuleSet(testObj.getRuleSetName());
        IRSession       session = rs.newSession();

        try{
            ostream.println("Clearing away old tests");
            // Delete old output files
            File dirx         = new File(testObj.getTestDirectory(rs));
            if(!dirx.exists()){
                dirx.mkdirs();
            }
            File oldOutput[] = dirx.listFiles();
            for(File file : oldOutput){
               file.delete();
            }
        }catch(Exception e){
            throw new RuntimeException(e);
        }
        try {
            ostream.println("Generating "+numCases+" Tests");
            int inc = 100;
            if(inc < 100) inc = 1;
            if(inc < 1000) inc = 10;
            int lines = inc*10;
           
            for(int i=1;i<=numCases; i++){
                if(i>0 && i%inc   ==0 )ostream.print(i+" ");
                if(i>0 && i%lines ==0 )ostream.print("\n");
                OutputStream out = new FileOutputStream(filename(name,numCases,i));
                DataMap datamap = session.getDataMap(session.getMapping(),testObj.getRuleSetName());
               
                DataObj request = generate();
                request.write2DataMap(datamap);
                datamap.print(out);
            }
View Full Code Here

Examples of com.dtrules.session.IRSession

    String          path    = System.getProperty("user.dir")+"/";
    String          config  = "DTRules_eBooks.xml";
        RulesDirectory  rd      = new RulesDirectory(path, config);
                        rs      = rd.getRuleSet(ruleset);
        IRSession       session = rs.newSession();

        try{
            ostream.println("Clearing away old tests");
            // Delete old output files
            File dir         = new File(testObj.getTestDirectory(rs));
            if(!dir.exists()){
                dir.mkdirs();
            }
            File oldOutput[] = dir.listFiles();
            for(File file : oldOutput){
               file.delete();
            }
        }catch(Exception e){
            throw new RuntimeException(e);
        }
       
    try {
      ostream.println("Generating "+numCases+" Tests");
      int inc = 100;
      if(inc < 100) inc = 1;
      if(inc < 1000) inc = 10;
      int lines = inc*10;
     
      for(int i=1;i<=numCases; i++){
        if(i>0 && i%inc   ==0 )ostream.print(i+" ");
        if(i>0 && i%lines ==0 )ostream.print("\n");
        OutputStream out = new FileOutputStream(filename(name,numCases,i));
                DataMap datamap = session.getDataMap(session.getMapping(),ruleset);
       
                DataObj request = generate();
        request.write2DataMap(datamap);
                datamap.print(out);
      }
View Full Code Here

Examples of com.dtrules.session.IRSession

    String          path    = System.getProperty("user.dir")+"/";
    String          config  = "DTRules_eBooks.xml";
        RulesDirectory  rd      = new RulesDirectory(path, config);
                        rs      = rd.getRuleSet(testObj.getRuleSetName());
        IRSession       session = rs.newSession();

        try{
            ostream.println("Clearing away old tests");
            // Delete old output files
            File dirx         = new File(testObj.getTestDirectory(rs));
            if(!dirx.exists()){
                dirx.mkdirs();
            }
            File oldOutput[] = dirx.listFiles();
            for(File file : oldOutput){
               file.delete();
            }
        }catch(Exception e){
            throw new RuntimeException(e);
        }

    try {
      ostream.println("Generating "+numCases+" Tests");
      int inc = 100;
      if(inc < 100) inc = 1;
      if(inc < 1000) inc = 10;
      int lines = inc*10;
     
      for(int i=1;i<=numCases; i++){
        if(i>0 && i%inc   ==0 )ostream.print(i+" ");
        if(i>0 && i%lines ==0 )ostream.print("\n");
        OutputStream out = new FileOutputStream(filename(name,numCases,i));
                DataMap datamap = session.getDataMap(session.getMapping(),testObj.getRuleSetName());
       
                DataObj request = generate();
        request.write2DataMap(datamap);
                datamap.print(out);
      }
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.