Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Micheal Marquiz
GET user related data.
13. Juni 2011 15:58
Antwort

Micheal Marquiz

Rang: New Member

Nachrichten: 6

Eintrittsdatum: 7. Juni 2011

Neue Beiträge

HI Liferay experts,
I have a requirement to pull the following data,
1) username, userid, user profile page link, user communities, user roles, user groups for all the users in the database

I am able to use a combination of Liferay API to get the data, but the process is very slow because of the loops involved, Is there a better approach to achieve this.

Thanks,
Micheal.
steve rieger
RE: GET user related data.
13. Juni 2011 16:12
Antwort

steve rieger

Rang: Expert

Nachrichten: 436

Eintrittsdatum: 11. September 2006

Neue Beiträge

if you share your process we might be able to help you
Micheal Marquiz
RE: GET user related data.
13. Juni 2011 16:32
Antwort

Micheal Marquiz

Rang: New Member

Nachrichten: 6

Eintrittsdatum: 7. Juni 2011

Neue Beiträge

These are the steps I am doing.

1) Get User list using a custom SQL with parameters startdate, end date, roled ids ( not mandatory ), groupids ( not mandatory )
SELECT DISTINCT User_.* FROM User_ , UserGroupRole
WHERE (User_.userId = UserGroupRole.userId)
AND ([$GROUP_ID$])
AND ( User_.createDate >= ? ) AND ( User_.createDate <= ? ) AND ( User_.AGREEDTOTERMSOFUSE=1 ) AND (User_.DEFAULTUSER = 0)
AND ([$ROLE_ID$])
2) Iterate over the User list to get
1) user display link by method user.getDisplayURL(themeDisplay)
2) user first name from user object
3) user last name
4) user email id
5) Get user groups, roles
1    for(UserGroupRole userGroupRole : UserGroupRoleLocalServiceUtil.getUserGroupRoles(user.getUserId()){
2                            groupsList.add(userGroupRole.getGroup().getDescriptiveName());
3                               rolesList.add( userGroupRole.getRole().getName());
4                }
5         

6) Get userGroups
1 List<UserGroup> userGroupList = UserGroupLocalServiceUtil.getUserUserGroups(user.getUserId());
2                    for(UserGroup userGroup : userGroupList){                   
3                        if(!userGroupNames.equals(StringPool.BLANK))
4                            userGroupNames += StringPool.COMMA_AND_SPACE;
5                        userGroupNames += userGroup.getName().trim();
6                    }
7 

Thanks,
Micheal