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;
|
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.domain.JdbcSupport;
|
||||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
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.jdbc.core.RowMapper;
|
||||||
import org.springframework.stereotype.Service;
|
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
|
@Service
|
||||||
public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformService {
|
public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformService {
|
||||||
|
|
||||||
@@ -48,6 +48,13 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
|
|||||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* used for caching in spring expression language.
|
||||||
|
*/
|
||||||
|
public PlatformSecurityContext getContext() {
|
||||||
|
return this.context;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "users", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy())")
|
@Cacheable(value = "users", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy())")
|
||||||
public Collection<AppUserData> retrieveAllUsers() {
|
public Collection<AppUserData> retrieveAllUsers() {
|
||||||
@@ -83,7 +90,6 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
|
|||||||
return AppUserData.template(offices, availableRoles);
|
return AppUserData.template(offices, availableRoles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AppUserData retrieveUser(final Long userId) {
|
public AppUserData retrieveUser(final Long userId) {
|
||||||
|
|
||||||
@@ -110,9 +116,10 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
|
|||||||
|
|
||||||
private final RoleReadPlatformService roleReadPlatformService;
|
private final RoleReadPlatformService roleReadPlatformService;
|
||||||
|
|
||||||
public AppUserMapper(final RoleReadPlatformService roleReadPlatformService){
|
public AppUserMapper(final RoleReadPlatformService roleReadPlatformService) {
|
||||||
this.roleReadPlatformService = roleReadPlatformService;
|
this.roleReadPlatformService = roleReadPlatformService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AppUserData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
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 Long officeId = JdbcSupport.getLong(rs, "officeId");
|
||||||
final String officeName = rs.getString("officeName");
|
final String officeName = rs.getString("officeName");
|
||||||
|
|
||||||
//pass the client id to retrieve the clients assigned roles
|
final Collection<RoleData> selectedRoles = this.roleReadPlatformService.retrieveAppUserRoles(id);
|
||||||
final Collection<RoleData> selectedRoles = this.roleReadPlatformService.retrieveClientRoles(id);
|
|
||||||
|
|
||||||
return AppUserData.instance(id, username, email, officeId, officeName, firstname, lastname, null, selectedRoles);
|
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";
|
+ " 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);
|
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;
|
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.domain.JdbcSupport;
|
||||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||||
import org.mifosplatform.useradministration.data.RoleData;
|
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.jdbc.core.RowMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class RoleReadPlatformServiceImpl implements RoleReadPlatformService {
|
public class RoleReadPlatformServiceImpl implements RoleReadPlatformService {
|
||||||
|
|
||||||
@@ -68,10 +68,10 @@ public class RoleReadPlatformServiceImpl implements RoleReadPlatformService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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"
|
final String sql = "select " + this.roleRowMapper.schema() + " inner join m_appuser_role"
|
||||||
+ " ar on ar.role_id = r.id where ar.appuser_id= ?";
|
+ " 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