Example usage for com.liferay.portal.kernel.model Group isOrganization

List of usage examples for com.liferay.portal.kernel.model Group isOrganization

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Group isOrganization.

Prototype

public boolean isOrganization();

Source Link

Usage

From source file:com.liferay.flags.internal.messaging.FlagsRequestMessageListener.java

License:Open Source License

protected Set<User> getRecipients(long companyId, long groupId) throws PortalException {

    Set<User> recipients = new LinkedHashSet<>();

    List<String> roleNames = new ArrayList<>();

    Group group = _groupLocalService.getGroup(groupId);

    if (group.isSite()) {
        roleNames.add(RoleConstants.SITE_ADMINISTRATOR);
        roleNames.add(RoleConstants.SITE_OWNER);
    }//ww  w .  j a v  a 2  s.  c o  m

    if (group.isCompany()) {
        roleNames.add(RoleConstants.ADMINISTRATOR);
    } else if (group.isOrganization()) {
        roleNames.add(RoleConstants.ORGANIZATION_ADMINISTRATOR);
        roleNames.add(RoleConstants.ORGANIZATION_OWNER);
    }

    for (String roleName : roleNames) {
        Role role = _roleLocalService.getRole(companyId, roleName);

        List<UserGroupRole> userGroupRoles = _userGroupRoleLocalService.getUserGroupRolesByGroupAndRole(groupId,
                role.getRoleId());

        for (UserGroupRole userGroupRole : userGroupRoles) {
            recipients.add(userGroupRole.getUser());
        }
    }

    if (recipients.isEmpty()) {
        Role role = _roleLocalService.getRole(companyId, RoleConstants.ADMINISTRATOR);

        recipients.addAll(_userLocalService.getRoleUsers(role.getRoleId()));
    }

    return recipients;
}

From source file:com.liferay.site.teams.web.internal.display.context.SiteTeamsDisplayContext.java

License:Open Source License

protected void addBreadcrumbEntries() throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    Group group = themeDisplay.getScopeGroup();

    if (group.isOrganization()) {
        Organization organization = OrganizationLocalServiceUtil.getOrganization(group.getOrganizationId());

        UsersAdminUtil.addPortletBreadcrumbEntries(organization, _request, _renderResponse);
    } else {/*  w w  w  .j av a2  s  .c  o m*/
        PortalUtil.addPortletBreadcrumbEntry(_request, group.getDescriptiveName(themeDisplay.getLocale()),
                null);
    }

    PortalUtil.addPortletBreadcrumbEntry(_request, LanguageUtil.get(_request, "manage-teams"),
            themeDisplay.getURLCurrent());
}

From source file:com.liferay.social.activities.web.internal.util.SocialActivitiesQueryHelper.java

License:Open Source License

public List<SocialActivitySet> getSocialActivitySets(Group group, Layout layout, Scope scope, int start,
        int end) {

    if (scope == Scope.ALL) {
        if (!group.isUser()) {
            return _socialActivitySetLocalService.getGroupActivitySets(group.getGroupId(), start, end);
        }/*from  ww  w  .ja  va  2  s.  co  m*/

        return _socialActivitySetLocalService.getUserViewableActivitySets(group.getClassPK(), start, end);
    } else if (group.isOrganization()) {
        return _socialActivitySetLocalService.getOrganizationActivitySets(group.getOrganizationId(), start,
                end);
    } else if (!group.isUser()) {
        return _socialActivitySetLocalService.getGroupActivitySets(group.getGroupId(), start, end);
    } else if (layout.isPublicLayout() || (scope == Scope.ME)) {
        return _socialActivitySetLocalService.getUserActivitySets(group.getClassPK(), start, end);
    } else if (scope == Scope.CONNECTIONS) {
        return _socialActivitySetLocalService.getRelationActivitySets(group.getClassPK(),
                SocialRelationConstants.TYPE_BI_CONNECTION, start, end);
    } else if (scope == Scope.FOLLOWING) {
        return _socialActivitySetLocalService.getRelationActivitySets(group.getClassPK(),
                SocialRelationConstants.TYPE_UNI_FOLLOWER, start, end);
    } else if (scope == Scope.MY_SITES) {
        return _socialActivitySetLocalService.getUserGroupsActivitySets(group.getClassPK(), start, end);
    } else {
        return Collections.emptyList();
    }
}

From source file:com.liferay.social.activities.web.internal.util.SocialActivitiesQueryHelper.java

License:Open Source License

public int getSocialActivitySetsCount(Group group, Layout layout, Scope scope) {

    if (scope == Scope.ALL) {
        if (!group.isUser()) {
            return _socialActivitySetLocalService.getGroupActivitySetsCount(group.getGroupId());
        }//  w  ww  . ja  v a2 s .  c om

        return _socialActivitySetLocalService.getUserViewableActivitySetsCount(group.getClassPK());
    } else if (group.isOrganization()) {
        return _socialActivitySetLocalService.getOrganizationActivitySetsCount(group.getOrganizationId());
    } else if (!group.isUser()) {
        return _socialActivitySetLocalService.getGroupActivitySetsCount(group.getGroupId());
    } else if (layout.isPublicLayout() || (scope == Scope.ME)) {
        return _socialActivitySetLocalService.getUserActivitySetsCount(group.getClassPK());
    } else if (scope == Scope.CONNECTIONS) {
        return _socialActivitySetLocalService.getRelationActivitySetsCount(group.getClassPK(),
                SocialRelationConstants.TYPE_BI_CONNECTION);
    } else if (scope == Scope.FOLLOWING) {
        return _socialActivitySetLocalService.getRelationActivitySetsCount(group.getClassPK(),
                SocialRelationConstants.TYPE_UNI_FOLLOWER);
    } else if (scope == Scope.MY_SITES) {
        return _socialActivitySetLocalService.getUserGroupsActivitySetsCount(group.getClassPK());
    } else {
        return 0;
    }
}