List of usage examples for com.liferay.portal.kernel.service GroupLocalServiceUtil search
public static java.util.List<com.liferay.portal.kernel.model.Group> search(long companyId, String name, String description, java.util.LinkedHashMap<String, Object> params, boolean andOperator, int start, int end)
From source file:com.liferay.asset.publisher.web.display.context.ChildSitesItemSelectorViewDisplayContext.java
License:Open Source License
@Override public GroupSearch getGroupSearch() throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); GroupSearch groupSearch = new GroupSearch(getPortletRequest(), getPortletURL()); GroupSearchTerms groupSearchTerms = (GroupSearchTerms) groupSearch.getSearchTerms(); List<Group> groups = GroupLocalServiceUtil.search(themeDisplay.getCompanyId(), _CLASS_NAME_IDS, groupSearchTerms.getKeywords(), _getGroupParams(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, groupSearch.getOrderByComparator()); groups = _filterGroups(groups, themeDisplay.getPermissionChecker()); groupSearch.setTotal(groups.size()); groups = groups.subList(groupSearch.getStart(), groupSearch.getResultEnd()); groupSearch.setResults(groups);/*w w w.j av a2 s . co m*/ return groupSearch; }
From source file:com.liferay.item.selector.taglib.servlet.taglib.GroupSelectorTag.java
License:Open Source License
protected List<Group> getGroups(HttpServletRequest request) { if (_groups != null) { return _groups; }/* w w w . ja v a 2 s . co m*/ ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String keywords = ParamUtil.getString(request, "keywords"); LinkedHashMap<String, Object> groupParams = new LinkedHashMap<>(); groupParams.put("site", Boolean.TRUE); int cur = ParamUtil.getInteger(request, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_CUR); int delta = ParamUtil.getInteger(request, SearchContainer.DEFAULT_DELTA_PARAM, SearchContainer.DEFAULT_DELTA); int[] startAndEnd = SearchPaginationUtil.calculateStartAndEnd(cur, delta); return GroupLocalServiceUtil.search(themeDisplay.getCompanyId(), _CLASS_NAME_IDS, keywords, groupParams, startAndEnd[0], startAndEnd[1], null); }
From source file:com.liferay.site.browser.web.internal.display.context.SiteBrowserDisplayContext.java
License:Open Source License
public GroupSearch getGroupSearch() throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); GroupSearch groupSearch = new GroupSearch(_liferayPortletRequest, getPortletURL()); GroupSearchTerms groupSearchTerms = (GroupSearchTerms) groupSearch.getSearchTerms(); List<Group> results = new ArrayList<>(); int additionalSites = 0; int total = 0; boolean includeCompany = ParamUtil.getBoolean(_request, "includeCompany"); boolean includeUserPersonalSite = ParamUtil.getBoolean(_request, "includeUserPersonalSite"); long[] classNameIds = _CLASS_NAME_IDS; if (includeCompany) { classNameIds = ArrayUtil.append(classNameIds, PortalUtil.getClassNameId(Company.class)); }// w w w . ja v a 2 s . co m if (includeUserPersonalSite) { if (groupSearch.getStart() == 0) { Group userPersonalSite = GroupLocalServiceUtil.getGroup(company.getCompanyId(), GroupConstants.USER_PERSONAL_SITE); results.add(userPersonalSite); } additionalSites++; } String type = getType(); if (type.equals("layoutScopes")) { total = GroupLocalServiceUtil.getGroupsCount(themeDisplay.getCompanyId(), Layout.class.getName(), getGroupId()); } else if (type.equals("parent-sites")) { } else { total = GroupLocalServiceUtil.searchCount(themeDisplay.getCompanyId(), classNameIds, groupSearchTerms.getKeywords(), getGroupParams()); } total += additionalSites; groupSearch.setTotal(total); int start = groupSearch.getStart(); if (groupSearch.getStart() > additionalSites) { start = groupSearch.getStart() - additionalSites; } List<Group> groups = null; if (type.equals("layoutScopes")) { groups = GroupLocalServiceUtil.getGroups(company.getCompanyId(), Layout.class.getName(), getGroupId(), start, groupSearch.getResultEnd() - additionalSites); groups = _filterLayoutGroups(groups, isPrivateLayout()); } else if (type.equals("parent-sites")) { Group group = GroupLocalServiceUtil.getGroup(getGroupId()); groups = group.getAncestors(); String filter = getFilter(); if (Validator.isNotNull(filter)) { groups = _filterGroups(groups, filter); } total = groups.size(); total += additionalSites; groupSearch.setTotal(total); } else { groups = GroupLocalServiceUtil.search(company.getCompanyId(), classNameIds, groupSearchTerms.getKeywords(), getGroupParams(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, groupSearch.getOrderByComparator()); groups = _filterGroups(groups, themeDisplay.getPermissionChecker()); total = groups.size(); total += additionalSites; groupSearch.setTotal(total); groups = groups.subList(start, groupSearch.getResultEnd() - additionalSites); } results.addAll(groups); groupSearch.setResults(results); return groupSearch; }
From source file:com.liferay.site.service.persistence.test.GroupServiceTest.java
License:Open Source License
protected void testSelectableParentSites(boolean staging) throws Exception { Group group = GroupTestUtil.addGroup(); Assert.assertTrue(group.isRoot());/*from www .j a va 2 s . co m*/ LinkedHashMap<String, Object> params = new LinkedHashMap<>(); params.put("site", Boolean.TRUE); List<Long> excludedGroupIds = new ArrayList<>(); excludedGroupIds.add(group.getGroupId()); if (staging) { GroupTestUtil.enableLocalStaging(group); Assert.assertTrue(group.hasStagingGroup()); excludedGroupIds.add(group.getStagingGroup().getGroupId()); } params.put("excludedGroupIds", excludedGroupIds); List<Group> selectableGroups = GroupLocalServiceUtil.search(group.getCompanyId(), null, StringPool.BLANK, params, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); for (Group selectableGroup : selectableGroups) { long selectableGroupId = selectableGroup.getGroupId(); Assert.assertNotEquals("A group cannot be its own parent", group.getGroupId(), selectableGroupId); if (staging) { Assert.assertNotEquals("A group cannot have its live group as parent", group.getLiveGroupId(), selectableGroupId); } } GroupLocalServiceUtil.deleteGroup(group); }