Example usage for com.liferay.portal.kernel.util ListUtil subList

List of usage examples for com.liferay.portal.kernel.util ListUtil subList

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util ListUtil subList.

Prototype

public static <E> List<E> subList(List<E> list, int start, int end) 

Source Link

Usage

From source file:com.liferay.configuration.admin.web.internal.util.ConfigurationModelIterator.java

License:Open Source License

public List<ConfigurationModel> getResults(int start, int end) {
    return ListUtil.subList(_configurationModels, start, end);
}

From source file:com.liferay.content.targeting.util.ReportSearchContainerIterator.java

License:Open Source License

@Override
public List<Report> getResults(int start, int end) throws PortalException, SystemException {

    return ListUtil.subList(getResults(), start, end);
}

From source file:com.liferay.document.library.repository.cmis.internal.CMISRepository.java

License:Open Source License

protected <E> List<E> subList(List<E> list, int start, int end, OrderByComparator<E> obc) {

    if ((obc != null) && ((obc instanceof RepositoryModelCreateDateComparator)
            || (obc instanceof RepositoryModelModifiedDateComparator)
            || (obc instanceof RepositoryModelSizeComparator)
            || (obc instanceof RepositoryModelTitleComparator))) {

        list = ListUtil.sort(list, obc);
    }/*from   w w  w .j av a2s.  co m*/

    return ListUtil.subList(list, start, end);
}

From source file:com.liferay.document.library.repository.external.ExtRepositoryAdapter.java

License:Open Source License

private <T, V extends T> List<T> _sublist(List<V> list, int start, int end, OrderByComparator<T> obc) {

    if (obc != null) {
        list = ListUtil.sort(list, obc);
    }/*from   www  .j  a v a  2 s.c o m*/

    return (List<T>) ListUtil.toList(ListUtil.subList(list, start, end));
}

From source file:com.liferay.dynamic.data.mapping.data.provider.internal.rest.DDMRESTDataProvider.java

License:Open Source License

protected DDMDataProviderResponse createDDMDataProviderResponse(DocumentContext documentContext,
        DDMDataProviderRequest ddmDataProviderRequest,
        DDMRESTDataProviderSettings ddmRESTDataProviderSettings) {

    DDMDataProviderOutputParametersSettings[] outputParameterSettingsArray = ddmRESTDataProviderSettings
            .outputParameters();/*from   www .j  a  va  2 s . c o  m*/

    if ((outputParameterSettingsArray == null) || (outputParameterSettingsArray.length == 0)) {

        return DDMDataProviderResponse.of();
    }

    List<DDMDataProviderResponseOutput> ddmDataProviderResponseOutputs = new ArrayList<>();

    for (DDMDataProviderOutputParametersSettings outputParameterSettings : outputParameterSettingsArray) {

        String name = outputParameterSettings.outputParameterName();
        String type = outputParameterSettings.outputParameterType();
        String path = outputParameterSettings.outputParameterPath();

        if (Objects.equals(type, "text")) {
            String value = documentContext.read(normalizePath(path), String.class);

            if (value != null) {
                ddmDataProviderResponseOutputs.add(DDMDataProviderResponseOutput.of(name, "text", value));
            }
        } else if (Objects.equals(type, "number")) {
            Number value = documentContext.read(normalizePath(path), Number.class);

            if (value != null) {
                ddmDataProviderResponseOutputs.add(DDMDataProviderResponseOutput.of(name, "number", value));
            }
        } else if (Objects.equals(type, "list")) {
            String[] paths = StringUtil.split(path, CharPool.SEMICOLON);

            String normalizedValuePath = normalizePath(paths[0]);

            String normalizedKeyPath = normalizedValuePath;

            List<String> values = documentContext.read(normalizedValuePath, List.class);

            if (values == null) {
                continue;
            }

            List<String> keys = new ArrayList<>(values);

            if (paths.length >= 2) {
                normalizedKeyPath = normalizePath(paths[1]);

                keys = documentContext.read(normalizedKeyPath);
            }

            List<KeyValuePair> keyValuePairs = new ArrayList<>();

            for (int i = 0; i < values.size(); i++) {
                keyValuePairs.add(new KeyValuePair(keys.get(i), values.get(i)));
            }

            if (ddmRESTDataProviderSettings.pagination()) {
                int start = Integer.valueOf(ddmDataProviderRequest.getParameter("paginationStart"));

                int end = Integer.valueOf(ddmDataProviderRequest.getParameter("paginationEnd"));

                if (keyValuePairs.size() > (end - start)) {
                    keyValuePairs = ListUtil.subList(keyValuePairs, start, end);
                }
            }

            ddmDataProviderResponseOutputs.add(DDMDataProviderResponseOutput.of(name, "list", keyValuePairs));
        }
    }

    int size = ddmDataProviderResponseOutputs.size();

    return DDMDataProviderResponse
            .of(ddmDataProviderResponseOutputs.toArray(new DDMDataProviderResponseOutput[size]));
}

From source file:com.liferay.JournalArticleAssetRendererFactory.java

License:Open Source License

@Override
public List<Tuple> getClassTypeFieldNames(long classTypeId, Locale locale, int start, int end)
        throws Exception {

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.getDDMStructure(classTypeId);

    List<Tuple> fieldNames = getDDMStructureFieldNames(ddmStructure, locale);

    return ListUtil.subList(fieldNames, start, end);
}

From source file:com.liferay.knowledgebase.admin.util.KBArticleAssetEntriesUtil.java

