Package com.dtrules.interpreter

Examples of com.dtrules.interpreter.RArray


           *
           */
          public static class TestDateFormat extends ROperator {
            TestDateFormat() {super("testdateformat"); }
              public void execute(DTState state) throws RulesException {
                  RArray formatStrings = state.datapop().rArrayValue();
                  String formats[]     = new String[formatStrings.size()];
                  for(int i=0; i<formats.length; i++){
                    formats[i]=formatStrings.get(i).stringValue();
                  }
                  String dateStr = state.datapop().stringValue();
                boolean result = state.getSession().getDateParser().testFormat(dateStr,formats);
                  state.datapush(RBoolean.getRBoolean(result));
              }
View Full Code Here


                        "Entity Factory does not define an entity '"+defaultstr+"'");
                return e;
        }
        if(itype == IRObject.iArray) {
                if(defaultstr.length()==0) return RArray.newArray(session, true,false);
                RArray rval;
                try{
                     RArray v = (RArray) RString.compile(session, defaultstr, false);     // We assume any values are surrounded by brackets, and regardless make
                    
                     rval = v.get(0).getNonExecutable().rArrayValue();             // sure they are non-executable.
                }catch(RulesException e){
                    throw new RulesException("ParsingError","EntityFactory.computeDefaultValue()","Bad format for an array. \r\n"+
                            "\r\nWe tried to interpret the string \r\n'"+defaultstr+"'\r\nas an array, but could not.\r\n"+e.toString());
                }
                return rval;
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

    public static class Forall extends ROperator {
        Forall(){super("forall");}

        public void arrayExecute(DTState state) throws RulesException {
           
            RArray   array = state.datapop().rArrayValue();
            IRObject body = state.datapop();        // Get the body
           
            for(IRObject o : array){
                 int      t = o.type().getId();
                 if(t== iNull)continue;
View Full Code Here

     */
    public static class For extends ROperator {
        For(){super("for");}

        public void arrayExecute(DTState state) throws RulesException {
            RArray   list = state.datapop().rArrayValue();
            IRObject body = state.datapop();        // Get the body
            for(IRObject o : list){
                 state.datapush(o);
                 body.execute(state);
            }
View Full Code Here

        DTState state   = session.getState();    // Get all the state information from our
                                //   Session.
       
        IREntity job     = state.findEntity("job"); // Get the Job Entity from the Entity Stack
       
        RArray   results = job.get("job.results").rArrayValue(); // Get the Rules Engine list
                              //   of result Entities
                             
        for(IRObject r :results){          // For each result entity
            IREntity result = r.rEntityValue();    //   (which we will alias to an IREntity
                                //    pointer to cut down on type casting).

            xout.opentag("Client","id",result.get("client_id").stringValue()); // Output the
                                // client tag and the client ID
              prt(xout,result,"totalGroupIncome");// Print the totalGroupIncome
              prt(xout,result,"client_fpl");    // Print the fpl percentage
             
              if(result.get("eligible").booleanValue()){  // Test their eligiblity result
                  xout.printdata("eligibility", "Approved")// If approved, print the details of their     
                  prt(xout,result,"program");    //   approval. 
                  prt(xout,result,"programLevel");
                
              }else{
                xout.printdata("eligibility", "Not Approved"); // If not approved, print the
                  prt(xout,result,"program");    //   details of their rejection.       
              }
              RArray notes = result.get("notes").rArrayValue();
              xout.opentag("Notes");        // Print out any notes attached to the result.
                  for(IRObject n : notes){
                     xout.printdata("note",n.stringValue());
                  }
              xout.closetag();          // Close tags
View Full Code Here

         return null;
     }
   
    public void printReport(int threadnum, ChipApp app, IRSession session) throws RulesException {
        IREntity   job     = session.getState().find("job.job").rEntityValue();
        RArray     results = job.get("job.results").rArrayValue();
        String      jobId   = job.get("id").stringValue();
        RArray      clients = session.getState().find("case.clients").rArrayValue();
     
        if(results.size()==0 && app.console){
          System.out.println("No results for job "+jobId);
        }
       
       
        int approved   = 0;
        int denied    = 0;
        for(IRObject r :results){
            IREntity result = r.rEntityValue();
           
            IREntity   client     = result.get("client").rEntityValue();
            String     clinetId   = client.get("id").stringValue();
            String     answer      = "";
            if(result.get("eligible").booleanValue()){
                answer = "Approved";
                approved++;
                app.getApprovedClients().add(Integer.parseInt(clinetId));
            }else{
              answer = "Denied";
              denied++;
                app.getDeniedClients().add(Integer.parseInt(clinetId));
            }
           
            if(app.console){
              String    notes    = "";
              RArray    ns      = result.get("notes").rArrayValue();
              for(IRObject n : ns){
                notes += "   "+n.stringValue() +"\n";
              }
              System.out.println();
              System.out.println("Job "+jobId+" Client "+clinetId+" was "+answer+"\n"+notes);
            }
           
            RArray notes = result.get("notes").rArrayValue();
            synchronized (app) {
                for(IRObject n : notes){
                    String note = n.stringValue();
                    Integer v = app.results.get(note);
                    if(v == null) v = 0;
View Full Code Here

        DTState state   = session.getState();    // Get all the state information from our
                                //   Session.
       
        IREntity job     = state.findEntity("job"); // Get the Job Entity from the Entity Stack
       
        RArray   results = job.get("job.results").rArrayValue(); // Get the Rules Engine list
                              //   of result Entities
                             
        for(IRObject r :results){          // For each result entity
            IREntity result = r.rEntityValue();    //   (which we will alias to an IREntity
                                //    pointer to cut down on type casting).

            xout.opentag("Client","id",result.get("client_id").stringValue()); // Output the
                                // client tag and the client ID
              prt(xout,result,"totalGroupIncome");// Print the totalGroupIncome
              prt(xout,result,"client_fpl");    // Print the fpl percentage
             
              if(result.get("eligible").booleanValue()){  // Test their eligiblity result
                  xout.printdata("eligibility", "Approved")// If approved, print the details of their     
                  prt(xout,result,"program");    //   approval. 
                  prt(xout,result,"programLevel");
                
              }else{
                xout.printdata("eligibility", "Not Approved"); // If not approved, print the
                  prt(xout,result,"program");    //   details of their rejection.       
              }
              RArray notes = result.get("notes").rArrayValue();
              xout.opentag("Notes");        // Print out any notes attached to the result.
                  for(IRObject n : notes){
                     xout.printdata("note",n.stringValue());
                  }
              xout.closetag();          // Close tags
View Full Code Here

     }
   
    synchronized public void printReport(int threadnum, BookPreviewApp app, IRSession session) throws RulesException {
        IREntity   request  = session.getState().find("request").rEntityValue();
        IREntity    customer = request.get("customer").rEntityValue();
        RArray      notes    = customer.get("notes").rArrayValue();
        for(IRObject note : notes){
            Integer cnt = app.results.get(note.stringValue());
            if(cnt == null){
                cnt = 1;
            }else{
View Full Code Here

    @SuppressWarnings({ "unchecked", "deprecation" })
    @Override
    public Object mapList(AutoDataMap autoDataMap, LabelMap labelMap, MapNodeList node) {
        IAttribute a = node.getAttribute();
        try {
            RArray list = null;
            RName rname = null;
            Object object = autoDataMap.getCurrentObject();
            if(object instanceof IREntity){
                IREntity entity = (IREntity) object;
                rname = mapName(autoDataMap, labelMap, node.getLabel());
                IRObject olist = entity.get(rname);
                if(olist != null && olist.type().getId() == IRObject.iArray){
                    list = olist.rArrayValue();
                }
            }
           
            node.setTargetList(list);
           
            // Handle Arrays of primitives ... We just keep a link to the list
            // from our data source in this case.
            if(a.getSubType().isPrimitive()){
                if(list == null) return null;
      
                if(node.getData()!=null) for (Object d : (List<Object>) node.getData()){
                    IRObject dobj = iconvert(d);
                    list.add(dobj);
                    if (autoDataMap.getSession().getState().testState(DTState.TRACE)) {
                        autoDataMap.getSession().getState().traceInfo(
                                "addto", "arrayId", ((RArray)list).getID() + "", dobj.postFix());
                    }

                }
                return list;
            }else{
                List<IMapNode> children = node.getChildren();
                for(IMapNode c : children){
                    autoDataMap.pushMark(); // Make sure no children try and update our list's parent
                    Object o = c.mapNode(autoDataMap, labelMap);
                    if(o instanceof List && ((List<Object>)o).size()==1){ // Mostly we are going to get an array of length 
                        o = ((List<Object>)o).get(0);                     //   one of the object we want.  If that's the
                    }                                                     //   case, get the object we want from the List.
                    autoDataMap.pop();                                    // Remove the mark.
                    if(list!=null                                         // If we have a list, and
                            && o != null                                  //   a rules engine object
                            && o instanceof IRObject){                    //   then add it to our list.
                        list.add((IRObject)o);
                        if (autoDataMap.getSession().getState().testState(DTState.TRACE)) {
                            autoDataMap.getSession().getState().traceInfo(
                                    "addto", "arrayId", ((RArray)list).getID() + "", ((IRObject)o).postFix());
                        }                         
                    }
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.