Example usage for com.liferay.portal.atom AtomPager AtomPager

List of usage examples for com.liferay.portal.atom AtomPager AtomPager

Introduction

In this page you can find the example usage for com.liferay.portal.atom AtomPager AtomPager.

Prototype

public AtomPager(int page, int totalElements) 

Source Link

Usage

From source file:com.liferay.document.library.internal.atom.FileEntryAtomCollectionAdapter.java

License:Open Source License

@Override
protected Iterable<FileEntry> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception {

    long folderId = atomRequestContext.getLongParameter("folderId");

    long repositoryId = 0;

    if (folderId != 0) {
        Folder folder = _dlAppService.getFolder(folderId);

        repositoryId = folder.getRepositoryId();
    } else {//from  w  w w  . j  a v  a  2  s.  com
        repositoryId = atomRequestContext.getLongParameter("repositoryId");
    }

    int count = _dlAppService.getFileEntriesCount(repositoryId, folderId);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    return _dlAppService.getFileEntries(repositoryId, folderId, atomPager.getStart(), atomPager.getEnd() + 1,
            new RepositoryModelTitleComparator<FileEntry>());
}

From source file:com.liferay.document.library.internal.atom.FolderAtomCollectionAdapter.java

License:Open Source License

@Override
protected Iterable<Folder> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception {

    long repositoryId = 0L;

    long parentFolderId = atomRequestContext.getLongParameter("parentFolderId");

    if (parentFolderId != 0) {
        Folder parentFolder = _dlAppService.getFolder(parentFolderId);

        repositoryId = parentFolder.getRepositoryId();
    } else {/*  ww w  .  j a va  2  s.com*/
        repositoryId = atomRequestContext.getLongParameter("repositoryId");
    }

    int count = _dlAppService.getFoldersCount(repositoryId, parentFolderId);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    return _dlAppService.getFolders(repositoryId, parentFolderId, atomPager.getStart(), atomPager.getEnd() + 1,
            new FolderNameComparator());
}

From source file:com.liferay.journal.atom.JournalArticleAtomCollectionProvider.java

License:Open Source License

@Override
protected Iterable<JournalArticle> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception {

    List<JournalArticle> journalArticles = new ArrayList<>();

    long companyId = CompanyThreadLocal.getCompanyId();
    long groupId = atomRequestContext.getLongParameter("groupId");

    if ((companyId <= 0) || (groupId <= 0)) {
        return journalArticles;
    }// ww  w.j av  a  2  s .  co  m

    List<Long> folderIds = Collections.emptyList();
    long classNameId = 0;
    String keywords = null;
    Double version = null;
    String ddmStructureKey = null;
    String ddmTemplateKey = null;
    Date displayDateGT = null;
    Date displayDateLT = new Date();
    int status = WorkflowConstants.STATUS_APPROVED;
    Date reviewDate = null;

    OrderByComparator<JournalArticle> obc = new ArticleVersionComparator();

    int count = _journalArticleService.searchCount(companyId, groupId, folderIds, classNameId, keywords,
            version, ddmStructureKey, ddmTemplateKey, displayDateGT, displayDateLT, status, reviewDate);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    journalArticles = _journalArticleService.search(companyId, groupId, folderIds, classNameId, keywords,
            version, ddmStructureKey, ddmTemplateKey, displayDateGT, displayDateLT, status, reviewDate,
            atomPager.getStart(), atomPager.getEnd() + 1, obc);

    return journalArticles;
}

From source file:com.liferay.portlet.documentlibrary.atom.FileEntryAtomCollectionAdapter.java

License:Open Source License

@Override
protected Iterable<FileEntry> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception {

    long folderId = atomRequestContext.getLongParameter("folderId");

    long repositoryId = 0;

    if (folderId != 0) {
        Folder folder = DLAppServiceUtil.getFolder(folderId);

        repositoryId = folder.getRepositoryId();
    } else {/*  w  ww .j a  v a  2 s .  c  o  m*/
        repositoryId = atomRequestContext.getLongParameter("repositoryId");
    }

    int count = DLAppServiceUtil.getFileEntriesCount(repositoryId, folderId);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    return DLAppServiceUtil.getFileEntries(repositoryId, folderId, atomPager.getStart(), atomPager.getEnd() + 1,
            new EntryNameComparator());
}

