Package ch.entwine.weblounge.common.impl.content

Examples of ch.entwine.weblounge.common.impl.content.SearchQueryImpl


    } catch (Throwable t) {
      throw new IllegalStateException("Unable to instantiate class " + handlerClass + ": " + t.getMessage(), t);
    }

    SearchResult searchResult;
    SearchQuery q = new SearchQueryImpl(site);
    q.withTypes(MovieResource.TYPE);
    q.sortByPublishingDate(Order.Descending);
    q.withPublisher(harvesterUser);
    try {
      searchResult = contentRepository.find(q);
    } catch (ContentRepositoryException e) {
      logger.error("Error searching for resources with harvester publisher.");
      throw new RuntimeException(e);
View Full Code Here


   *          the record identifier
   * @return the search result
   */
  private SearchResult searchSource(String sourceIdentifier) {
    SearchResult searchResult;
    SearchQuery q = new SearchQueryImpl(site);
    q.withSource(sourceIdentifier);
    try {
      searchResult = contentRepository.find(q);
    } catch (ContentRepositoryException e) {
      logger.error("Error searching for resources with given subject: " + sourceIdentifier);
      throw new RuntimeException(e);
View Full Code Here

        logger.debug("Unable to load content repository for site '{}'", site);
        throw new ContentRepositoryUnavailableException();
      }

      // Specify which pages to load
      SearchQuery query = new SearchQueryImpl(site);
      query.withVersion(Resource.LIVE);

      // Add the keywords (or)
      for (String subject : subjects) {
        query.withSubject(subject);
      }

      // Add the pagelets required on stage (and)
      if (requiredPagelets.size() > 0) {
        List<Pagelet> pagelets = new ArrayList<Pagelet>();
        for (String headline : requiredPagelets) {
          String[] parts = headline.split("/");
          if (parts.length > 1) {
            Pagelet pagelet = new PageletImpl(parts[0], parts[1]);
            pagelets.add(pagelet);
          }
        }
        query.withPagelets(All, pagelets.toArray(new Pagelet[pagelets.size()])).inStage();
      }

      // Order by date and limit the result set
      query.sortByPublishingDate(SearchQuery.Order.Descending);
      query.withLimit(count);

      // Finally Load the pages
      pages = repository.find(query);
    }
View Full Code Here

      logger.debug("Unable to load content repository for site '{}'", site);
      response.invalidate();
      return SKIP_BODY;
    }

    SearchQuery query = new SearchQueryImpl(site);
    query.withVersion(Resource.LIVE);
    query.withTypes(ImageResource.TYPE);
    for (int i = 0; i < imageSubjects.size(); i++)
      query.withSubject(imageSubjects.get(i));
    SearchResult result;
    try {
      result = repository.find(query);
    } catch (ContentRepositoryException e) {
      logger.warn("Error searching for image with given subjects.");
View Full Code Here

      p.setTemplate(template.getIdentifier());
      repository.put(p);
    }

    // Make sure everything is the way we set it up
    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).withPath(root);
    assertEquals(1, repository.find(q).getDocumentCount());
    q = new SearchQueryImpl(site).withTypes(Page.TYPE).withPathPrefix(root);
    assertEquals(pages, repository.find(q).getDocumentCount());

    // Move the resources
    repository.move(rootURI, newRoot, true);

    // Make sure everything is gone from /root
    q = new SearchQueryImpl(site).withTypes(Page.TYPE).withPath(root);
    assertEquals(0, repository.find(q).getDocumentCount());
    q = new SearchQueryImpl(site).withTypes(Page.TYPE).withPathPrefix(root);
    assertEquals(0, repository.find(q).getDocumentCount());

    // Make sure everything can be found in the new place
    q = new SearchQueryImpl(site).withTypes(Page.TYPE).withPath(newRoot);
    assertEquals(1, repository.find(q).getDocumentCount());
    q = new SearchQueryImpl(site).withTypes(Page.TYPE).withPathPrefix(newRoot);
    assertEquals(pages, repository.find(q).getDocumentCount());

  }
View Full Code Here

  @Test
  public void testFind() throws IllegalStateException,
  ContentRepositoryException, IOException {
    populateRepository();
    SearchQuery q = null;
    q = new SearchQueryImpl(site).withTemplate("default");
    assertEquals(1, repository.find(q).getDocumentCount());
    assertEquals(1, repository.find(q).getHitCount());
  }
View Full Code Here

    Page work = new PageImpl(workURI);
    work.setTemplate(template.getIdentifier());

    repository.put(work);

    SearchQuery q = new SearchQueryImpl(site);
    q.withoutPublication();

    SearchResult result = repository.find(q);
    assertEquals(1, result.getDocumentCount());
  }
View Full Code Here

  @Test
  public void testWithoutModification() throws ContentRepositoryException,
  IllegalStateException, IOException {
    FileResource fileResource = new FileResourceImpl(documentURI);

    SearchQuery q = new SearchQueryImpl(site);
    SearchResult result = repository.find(q);
    assertEquals(1, result.getDocumentCount());

    repository.put(fileResource);

    q = new SearchQueryImpl(site);
    q.withoutModification();

    result = repository.find(q);
    assertEquals(2, result.getDocumentCount());
  }
View Full Code Here

      DispatchUtils.sendServiceUnavailable(request, response);
      return true;
    }

    // Create the search expression and the query
    SearchQuery q = new SearchQueryImpl(site);
    q.withText(true, queryString);
    q.withVersion(Resource.LIVE);
    q.withRececyPriority();
    q.withOffset(offset);
    q.withLimit(limit);
    q.withTypes(Page.TYPE);

    // Return the result
    SearchResult result = null;
    try {
      result = repository.find(q);
View Full Code Here

    SearchResult result = null;

    // Make sure the homepage doesn't get into our way
    repository.delete(new PageURIImpl(site, "/"), true);

    SearchQuery workPreferredQuery = new SearchQueryImpl(site).withPreferredVersion(WORK).sortByCreationDate(Order.Ascending);
    SearchQuery livePreferredQuery = new SearchQueryImpl(site).withPreferredVersion(LIVE).sortByCreationDate(Order.Ascending);
    SearchQuery workOnlyQuery = new SearchQueryImpl(site).withVersion(WORK).sortByCreationDate(Order.Ascending);
    SearchQuery liveOnlyQuery = new SearchQueryImpl(site).withVersion(LIVE).sortByCreationDate(Order.Ascending);

    // Test empty repository
    assertEquals(0, repository.find(workPreferredQuery).getDocumentCount());
    assertEquals(0, repository.find(livePreferredQuery).getDocumentCount());
    assertEquals(0, repository.find(workOnlyQuery).getDocumentCount());
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.impl.content.SearchQueryImpl

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.