Package com.dtrules.entity

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


     */
  public IREntity createEntity(Object id, RName name) throws RulesException{
      if(id==null){
          id = getUniqueID()+"";
      }
    IREntity ref = ef.findRefEntity(name);
        if(ref==null){
            throw new RulesException("undefined","session.createEntity","An attempt ws made to create the entity "+name.stringValue()+"\n" +
                    "This entity isn't defined in the EDD");
        }
  
        if(ref.isReadOnly()) return ref;
       
        if(getState().testState(DTState.TRACE)){
          IREntity e = entityInstances.get(id);
            if(e==null){
             
              try { // Try and make the uniqueId match.  But ignore errors.
          int eid = Integer.parseInt(id.toString());
          if(uniqueID!=eid) uniqueID = eid;
        } catch (NumberFormatException e1) {
          e1.printStackTrace();
        }

              e = (REntity) ref.clone(this);
             
              dtstate.traceInfo(
                  "createentity",
                  "name", e.getName().stringValue(),
                  "id",   ""+e.getID(),
                  null);

              entityInstances.put(id,e);
            }
            return e;
      }else{
        REntity e = (REntity) ref.clone(this);
        try {
                e.setId(Integer.parseInt(id.toString()));
            } catch (NumberFormatException e1) { }
        return e;
      }
  
  }
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 void begin_entity () {
    String entity     = ((String) _attribs.get("name")).toLowerCase();
    String number     = (String) _attribs.get("number");
   
    IREntity rEntity = map.getSession().getEntityFactory().findRefEntity(RName.getRName(entity));
    if(rEntity==null){
        System.out.println("The Entity specified, '"+entity+"' is not defined");
        loadSuccessful = false;
    }
    if(number.equals("1") || number.equals("+") || number.equals("*")){
 
View Full Code Here

    final String id        = (String) _attribs.get("id");
              String list      = (String) _attribs.get("list");
        list = list==null?"":list;
       
        try {
            IREntity theentity = ef.findRefEntity(RName.getRName(entity));
            if(theentity==null)throw new Exception();
        } catch (Exception e) {
            System.out.println("\nThe Entity found in the Map File => "+entity+" <= isn't defined by the EDD.");
            loadSuccessful = false;
        }
View Full Code Here

       AttributeInfo info = (AttributeInfo) this.map.setattributes.get(tag);
      if(info==null){
         info = new AttributeInfo();
      }     
      try {
            IREntity e = ef.findRefEntity(RName.getRName(entity));
            if(e==null){
                if(!undefinedEntities.containsKey(entity)){
                   System.out.println("The entity "+entity+" isn't defined in the EDD");
                   loadSuccessful = false;
                   undefinedEntities.put(entity, entity);
                }  
            }else{
                if(definedAttributes.containsKey(entity+"*"+rattribute)){
                    System.out.println("The Entity "+entity+" and Attribute "+rattribute +" have multiple definitions");
                    loadSuccessful = false;
                }
                if(e.getEntry(RName.getRName(rattribute))==null){
                    System.out.println("The Attribute "+rattribute+" isn't defined by "+entity);
                    loadSuccessful = false;
                }
                info.add(state,tag, entity,rattribute.toLowerCase(),type);
            }   
View Full Code Here

     
      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

   * @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

      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(IREntity.mappingKey,RString.newRString(code));
          }else{
            e.put(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

      // 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

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.