Package railo.runtime

Examples of railo.runtime.ComponentScope


  private Serializable toIdentifier(Serializable id) {
    if(id instanceof Component) {
      HashMap<String, String> map = new HashMap<String, String>();
      Component cfc=(Component) id;
      ComponentScope scope = cfc.getComponentScope();
      railo.runtime.component.Property[] props = HibernateUtil.getIDProperties(cfc, true,true);
      String name,value;
      for(int i=0;i<props.length;i++){
        name=props[i].getName();
        value=CommonUtil.toString(scope.get(CommonUtil.createKey(name),null),null);
        map.put(name, value);
      }
      return map;
    }
    return id;
View Full Code Here




  private static Query populateQuery(PageContext pc,HibernateORMSession session,Component cfc,Query qry) throws PageException {
    Property[] properties = CommonUtil.getProperties(cfc,true,true,false,false);
    ComponentScope scope = cfc.getComponentScope();
    HibernateORMEngine engine=(HibernateORMEngine) session.getEngine();
   
    // init
    if(qry==null){
      ClassMetadata md = ((HibernateORMEngine)session.getEngine()).getSessionFactory(pc).getClassMetadata(getEntityName(cfc));
      //Struct columnsInfo= engine.getTableInfo(session.getDatasourceConnection(),toEntityName(engine, cfc),session.getEngine());
      Array names=CommonUtil.createArray();
      Array types=CommonUtil.createArray();
      String name;
      //ColumnInfo ci;
      int t;
      Object obj;
      Struct sct;
      String fieldType;
      for(int i=0;i<properties.length;i++){
        obj = properties[i].getMetaData();
        if(obj instanceof Struct) {
          sct=(Struct) obj;
          fieldType = CommonUtil.toString(sct.get(CommonUtil.FIELDTYPE,null),null);
          if("one-to-many".equalsIgnoreCase(fieldType) || "many-to-many".equalsIgnoreCase(fieldType) || "many-to-one".equalsIgnoreCase(fieldType) || "one-to-one".equalsIgnoreCase(fieldType))
            continue;
         
        }
       
        name=HibernateUtil.validateColumnName(md, properties[i].getName(),null);
        //if(columnsInfo!=null)ci=(ColumnInfo) columnsInfo.get(name,null);
        //else ci=null;
        names.append(name);
        if(name!=null){
         
          t=HibernateCaster.toSQLType(HibernateUtil.getPropertyType(md, name).getName(), NULL);
          if(t==NULL)
            types.append("object");
          else
            types.append(SQLCaster.toStringType(t));
        }
        else
          types.append("object");
      }
     
      qry=CommonUtil.createQuery(names,types,0,getEntityName(cfc));
     
    }
    // check
    else if(engine.getMode() == ORMEngine.MODE_STRICT){
      if(!qry.getName().equals(getEntityName(cfc)))
        throw ExceptionUtil.createException(session,null,"can only merge entities of the same kind to a query",null);
    }
   
    // populate
    Key[] names=QueryUtil.getColumnNames(qry);
   
    int row=qry.addRow();
    for(int i=0;i<names.length;i++){
      qry.setAtEL(names[i], row, scope.get(names[i],null));
    }
    return qry;
  }
View Full Code Here



  private static Query inheritance(PageContext pc,HibernateORMSession session,Component cfc,Query qry, String entityName) throws PageException {
    Property[] properties = cfc.getProperties(true);
    ComponentScope scope = cfc.getComponentScope();
    Object value;
    Array arr;
    for(int i=0;i<properties.length;i++){
      value=scope.get(CommonUtil.createKey(properties[i].getName()),null);
      if(value instanceof Component){
        qry=inheritance(pc,session,qry,cfc,(Component) value,entityName);
      }
      else if(CommonUtil.isArray(value)){
        arr = CommonUtil.toArray(value);
View Full Code Here

    return CommonUtil.toArray(loadByExample(pc,obj, false));
  }
 
  private Object loadByExample(PageContext pc, Object obj,  boolean unique) throws PageException {
     Component cfc=HibernateCaster.toComponent(obj);
     ComponentScope scope = cfc.getComponentScope();
     String name=HibernateCaster.getEntityName(cfc);
     //Session session=getSession(pc, cfc);
    
     Object rtn=null;
    
     try{
      //trans.begin();
     
      ClassMetadata metaData = getSessionFactory(pc).getClassMetadata(name);
      String idName = metaData.getIdentifierPropertyName();
      Type idType = metaData.getIdentifierType();
    
      Criteria criteria=session().createCriteria(name);
      if(!Util.isEmpty(idName)){
        Object idValue = scope.get(CommonUtil.createKey(idName),null);
        if(idValue!=null){
          criteria.add(Restrictions.eq(idName, HibernateCaster.toSQL(idType, idValue,null)));
        }
      }
      criteria.add(Example.create(cfc));
View Full Code Here

          deep--;
    }
        {
          boolean isPeristent=ci.isPersistent();
       
          ComponentScope scope = ci.getComponentScope();
          Iterator<Entry<Key, Object>> it = scope.entryIterator();
            sb.append(",{");
          deep++;
          doIt=false;
          Property p;
            Boolean remotingFetch;
View Full Code Here

        }

        Property p;
        Boolean remotingFetch;
      Struct props = ignoreRemotingFetch?null:ComponentUtil.getPropertiesAsStruct(ca,false);
        ComponentScope scope = ca.getComponentScope();
        it=scope.keyIterator();
        while(it.hasNext()) {
          key=Caster.toKey(it.next(),null);
          if(!ignoreRemotingFetch) {
            p=(Property) props.get(key,null);
              if(p!=null) {
                remotingFetch=Caster.toBoolean(p.getDynamicAttributes().get(REMOTING_FETCH,null),null);
                if(remotingFetch==null){
              if(isPeristent  && ORMUtil.isRelated(p)) continue;
            }
            else if(!remotingFetch.booleanValue()) continue;
              }
        }
         
          member = scope.get(key,null);
          if(member instanceof UDF || key.equals(KeyConstants._this)) continue;
            sb.append(goIn()+"<var scope=\"variables\" name="+_+key.toString()+_+">");
            sb.append(_serialize(member,done));
            sb.append(goIn()+"</var>");
        }
View Full Code Here

      throw new ConverterException(e.getMessage());
    }
   
   
    NodeList list=elComp.getChildNodes();
    ComponentScope scope = comp.getComponentScope();
    int len=list.getLength();
    String scopeName;
    Element var,value;
    Collection.Key key;
    for(int i=0;i<len;i++) {
            Node node=list.item(i);
      if(node instanceof Element) {
        var=(Element)node;
        value=getChildElement((Element)node);
        scopeName=var.getAttribute("scope");
        if(value!=null) {
          key=Caster.toKey(var.getAttribute("name"),null);
          if(key==null) continue;
          if("variables".equalsIgnoreCase(scopeName))
            scope.setEL(key,_deserialize(value));
          else
            comp.setEL(key,_deserialize(value));
        }
            }
    }
View Full Code Here

        ComponentAccess ca = ComponentUtil.toComponentAccess(cp);
        isPeristent=ca.isPersistent();
      } catch (ExpressionException ee) {}
     
          Property[] props = cp.getProperties(false);
          ComponentScope scope = cp.getComponentScope();
          for(int i=0;i<props.length;i++) {
            if(!ignoreRemotingFetch) {
              remotingFetch=Caster.toBoolean(props[i].getDynamicAttributes().get(REMOTING_FETCH,null),null);
              if(remotingFetch==null){
                if(isPeristent  && ORMUtil.isRelated(props[i])) continue;
              }
              else if(!remotingFetch.booleanValue()) continue;
               
            }
            Key key = KeyImpl.getInstance(props[i].getName());
              value=scope.get(key,null);
              if(!addUDFs && (value instanceof UDF || value==null))continue;
              if(doIt)sb.append(',');
                doIt=true;
                sb.append('"');
                sb.append(escape(key.getString()));
View Full Code Here

        }

        Property p;
        Boolean remotingFetch;
      Struct props = ignoreRemotingFetch?null:ComponentUtil.getPropertiesAsStruct(ca,false);
        ComponentScope scope = ca.getComponentScope();
        it=scope.keyIterator();
        while(it.hasNext()) {
          key=Caster.toKey(it.next(),null);
          if(!ignoreRemotingFetch) {
            p=(Property) props.get(key,null);
              if(p!=null) {
                remotingFetch=Caster.toBoolean(p.getDynamicAttributes().get(REMOTING_FETCH,null),null);
                if(remotingFetch==null){
              if(isPeristent  && ORMUtil.isRelated(p)) continue;
            }
            else if(!remotingFetch.booleanValue()) continue;
              }
        }
         
          member = scope.get(key,null);
          if(member instanceof UDF || key.equals(KeyConstants._this)) continue;
            sb.append(goIn()+"<var scope=\"variables\" name="+_+key.toString()+_+">");
            sb.append(_serialize(member,done));
            sb.append(goIn()+"</var>");
        }
View Full Code Here

      throw new ConverterException(e.getMessage());
    }
   
   
    NodeList list=elComp.getChildNodes();
    ComponentScope scope = comp.getComponentScope();
    int len=list.getLength();
    String scopeName;
    Element var,value;
    Collection.Key key;
    for(int i=0;i<len;i++) {
            Node node=list.item(i);
      if(node instanceof Element) {
        var=(Element)node;
        value=getChildElement((Element)node);
        scopeName=var.getAttribute("scope");
        if(value!=null) {
          key=Caster.toKey(var.getAttribute("name"),null);
          if(key==null) continue;
          if("variables".equalsIgnoreCase(scopeName))
            scope.setEL(key,_deserialize(value));
          else
            comp.setEL(key,_deserialize(value));
        }
            }
    }
View Full Code Here

TOP

Related Classes of railo.runtime.ComponentScope

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.