From source file:com.liferay.portlet.documentlibrary.atom.FolderAtomCollectionAdapter.java

License:Open Source License

@Override
protected Iterable<Folder> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception {

    long repositoryId = 0;

    long parentFolderId = atomRequestContext.getLongParameter("parentFolderId");

    if (parentFolderId != 0) {
        Folder parentFolder = DLAppServiceUtil.getFolder(parentFolderId);

        repositoryId = parentFolder.getRepositoryId();
    } else {/*w w  w. j  a  v a  2s  .  c  o m*/
        repositoryId = atomRequestContext.getLongParameter("repositoryId");
    }

    int count = DLAppServiceUtil.getFoldersCount(repositoryId, parentFolderId);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    return DLAppServiceUtil.getFolders(repositoryId, parentFolderId, atomPager.getStart(),
            atomPager.getEnd() + 1, new EntryNameComparator());
}

From source file:com.liferay.portlet.journal.atom.JournalArticleAtomCollectionProvider.java

License:Open Source License

@Override
protected Iterable<JournalArticle> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception {

    List<JournalArticle> journalArticles = new ArrayList<JournalArticle>();

    long companyId = CompanyThreadLocal.getCompanyId();
    long groupId = atomRequestContext.getLongParameter("groupId");

    if ((companyId <= 0) || (groupId <= 0)) {
        return journalArticles;
    }//  www .  ja va 2s .  c  o m

    long classNameId = 0;
    String keywords = null;
    Double version = null;
    String type = atomRequestContext.getParameter("type", "general");
    String structureId = null;
    String templateId = null;
    Date displayDateGT = null;
    Date displayDateLT = new Date();
    int status = WorkflowConstants.STATUS_APPROVED;
    Date reviewDate = null;

    OrderByComparator obc = new ArticleVersionComparator();

    int count = JournalArticleLocalServiceUtil.searchCount(companyId, groupId, classNameId, keywords, version,
            type, structureId, templateId, displayDateGT, displayDateLT, status, reviewDate);

    AtomPager atomPager = new AtomPager(atomRequestContext, count);

    AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

    journalArticles = JournalArticleLocalServiceUtil.search(companyId, groupId, classNameId, keywords, version,
            type, structureId, templateId, displayDateGT, displayDateLT, status, reviewDate,
            atomPager.getStart(), atomPager.getEnd() + 1, obc);

    return journalArticles;
}

From source file:com.liferay.portlet.usersadmin.atom.UserAtomCollectionAdapter.java

License:Open Source License

@Override
protected Iterable<User> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception {

    long groupId = atomRequestContext.getLongParameter("groupId");

    if (groupId > 0) {
        List<User> users = UserLocalServiceUtil.getGroupUsers(groupId);

        return users;
    }/* w ww  . j  a v a2 s.  c  om*/

    long organizationId = atomRequestContext.getLongParameter("organizationId");

    if (organizationId > 0) {
        List<User> users = UserLocalServiceUtil.getOrganizationUsers(organizationId);

        return users;
    }

    long userGroupId = atomRequestContext.getLongParameter("userGroupId");

    if (userGroupId > 0) {
        List<User> users = UserLocalServiceUtil.getUserGroupUsers(userGroupId);

        return users;
    }

    long companyId = CompanyThreadLocal.getCompanyId();

    if (companyId > 0) {
        int usersCount = UserLocalServiceUtil.getCompanyUsersCount(companyId);

        AtomPager atomPager = new AtomPager(atomRequestContext, usersCount);

        AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager);

        List<User> users = UserLocalServiceUtil.getCompanyUsers(companyId, atomPager.getStart(),
                atomPager.getEnd() + 1);

        return users;
    }

    return Collections.emptyList();
}