Example #1
0
  @Test
  @SuppressWarnings("unchecked")
  public void testGroupsPageProviderSearchMode() {
    Map<String, Serializable> properties = new HashMap<String, Serializable>();
    properties.put(
        AbstractGroupsPageProvider.GROUPS_LISTING_MODE_PROPERTY,
        AbstractGroupsPageProvider.SEARCH_ONLY_MODE);
    PageProvider<DocumentModel> groupsProvider =
        (PageProvider<DocumentModel>)
            ppService.getPageProvider(PROVIDER_NAME, null, null, null, properties, "gr");
    List<DocumentModel> groups = groupsProvider.getCurrentPage();
    assertNotNull(groups);
    assertEquals(2, groups.size());
    DocumentModel group = groups.get(0);
    assertEquals("group1", group.getId());
    group = groups.get(1);
    assertEquals("group2", group.getId());

    // check computed groups
    groupsProvider =
        (PageProvider<DocumentModel>)
            ppService.getPageProvider(PROVIDER_NAME, null, null, null, properties, "Grp");
    groups = groupsProvider.getCurrentPage();
    assertNotNull(groups);
    assertEquals(2, groups.size());
    group = groups.get(0);
    assertEquals("Grp1", group.getId());
    group = groups.get(1);
    assertEquals("Grp2", group.getId());
  }
  @Test
  public void iCanGetLatestUploadsPageProvider() throws Exception {
    DocumentModel site = createSite();

    PageClasseur classeur =
        new PageClasseurAdapter.Model(
                session,
                site.getPathAsString() + "/" + LabsSiteConstants.Docs.TREE.docName(),
                "ma page classeur")
            .desc("desc page classeur")
            .create();
    assertThat(classeur.getFolders().size(), is(0));

    classeur.addFolder("My Folder", null);
    session.save();
    PageClasseurFolder folder = classeur.getFolders().get(0);
    assertThat(folder.getFiles().size(), is(0));
    folder.addFile(getTestBlob(), "Pomodoro cheat sheet", "title");
    session.save();
    assertThat(folder.getFiles().size(), is(1));
    session.save();

    Tools.getAdapter(LabsPublisher.class, classeur.getDocument(), null).publish();

    PageProvider<DocumentModel> latestUploadsPageProvider =
        LabsSiteWebAppUtils.getLatestUploadsPageProvider(site, 0, session);
    assertNotNull(latestUploadsPageProvider);
    List<DocumentModel> lastUploadedDoc = latestUploadsPageProvider.getCurrentPage();
    assertNotNull(lastUploadedDoc);
    assertEquals(1, lastUploadedDoc.size());
  }
Example #3
0
  @Test
  @SuppressWarnings("unchecked")
  public void testGroupsPageProviderAllMode() {
    Map<String, Serializable> properties = new HashMap<String, Serializable>();
    properties.put(
        AbstractGroupsPageProvider.GROUPS_LISTING_MODE_PROPERTY,
        AbstractGroupsPageProvider.ALL_MODE);
    PageProvider<DocumentModel> groupsProvider =
        (PageProvider<DocumentModel>)
            ppService.getPageProvider(PROVIDER_NAME, null, null, null, properties, "");
    List<DocumentModel> groups = groupsProvider.getCurrentPage();
    assertNotNull(groups);
    assertEquals(5, groups.size());

    DocumentModel group = groups.get(0);
    assertEquals("administrators", group.getId());
    group = groups.get(1);
    assertEquals("group1", group.getId());
    group = groups.get(2);
    assertEquals("group2", group.getId());
    group = groups.get(3);
    assertEquals("members", group.getId());
    group = groups.get(4);
    assertEquals("powerusers", group.getId());
  }
  @Test
  public void testSimplePageProviderWithParams() throws Exception {

    LogEntryGen.generate("withParams", "entry", "category", 15);
    PageProvider<?> pp =
        pps.getPageProvider(
            "SimpleESAuditPPWithParams",
            null,
            Long.valueOf(5),
            Long.valueOf(0),
            new HashMap<String, Serializable>(),
            "category1");
    assertNotNull(pp);

    List<LogEntry> entries = (List<LogEntry>) pp.getCurrentPage();
    Assert.assertEquals(2, entries.size());

    // check that sort does work
    Assert.assertTrue(entries.get(0).getId() > entries.get(1).getId());

    pp =
        pps.getPageProvider(
            "SimpleESAuditPPWithParams",
            null,
            Long.valueOf(5),
            Long.valueOf(0),
            new HashMap<String, Serializable>(),
            "category0");
    entries = (List<LogEntry>) pp.getCurrentPage();
    Assert.assertEquals(1, entries.size());
  }
