Example usage for com.liferay.portal.kernel.dao.orm QueryDefinition setStart

List of usage examples for com.liferay.portal.kernel.dao.orm QueryDefinition setStart

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.orm QueryDefinition setStart.

Prototype

public void setStart(int start) 

Source Link

Usage

From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java

License:Open Source License

@Override
public List<BlogsEntry> getCompanyEntries(long companyId, Date displayDate, int status, int max)
        throws PortalException {

    List<BlogsEntry> entries = new ArrayList<>();

    boolean listNotExhausted = true;

    QueryDefinition<BlogsEntry> queryDefinition = new QueryDefinition<>(status, false, 0, 0,
            new EntryDisplayDateComparator());

    if (status == WorkflowConstants.STATUS_ANY) {
        queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true);
    }// w  w w . j  a v a 2  s  .c  o  m

    while ((entries.size() < max) && listNotExhausted) {
        queryDefinition.setEnd(queryDefinition.getStart() + max);

        List<BlogsEntry> entryList = blogsEntryLocalService.getCompanyEntries(companyId, displayDate,
                queryDefinition);

        queryDefinition.setStart(queryDefinition.getStart() + max);

        listNotExhausted = (entryList.size() == max);

        for (BlogsEntry entry : entryList) {
            if (entries.size() >= max) {
                break;
            }

            if (BlogsEntryPermission.contains(getPermissionChecker(), entry, ActionKeys.VIEW)) {

                entries.add(entry);
            }
        }
    }

    return entries;
}

From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java

License:Open Source License

@Override
public List<BlogsEntry> getGroupsEntries(long companyId, long groupId, Date displayDate, int status, int max)
        throws PortalException {

    List<BlogsEntry> entries = new ArrayList<>();

    boolean listNotExhausted = true;

    QueryDefinition<BlogsEntry> queryDefinition = new QueryDefinition<>(status, false, 0, 0,
            new EntryDisplayDateComparator());

    if (status == WorkflowConstants.STATUS_ANY) {
        queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true);
    }/*  w w  w. ja  va  2s. c o m*/

    while ((entries.size() < max) && listNotExhausted) {
        queryDefinition.setEnd(queryDefinition.getStart() + max);

        List<BlogsEntry> entryList = blogsEntryLocalService.getGroupsEntries(companyId, groupId, displayDate,
                queryDefinition);

        queryDefinition.setStart(queryDefinition.getStart() + max);

        listNotExhausted = (entryList.size() == max);

        for (BlogsEntry entry : entryList) {
            if (entries.size() >= max) {
                break;
            }

            if (BlogsEntryPermission.contains(getPermissionChecker(), entry, ActionKeys.VIEW)) {

                entries.add(entry);
            }
        }
    }

    return entries;
}

From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java

License:Open Source License

@Override
public List<BlogsEntry> getOrganizationEntries(long organizationId, Date displayDate, int status, int max)
        throws PortalException {

    List<BlogsEntry> entries = new ArrayList<>();

    boolean listNotExhausted = true;

    QueryDefinition<BlogsEntry> queryDefinition = new QueryDefinition<>(status, false, 0, 0,
            new EntryDisplayDateComparator());

    if (status == WorkflowConstants.STATUS_ANY) {
        queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true);
    }/*from  ww  w . j av a2  s  .  c  o  m*/

    while ((entries.size() < max) && listNotExhausted) {
        queryDefinition.setEnd(queryDefinition.getStart() + max);

        List<BlogsEntry> entryList = blogsEntryFinder.findByOrganizationId(organizationId, displayDate,
                queryDefinition);

        queryDefinition.setStart(queryDefinition.getStart() + max);

        listNotExhausted = (entryList.size() == max);

        for (BlogsEntry entry : entryList) {
            if (entries.size() >= max) {
                break;
            }

            if (BlogsEntryPermission.contains(getPermissionChecker(), entry, ActionKeys.VIEW)) {

                entries.add(entry);
            }
        }
    }

    return entries;
}

From source file:com.liferay.wiki.service.impl.WikiPageServiceImpl.java

License:Open Source License

@Override
public List<WikiPage> getPages(long groupId, long nodeId, boolean head, long userId, boolean includeOwner,
        int status, int start, int end, OrderByComparator<WikiPage> obc) throws PortalException {

    WikiNodePermissionChecker.check(getPermissionChecker(), nodeId, ActionKeys.VIEW);

    QueryDefinition<WikiPage> queryDefinition = new QueryDefinition<>(status, userId, includeOwner);

    queryDefinition.setEnd(end);//from ww  w .j a  v  a  2s.  c  om
    queryDefinition.setOrderByComparator(obc);
    queryDefinition.setStart(start);

    return wikiPageFinder.filterFindByG_N_H_S(groupId, nodeId, head, queryDefinition);
}