Package org.apache.jackrabbit.ocm.query

Examples of org.apache.jackrabbit.ocm.query.Query


                QueryManager queryManager = ocm.getQueryManager();
                Filter filter = queryManager.createFilter(Paragraph.class);
                filter.addLike("text", "Para%");
                filter.setScope("/test/");

                Query query = queryManager.createQuery(filter);
                query.addOrderByDescending("text");

                String strQueryBuilderStringWithDescending = ((QueryImpl)query).getOrderByExpression();

                Collection result = ocm.getObjects(query);
                assertEquals("Invalid number of objects - should be = 3", 3, result.size());

                //Text is Descending
                Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
                Iterator iterator = result.iterator();
                Paragraph para = (Paragraph)iterator.next();
                assertEquals("Para 3",para.getText());
                para = (Paragraph)iterator.next();
                assertEquals("Para 2",para.getText());
                para = (Paragraph)iterator.next();
                assertEquals("Para 1",para.getText());

                //Text is Ascending
                query = queryManager.createQuery(filter);
                query.addOrderByAscending("text");

                ocm = this.getObjectContentManager();
                result = ocm.getObjects(query);
                assertEquals("Invalid number of objects - should be = 3", 3, result.size());
                iterator = result.iterator();
View Full Code Here


      // Test Boolean value
      QueryManager queryManager = ocm.getQueryManager();
      Filter filter = queryManager.createFilter(Atomic.class);
      filter.addEqualTo("booleanObject", new Boolean(true));
      Query query = queryManager.createQuery(filter);

      long start = System.currentTimeMillis();
      Collection result = ocm.getObjects(query);
      log.info("getObjects  : " + (System.currentTimeMillis() - start));
View Full Code Here

    // Test Boolean value
    QueryManager queryManager = ocm.getQueryManager();
    Filter filter = queryManager.createFilter(Atomic.class);
    filter.addEqualTo("int2boolean", new Boolean(true));
    Query query = queryManager.createQuery(filter);

    long start = System.currentTimeMillis();
    Collection result = ocm.getObjects(query);
    log.info("getObjects  : " + (System.currentTimeMillis() - start));
View Full Code Here

  //--------------------------------------------------------------------------------------------------------- 
  // Retrieve Folders found on the root level
  //---------------------------------------------------------------------------------------------------------     
  QueryManager queryManager = ocm.getQueryManager();
  Filter filter = queryManager.createFilter(Folder.class);
  Query query = queryManager.createQuery(filter);
  filter.setScope("/");
  Collection result = ocm.getObjects(query);
  assertEquals("Invalid number of folders found", result.size(), 2);
  assertTrue("Invalid item in the collection", this.contains(result, "/folder1",FolderImpl.class));
  assertTrue("Invalid item in the collection", this.contains(result, "/folder2", FolderImpl.class));   
View Full Code Here

    //---------------------------------------------------------------------------------------------------------
    // Retrieve Folders found on the root level
    //---------------------------------------------------------------------------------------------------------
    QueryManager queryManager = ocm.getQueryManager();
    Filter filter = queryManager.createFilter(FolderImpl.class);
    Query query = queryManager.createQuery(filter);
    filter.setScope("/");
    Collection result = ocm.getObjects(query);
    assertEquals("Invalid number of folders found", result.size(), 2);
    assertTrue("Invalid item in the collection", this.contains(result, "/folder1",FolderImpl.class));
    assertTrue("Invalid item in the collection", this.contains(result, "/folder2", FolderImpl.class));
View Full Code Here

        {
            // construct query filter
            QueryManager queryManager = ocm.getQueryManager();
            Filter filter = queryManager.createFilter(beanClass);
            filter.setScope(beanClassNodeRootPaths.get(beanClass)+"//");
            Query query = queryManager.createQuery(filter);
           
            // invoke query
            Collection<? extends IBean> beansExtentList = ocm.getObjects(query);
            if ((beansExtentList != null) && !beansExtentList.isEmpty())
            {
View Full Code Here

                {
                    value = ((IUuidBean)value).getUuid();
                }
                filter = ((value != null) ? filter.addEqualTo(name, value) : filter.addIsNull(name));
            }           
            Query query = queryManager.createQuery(filter);
            if (orderBy != null)
            {
                String mappedOrderBy = IMPLEMENTATION_FIELD_MAP.get(orderBy);
                orderBy = ((mappedOrderBy != null) ? mappedOrderBy : orderBy);
                if (ascending)
                {
                    query.addOrderByAscending(orderBy);
                }
                else
                {
                    query.addOrderByDescending(orderBy);
                }
            }

            // invoke query
            Collection<? extends IBean> beansExtentList = ocm.getObjects(query);
View Full Code Here

                        valueValue = ((IUuidBean)valueValue).getUuid();
                    }
                    filter = ((valueValue != null) ? filter.addEqualTo(valueName, valueValue) : filter.addIsNull(valueName));
                }
            }
            Query query = queryManager.createQuery(filter);
            if (orderBy != null)
            {
                String mappedOrderBy = IMPLEMENTATION_FIELD_MAP.get(orderBy);
                orderBy = ((mappedOrderBy != null) ? mappedOrderBy : orderBy);
                if (ascending)
                {
                    query.addOrderByAscending(orderBy);
                }
                else
                {
                    query.addOrderByDescending(orderBy);
                }
            }

            // invoke query
            Collection<? extends IBean> beansExtentList = ocm.getObjects(query);
View Full Code Here

    //---------------------------------------------------------------------------------------------------------
    // Retrieve Folders found on the root level
    //---------------------------------------------------------------------------------------------------------
    QueryManager queryManager = ocm.getQueryManager();
    Filter filter = queryManager.createFilter(FolderImpl.class);
    Query query = queryManager.createQuery(filter);
    filter.setScope("/");
    Collection result = ocm.getObjects(query);
    assertEquals("Invalid number of folders found", result.size(), 2);
    assertTrue("Invalid item in the collection", this.contains(result, "/folder1",FolderImpl.class));
    assertTrue("Invalid item in the collection", this.contains(result, "/folder2", FolderImpl.class));
View Full Code Here

       
      // Query all objects
      QueryManager queryManager = this.getQueryManager();
      Filter filter = queryManager.createFilter(Atomic.class)
      filter.setScope("/");
      Query query = queryManager.createQuery(filter);
      Collection result = ocm.getObjects(query);
            assertEquals("Incorrect number of objects found", 10, result.size());

            // Get objects
            Atomic atomic = (Atomic) ocm.getObject( "/test[2]");
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.ocm.query.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.