Example usage for com.liferay.portal.kernel.dao.search SearchContainer DEFAULT_DELTA

List of usage examples for com.liferay.portal.kernel.dao.search SearchContainer DEFAULT_DELTA

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.search SearchContainer DEFAULT_DELTA.

Prototype

int DEFAULT_DELTA

To view the source code for com.liferay.portal.kernel.dao.search SearchContainer DEFAULT_DELTA.

Click Source Link

Usage

From source file:org.lsug.quota.portlet.ServerQuotaPortlet.java

License:Open Source License

private void listServerQuotas(RenderRequest renderRequest, RenderResponse renderResponse)
        throws SystemException {

    int cur = ParamUtil.getInteger(renderRequest, "cur", 0);
    int paramDelta = ParamUtil.getInteger(renderRequest, "delta", SearchContainer.DEFAULT_DELTA);
    PortletURL portletURL = renderResponse.createRenderURL();

    // OrderByComparator

    final String orderByCol = ParamUtil.getString(renderRequest, "orderByCol", "quotaUsed");
    final String orderByType = ParamUtil.getString(renderRequest, "orderByType", "desc");
    final OrderByComparator orderByComparator = QuotaUtil.getQuotaOrderByComparator(orderByCol, orderByType);

    SearchContainer<Quota> searchContainer = new SearchContainer<Quota>(renderRequest, null, null,
            SearchContainer.DEFAULT_CUR_PARAM, cur, paramDelta, portletURL, null, null);
    searchContainer.setDelta(paramDelta);
    searchContainer.setDeltaConfigurable(false);
    searchContainer.setOrderByCol(orderByCol);
    searchContainer.setOrderByType(orderByType);
    searchContainer.setOrderByComparator(orderByComparator);

    long classNameId = PortalUtil.getClassNameId(Company.class.getName());
    long listQuotasCount = QuotaLocalServiceUtil.countByClassNameId(classNameId);

    List<Quota> listCompanyQuota = QuotaLocalServiceUtil.getQuotaByClassNameId(classNameId,
            searchContainer.getStart(), searchContainer.getEnd(), orderByComparator);

    renderRequest.setAttribute("searchContainer", searchContainer);
    renderRequest.setAttribute("list", listCompanyQuota);
    renderRequest.setAttribute("count", listQuotasCount);
}

From source file:org.lsug.quota.portlet.SitesQuotaPortlet.java

License:Open Source License

@Override
public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
        throws IOException, PortletException {

    // Parametro para identificar la pestaa en la que estamos
    final String tabs2 = ParamUtil.getString(renderRequest, "tabs2", "sites");

    final int cur = ParamUtil.getInteger(renderRequest, "cur", 0);
    final int paramDelta = ParamUtil.getInteger(renderRequest, "delta", SearchContainer.DEFAULT_DELTA);

    // Url del searchContainer
    final PortletURL portletURL = renderResponse.createRenderURL();
    portletURL.setParameter("tabs2", tabs2);

    // OrderByComparator
    final String orderByCol = ParamUtil.getString(renderRequest, "orderByCol", "quotaUsed");
    final String orderByType = ParamUtil.getString(renderRequest, "orderByType", "desc");
    final OrderByComparator orderByComparator = QuotaUtil.getQuotaOrderByComparator(orderByCol, orderByType);

    // Crear searchContainer
    SearchContainer<Quota> searchContainer = new SearchContainer<Quota>(renderRequest, null, null,
            SearchContainer.DEFAULT_CUR_PARAM, cur, paramDelta, portletURL, null, null);
    searchContainer.setDelta(paramDelta);
    searchContainer.setDeltaConfigurable(false);
    searchContainer.setOrderByCol(orderByCol);
    searchContainer.setOrderByType(orderByType);

    try {//from  ww  w. j  av  a  2s  .  c o  m

        // Identificador instancia de Liferay
        final long companyId = PortalUtil.getCompanyId(renderRequest);

        // Si la pestaa es sites obtenemos los sitios web de una instancia
        if (tabs2.equalsIgnoreCase("sites")) {
            final List<Quota> results = QuotaUtil.getSitesQuotas(companyId, searchContainer.getStart(),
                    searchContainer.getEnd(), orderByComparator);
            final int total = QuotaUtil.getSitesQuotasCount(companyId);

            searchContainer.setResults(results);
            searchContainer.setTotal(total);

        } else if (tabs2.equalsIgnoreCase("user-sites")) {

            // Obtenemos los sitios de usuario de una instancia
            final List<Quota> results = QuotaUtil.getSitesUsersQuotas(companyId, searchContainer.getStart(),
                    searchContainer.getEnd(), orderByComparator);
            final int total = QuotaUtil.getSitesUsersQuotasCount(companyId);

            searchContainer.setResults(results);
            searchContainer.setTotal(total);
        }

    } catch (SystemException e) {
        LOGGER.error(e);
        throw new PortletException(e);
    } catch (PortalException e) {
        LOGGER.error(e);
        throw new PortletException(e);
    }

    renderRequest.setAttribute("tabs2", tabs2);
    renderRequest.setAttribute("searchContainer", searchContainer);

    super.doView(renderRequest, renderResponse);
}

