Package railo.runtime.type

Examples of railo.runtime.type.Query


  public Query getClosedTasksAsQuery(int startrow, int maxrow) throws PageException {
    return getTasksAsQuery(createQuery(),closedDirectory,startrow, maxrow);
  }

  public Query getAllTasksAsQuery(int startrow, int maxrow) throws PageException {
    Query query = createQuery();
    //print.o(startrow+":"+maxrow);
    getTasksAsQuery(query,openDirectory,startrow, maxrow);
    int records = query.getRecordcount();
    if(maxrow<0) maxrow=Integer.MAX_VALUE;
    // no open tasks
    if(records==0) {
      startrow-=getOpenTaskCount();
      if(startrow<1) startrow=1;
View Full Code Here


    Stopwatch stopwatch=new Stopwatch(Stopwatch.UNIT_NANO);
    stopwatch.start();
       
    checkTable(metaData);
    ResultSet result = metaData.getSchemas();
    Query qry = new QueryImpl(result,"query",pageContext.getTimeZone());
   
   
    qry.rename(TABLE_SCHEM,USER);
       
        qry.setExecutionTime(stopwatch.time());
       
       
    pageContext.setVariable(name, qry);
  }
View Full Code Here

      schema=table.substring(0,index);
      table=table.substring(index+1);
    }
    checkTable(metaData);
   
        Query qry = new QueryImpl(
            metaData.getColumns(dbname, schema, table, pattern),
            "query",
            pageContext.getTimeZone());
       
    int len=qry.getRecordcount();

    if(qry.getColumn(COLUMN_DEF,null) != null)
      qry.rename(COLUMN_DEF,COLUMN_DEFAULT_VALUE);
    else if(qry.getColumn(COLUMN_DEFAULT,null) != null)
      qry.rename(COLUMN_DEFAULT,COLUMN_DEFAULT_VALUE);
   
    // make sure decimal digits exists
    QueryColumn col = qry.getColumn(DECIMAL_DIGITS,null);
    if(col==null){
      Array arr=new ArrayImpl();
      for(int i=1;i<=len;i++) {
        arr.append(railo.runtime.op.Constants.DOUBLE_ZERO);
      }
      qry.addColumn(DECIMAL_DIGITS, arr);
    }
   
   
    // add is primary
    Map primaries = new HashMap();
    String tblName;
    Array isPrimary=new ArrayImpl();
    Set set;
    Object o;
    for(int i=1;i<=len;i++) {
     
      // decimal digits
      o=qry.getAt(DECIMAL_DIGITS, i,null);
      if(o==null)qry.setAtEL(DECIMAL_DIGITS, i,railo.runtime.op.Constants.DOUBLE_ZERO);
     
      set=(Set) primaries.get(tblName=(String) qry.getAt(TABLE_NAME, i));
      if(set==null) {
        set=toSet(metaData.getPrimaryKeys(dbname, null, tblName),true,"COLUMN_NAME");
        primaries.put(tblName,set);
      }
      isPrimary.append(set.contains(qry.getAt(COLUMN_NAME, i))?"YES":"NO");
    }
    qry.addColumn(IS_PRIMARYKEY, isPrimary);
   
    // add is foreignkey
    Map foreigns = new HashMap();
    Array isForeign=new ArrayImpl();
    Array refPrim=new ArrayImpl();
    Array refPrimTbl=new ArrayImpl();
    //Map map,inner;
    Map<String, Map<String, SVArray>> map;
    Map<String, SVArray> inner;
    for(int i=1;i<=len;i++) {
      map=(Map) foreigns.get(tblName=(String) qry.getAt(TABLE_NAME, i));
      if(map==null) {
        map=toMap(
            metaData.getImportedKeys(dbname, schema, table),
            true,
            "FKCOLUMN_NAME",
            new String[]{"PKCOLUMN_NAME","PKTABLE_NAME"});
        foreigns.put(tblName, map);
      }
      inner = map.get(qry.getAt(COLUMN_NAME, i));
      if(inner!=null) {
        isForeign.append("YES");
        refPrim.append(inner.get("PKCOLUMN_NAME"));
        refPrimTbl.append(inner.get("PKTABLE_NAME"));
      }
      else {
        isForeign.append("NO");
        refPrim.append("N/A");
        refPrimTbl.append("N/A");     
      }
    }
    qry.addColumn(IS_FOREIGNKEY, isForeign);
    qry.addColumn(REFERENCED_PRIMARYKEY, refPrim);
    qry.addColumn(REFERENCED_PRIMARYKEY_TABLE, refPrimTbl);
   
   
    qry.setExecutionTime(stopwatch.time());
       
       
    pageContext.setVariable(name, qry);
  }