Example #5
0
 @Override
 public void refreshAndRewindPageProvider() {
   if (pageProvider != null) {
     pageProvider.refresh();
     pageProvider.firstPage();
   }
   setExecuted(true);
 }
Example #6
0
 @SuppressWarnings("rawtypes")
 @Override
 public void resetPageProviderAggregates() {
   if (pageProvider != null && pageProvider.hasAggregateSupport()) {
     Map<String, ? extends Aggregate> aggs = pageProvider.getAggregates();
     for (Aggregate agg : aggs.values()) {
       agg.resetSelection();
     }
   }
 }
Example #7
0
 @Override
 public void resetSearchDocumentModel() {
   searchDocumentModel = null;
   if (pageProvider != null) {
     pageProvider.setSearchDocumentModel(null);
   }
 }
Example #8
0
 @Override
 public void setSearchDocumentModel(DocumentModel searchDocumentModel) {
   this.searchDocumentModel = searchDocumentModel;
   if (pageProvider != null) {
     pageProvider.setSearchDocumentModel(searchDocumentModel);
   }
 }
Example #9
0
 @SuppressWarnings("unchecked")
 protected List<DocumentModel> getDomainsFiltered() {
   PageProviderService pps = Framework.getService(PageProviderService.class);
   Map<String, Serializable> props = new HashMap<String, Serializable>();
   props.put(CoreQueryDocumentPageProvider.CORE_SESSION_PROPERTY, (Serializable) session);
   PageProvider<DocumentModel> pageProvider =
       (PageProvider<DocumentModel>)
           pps.getPageProvider(
               PUBLISHING_DOMAINS_PROVIDER,
               null,
               null,
               null,
               props,
               new Object[] {session.getRootDocument().getId()});
   return pageProvider.getCurrentPage();
 }
Example #10
0
 @Override
 public void refreshPageProvider() {
   if (pageProvider != null) {
     pageProvider.refresh();
   }
   setExecuted(true);
 }
  @Test
  public void testSimplePageProviderWithUUID() throws Exception {

    LogEntryGen.generate("uuid1", "uentry", "ucategory", 10);
    PageProvider<?> pp =
        pps.getPageProvider(
            "SearchById",
            null,
            Long.valueOf(5),
            Long.valueOf(0),
            new HashMap<String, Serializable>(),
            "uuid1");
    assertNotNull(pp);

    List<LogEntry> entries = (List<LogEntry>) pp.getCurrentPage();
    Assert.assertEquals(5, entries.size());
  }
  @Test
  public void testAdminPageProvider() throws Exception {

    LogEntryGen.generate("uuid2", "aentry", "acategory", 10);

    PageProvider<?> pp =
        pps.getPageProvider(
            "ADMIN_HISTORY",
            null,
            Long.valueOf(5),
            Long.valueOf(0),
            new HashMap<String, Serializable>());
    assertNotNull(pp);

    List<LogEntry> entries = (List<LogEntry>) pp.getCurrentPage();
    Assert.assertEquals(5, entries.size());
  }