License:Open Source License

public static List<AssetEntry> getAssetEntries(long[] groupIds, long[] classNameIds, long[] assetTagIds,
        long resourcePrimKey, int start, int end, String orderByColumn) throws PortalException {

    AssetEntryQuery assetEntryQuery = new AssetEntryQuery();

    assetEntryQuery.setAnyTagIds(assetTagIds);
    assetEntryQuery.setClassNameIds(classNameIds);
    assetEntryQuery.setEnd(end + 1);/*  w  ww  . j av a  2s  . com*/
    assetEntryQuery.setGroupIds(groupIds);
    assetEntryQuery.setOrderByCol1(orderByColumn);
    assetEntryQuery.setStart(start);

    List<AssetEntry> assetEntries = ListUtil.copy(AssetEntryServiceUtil.getEntries(assetEntryQuery));

    AssetEntry assetEntry = null;

    for (AssetEntry curAssetEntry : assetEntries) {
        if (curAssetEntry.getClassPK() == resourcePrimKey) {
            assetEntry = curAssetEntry;
        }
    }

    assetEntries.remove(assetEntry);

    return ListUtil.subList(assetEntries, 0, 10);
}

From source file:com.liferay.knowledgebase.service.impl.KBArticleServiceImpl.java

License:Open Source License

@Override
public String getKBArticleRSS(long resourcePrimKey, int status, int rssDelta, String rssDisplayStyle,
        String rssFormat, ThemeDisplay themeDisplay) throws PortalException {

    KBArticle kbArticle = kbArticleLocalService.getLatestKBArticle(resourcePrimKey, status);

    String name = kbArticle.getTitle();
    String description = kbArticle.getTitle();

    String feedURL = KnowledgeBaseUtil.getKBArticleURL(themeDisplay.getPlid(), resourcePrimKey, status,
            themeDisplay.getPortalURL(), false);

    List<KBArticle> kbArticles = getKBArticleAndAllDescendantKBArticles(kbArticle.getGroupId(), resourcePrimKey,
            status, new KBArticleModifiedDateComparator());

    return exportToRSS(rssDisplayStyle, rssFormat, name, description, feedURL,
            ListUtil.subList(kbArticles, 0, rssDelta), themeDisplay);
}

From source file:com.liferay.lexicon.test.web.internal.display.context.LexiconTestDisplayContext.java

License:Open Source License

public SearchContainer getSearchContainer() throws Exception {
    if (_searchContainer != null) {
        return _searchContainer;
    }/*w w  w .  j  a va2s. c om*/

    _searchContainer = new SearchContainer(_portletRequest,
            PortletURLUtil.clone(getPortletURL(), _portletResponse), null,
            LanguageUtil.get(_request, "no-super-hero-were-found"));

    _searchContainer.setRowChecker(new EmptyOnClickRowChecker(_portletResponse));

    _searchContainer.setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");

    _searchContainer.setTotal(_getTotal());
    _searchContainer.setResults(
            ListUtil.subList(_getResults(), _searchContainer.getStart(), _searchContainer.getEnd()));

    return _searchContainer;
}

From source file:com.liferay.portlet.messageboards.service.persistence.MBCategoryFinderImpl.java

License:Open Source License

protected List<MBCategory> doFindByS_G_U_P(long groupId, long userId, long[] parentCategoryIds, int start,
        int end, boolean inlineSQLHelper) throws SystemException {

    Session session = null;/*from   w w w.j  a  v  a  2 s .c o m*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(FIND_BY_S_G_U_P);

        if ((parentCategoryIds == null) || (parentCategoryIds.length == 0)) {

            sql = StringUtil.replace(sql, "(MBCategory.parentCategoryId = ?) AND", StringPool.BLANK);
        } else {
            sql = StringUtil.replace(sql, "MBCategory.parentCategoryId = ?", "MBCategory.parentCategoryId = "
                    + StringUtil.merge(parentCategoryIds, " OR MBCategory.parentCategoryId = "));
        }

        if (inlineSQLHelper) {
            sql = InlineSQLHelperUtil.replacePermissionCheck(sql, MBCategory.class.getName(),
                    "MBCategory.categoryId", groupId);
        }

        SQLQuery q = session.createSQLQuery(sql);

        q.addEntity("MBCategory", MBCategoryImpl.class);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(PortalUtil.getClassNameId(MBCategory.class.getName()));
        qPos.add(groupId);
        qPos.add(userId);

        List<MBCategory> list = (List<MBCategory>) QueryUtil.list(q, getDialect(), QueryUtil.ALL_POS,
                QueryUtil.ALL_POS, false);

        try {
            Group group = GroupLocalServiceUtil.getGroup(groupId);

            SubscriptionLocalServiceUtil.getSubscription(group.getCompanyId(), userId,
                    MBCategory.class.getName(), groupId);

            int threadCount = MBThreadLocalServiceUtil.getCategoryThreadsCount(groupId,
                    MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED);
            int messageCount = MBMessageLocalServiceUtil.getCategoryMessagesCount(groupId,
                    MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED);

            MBCategory category = new MBCategoryImpl();

            category.setCompanyId(group.getCompanyId());
            category.setName(group.getName());
            category.setDescription(group.getDescription());
            category.setThreadCount(threadCount);
            category.setMessageCount(messageCount);

            list.add(category);
        } catch (NoSuchSubscriptionException nsse) {
        }

        return new UnmodifiableList<MBCategory>(ListUtil.subList(list, start, end));
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}