Examples of IREntity


Examples of com.dtrules.entity.IREntity

         * Add all the reference entities to the session list
         * of entities.
         */
        Iterator<RName> ie = ef.referenceEntities.keySet().iterator();
        while(ie.hasNext()){
            IREntity e  = ef.findRefEntity(ie.next());
            String   id = e.getID()+"";
            if(entityInstances.containsKey(id)){
                throw new RulesException("duplicate","new RSession()","Duplicate id "+id+" found between:\n"
                        +e.getName()+" and "+entityInstances.get(id).getName());
            }
            entityInstances.put(id,e);
        }
        try {
            dtstate.entitypush(ROperator.getPrimitives());
            dtstate.entitypush(ef.decisiontables);
        } catch (RulesException e) {
            throw new RulesException("Initialization Error",
                    "RSession",
                    "Failed to initialize dtstate in init(): "+e.toString());
        }
    }
View Full Code Here

Examples of com.dtrules.entity.IREntity

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

        public void execute(DTState state) throws RulesException {
            IRObject o = state.datapop();
            IREntity e;
            try{
               e = o.rEntityValue();
            }catch(RulesException ex){
               ex.addToMessage("entitypush could not convert a "+RSession.typeInt2Str(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

Examples of com.dtrules.entity.IREntity

     */
    static class Get    extends ROperator {
        Get(){super("get");}
        public void execute(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

Examples of com.dtrules.entity.IREntity

      // Look and see if we have an attribute name defined.
            if(body!=null){
          RName a = RName.getRName(attr);                
          IRObject value;
                    
                    IREntity enclosingEntity = session.getState().findEntity(a);
                    if(enclosingEntity==null){
                        throw new Exception ("No Entity is in the context that defines "+ a.stringValue());
                    }
          int type = enclosingEntity.getEntry(a).type;
         
          if(type == IRObject.iInteger){
            value = RInteger.getRIntegerValue(getLong(body));
          } else if (type == IRObject.iDouble) {
            value = RDouble.getRDoubleValue(getDouble(body));
View Full Code Here

Examples of com.dtrules.entity.IREntity

        }
        // Then update any reference to this entity that might be on the Entity Stack.
        // DON'T mess with any entity's self reference though!  That is BAD.
        for(int i=0;i< state.edepth(); i++){
          if((state.getes(i)).get(e.getName())!=null){
                IREntity refto = state.getes(i);
               
                if(! refto.getName().equals(e.getName()))           // Update a reference to an Entity of the same name,
               (state.getes(i)).put(null,e.getName(), e)//  but only if it isn't a self reference.
           
          }
        }
    
View Full Code Here

Examples of com.dtrules.entity.IREntity

    IREntity getInstance(IRSession s)throws RulesException{
        if(number.equals("1"))return entity;
        DTState state = s.getState();
        IRObject rarray = state.find(RName.getRName(name+"s"));
       
        IREntity newentity = (IREntity) entity.clone(s);
        if(rarray!=null && rarray.type() ==IRObject.iArray){
           ((RArray)rarray).add(newentity);
        }
        return newentity;
    }
View Full Code Here

Examples of com.dtrules.entity.IREntity

     
      Iterator<RName> es = this.map.entities.keySet().iterator();
      while(es.hasNext()){
        RName  ename = (RName) es.next();            
         try {
        IREntity e     = findEntity(ename.stringValue().toLowerCase(),null,null);
        state.entitypush(e);
       } catch (RulesException e) {
              state.traceInfo("error", "Failed to initialize the Entity Stack (Failed on "+ename+")\n"+e);
          throw new RuntimeException(e)
       }
View Full Code Here

Examples of com.dtrules.entity.IREntity

   * @return
   * @throws RulesException
   */
  IREntity findEntity( String entity, String code, EntityInfo info) throws RulesException{
     String number = (String) this.map.entityinfo.get(entity);
     IREntity e;
     if(number==null){
       number = "*";
     }
     if(number.equals("1")){
      e = (IREntity)entities.get(entity);
View Full Code Here

Examples of com.dtrules.entity.IREntity

      String eName = info.name;
      if (eName == null || eName.length() <= 0)
      {
        eName =  (String) attribs.get("name");
      }
      IREntity e = findEntity(eName, code, info);     // Look up the entity I should create.
        if(e!=null){                  // I hope to goodness I can find it!
          attribs.put("create entity","true")
          if(code.length()!=0) {
            e.put(null, IREntity.mappingKey,RString.newRString(code));
          }else{
            e.put(null, IREntity.mappingKey,RString.newRString("v"+ (++codeCnt)));
          }
       
          state.entitypush(e);
        if(state.testState(DTState.TRACE)){
              state.traceTagBegin("createEntity", "name",info.name,"id",code);
View Full Code Here

Examples of com.dtrules.entity.IREntity

      // Look and see if we have an attribute name defined.
       
          RName a = RName.getRName(attr);                
          IRObject value;
                    
                    IREntity enclosingEntity = session.getState().findEntity(a);
                    if(enclosingEntity!=null){
                       
                   
              int type = enclosingEntity.getEntry(a).type;
             
              if(type == IRObject.iInteger){
                value = RInteger.getRIntegerValue(body.length()==0? "0" : body);
              } else if (type == IRObject.iDouble) {
                value = RDouble.getRDoubleValue(body.length()==0? "0" : body);
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.