Package railo.runtime.type

Examples of railo.runtime.type.QueryImpl


                "url","port","interval","timeout","username","password","proxyserver",
                "proxyport","proxyuser","proxypassword","resolveurl","publish","valid","paused","autoDelete"};
        String[] types = new String[]{v,v,v,"DATE","OTHER","DATE","OTHER",
                v,v,v,v,v,v,v,
                v,v,v,v,"BOOLEAN",v,"BOOLEAN","BOOLEAN"};
        railo.runtime.type.Query query=new QueryImpl(cols,types,tasks.length,"query"
        );
        try {
          for(int i=0;i<tasks.length;i++) {
              int row=i+1;
              ScheduleTask task=tasks[i];
              query.setAt(KeyConstants._task,row,task.getTask());
              if(task.getResource()!=null) {
                  query.setAt(KeyConstants._path,row,task.getResource().getParent());
                  query.setAt(KeyConstants._file,row,task.getResource().getName());
              }
              query.setAt("publish",row,Caster.toBoolean(task.isPublish()));
              query.setAt("startdate",row,task.getStartDate());
              query.setAt("starttime",row,task.getStartTime());
              query.setAt("enddate",row,task.getEndDate());
              query.setAt("endtime",row,task.getEndTime());
              query.setAt(KeyConstants._url,row,printUrl(task.getUrl()));
              query.setAt(KeyConstants._port,row,Caster.toString(HTTPUtil.getPort(task.getUrl())));
              query.setAt("interval",row,task.getStringInterval());
              query.setAt("timeout",row,Caster.toString(task.getTimeout()/1000));
              query.setAt("valid",row,Caster.toString(task.isValid()));
              if(task.hasCredentials()) {
                  query.setAt("username",row,task.getCredentials().getUsername());
                  query.setAt("password",row,task.getCredentials().getPassword());
              }
              ProxyData pd = task.getProxyData();
              if(ProxyDataImpl.isValid(pd)){
                query.setAt("proxyserver",row,pd.getServer());
                if(pd.getPort()>0)query.setAt("proxyport",row,Caster.toString(pd.getPort()));
                if(ProxyDataImpl.hasCredentials(pd)) {
                    query.setAt("proxyuser",row,pd.getUsername());
                    query.setAt("proxypassword",row,pd.getPassword());
                }
              }
              query.setAt("resolveurl",row,Caster.toString(task.isResolveURL()));

              query.setAt("paused",row,Caster.toBoolean(task.isPaused()));
              query.setAt("autoDelete",row,Caster.toBoolean(((ScheduleTaskImpl)task).isAutoDelete()));
             
             
             
          }
          pageContext.setVariable(returnvariable,query);
View Full Code Here


       
       
        try {
            RegistryEntry[] entries = RegistryQuery.getValues(branch,type);
            if(entries!=null) {
              railo.runtime.type.Query qry=new QueryImpl(
                        new String[]{"entry","type","value"},
                        new String[]{"VARCHAR","VARCHAR","OTHER"},
                        entries.length,"query");
                for(int i=0;i<entries.length;i++) {
                    RegistryEntry e = entries[i];
                    int row=i+1;
                    qry.setAt(KeyConstants._entry,row,e.getKey());
                    qry.setAt(KeyConstants._type,row,RegistryEntry.toCFStringType(e.getType()));
                    qry.setAt(KeyConstants._value,row,e.getValue());
                }
               

            // sort
            if(sort!=null) {
              String[] arr=sort.toLowerCase().split(",");
              for(int i=arr.length-1;i>=0;i--) {
                String[] col=arr[i].trim().split("\\s+");
                if(col.length==1)qry.sort(KeyImpl.init(col[0].trim()));
                else if(col.length==2) {
                  String order=col[1].toLowerCase().trim();
                  if(order.equals("asc"))
                      qry.sort(KeyImpl.init(col[0]),railo.runtime.type.Query.ORDER_ASC);
                  else if(order.equals("desc"))
                      qry.sort(KeyImpl.init(col[0]),railo.runtime.type.Query.ORDER_DESC);
                  else
                    throw new ApplicationException("invalid order type ["+col[1]+"]");
                }
              }   
            }
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

  private void typeDBNames(DatabaseMetaData metaData) throws PageException, SQLException {

    Stopwatch stopwatch=new Stopwatch(Stopwatch.UNIT_NANO);
    stopwatch.start();
       
        railo.runtime.type.Query catalogs = new QueryImpl(metaData.getCatalogs(),"query",pageContext.getTimeZone());
        railo.runtime.type.Query scheme = new QueryImpl(metaData.getSchemas(),"query",pageContext.getTimeZone());
       
        Pattern p=null;
        if(pattern!=null && !"%".equals(pattern))
          p=SQLUtil.pattern(pattern, true);
   
       
       
        String[] columns=new String[]{"database_name","type"};
    String[] types=new String[]{"VARCHAR","VARCHAR"};
    railo.runtime.type.Query qry=new QueryImpl(columns,types,0,"query");
    int row=1,len=catalogs.getRecordcount();
    String value;
    // catalog
    for(int i=1;i<=len;i++) {
      value=(String) catalogs.getAt(TABLE_CAT, i);
      if(!matchPattern(value,p)) continue;
      qry.addRow();
      qry.setAt(DATABASE_NAME, row, value);
      qry.setAt(KeyConstants._type, row, "CATALOG");
      row++;
    }
    // scheme
    len=scheme.getRecordcount();
    for(int i=1;i<=len;i++) {
      value=(String) scheme.getAt(TABLE_SCHEM, i);
      if(!matchPattern(value,p)) continue;
      qry.addRow();
      qry.setAt(DATABASE_NAME, row, value);
      qry.setAt(KeyConstants._type, row, "SCHEMA");
      row++;
    }
   
        qry.setExecutionTime(stopwatch.time());
       
       
    pageContext.setVariable(name, qry);
  }
View Full Code Here

      table=table.substring(index+1);
    }
   
    checkTable(metaData);
   
    railo.runtime.type.Query qry = new QueryImpl(
        metaData.getExportedKeys(dbname, schema, table),
        "query",
        pageContext.getTimeZone());   
    qry.setExecutionTime(stopwatch.time());       
       
    pageContext.setVariable(name, qry);
  }
View Full Code Here

    }
   
    checkTable(metaData);
   
        ResultSet tables = metaData.getIndexInfo(dbname, schema, table, false, true);
        railo.runtime.type.Query qry = new QueryImpl(tables,"query",pageContext.getTimeZone());
       
        // type int 2 string
        int rows = qry.getRecordcount();
        String strType;
        int type,card;
        for(int row=1;row<=rows;row++){
         
          // type
          switch(type=Caster.toIntValue(qry.getAt(KeyConstants._type,row))){
          case 0:
            strType="Table Statistic";
          break;
          case 1:
          strType="Clustered Index";
        break;
          case 2:
          strType="Hashed Index";
        break;
          case 3:
          strType="Other Index";
        break;
        default:
          strType=Caster.toString(type);
        }
          qry.setAt(KeyConstants._type, row, strType);
         
          // CARDINALITY
          card=Caster.toIntValue(qry.getAt(CARDINALITY,row),0);
          qry.setAt(CARDINALITY, row, Caster.toDouble(card));
         
        }
        qry.setExecutionTime(stopwatch.time());
       
       
    pageContext.setVariable(name, qry);
  }