Example #13
0
 @Override
 public Long getCurrentPageSize() {
   // take actual value on page provider first in case it's reached its
   // max page size
   if (pageProvider != null) {
     long pageSize = pageProvider.getPageSize();
     long maxPageSize = pageProvider.getMaxPageSize();
     if (pageSize > 0 && maxPageSize > 0 && maxPageSize < pageSize) {
       return Long.valueOf(maxPageSize);
     }
     return Long.valueOf(pageSize);
   }
   if (currentPageSize != null && currentPageSize.longValue() >= 0) {
     return currentPageSize;
   }
   return null;
 }
 @SuppressWarnings("unchecked")
 protected List<DocumentModel> getCurrentPageDocuments(String contentViewName)
     throws ClientException {
   List<DocumentModel> documents = null;
   ContentView cView = contentViewActions.getContentView(contentViewName);
   if (cView != null) {
     PageProvider<?> cProvider = cView.getCurrentPageProvider();
     if (cProvider != null) {
       List<?> items = cProvider.getCurrentPage();
       try {
         documents = (List<DocumentModel>) items;
       } catch (Exception e) {
         throw new ClientException(e);
       }
     }
   }
   return documents;
 }
  @Test
  public void testSimplePageProvider() throws Exception {

    LogEntryGen.generate("dummy", "entry", "category", 15);
    PageProvider<?> pp =
        pps.getPageProvider(
            "SimpleESAuditPP",
            null,
            Long.valueOf(5),
            Long.valueOf(0),
            new HashMap<String, Serializable>());
    assertNotNull(pp);

    List<LogEntry> entries = (List<LogEntry>) pp.getCurrentPage();

    Assert.assertEquals(5, entries.size());
    Assert.assertEquals(5, pp.getCurrentPageSize());
    Assert.assertEquals(7, pp.getResultsCount());

    // check that sort does work
    Assert.assertTrue(entries.get(0).getId() < entries.get(1).getId());
    Assert.assertTrue(entries.get(3).getId() < entries.get(4).getId());
  }
Example #16
0
 @Override
 public boolean hasError() {
   return pageProvider.hasError();
 }
Example #17
0
 @Override
 public boolean isSortable() {
   return pageProvider.isSortable();
 }
Example #18
0
 @Override
 public long getCurrentPageIndex() {
   return pageProvider.getCurrentPageIndex();
 }
Example #19
0
 @Override
 public boolean isPreviousPageAvailable() {
   return pageProvider.isPreviousPageAvailable();
 }
Example #20
0
 @Override
 public boolean isLastPageAvailable() {
   return pageProvider.isLastPageAvailable();
 }
Example #21
0
 @Override
 public long getNumberOfPages() {
   return pageProvider.getNumberOfPages();
 }
Example #22
0
 @Override
 public String getErrorMessage() {
   return pageProvider.getErrorMessage();
 }
Example #23
0
 public PaginablePageProvider(PageProvider<T> pageProvider) {
   super(pageProvider.getCurrentPage());
   this.pageProvider = pageProvider;
 }
Example #24
0
 @Override
 public boolean hasAggregateSupport() {
   return pageProvider.hasAggregateSupport();
 }
Example #25
0
 @Override
 public Map<String, Aggregate<? extends Bucket>> getAggregates() {
   return pageProvider.getAggregates();
 }
  @Override
  public List<LogEntry> getDocumentHistory(DocumentModel doc, long pageIndex, long pageSize) {

    PageProvider<LogEntry> pp = getPageProvider(doc, pageIndex, pageSize);
    return pp.getCurrentPage();
  }
Example #27
0
 @Override
 public long getMaxPageSize() {
   return pageProvider.getMaxPageSize();
 }
Example #28
0
 @Override
 public long getResultsCount() {
   return pageProvider.getResultsCount();
 }
Example #29
0
 @Override
 public List<QuickFilter> getActiveQuickFilters() {
   return pageProvider.getQuickFilters();
 }
Example #30
0
 @Override
 public List<QuickFilter> getAvailableQuickFilters() {
   return pageProvider.getAvailableQuickFilters();
 }