Package railo.runtime.type

Examples of railo.runtime.type.Query


        }
        else if(type==SearchIndex.TYPE_URL) {
          ir=indexURL(id,title,new URL(key),extensions,recurse,language,timeout);
        }
        else if(type==SearchIndex.TYPE_CUSTOM) {
          Query qv;
          if(StringUtil.isEmpty(query)){
           
          // set columns
            railo.runtime.type.Array columns=new ArrayImpl();
              columns.append("key");
              columns.append("body");
              if(!StringUtil.isEmpty(title))columns.append("title");
              if(!StringUtil.isEmpty(urlpath))columns.append("urlpath");
              if(!StringUtil.isEmpty(custom1))columns.append("custom1");
              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
                qv.setAt(KeyConstants._body, 1, body);
                body="body";

                // title
                if(!StringUtil.isEmpty(title)){
                  qv.setAt(KeyConstants._title, 1, title);
                  title="title";
                }

                // urlpath
                if(!StringUtil.isEmpty(urlpath)){
                  qv.setAt("urlpath", 1, urlpath);
                  urlpath="urlpath";
                }

                // custom1
                if(!StringUtil.isEmpty(custom1)){
                  qv.setAt("custom1", 1, custom1);
                  custom1="custom1";
                }
                // custom2
                if(!StringUtil.isEmpty(custom2)){
                  qv.setAt("custom2", 1, custom2);
                  custom2="custom2";
                }
                // custom3
                if(!StringUtil.isEmpty(custom3)){
                  qv.setAt("custom3", 1, custom3);
                  custom3="custom3";
                }
                // custom4
                if(!StringUtil.isEmpty(custom4)){
                  qv.setAt("custom4", 1, custom4);
                  custom4="custom4";
                }
            }
          else qv = Caster.toQuery(pc.getVariable(query));
           
          QueryColumn keyColumn=qv.getColumn(key);
           
            String[] strBodies=ListUtil.toStringArrayTrim(ListUtil.listToArrayRemoveEmpty(body,','));
            QueryColumn[] bodyColumns=new QueryColumn[strBodies.length];
            for(int i=0;i<bodyColumns.length;i++) {
                bodyColumns[i]=qv.getColumn(strBodies[i]);
            }
           
            ir= indexCustom(id,
                getValue(qv,title),
                    keyColumn,
View Full Code Here


          // delete all when no key is defined
          if(StringUtil.isEmpty(key,true))
            return deleteIndexNotCustom(pc, key, type, queryName);
         
          try{
            Query qv;
              if(!StringUtil.isEmpty(queryName)) {
                k=KeyImpl.init(key);
                qv = Caster.toQuery(pc.getVariable(queryName));
              }
              else {
                k=KeyConstants._id;
                    Key[] cols = new Key[]{k};
                    String[] types = new String[]{"VARCHAR"};
                qv=new QueryImpl(cols,types, 1,"query");
                qv.setAtEL(k, 1, key);
              }
           
           
           
              QueryColumn keyColumn=qv.getColumn(k);
            return deleteCustom("custom", keyColumn);
          }
          catch(PageException pe){
            throw new SearchException(pe);
          }
View Full Code Here

  // FUTURE
  public Object getIndexesAsQuery() {
    Iterator<Entry<String, SearchIndex>> it = indexes.entrySet().iterator();
   
    final String v="VARCHAR";
        Query query=null;
        String[] cols = new String[]{
            "categories","categoryTree","custom1","custom2","custom3","custom4","extensions",
            "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;
    while(it.hasNext()) {
      query.addRow();
      row++;
          entry = it.next();
          index= entry.getValue();
          if(index==null)continue;
          try {
           
                query.setAt("categories",row,ListUtil.arrayToList(index.getCategories(),""));
                query.setAt("categoryTree",row,index.getCategoryTree());
               
                query.setAt(KeyConstants._custom1,row,index.getCustom1());
                query.setAt(KeyConstants._custom2,row,index.getCustom2());
                query.setAt(KeyConstants._custom3,row,index.getCustom3());
                query.setAt(KeyConstants._custom4,row,index.getCustom4());
               
                query.setAt(KeyConstants._extensions,row,ListUtil.arrayToList(index.getExtensions(),","));
                query.setAt(KeyConstants._key,row,index.getKey());
                query.setAt(KeyConstants._language,row,index.getLanguage());
                query.setAt(KeyConstants._query,row,index.getQuery());
                query.setAt(KeyConstants._title,row,index.getTitle());
                query.setAt(KeyConstants._urlpath,row,index.getUrlpath());
                query.setAt(KeyConstants._type,row,SearchIndex.toStringTypeEL(index.getType()));
               
          }
        catch(PageException pe) {}
      }
    return query;
View Full Code Here

       

        InitialLdapContext context = new InitialLdapContext(env, null);
       
        // Search
        Query qry=new QueryImpl(attributes,0,"query");
        try {
            NamingEnumeration results = context.search(start, filter, controls);
           
            // Fill result
            int row=1;
            if(!attEQAsterix) {
                while(results.hasMoreElements()) {
                    SearchResult resultRow = (SearchResult)results.next();
                    if(row++<startrow)continue;
                   
                    int len=qry.addRow();
                    NamingEnumeration rowEnum = resultRow.getAttributes().getAll();
                    String dn = resultRow.getNameInNamespace();
                    qry.setAtEL("dn",len,dn);
                    while(rowEnum.hasMore()) {
                        Attribute attr = (Attribute)rowEnum.next();
                        Collection.Key key = KeyImpl.init(attr.getID());
                        Enumeration values = attr.getAll();
                        Object value;
                        String existing,strValue;
                        while(values.hasMoreElements()) {
                            value = values.nextElement();
                            strValue=Caster.toString(value,null);
                            existing=Caster.toString(qry.getAt(key, len,null),null);
                            if(!StringUtil.isEmpty(existing) && !StringUtil.isEmpty(strValue)) {
                              value = existing + separator + strValue;
                           }
                            else if(!StringUtil.isEmpty(existing))
                              value = existing;
                           
                           qry.setAtEL(key,len,value);
                        }           
                    }
                    if(maxrows>0 && len>=maxrows)break;
                }
            }
            else {
               
                outer:while(results.hasMoreElements()) {
                    SearchResult resultRow = (SearchResult)results.next();
                    if(row++<startrow)continue;
                   
                    Attributes attributesRow = resultRow.getAttributes();
                    NamingEnumeration rowEnum = attributesRow.getIDs();
                    while(rowEnum.hasMoreElements()) {
                        int len=qry.addRow();
                        String name = Caster.toString(rowEnum.next());
                        Object value=null;
                       
                        try {
                            value=attributesRow.get(name).get();
                        }catch(Exception e) {}
                       
                        qry.setAtEL("name",len,name);
                        qry.setAtEL("value",len,value);
                        if(maxrows>0 && len>=maxrows)break outer;
                    }
                    qry.setAtEL("name",qry.size(),"dn");
                }
            }
        }
        finally {
            context.close();
        }
        // Sort
        if(sort!=null && sort.length>0) {
            int order = sortDirection==SORT_DIRECTION_ASC ? Query.ORDER_ASC : Query.ORDER_DESC;
            for(int i=sort.length-1;i>=0;i--) {
                String item=sort[i];
                if(item.indexOf(' ')!=-1)item=ListUtil.first(item," ",true);
                qry.sort(KeyImpl.getInstance(item),order);
                //keys[i] = new SortKey(item);
            }
        }   
        return qry;
    }
View Full Code Here

    private Query toCFMLObject(ASRecordSet rs) throws PageException {
        String[] columns = rs.getColumnNames();
        List rows = rs.rows();
        int len=0;
        if(rows.size()>0) len=((List)rows.get(0)).size();
        Query qry=new QueryImpl(columns,len,"query");
       
        List row;
        for(int iCol=0;iCol<columns.length;iCol++) {
            row=(List) rows.get(iCol);
            QueryColumn column = qry.getColumn(columns[iCol]);
           
            for(int iRow=0;iRow<row.size();iRow++) {
                column.set(iRow+1,toCFMLObject(row.get(iRow)));
            }
        }
View Full Code Here

  }
 
  private void doActionCreate() throws PageException {
   
    // name
    Query qry;
    Struct props;
    boolean splitString=true;
    if(name!=null)  {
      Struct data;
      if(name instanceof String){
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.