Package ch.entwine.weblounge.common.content

Examples of ch.entwine.weblounge.common.content.SearchQuery


   * .
   */
  @Test
  public void testGetWithFilename() throws Exception {
    populateIndex();
    SearchQuery q = new SearchQueryImpl(site);
    q.withFilename(filename);
    assertEquals(2, idx.getByQuery(q).getDocumentCount());
  }
View Full Code Here


   * .
   */
  @Test
  public void testGetWithMimetype() throws Exception {
    populateIndex();
    SearchQuery q = new SearchQueryImpl(site);
    q.withMimetype(mimetype);
    assertEquals(2, idx.getByQuery(q).getDocumentCount());
  }
View Full Code Here

    populateIndex();

    idx.clear();

    // Run a query and see if we get anything back
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE);
    assertEquals(0, idx.getByQuery(q).getDocumentCount());
  }
View Full Code Here

    // Delete a page
    idx.delete(pages[0].getURI());

    // Test if we can query for the added document
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE);
    assertEquals(pages.length - 1, idx.getByQuery(q).getDocumentCount());
  }
View Full Code Here

   * .
   */
  @Test
  public void testAdd() throws Exception {
    populateIndex();
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE);
    assertEquals(pages.length, idx.getByQuery(q).getDocumentCount());
  }
View Full Code Here

    // Post the update
    idx.update(page);

    // Check if the index actually reflects the updated data
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).withSubject(subject);
    assertEquals(1, idx.getByQuery(q).getDocumentCount());
  }
View Full Code Here

    // Post the update
    idx.move(pages[0].getURI(), newPath);

    // Make sure there is a page with the new path
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).withPath(newPath);
    assertEquals(1, idx.getByQuery(q).getDocumentCount());

    // Make sure the number of pages remains the same
    q = new SearchQueryImpl(site).withTypes(Page.TYPE);
    assertEquals(pages.length, idx.getByQuery(q).getDocumentCount());
View Full Code Here

   * @return the number of resources
   * @throws ContentRepositoryException
   *           if querying for the resource count fails
   */
  public long getResourceCount() throws ContentRepositoryException {
    SearchQuery q = new SearchQueryImpl(site).withPreferredVersion(Resource.LIVE).withField(RESOURCE_ID);
    return searchIdx.getByQuery(q).getHitCount();
  }
View Full Code Here

   * @return the number of revisions
   * @throws ContentRepositoryException
   *           if querying for the resource count fails
   */
  public long getRevisionCount() throws ContentRepositoryException {
    SearchQuery q = new SearchQueryImpl(site).withField(RESOURCE_ID);
    return searchIdx.getByQuery(q).getHitCount();
  }
View Full Code Here

    long version = uri.getVersion();

    // Make sure we are not asked to add a resource to the index that has the
    // same id as an existing one
    if (id != null) {
      SearchQuery q = new SearchQueryImpl(site).withIdentifier(id).withPreferredVersion(version).withLimit(1).withField(PATH);
      SearchResultItem[] items = searchIdx.getByQuery(q).getItems();
      if (items.length > 0) {
        long versionInIndex = (Long) ((ResourceSearchResultItem) items[0]).getMetadataByKey(VERSION).getValue();
        if (items.length == 1 && versionInIndex == version)
          throw new ContentRepositoryException("Resource '" + id + "' already exists in version " + version);
        if (path == null) {
          path = (String) ((ResourceSearchResultItem) items[0]).getMetadataByKey(PATH).getValue();
          resource.getURI().setPath(path);
        }
      }
    }

    // Make sure we are not asked to add a resource to the index that has the
    // same path as an existing one
    if (path != null) {
      SearchQuery q = new SearchQueryImpl(site).withPath(path).withPreferredVersion(version).withLimit(1).withField(RESOURCE_ID);
      SearchResultItem[] items = searchIdx.getByQuery(q).getItems();
      if (items.length > 0) {
        long versionInIndex = (Long) ((ResourceSearchResultItem) items[0]).getMetadataByKey(VERSION).getValue();
        if (items.length == 1 && versionInIndex == version)
          throw new ContentRepositoryException("Resource '" + id + "' already exists in version " + version);
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.content.SearchQuery

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.