MIFOSX-794: some changes to terms - userRoles not clientRoles.
This commit is contained in:
+16
-14
@@ -5,6 +5,12 @@
|
||||
*/
|
||||
package org.mifosplatform.useradministration.service;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
@@ -22,12 +28,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformService {
|
||||
|
||||
@@ -48,6 +48,13 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
/*
|
||||
* used for caching in spring expression language.
|
||||
*/
|
||||
public PlatformSecurityContext getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "users", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy())")
|
||||
public Collection<AppUserData> retrieveAllUsers() {
|
||||
@@ -83,7 +90,6 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
|
||||
return AppUserData.template(offices, availableRoles);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AppUserData retrieveUser(final Long userId) {
|
||||
|
||||
@@ -110,9 +116,10 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
|
||||
|
||||
private final RoleReadPlatformService roleReadPlatformService;
|
||||
|
||||
public AppUserMapper(final RoleReadPlatformService roleReadPlatformService){
|
||||
public AppUserMapper(final RoleReadPlatformService roleReadPlatformService) {
|
||||
this.roleReadPlatformService = roleReadPlatformService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUserData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
@@ -124,8 +131,7 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
|
||||
final Long officeId = JdbcSupport.getLong(rs, "officeId");
|
||||
final String officeName = rs.getString("officeName");
|
||||
|
||||
//pass the client id to retrieve the clients assigned roles
|
||||
final Collection<RoleData> selectedRoles = this.roleReadPlatformService.retrieveClientRoles(id);
|
||||
final Collection<RoleData> selectedRoles = this.roleReadPlatformService.retrieveAppUserRoles(id);
|
||||
|
||||
return AppUserData.instance(id, username, email, officeId, officeName, firstname, lastname, null, selectedRoles);
|
||||
}
|
||||
@@ -154,8 +160,4 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
|
||||
+ " join m_office o on o.id = u.office_id where o.hierarchy like ? and u.is_deleted=0 order by u.username";
|
||||
}
|
||||
}
|
||||
|
||||
public PlatformSecurityContext getContext() {
|
||||
return this.context;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -15,5 +15,5 @@ public interface RoleReadPlatformService {
|
||||
|
||||
RoleData retrieveOne(Long roleId);
|
||||
|
||||
Collection<RoleData> retrieveClientRoles(Long clientId);
|
||||
Collection<RoleData> retrieveAppUserRoles(Long appUserId);
|
||||
}
|
||||
+6
-6
@@ -5,6 +5,10 @@
|
||||
*/
|
||||
package org.mifosplatform.useradministration.service;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.useradministration.data.RoleData;
|
||||
@@ -15,10 +19,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
@Service
|
||||
public class RoleReadPlatformServiceImpl implements RoleReadPlatformService {
|
||||
|
||||
@@ -68,10 +68,10 @@ public class RoleReadPlatformServiceImpl implements RoleReadPlatformService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RoleData> retrieveClientRoles(Long clientId) {
|
||||
public Collection<RoleData> retrieveAppUserRoles(final Long appUserId) {
|
||||
final String sql = "select " + this.roleRowMapper.schema() + " inner join m_appuser_role"
|
||||
+ " ar on ar.role_id = r.id where ar.appuser_id= ?";
|
||||
|
||||
return this.jdbcTemplate.query(sql,this.roleRowMapper,new Object[]{clientId});
|
||||
return this.jdbcTemplate.query(sql,this.roleRowMapper,new Object[]{appUserId});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user