Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Shafia Kiran
How to get users associated with a team
2 de Fevereiro de 2011 05:51
Resposta

Shafia Kiran

Ranking: New Member

Mensagens: 12

Data de entrada: 2 de Novembro de 2010

Mensagens recentes

Hello ,

i am trying to get users associated with a team. i get team id with the following code

List<Team> lstTeam = TeamLocalServiceUtil.getUserTeams(user.getUserId());

but i cannot get the list of users associated with specific team. please help me out.

regards
Andy Harb
RE: How to get users associated with a team
14 de Novembro de 2011 09:49
Resposta

Andy Harb

Ranking: Junior Member

Mensagens: 66

Data de entrada: 22 de Outubro de 2009

Mensagens recentes

Hi Shafia,

Did you find a solution to this? I need to do the same thing but can't seem to find a method to do this. The TeamUtil class does have a method called getUsers but since it is a persistence utility you can't access it directly from a jsp.

Thanks
Andy
Jan Geißler
RE: How to get users associated with a team
1 de Novembro de 2012 02:38
Resposta

Jan Geißler

Community Moderator

Ranking: Liferay Master

Mensagens: 735

Data de entrada: 5 de Julho de 2011

Mensagens recentes

I know it's an old thread, but maybr this is going to help someone. Had the same Problem ;)

 1
 2List<User> recruiter;
 3        try {
 4            Team team = TeamLocalServiceUtil.getTeam(getRecruiterTeamId());
 5            recruiter = UserLocalServiceUtil.getGroupUsers(team.getGroupId());
 6        } catch (SystemException e) {
 7            e.printStackTrace();
 8            return Collections.EMPTY_LIST;
 9        }


EDIT:

As it turns out, the Group is tells you in which Group the Team is, so THIS CODE WILL NOT WORK! It will fetch all Users associated with the Group the Team is in.
There is no build in function to retrieve all Users of a team.

Strange that there is no functionality built in to retrieve the User of a team. And also kind of annoying.
emoticon
emoticon

EDIT2:
http://issues.liferay.com/browse/LPS-30795
Jan Geißler
RE: How to get users associated with a team
1 de Novembro de 2012 02:50
Resposta

Jan Geißler

Community Moderator

Ranking: Liferay Master

Mensagens: 735

Data de entrada: 5 de Julho de 2011

Mensagens recentes

Aeeehm.... Don't think so. We need to RETRIEVE the users, not to add Users....

Workaround:
Write a Custom Finder, with a Custom query in your Service Layer you need to get those Users. Not clean, not elegant, but working.
Harish Kumar
RE: How to get users associated with a team
1 de Novembro de 2012 02:56
Resposta

Harish Kumar

Ranking: Expert

Mensagens: 474

Data de entrada: 31 de Julho de 2010

Mensagens recentes

Ohhh my mistake
Thomas Berg
RE: How to get users associated with a team
7 de Janeiro de 2013 00:28
Resposta

Thomas Berg

Ranking: Regular Member

Mensagens: 134

Data de entrada: 7 de Setembro de 2009

Mensagens recentes

Since
1UserLocalServiceUtil.getTeamUsers()

is not yet implemented (I'm using Liferay 6.1.1 CE GA2) I had to find another way to get users associated with teams.
Looking at portal/portal-web/docroot/html/portlet/sites_admin/edit_team_assignments_user.jsp, I managed to get a list of users with the following snippet:

1LinkedHashMap<String, Object> userParams = new LinkedHashMap<String, Object>();
2userParams.put("usersTeams", teamId);
3
4List<User> teamUsers = UserLocalServiceUtil.search(companyId,
5    null, WorkFlowConstants.STATUS_ANY, userParams,
6    QueryUtil.ALL_POS, QueryUtil.ALL_POS, (OrderByComparator) null);


May not be the best way to do it but does not require servicebuilder or custom queries.

The Liferay docs suggest that, for performance reasons, it would be better to use the indexed version of UserLocalServiceUtil.search() but I haven't seen any examples of that version being used. If anyone has info about the indexed version, please share.

Anyway, hopefully someone will have use for this workaround while we wait for UserLocalServiceUtil.getTeamUsers() to be implemented.

Regards
Thomas
Chris Doar
RE: How to get users associated with a team
18 de Fevereiro de 2013 08:04
Resposta

Chris Doar

Ranking: New Member

Mensagens: 2

Data de entrada: 15 de Fevereiro de 2013

Mensagens recentes

Hi Thomas,

Thanks for that example. I just have a few questions with regards to it. I'm quite new to all this so I apologize if this all a little basic.

I've got a portlet that being deployed to a site within liferay. Within this I have a number of teams and some users assigned to the teams. What I am currently trying to do is get all the users in one of the teams (called co-ordinators). So, I've set up all of this in Liferay which has given me a siteId of 18002 (project) and a teamId of 18312 for the co-ordinators.

So, am I right in presuming that in your example the teamId added to the LinkedHashMap would be 18312 and that the companyId would be 18002 for the siteId?

I've also added some logging information so I can see what the code is doing. logger.info("user params " + userParams) gives user params {usersTeams=18312} and logger.info("User size" + teamUsers.size()); gives user size0. For some reason I dont seem to be returning any users for my team.

Cheers

Chris
Thomas Berg
RE: How to get users associated with a team
19 de Fevereiro de 2013 09:58
Resposta

Thomas Berg

Ranking: Regular Member

Mensagens: 134

Data de entrada: 7 de Setembro de 2009

Mensagens recentes

Chris Doar:
So, am I right in presuming that in your example the teamId added to the LinkedHashMap would be 18312 and that the companyId would be 18002 for the siteId?

Well, not quite. You have to specify the companyId instead of the siteId:

1long companyId = themeDisplay.getCompanyId();

The ThemeDisplay-object is available as an implicit object in your jsp if you've defined

1<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
2<liferay-theme:defineObjects />


Another way to get it (for example in java-files) is
1ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY)

where request is an implementation of javax.portlet.PortletRequest (i.e., RenderRequest, ResourceRequest etc.)

Cheers
Thomas
Chris Doar
RE: How to get users associated with a team
21 de Fevereiro de 2013 07:25
Resposta

Chris Doar

Ranking: New Member

Mensagens: 2

Data de entrada: 15 de Fevereiro de 2013

Mensagens recentes

Ah ok. Cheers for all that. I'll have a go and see what happens.

Thanks for your help.

Chris
Beppo Ivel
RE: How to get users associated with a team
16 de Março de 2015 06:08
Resposta

Beppo Ivel

Ranking: Regular Member

Mensagens: 112

Data de entrada: 9 de Abril de 2014

Mensagens recentes

Is the way that Thomas Berg mentioned the most feasible way to get the users of a Team? And is it possible to get the team object by the name of the team?