Package com.dtrules.entity

Examples of com.dtrules.entity.IREntity


     */
    public static class Entityforall extends ROperator {
        Entityforall(){super("entityforall");}

        public void execute(DTState state) throws RulesException {
            IREntity        entity  = state.datapop().rEntityValue()// Get the entity
            IRObject        body    = state.datapop();                    // Get the body
            Iterator<RName> keys    = entity.getAttributeIterator();      // Get the Attribute Iterator
           
            while(keys.hasNext()){                         // For each attribute
                RName     n = (RName) keys.next();
                IRObject  v = entity.get(n);
                if(v!=null){
                    state.datapush(n);
                    state.datapush(v);
                    body.execute(state);
                }   
View Full Code Here


            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();
                state.entitypush(e);
                test.execute(state);
                if(state.datapop().booleanValue()){
                    body1.execute(state);
                    state.entitypop();
View Full Code Here

                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,
                // and they don't need to define them if they don't need them.
               
                try { errorEntity.put(null, n("errortype"),     p(e.getErrortype()));                         }catch(RulesException ex){}
                try { errorEntity.put(null, n("location"),      p(e.getLocation()));                          }catch(RulesException ex){}
                try { errorEntity.put(null, n("message"),       p(e.getMessage()));                           }catch(RulesException ex){}
                try { errorEntity.put(null, n("decisionTable"), p(e.getDecisionTable()));                     }catch(RulesException ex){}
                try { errorEntity.put(null, n("formal"),        p(e.getErrortype()));                         }catch(RulesException ex){}
                try { errorEntity.put(null, n("postfix"),       p(e.getPostfix()));                           }catch(RulesException ex){}
                try { errorEntity.put(null, n("filename"),      p(e.getFilename()));                          }catch(RulesException ex){}
                try { errorEntity.put(null, n("section"),       p(e.getSection()));                           }catch(RulesException ex){}
                try { errorEntity.put(null, n("number"),        RInteger.getRIntegerValue(e.getNumber()));    }catch(RulesException ex){}
               
            }
        }
View Full Code Here

    public static class EntityName extends ROperator {
        EntityName() {
            super("entityname");
        }
        public void arrayExecute(DTState state) throws RulesException {
            IREntity entity = state.datapop().rEntityValue();
            state.datapush(entity.getName());
        }
View Full Code Here

       
        types = new HashMap<RName, IRType>();
        Iterator<RName> entities = ef.getEntityRNameIterator();
        while(entities.hasNext()){
            RName     name    = entities.next();
            IREntity  entity  = ef.findRefEntity(name);
            Iterator<RName> attribs = entity.getAttributeIterator();
            addType(entity,entity.getName(),IRObject.iEntity);
            while(attribs.hasNext()){
                RName        attribname = attribs.next();
                REntityEntry entry      = entity.getEntry(attribname);
                addType(entity,attribname,entry.type.getId());
            }
        }
       
        Iterator<RName> tables = ef.getDecisionTableRNameIterator();
View Full Code Here

    }
   
    private void initialize(){
        for(String entity : entitystack){
            try {
                IREntity newEntity = ((RSession)session).createEntity(null,entity);
                session.getState().entitypush(newEntity);
            } catch (RulesException e) {
                throw new RuntimeException("Failed to initialize the Entity Stack: "+e);
            }
        }
View Full Code Here

    public static class Entitypush    extends ROperator {
        Entitypush(){super("entitypush");}

        public void arrayExecute(DTState state) throws RulesException {
            IRObject o = state.datapop();
            IREntity e;
            try{
               e = o.rEntityValue();
            }catch(RulesException ex){
               ex.addToMessage("entitypush could not convert a "+o.type()+" to an Entity");
               throw ex;
            }
            state.entitypush(e);           
            if(state.testState(DTState.TRACE)){
               state.traceInfo("entitypush", "value",e.stringValue(),"id",e.getID()+"",null);
            }
        }
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

     */
    public static class Get    extends ROperator {
        Get(){super("get");}
        public void arrayExecute(DTState state) throws RulesException {
          RName    n = state.datapop().rNameValue();
            IREntity e = state.datapop().rEntityValue();
            IRObject v = e.get(n);
            state.datapush(v);
        }
View Full Code Here

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

            public void execute(DTState state) throws RulesException {
                RName       entityName  = state.datapop().rNameValue();
                IREntity    entity      = state.findEntity(entityName);
                if (entity == null)
                {
                  state.datapush(RBoolean.getRBoolean(false));
                } else {
                  state.datapush(RBoolean.getRBoolean(true));
View Full Code Here

TOP

Related Classes of com.dtrules.entity.IREntity

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.