Package railo.runtime.type

Examples of railo.runtime.type.QueryImpl


        Query query=null;
        String[] cols = new String[]{"external","language","mapped","name","online","path","registered","lastmodified","categories","charset","created",
                       "size","doccount"};
        String[] types = new String[]{"BOOLEAN",v,"BOOLEAN",v,"BOOLEAN",v,v,"DATE","BOOLEAN",v,"OBJECT","DOUBLE","DOUBLE"};
        try {
            query=new QueryImpl(cols,types, collections.size(),"query");
        } catch (DatabaseException e) {
            query=new QueryImpl(cols, collections.size(),"query");
        }
       
        //Collection.Key[] keys = collections.keys();
      Iterator<Object> it = collections.valueIterator();
      int i=-1;
View Full Code Here


    init(DEFAULT_SAX_PARSER,is);
  }
 
  private void init(String saxParser,InputSource is) throws SAXException, IOException, DatabaseException  {
    properties=new StructImpl();
    items=new QueryImpl(COLUMNS,0,"query");
    xmlReader=XMLUtil.createXMLReader(saxParser);
    xmlReader.setContentHandler(this);
    xmlReader.setErrorHandler(this);
   
    //xmlReader.setEntityResolver(new TagLibEntityResolver());
View Full Code Here

    public Query execute(PageContext pc,SQL sql, Selects selects,int maxrows) throws PageException {
      Column[] orders=selects.getOrderbys();
      Select[] arrSelects = selects.getSelects();
     
     
      QueryImpl target=new QueryImpl(new Collection.Key[0],0,"query");
    target.setSql(sql);
     
      for(int i=0;i<arrSelects.length;i++) {
        arrSelects[i].getFroms();
        Column[] froms = arrSelects[i].getFroms();
        if(froms.length>1) throw new DatabaseException("can only work with single tables yet",null,sql,null);
        executeSingle(pc,arrSelects[i],getSingleTable(pc, froms[0]),target,arrSelects.length>1?-1:maxrows,sql,
            orders.length>0);
      }
     
  // Order By 
    if(orders.length>0) {
      order(target,orders);
      if(maxrows>-1) target.cutRowsTo(maxrows);
    }
    // Distinct
        if(selects.isDistinct()) {
          order(target,selects.getDistincts()); // order to filter
          //print.e(selects.getDistincts());
          Key[] _keys = target.getColumnNames();
            QueryColumn[] columns=new QueryColumn[_keys.length];
            for(int i=0;i<columns.length;i++) {
                columns[i]=target.getColumn(_keys[i]);
            }
           
            int i;
            Object l,r;
            outer:for(int row=target.getRecordcount();row>1;row--) {
                for(i=0;i<columns.length;i++) {
                  l=columns[i].get(row,null);
                  r=columns[i].get(row-1,null);
                  if(l==null || r==null) {
                    if(l!=r)continue outer;
                  }
                  else if(!Operator.equals(l,r,true))
                        continue outer;
                }
                target.removeRow(row);
            }
        }
        order(target,orders);
     
       
View Full Code Here

        String[] types = new String[]{"VARCHAR","DOUBLE","VARCHAR","VARCHAR","DOUBLE","VARCHAR","ANY"};
       
        //queries
        Query qryQueries=null;
        try {
            qryQueries = new QueryImpl(cols,types,queries.size(),"query");
        } catch (DatabaseException e) {
            qryQueries = new QueryImpl(cols,queries.size(),"query");
        }
    int row=0;
    try {
        while(qryIt.hasNext()) {
            row++;
            QueryEntryPro qe=(QueryEntryPro) qryIt.next();
        qryQueries.setAt(KeyConstants._name,row,qe.getName()==null?"":qe.getName());
            qryQueries.setAt(KeyConstants._time,row,Long.valueOf(qe.getExecutionTime()));
            qryQueries.setAt(KeyConstants._sql,row,qe.getSQL().toString());
        qryQueries.setAt(KeyConstants._src,row,qe.getSrc());
                qryQueries.setAt(KeyConstants._count,row,Integer.valueOf(qe.getRecordcount()));
                qryQueries.setAt(KeyConstants._datasource,row,qe.getDatasource());
               
                Struct usage = getUsage(qe);
                if(usage!=null) qryQueries.setAt(KeyConstants._usage,row,usage);

            Object o=qryExe.get(KeyImpl.init(qe.getSrc()),null);
            if(o==null) qryExe.setEL(KeyImpl.init(qe.getSrc()),Long.valueOf(qe.getExecutionTime()));
            else qryExe.setEL(KeyImpl.init(qe.getSrc()),Long.valueOf(((Long)o).longValue()+qe.getExecutionTime()));
        }
    }
    catch(PageException dbe) {}
   
      // Pages
      // src,load,app,query,total
      Struct debugging=new StructImpl();
      row=0;
        ArrayList<DebugEntryTemplate> arrPages = toArray();
    int len=arrPages.size();
        Query qryPage=new QueryImpl(
                new Collection.Key[]{
                    KeyConstants._id,
                    KeyConstants._count,
                    KeyConstants._min,
                    KeyConstants._max,
                    KeyConstants._avg
                    ,KeyConstants._app,
                    KeyConstants._load,
                    KeyConstants._query,
                    KeyConstants._total,
                    KeyConstants._src},
                len,"query");

    try {
            DebugEntryTemplate de;
            //PageSource ps;
        for(int i=0;i<len;i++) {
            row++;
            de=arrPages.get(i);
                //ps = de.getPageSource();
               
            qryPage.setAt(KeyConstants._id,row,de.getId());
            qryPage.setAt(KeyConstants._count,row,_toString(de.getCount()));
                qryPage.setAt(KeyConstants._min,row,_toString(de.getMin()));
                qryPage.setAt(KeyConstants._max,row,_toString(de.getMax()));
                qryPage.setAt(KeyConstants._avg,row,_toString(de.getExeTime()/de.getCount()));
                qryPage.setAt(KeyConstants._app,row,_toString(de.getExeTime()-de.getQueryTime()));
                qryPage.setAt(KeyConstants._load,row,_toString(de.getFileLoadTime()));
            qryPage.setAt(KeyConstants._query,row,_toString(de.getQueryTime()));
                qryPage.setAt(KeyConstants._total,row,_toString( de.getFileLoadTime() + de.getExeTime()));
            qryPage.setAt(KeyConstants._src,row,de.getSrc());   
      }
    }
    catch(PageException dbe) {}


      // Pages Parts
    List<DebugEntryTemplatePart> filteredPartEntries = null;
    boolean hasParts=partEntries!=null && !partEntries.isEmpty() && !arrPages.isEmpty();
    int qrySize=0;

    if(hasParts) {

      String slowestTemplate = arrPages.get( 0 ).getPath();

      filteredPartEntries = new ArrayList();

      java.util.Collection<DebugEntryTemplatePartImpl> col = partEntries.values();
      for ( DebugEntryTemplatePart detp : col ) {

        if ( detp.getPath().equals( slowestTemplate ) )
          filteredPartEntries.add( detp );
      }

      qrySize = Math.min( filteredPartEntries.size(), MAX_PARTS );
    }

    Query qryPart = new QueryImpl(
            new Collection.Key[]{
                 KeyConstants._id
                ,KeyConstants._count
                ,KeyConstants._min
                ,KeyConstants._max
                ,KeyConstants._avg
                ,KeyConstants._total
                ,KeyConstants._path
                ,KeyConstants._start
                ,KeyConstants._end
                ,KeyConstants._startLine
                ,KeyConstants._endLine
                ,KeyConstants._snippet
            }, qrySize, "query" );

    if(hasParts) {
      row=0;
          Collections.sort( filteredPartEntries, DEBUG_ENTRY_TEMPLATE_PART_COMPARATOR );

      DebugEntryTemplatePart[] parts = new DebugEntryTemplatePart[ qrySize ];

      if ( filteredPartEntries.size() > MAX_PARTS )
        parts = filteredPartEntries.subList(0, MAX_PARTS).toArray( parts );
      else
        parts = filteredPartEntries.toArray( parts );

      try {
              DebugEntryTemplatePart de;
              //PageSource ps;
          for(int i=0;i<parts.length;i++) {
              row++;
              de=parts[i];
                 
              qryPart.setAt(KeyConstants._id,row,de.getId());
              qryPart.setAt(KeyConstants._count,row,_toString(de.getCount()));
              qryPart.setAt(KeyConstants._min,row,_toString(de.getMin()));
              qryPart.setAt(KeyConstants._max,row,_toString(de.getMax()));
              qryPart.setAt(KeyConstants._avg,row,_toString(de.getExeTime()/de.getCount()));
              qryPart.setAt(KeyConstants._start,row,_toString(de.getStartPosition()));
              qryPart.setAt(KeyConstants._end,row,_toString(de.getEndPosition()));
              qryPart.setAt(KeyConstants._total,row,_toString(de.getExeTime()));
              qryPart.setAt(KeyConstants._path,row,de.getPath());

                    if ( de instanceof DebugEntryTemplatePartImpl ) {

                        qryPart.setAt( KeyConstants._startLine, row, _toString( ((DebugEntryTemplatePartImpl)de).getStartLine() ) );
                        qryPart.setAt( KeyConstants._endLine, row, _toString( ((DebugEntryTemplatePartImpl)de).getEndLine() ));
                        qryPart.setAt( KeyConstants._snippet, row, ((DebugEntryTemplatePartImpl)de).getSnippet() );
                    }
        }
      }
      catch(PageException dbe) {}
    }
   
   
   

    // exceptions
    len = exceptions==null?0:exceptions.size();
   
        Array arrExceptions=new ArrayImpl();
        if(len>0) {
            Iterator<CatchBlock> it = exceptions.iterator();
            row=0;
            while(it.hasNext()) {
              arrExceptions.appendEL(it.next())
            }
     
        }

    // output log
        //Query qryOutputLog=getOutputText();
       
       

    // timers
    len=timers==null?0:timers.size();
        Query qryTimers=new QueryImpl(
                new Collection.Key[]{KeyConstants._label,KeyConstants._time,KeyConstants._template},
                len,"timers");
        if(len>0) {
          try {
            Iterator<DebugTimerImpl> it = timers.iterator();
            DebugTimer timer;
            row=0;
            while(it.hasNext()) {
              timer=it.next();
              row++;
              qryTimers.setAt(KeyConstants._label,row,timer.getLabel());
              qryTimers.setAt(KeyConstants._template,row,timer.getTemplate());
              qryTimers.setAt(KeyConstants._time,row,Caster.toDouble(timer.getTime()));   
            }
      }
      catch(PageException dbe) {}
        }

    // traces
    len=traces==null?0:traces.size();
    if(!((ConfigImpl)pc.getConfig()).hasDebugOptions(ConfigImpl.DEBUG_TRACING))len=0;
        Query qryTraces=new QueryImpl(
                new Collection.Key[]{
                    KeyConstants._type,
                    KeyConstants._category,
                    KeyConstants._text,
                    KeyConstants._template,
                    KeyConstants._line,
                    KeyConstants._action,
                    KeyConstants._varname,
                    KeyConstants._varvalue,
                    KeyConstants._time},
                len,"traces");
        if(len>0) {
          try {
            Iterator<DebugTraceImpl> it = traces.iterator();
            DebugTraceImpl trace;
            row=0;
            while(it.hasNext()) {
              trace= it.next();
              row++;
              qryTraces.setAt(KeyConstants._type,row,LogUtil.toStringType(trace.getType(), "INFO"))
              if(!StringUtil.isEmpty(trace.getCategory()))qryTraces.setAt(KeyConstants._category,row,trace.getCategory());
              if(!StringUtil.isEmpty(trace.getText()))qryTraces.setAt(KeyConstants._text,row,trace.getText());
              if(!StringUtil.isEmpty(trace.getTemplate()))qryTraces.setAt(KeyConstants._template,row,trace.getTemplate());
              if(trace.getLine()>0)qryTraces.setAt(KeyConstants._line,row,new Double(trace.getLine()));
              if(!StringUtil.isEmpty(trace.getAction()))qryTraces.setAt(KeyConstants._action,row,trace.getAction());
              if(!StringUtil.isEmpty(trace.getVarName()))qryTraces.setAt(KeyImpl.init("varname"),row,trace.getVarName());
              if(!StringUtil.isEmpty(trace.getVarValue()))qryTraces.setAt(KeyImpl.init("varvalue"),row,trace.getVarValue());
              qryTraces.setAt(KeyConstants._time,row,new Double(trace.getTime()));
            }
      }
      catch(PageException dbe) {}
        }
       


    // scope access
    len=implicitAccesses==null?0:implicitAccesses.size();
        Query qryImplicitAccesseses=new QueryImpl(
                new Collection.Key[]{
                    KeyConstants._template,
                    KeyConstants._line,
                    KeyConstants._scope,
                    KeyConstants._count,
                    KeyConstants._name},
                len,"implicitAccess");
        if(len>0) {
          try {
            Iterator<ImplicitAccessImpl> it = implicitAccesses.values().iterator();
            ImplicitAccessImpl das;
            row=0;
            while(it.hasNext()) {
              das= it.next();
              row++;
              qryImplicitAccesseses.setAt(KeyConstants._template,row,das.getTemplate());
              qryImplicitAccesseses.setAt(KeyConstants._line,row,new Double(das.getLine()));
              qryImplicitAccesseses.setAt(KeyConstants._scope,row,das.getScope());
              qryImplicitAccesseses.setAt(KeyConstants._count,row,new Double(das.getCount()));
              qryImplicitAccesseses.setAt(KeyConstants._name,row,das.getName())
             
            }
      }
      catch(PageException dbe) {}
        }
       
        Query history=new QueryImpl(new Collection.Key[]{},0,"history");
        try {
      history.addColumn(KeyConstants._id, historyId);
          history.addColumn(KeyConstants._level, historyLevel);
    } catch (PageException e) {
    }
   
    if(addAddionalInfo) {
      debugging.setEL(KeyConstants._cgi,pc.cgiScope());
View Full Code Here

              if(!StringUtil.isEmpty(custom2))columns.append("custom2");
              if(!StringUtil.isEmpty(custom3))columns.append("custom3");
              if(!StringUtil.isEmpty(custom4))columns.append("custom4");
             
            // populate query with a single row
                qv=new QueryImpl(columns,1,"query");
                // body
                qv.setAt(KeyConstants._key, 1, key);
                key="key";

                // body
View Full Code Here

            "key","language","query","title","urlpath","type"};
        String[] types = new String[]{
            v,v,v,v,v,v,v,
            v,v,v,v,v,v};
        try {
            query=new QueryImpl(cols,types, 0,"query");
        } catch (DatabaseException e) {
            query=new QueryImpl(cols, 0,"query");
        }
       
        Entry<String, SearchIndex> entry;
        SearchIndex index;
        int row=0;
View Full Code Here

      if(columns!=null) {
        if(keys.length==2 && contains(keys,KeyConstants._DATA)) {
         
          Array[] data = toData(sct.get(KeyConstants._DATA,null),columns);
          if(data!=null) {
            return new QueryImpl(columns,data,"query");
          }
        }
       
        else if(keys.length==3 && rowcount!=-1 && contains(keys,KeyConstants._DATA)) {
          Array[] data = toData(sct.get(KeyConstants._DATA,null),columns,rowcount);
          if(data!=null) {
            return new QueryImpl(columns,data,"query");
          }
        }
      }
      return toQuery(sct,keys);
    }
View Full Code Here

          ConfigWebImpl cw=(ConfigWebImpl) config;
        factories = new CFMLFactory[]{cw.getFactory()};
      }
       
        railo.runtime.type.Query qry=
          new QueryImpl(
              new Collection.Key[]{
                  KeyConstants._path,
                  KeyConstants._id,KeyConstants._hash,
                  KeyConstants._label,
                  HAS_OWN_SEC_CONTEXT,
                  KeyConstants._url,
                  CONFIG_FILE,
                  CLIENT_SIZE,CLIENT_ELEMENTS,SESSION_SIZE,SESSION_ELEMENTS},
              factories.length,getString("admin",action,"returnVariable"));
        pageContext.setVariable(getString("admin",action,"returnVariable"),qry);
        ConfigWebImpl cw;
        for(int i=0;i<factories.length;i++) {
          int row=i+1;
            CFMLFactoryImpl factory = (CFMLFactoryImpl) factories[i];
            cw = (ConfigWebImpl) factory.getConfig();
            qry.setAtEL(KeyConstants._path,row,ReqRspUtil.getRootPath(factory.getConfigWebImpl().getServletContext()));
           
            qry.setAtEL(CONFIG_FILE,row,factory.getConfigWebImpl().getConfigFile().getAbsolutePath());
            if(factory.getURL()!=null)qry.setAtEL(KeyConstants._url,row,factory.getURL().toExternalForm());
           

            qry.setAtEL(KeyConstants._id,row,factory.getConfig().getId());
            qry.setAtEL(KeyConstants._hash,row,SystemUtil.hash(factory.getConfigWebImpl().getServletContext()));
            qry.setAtEL(KeyConstants._label,row,factory.getLabel());
            qry.setAtEL(HAS_OWN_SEC_CONTEXT,row,Caster.toBoolean(cw.hasIndividualSecurityManager()));

            setScopeDirInfo(qry,row,CLIENT_SIZE,CLIENT_ELEMENTS,cw.getClientScopeDir());
            setScopeDirInfo(qry,row,SESSION_SIZE,SESSION_ELEMENTS,cw.getSessionScopeDir());
        }
    }
