Foren
GET user related data.
Micheal Marquiz, geändert vor 12 Jahren.
GET user related data.
New Member Beiträge: 6 Beitrittsdatum: 07.06.11 Neueste 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.
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, geändert vor 12 Jahren.
RE: GET user related data.
Expert Beiträge: 436 Beitrittsdatum: 11.09.06 Neueste Beiträge
if you share your process we might be able to help you
Micheal Marquiz, geändert vor 12 Jahren.
RE: GET user related data.
New Member Beiträge: 6 Beitrittsdatum: 07.06.11 Neueste 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
6) Get userGroups
Thanks,
Micheal
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
for(UserGroupRole userGroupRole : UserGroupRoleLocalServiceUtil.getUserGroupRoles(user.getUserId()){
groupsList.add(userGroupRole.getGroup().getDescriptiveName());
rolesList.add( userGroupRole.getRole().getName());
}
6) Get userGroups
List<usergroup> userGroupList = UserGroupLocalServiceUtil.getUserUserGroups(user.getUserId());
for(UserGroup userGroup : userGroupList){
if(!userGroupNames.equals(StringPool.BLANK))
userGroupNames += StringPool.COMMA_AND_SPACE;
userGroupNames += userGroup.getName().trim();
}
</usergroup>
Thanks,
Micheal