View Full Code Here

        }
        else if(action.equals("query")) {
            required("LDAP",action,"start",start);
            required("LDAP",action,"attributes",attributes);
            required("LDAP",action,"name",name);
            Query qry = client.query(attributes,scope,startrow,maxrows,
                    timeout,sort,sortType,sortDirection,start,separator,filter);
            pageContext.setVariable(name,qry);
           
        }
        else throw new ApplicationException("invalid value for attribute action ["+action+"], valid values are [add,delete,modifydn,modify,query]");
View Full Code Here

    VariableReference ref = ((PageContextImpl)pc).getVariableReference(strQueryColumn);
    if(ref.getParent() instanceof Scope)
        throw new ExpressionException("invalid query column definition ["+strQueryColumn+"]");
   
   
    Query query=Caster.toQuery(ref.getParent());
    return query.getColumn(ref.getKey());
  }
View Full Code Here

    int trgRows = srcRows-start+1;
    if (trgRows > pageSize) trgRows = pageSize;
    if(trgRows<0)trgRows=0;
   
    Query trg=new QueryImpl(srcColumns,trgRows,src.getName());
    int trgRow=0;
    for (int srcRow = start; (srcRow <= end) && (srcRow <= srcRows); srcRow++) {
      trgRow++;
      for (int col = 0; col < srcColumns.length; col++){
        trg.setAtEL(
          srcColumns[col],
          trgRow,
          src.getAt(srcColumns[col],srcRow, null));
      }
    }
View Full Code Here

        }
        else throw new DatabaseException("invalid argument for function query, only array as value are allowed","example: query(column1:array(1,2,3))",null,null);
      }
      else throw new DatabaseException("invalid argument for function query, only named argument are allowed","example: query(column1:array(1,2,3))",null,null);
    }
    Query query=new QueryImpl(names,columns,"query");
    return query;
  }
View Full Code Here

    columnName=columnName.trim();
    newColumnName=newColumnName.trim();
    Collection.Key src=KeyImpl.getInstance(columnName);
    Collection.Key trg=KeyImpl.getInstance(newColumnName);
   
    Query qp = Caster.toQuery(query,null);
    if(qp!=null) qp.rename(src, trg);
    else {
      QueryColumn qc = query.removeColumn(src);
      Array content=new ArrayImpl();
      int len=qc.size();
      for(int i=1;i<=len;i++){
View Full Code Here

  }

  private static Query get(Query qry, int from, int to) throws PageException {
    Collection.Key[] columns;
    //print.out(from+"::"+to);
    Query nq=new QueryImpl(columns=qry.getColumnNames(),0,qry.getName());
   
    int row=1;
    for(int i=from;i<=to;i++) {nq.addRow();
      for(int y=0;y<columns.length;y++) {
        nq.setAt(columns[y], row, qry.getAt(columns[y], i));
      }
      row++;
    }
    return nq;
  }
View Full Code Here

   * @throws ConverterException
   */
  private Object _deserializeQuery(Element recordset) throws ConverterException {
    try {
      // create Query Object
      Query query=new QueryImpl(
          railo.runtime.type.util.ListUtil.listToArray(
              recordset.getAttribute("fieldNames"),','
          )
        ,Caster.toIntValue(recordset.getAttribute("rowCount")),"query"
      );
View Full Code Here

TOP

Related Classes of railo.runtime.type.Query

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.