View Full Code Here

    private void doGetPlugins() throws PageException {
        Resource dir = getPluginDirectory();
     
      String[] list = dir.list(new PluginFilter());
      railo.runtime.type.Query qry=
          new QueryImpl(
              new Collection.Key[]{KeyConstants._name},
              list.length,getString("admin",action,"returnVariable"));
        pageContext.setVariable(getString("admin",action,"returnVariable"),qry);
       
        for(int i=0;i<list.length;i++) {
            int row=i+1;
            qry.setAtEL(KeyConstants._name,row,list[i]);
        }
     }
View Full Code Here

    private void doGetDebugEntry() throws PageException {
      DebugEntry[] entries = config.getDebugEntries();
     
      String rtn = getString("admin",action,"returnVariable");
      railo.runtime.type.Query qry=
          new QueryImpl(new Collection.Key[]{KeyConstants._id,LABEL,IP_RANGE,READONLY,KeyConstants._type,CUSTOM},entries.length,rtn);
        pageContext.setVariable(rtn,qry);
        DebugEntry de;
        for(int i=0;i<entries.length;i++) {
            int row=i+1;
            de=entries[i];
            qry.setAtEL(KeyConstants._id,row,de.getId());
            qry.setAtEL(LABEL,row,de.getLabel());
            qry.setAtEL(IP_RANGE,row,de.getIpRangeAsString());
            qry.setAtEL(KeyConstants._type,row,de.getType());
            qry.setAtEL(READONLY,row,Caster.toBoolean(de.isReadOnly()));
            qry.setAtEL(CUSTOM,row,de.getCustom());
        }
    }
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.