Package com.dtrules.interpreter

Examples of com.dtrules.interpreter.RArray


     */
    public static class ForFirstElse extends ROperator {
        ForFirstElse(){super("forfirstelse");}

        public void execute(DTState state) throws RulesException {
            RArray   array = state.datapop().rArrayValue();
            IRObject test  = state.datapop();
            IRObject body2 = state.datapop();
            IRObject body1 = state.datapop();
            for(IRObject obj : array) {
                IREntity e = obj.rEntityValue();
View Full Code Here


     */
    public static class PolicyStatements extends ROperator {
        PolicyStatements(){super("policystatements");}

        public void execute(DTState state) throws RulesException {
            RArray ra = RArray.newArray(state.getSession(),true,false);
            state.datapush(ra);
            if(!state.getCurrentTable().equals(state.getAnode().getrDecisionTable())){
                return;
            }

            ArrayList<Integer> columns = state.getAnode().getColumns();
            IRObject rps [] = state.getCurrentTable().getRpolicystatements();
            if(rps!= null) {
                for(int column : columns){
                    if(column < rps.length){
                       IRObject ps = rps[column];
                       if(ps != null){
                          ps.execute(state);
                          ps = state.datapop();
                          if(ps != RNull.getRNull()){
                              ra.add(ps);
                              if (state.testState(DTState.TRACE)) {
                                  state.traceInfo("addto", "arrayId", ra.getID() + "",
                                          ps.postFix());
                              }
                          }
                       }
                    }
                }
                if(columns.size()==0){
                    IRObject ps = rps[0];
                    if(ps != null){
                       ps.execute(state);
                       ps = state.datapop();
                       if(ps != RNull.getRNull()){
                           ra.add(ps);
                           if (state.testState(DTState.TRACE)) {
                               state.traceInfo("addto", "arrayId", ra.getID() + "",
                                       ps.postFix());
                           }
                       }
                    }
                
View Full Code Here

      }
     
      public void printReport(int runNumber, IRSession session, PrintStream _out) throws RulesException {
          XMLPrinter xout = new XMLPrinter(_out);
          xout.opentag("results","runNumber",runNumber);
          RArray results = session.getState().find("job.results").rArrayValue();
          for(IRObject r :results){
              IREntity result = r.rEntityValue();

              xout.opentag("Client","id",result.get("client_id").stringValue());
              prt(xout,result,"totalGroupIncome");
              prt(xout,result,"client_fpl");
              if(result.get("eligible").booleanValue()){
                  xout.opentag("Approved");
                    prt(xout,result,"program");
                    prt(xout,result,"programLevel");
                    RArray notes = result.get("notes").rArrayValue();
                    xout.opentag("Notes");
                        for(IRObject n : notes){
                           xout.printdata("note",n.stringValue());
                        }
                      xout.closetag();
                  xout.closetag();
              }else{
                  xout.opentag("NotApproved");
                      prt(xout,result,"program");
                      RArray notes = result.get("notes").rArrayValue();
                      xout.opentag("Notes");
                          for(IRObject n : notes){
                             xout.printdata("note",n.stringValue());
                          }
                      xout.closetag();
View Full Code Here

              return true;
          }
    
          if(c.type().getId() == iArray){
              list.add(c);
              RArray ar = c.rArrayValue();
              for(IRObject v : ar){
                  boolean f = callsPolicyStatement(v,list);
                  if(f) return f;
              }
          }
View Full Code Here

    }
   
    private void addTables(IRObject action,List<RArray> stack, List<RDecisionTable> tables){
        if(action==null)return;
        if(action.type().getId()==iArray){
            RArray array = (RArray)action;
            if(stack.contains(array))return;    // We have already been here.
            stack.add(array);
            try {     // As this is an array, arrayValue() will not ever throw an exception
                Iterator<?> objects = array.arrayValue().iterator();
                while(objects.hasNext()){
                    addTables((IRObject) objects.next(),stack,tables);
                }
            } catch (RulesException e) { }
        }
View Full Code Here

                     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;
View Full Code Here

     * In general, we usually print a valid XML file as a report, but nothing
     * says you have to.
     */
    public void printReport(int runNumber, IRSession session, PrintStream out)
            throws Exception {
        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(out),true, false, session.getState(), "entitystack", entitystack);
    }
View Full Code Here

     */
    public static class Forfirst extends ROperator {
        Forfirst(){super("forfirst");}

        public void arrayExecute(DTState state) throws RulesException {
            RArray   array = state.datapop().rArrayValue();
            IRObject test  = state.datapop();
            IRObject body  = state.datapop();
            Iterator<REntity> ie = (Iterator<REntity>) array.getIterator();
            while(ie.hasNext()){
                state.entitypush(ie.next());
                test.execute(state);
                if(state.datapop().booleanValue()){
                    body.execute(state);
View Full Code Here

     */
    public static class ForFirstElse extends ROperator {
        ForFirstElse(){super("forfirstelse");}

        public void arrayExecute(DTState state) throws RulesException {
            RArray   array = state.datapop().rArrayValue();
            IRObject test  = state.datapop();
            IRObject body2 = state.datapop();
            IRObject body1 = state.datapop();
            for(IRObject obj : array) {
                IREntity e = obj.rEntityValue();
View Full Code Here

     */
    public static class PolicyStatements extends ROperator {
        PolicyStatements(){super("policystatements");}

        public void arrayExecute(DTState state) throws RulesException {
            RArray ra = new RArray(state.getSession().getUniqueID(),true,false);
            state.datapush(ra);
            if(!state.getCurrentTable().equals(state.getAnode().getrDecisionTable())){
                return;
            }

            ArrayList<Integer> columns = state.getAnode().getColumns();
            IRObject rps [] = state.getCurrentTable().getRpolicystatements();
            if(rps!= null) {
                for(int column : columns){
                    if(column < rps.length){
                       IRObject ps = rps[column];
                       if(ps != null){
                          ps.execute(state);
                          ps = state.datapop();
                          if(ps != RNull.getRNull()){
                              ra.add(ps);
                          }
                       }
                    }
                }
                if(columns.size()==0){
                    IRObject ps = rps[0];
                    if(ps != null){
                       ps.execute(state);
                       ps = state.datapop();
                       if(ps != RNull.getRNull()){
                           ra.add(ps);
                       }
                    }
                
                }
            }
View Full Code Here

TOP

Related Classes of com.dtrules.interpreter.RArray

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.