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

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

Introduction

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

Prototype

public void setEnd(int end) 

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);
    }//from   ww w .  j  a va2s. 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);
    }//from  w w w .jav a2s.  c om

    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);
    }//w  w  w .j a v  a2  s . co  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);
    queryDefinition.setOrderByComparator(obc);
    queryDefinition.setStart(start);//from w ww  .j a  v a  2s  .  c  o m

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