From source file:org.lsug.quota.web.internal.portlet.ServerQuotaWebPortlet.java

License:Open Source License

private void listServerQuotas(RenderRequest renderRequest, RenderResponse renderResponse)
        throws SystemException {

    int cur = ParamUtil.getInteger(renderRequest, "cur", 0);
    int paramDelta = ParamUtil.getInteger(renderRequest, "delta", SearchContainer.DEFAULT_DELTA);
    PortletURL portletURL = renderResponse.createRenderURL();

    // OrderByComparator

    final String orderByCol = ParamUtil.getString(renderRequest, "orderByCol", "quotaUsed");
    final String orderByType = ParamUtil.getString(renderRequest, "orderByType", "desc");
    final OrderByComparator<Quota> orderByComparator = QuotaUtil.getQuotaOrderByComparator(orderByCol,
            orderByType);//  w w w  .j  a  va  2  s .  c  om

    SearchContainer<Quota> searchContainer = new SearchContainer<Quota>(renderRequest, null, null,
            SearchContainer.DEFAULT_CUR_PARAM, cur, paramDelta, portletURL, null, null);
    searchContainer.setDelta(paramDelta);
    searchContainer.setDeltaConfigurable(false);
    searchContainer.setOrderByCol(orderByCol);
    searchContainer.setOrderByType(orderByType);
    searchContainer.setOrderByComparator(orderByComparator);

    long classNameId = PortalUtil.getClassNameId(Company.class.getName());
    long listQuotasCount = _quotaLocalService.countByClassNameId(classNameId);

    List<Quota> listCompanyQuota = _quotaLocalService.getQuotaByClassNameId(classNameId,
            searchContainer.getStart(), searchContainer.getEnd(), orderByComparator);

    renderRequest.setAttribute("searchContainer", searchContainer);
    renderRequest.setAttribute("list", listCompanyQuota);
    renderRequest.setAttribute("count", listQuotasCount);
}

From source file:org.lsug.quota.web.internal.portlet.SitesQuotaWebPortlet.java

License:Open Source License

@Override
public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
        throws IOException, PortletException {

    // Parametro para identificar la pestaa en la que estamos

    final String tabs2 = ParamUtil.getString(renderRequest, "tabs2", "sites");

    final int cur = ParamUtil.getInteger(renderRequest, "cur", 0);
    final int paramDelta = ParamUtil.getInteger(renderRequest, "delta", SearchContainer.DEFAULT_DELTA);

    // Url del searchContainer

    final PortletURL portletURL = renderResponse.createRenderURL();
    portletURL.setParameter("tabs2", tabs2);

    // OrderByComparator

    final String orderByCol = ParamUtil.getString(renderRequest, "orderByCol", "quotaUsed");
    final String orderByType = ParamUtil.getString(renderRequest, "orderByType", "desc");
    final OrderByComparator<Quota> orderByComparator = QuotaUtil.getQuotaOrderByComparator(orderByCol,
            orderByType);//  www .  j  av  a2  s .  co  m

    // Crear searchContainer

    SearchContainer<Quota> searchContainer = new SearchContainer<Quota>(renderRequest, null, null,
            SearchContainer.DEFAULT_CUR_PARAM, cur, paramDelta, portletURL, null, null);
    searchContainer.setDelta(paramDelta);
    searchContainer.setDeltaConfigurable(false);
    searchContainer.setOrderByCol(orderByCol);
    searchContainer.setOrderByType(orderByType);

    try {

        // Identificador instancia de Liferay

        final long companyId = PortalUtil.getCompanyId(renderRequest);

        int total = 0;
        List<Quota> results = null;

        long[] classNameIds = null;

        // Si la pestaa es sites obtenemos los sitios web de una instancia

        if (tabs2.equalsIgnoreCase("sites")) {
            classNameIds = new long[] { PortalUtil.getClassNameId(Group.class.getName()),
                    PortalUtil.getClassNameId(Organization.class.getName()) };

        } else if (tabs2.equalsIgnoreCase("user-sites")) {
            classNameIds = new long[] { PortalUtil.getClassNameId(User.class.getName()) };
        }

        results = _quotaLocalService.getQuotaByCompanyIdClassNameIds(companyId, classNameIds,
                searchContainer.getStart(), searchContainer.getEnd(), orderByComparator);
        total = _quotaLocalService.countByCompanyIdClassNameIds(companyId, classNameIds);

        searchContainer.setResults(results);
        searchContainer.setTotal(total);

    } catch (SystemException e) {
        LOGGER.error(e);
        throw new PortletException(e);
    }

    renderRequest.setAttribute("tabs2", tabs2);
    renderRequest.setAttribute("searchContainer", searchContainer);

    super.doView(renderRequest, renderResponse);
}