View Full Code Here

    pattern=setCase(metaData, pattern);
    if(StringUtil.isEmpty(pattern,true)) {
      pattern=null;
    }
   
        railo.runtime.type.Query qry = new QueryImpl(
            metaData.getProcedures(dbname, schema, pattern),
            "query",
            pageContext.getTimeZone());
        qry.setExecutionTime(stopwatch.time());
       
       
    pageContext.setVariable(name, qry);
  }
View Full Code Here

      schema=procedure.substring(0,index);
      procedure=procedure.substring(index+1);
    }
   
   
    railo.runtime.type.Query qry = new QueryImpl(
        metaData.getProcedureColumns(dbname, schema, procedure, pattern),
        "query",
        pageContext.getTimeZone());
    qry.setExecutionTime(stopwatch.time());
       
       
    pageContext.setVariable(name, qry);
  }
View Full Code Here

    Stopwatch stopwatch=new Stopwatch(Stopwatch.UNIT_NANO);
    stopwatch.start();
       
    pattern=setCase(metaData, pattern);
   
        railo.runtime.type.Query qry = new QueryImpl(
            metaData.getTables(dbname, null, pattern, null),
            "query",
            pageContext.getTimeZone());
        qry.setExecutionTime(stopwatch.time());
       
       
    pageContext.setVariable(name, qry);
  }
View Full Code Here

    stopwatch.start();
   
    Key[] columns=new Key[]{DATABASE_PRODUCTNAME,DATABASE_VERSION,DRIVER_NAME,DRIVER_VERSION,JDBC_MAJOR_VERSION,JDBC_MINOR_VERSION};
    String[] types=new String[]{"VARCHAR","VARCHAR","VARCHAR","VARCHAR","DOUBLE","DOUBLE"};
   
    railo.runtime.type.Query qry=new QueryImpl(columns,types,1,"query");

    qry.setAt(DATABASE_PRODUCTNAME,1,metaData.getDatabaseProductName());
    qry.setAt(DATABASE_VERSION,1,metaData.getDatabaseProductVersion());
    qry.setAt(DRIVER_NAME,1,metaData.getDriverName());
    qry.setAt(DRIVER_VERSION,1,metaData.getDriverVersion());
    qry.setAt(JDBC_MAJOR_VERSION,1,new Double(metaData.getJDBCMajorVersion()));
    qry.setAt(JDBC_MINOR_VERSION,1,new Double(metaData.getJDBCMinorVersion()));
   
   
        qry.setExecutionTime(stopwatch.time());
       
       
    pageContext.setVariable(name, qry);
  }
View Full Code Here

TOP

Related Classes of railo.runtime.type.QueryImpl

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.