Merge remote-tracking branch 'nayan/MIFOSX-164'

This commit is contained in:
Keith Woodlock
2013-02-21 13:52:41 +00:00
5 changed files with 151 additions and 65 deletions
@@ -30,14 +30,9 @@ import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer; import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
import org.mifosplatform.organisation.office.data.OfficeLookup;
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
import org.mifosplatform.portfolio.client.data.ClientLookup;
import org.mifosplatform.portfolio.client.service.ClientReadPlatformService;
import org.mifosplatform.portfolio.group.command.GroupCommand; import org.mifosplatform.portfolio.group.command.GroupCommand;
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData; import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData;
import org.mifosplatform.portfolio.group.data.GroupData; import org.mifosplatform.portfolio.group.data.GroupData;
import org.mifosplatform.portfolio.group.data.GroupLookupData;
import org.mifosplatform.portfolio.group.service.GroupReadPlatformService; import org.mifosplatform.portfolio.group.service.GroupReadPlatformService;
import org.mifosplatform.portfolio.group.service.GroupWritePlatformService; import org.mifosplatform.portfolio.group.service.GroupWritePlatformService;
import org.mifosplatform.portfolio.savingsaccount.PortfolioApiDataConversionService; import org.mifosplatform.portfolio.savingsaccount.PortfolioApiDataConversionService;
@@ -51,13 +46,11 @@ import org.springframework.stereotype.Component;
public class GroupsApiResource { public class GroupsApiResource {
private static final Set<String> GROUP_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "officeId", "name", "externalId", private static final Set<String> GROUP_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "officeId", "name", "externalId",
"clientMembers", "allowedClients", "allowedOffices" , "allowedParentGroups" ,"groupLevel")); "clientMembers", "allowedClients", "allowedOffices" , "allowedParentGroups" ,"groupLevel" ,"allowedStaffs" ,"childGroups"));
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final GroupReadPlatformService groupReadPlatformService; private final GroupReadPlatformService groupReadPlatformService;
private final GroupWritePlatformService groupWritePlatformService; private final GroupWritePlatformService groupWritePlatformService;
private final ClientReadPlatformService clientReadPlatformService;
private final OfficeReadPlatformService officeReadPlatformService;
private final ToApiJsonSerializer<GroupData> toApiJsonSerializer; private final ToApiJsonSerializer<GroupData> toApiJsonSerializer;
private final ToApiJsonSerializer<GroupAccountSummaryCollectionData> groupSummaryToApiJsonSerializer; private final ToApiJsonSerializer<GroupAccountSummaryCollectionData> groupSummaryToApiJsonSerializer;
private final ApiRequestParameterHelper apiRequestParameterHelper; private final ApiRequestParameterHelper apiRequestParameterHelper;
@@ -68,8 +61,6 @@ public class GroupsApiResource {
final PlatformSecurityContext context, final PlatformSecurityContext context,
final GroupReadPlatformService groupReadPlatformService, final GroupReadPlatformService groupReadPlatformService,
final GroupWritePlatformService groupWritePlatformService, final GroupWritePlatformService groupWritePlatformService,
final ClientReadPlatformService clientReadPlatformService,
final OfficeReadPlatformService officeReadPlatformService,
final ToApiJsonSerializer<GroupData> toApiJsonSerializer, final ToApiJsonSerializer<GroupData> toApiJsonSerializer,
final ToApiJsonSerializer<GroupAccountSummaryCollectionData> groupSummaryToApiJsonSerializer, final ToApiJsonSerializer<GroupAccountSummaryCollectionData> groupSummaryToApiJsonSerializer,
final ApiRequestParameterHelper apiRequestParameterHelper, final ApiRequestParameterHelper apiRequestParameterHelper,
@@ -77,8 +68,6 @@ public class GroupsApiResource {
this.context = context; this.context = context;
this.groupReadPlatformService = groupReadPlatformService; this.groupReadPlatformService = groupReadPlatformService;
this.groupWritePlatformService = groupWritePlatformService; this.groupWritePlatformService = groupWritePlatformService;
this.clientReadPlatformService = clientReadPlatformService;
this.officeReadPlatformService = officeReadPlatformService;
this.toApiJsonSerializer = toApiJsonSerializer; this.toApiJsonSerializer = toApiJsonSerializer;
this.groupSummaryToApiJsonSerializer = groupSummaryToApiJsonSerializer; this.groupSummaryToApiJsonSerializer = groupSummaryToApiJsonSerializer;
this.apiRequestParameterHelper = apiRequestParameterHelper; this.apiRequestParameterHelper = apiRequestParameterHelper;
@@ -105,34 +94,13 @@ public class GroupsApiResource {
@Path("{groupId}") @Path("{groupId}")
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
public String retrieveGroupData(@Context final UriInfo uriInfo, @PathParam("groupId") final Long groupId, public String retrieveGroupData(@Context final UriInfo uriInfo, @PathParam("groupId") final Long groupId) {
@QueryParam("officeId") final Long officeId) {
context.authenticatedUser().validateHasReadPermission("GROUP"); context.authenticatedUser().validateHasReadPermission("GROUP");
GroupData group = this.groupReadPlatformService.retrieveGroup(groupId);
final Collection<ClientLookup> clientMembers = this.groupReadPlatformService.retrieveClientMembers(groupId);
Collection<ClientLookup> availableClients = null;
Collection<OfficeLookup> allowedOffices = null;
Collection<GroupLookupData> allowedParentGroups = null;
group = new GroupData(group, clientMembers, availableClients, allowedOffices , allowedParentGroups , null);
boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters()); boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
if (template) { GroupData group = this.groupReadPlatformService.retrieveGroupDetails(groupId, template);
if (officeId != null) {
availableClients = this.clientReadPlatformService.retrieveAllIndividualClientsForLookupByOfficeId(officeId);
} else {
availableClients = this.clientReadPlatformService.retrieveAllIndividualClientsForLookupByOfficeId(group.getOfficeId());
}
availableClients.removeAll(group.clientMembers());
allowedOffices = officeReadPlatformService.retrieveAllOfficesForLookup();
group = new GroupData(group, group.clientMembers(), availableClients, allowedOffices , allowedParentGroups ,null);
}
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
return this.toApiJsonSerializer.serialize(settings, group, GROUP_DATA_PARAMETERS); return this.toApiJsonSerializer.serialize(settings, group, GROUP_DATA_PARAMETERS);
} }
@@ -45,8 +45,6 @@ public class GroupCommandValidator {
baseDataValidator.reset().parameter("id").value(command.getId()).notNull(); baseDataValidator.reset().parameter("id").value(command.getId()).notNull();
baseDataValidator.reset().parameter("name").value(command.getName()).ignoreIfNull().notBlank(); baseDataValidator.reset().parameter("name").value(command.getName()).ignoreIfNull().notBlank();
baseDataValidator.reset().parameter("externalId").value(command.getExternalId()).ignoreIfNull().notExceedingLengthOf(100); baseDataValidator.reset().parameter("externalId").value(command.getExternalId()).ignoreIfNull().notExceedingLengthOf(100);
baseDataValidator.reset().parameter("clientMembers").value(command.getClientMembers()).arrayNotEmpty();
if (command.isOfficeIdChanged()) { if (command.isOfficeIdChanged()) {
baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).notNull().integerGreaterThanZero(); baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).notNull().integerGreaterThanZero();
@@ -8,6 +8,7 @@ package org.mifosplatform.portfolio.group.data;
import java.util.Collection; import java.util.Collection;
import org.mifosplatform.organisation.office.data.OfficeLookup; import org.mifosplatform.organisation.office.data.OfficeLookup;
import org.mifosplatform.organisation.staff.data.StaffData;
import org.mifosplatform.portfolio.client.data.ClientLookup; import org.mifosplatform.portfolio.client.data.ClientLookup;
/** /**
@@ -20,9 +21,9 @@ public class GroupData {
private final String externalId; private final String externalId;
private final Long officeId; private final Long officeId;
private final String officeName; private final String officeName;
private final Long groupLevel;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final GroupLevelData groupLevelData; private final GroupLevelData groupLevelData;
private final Collection<ClientLookup> clientMembers; private final Collection<ClientLookup> clientMembers;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final Collection<ClientLookup> allowedClients; private final Collection<ClientLookup> allowedClients;
@@ -30,50 +31,61 @@ public class GroupData {
private final Collection<OfficeLookup> allowedOffices; private final Collection<OfficeLookup> allowedOffices;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final Collection<GroupLookupData> allowedParentGroups; private final Collection<GroupLookupData> allowedParentGroups;
@SuppressWarnings("unused")
private final Collection<StaffData> allowedStaffs;
@SuppressWarnings("unused")
private final Collection<GroupLookupData> childGroups;
public GroupData(final Long id, final Long officeId, final String officeName, final String name, final String externalId) { public GroupData(final Long id, final Long officeId, final String officeName, final String name, final String externalId , final Long groupLevel ) {
this.id = id; this.id = id;
this.officeId = officeId; this.officeId = officeId;
this.officeName = officeName; this.officeName = officeName;
this.name = name; this.name = name;
this.externalId = externalId; this.externalId = externalId;
this.groupLevel =groupLevel;
this.groupLevelData = null; this.groupLevelData = null;
this.clientMembers = null; this.clientMembers = null;
this.allowedClients = null; this.allowedClients = null;
this.allowedOffices = null; this.allowedOffices = null;
this.allowedParentGroups = null; this.allowedParentGroups = null;
this.allowedStaffs = null;
this.childGroups = null;
} }
public GroupData(final GroupData group, final Collection<ClientLookup> clientMembers, final Collection<ClientLookup> allowedClients, public GroupData(final GroupData group, final Collection<ClientLookup> clientMembers, final Collection<ClientLookup> allowedClients,
final Collection<OfficeLookup> allowedOffices, final Collection<GroupLookupData> allowedParentGroups, final Collection<OfficeLookup> allowedOffices, final Collection<GroupLookupData> allowedParentGroups,
final GroupLevelData groupLevelData) { final GroupLevelData groupLevelData , final Collection<StaffData> allowedStaffs , final Collection<GroupLookupData> childGroups) {
this.id = group.getId(); this.id = group.getId();
this.officeId = group.getOfficeId(); this.officeId = group.getOfficeId();
this.officeName = group.getOfficeName(); this.officeName = group.getOfficeName();
this.name = group.getName(); this.name = group.getName();
this.externalId = group.getExternalId(); this.externalId = group.getExternalId();
this.groupLevel = group.getGroupLevel();
this.groupLevelData = groupLevelData; this.groupLevelData = groupLevelData;
this.clientMembers = clientMembers; this.clientMembers = clientMembers;
this.allowedClients = allowedClients; this.allowedClients = allowedClients;
this.allowedOffices = allowedOffices; this.allowedOffices = allowedOffices;
this.allowedParentGroups = allowedParentGroups; this.allowedParentGroups = allowedParentGroups;
this.allowedStaffs = allowedStaffs;
this.childGroups = childGroups;
} }
public GroupData(final Long officeId, final Collection<ClientLookup> allowedClients, final Collection<OfficeLookup> allowedOffices, public GroupData(final Long officeId, final Collection<ClientLookup> allowedClients, final Collection<OfficeLookup> allowedOffices,
final Collection<GroupLookupData> allowedParentGroups, final GroupLevelData groupLevelData) { final Collection<GroupLookupData> allowedParentGroups, final GroupLevelData groupLevelData , final Collection<StaffData> allowedStaffs ) {
this.id = null; this.id = null;
this.officeId = officeId; this.officeId = officeId;
this.officeName = null; this.officeName = null;
this.name = null; this.name = null;
this.externalId = null; this.externalId = null;
this.clientMembers = null; this.clientMembers = null;
this.groupLevel =null;
this.groupLevelData = groupLevelData; this.groupLevelData = groupLevelData;
this.allowedClients = allowedClients; this.allowedClients = allowedClients;
this.allowedOffices = allowedOffices; this.allowedOffices = allowedOffices;
this.allowedParentGroups = allowedParentGroups; this.allowedParentGroups = allowedParentGroups;
this.allowedStaffs = allowedStaffs;
this.childGroups = null;
} }
public Long getId() { public Long getId() {
@@ -95,6 +107,11 @@ public class GroupData {
public String getOfficeName() { public String getOfficeName() {
return officeName; return officeName;
} }
public Long getGroupLevel() {
return this.groupLevel;
}
public Collection<ClientLookup> clientMembers() { public Collection<ClientLookup> clientMembers() {
return this.clientMembers; return this.clientMembers;
@@ -7,6 +7,7 @@ package org.mifosplatform.portfolio.group.service;
import java.util.Collection; import java.util.Collection;
import org.mifosplatform.organisation.staff.data.StaffData;
import org.mifosplatform.portfolio.client.data.ClientLookup; import org.mifosplatform.portfolio.client.data.ClientLookup;
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData; import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData;
import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData; import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData;
@@ -31,4 +32,10 @@ public interface GroupReadPlatformService {
Collection<GroupLookupData> retrieveAllGroupsbyOfficeIdAndLevelId(Long officeId , Long levelId); Collection<GroupLookupData> retrieveAllGroupsbyOfficeIdAndLevelId(Long officeId , Long levelId);
GroupLevelData retrieveGroupLevelDetails(Long levelId); GroupLevelData retrieveGroupLevelDetails(Long levelId);
Collection<StaffData> retrieveStaffsbyOfficeId(Long officeId);
GroupData retrieveGroupDetails(Long groupId, boolean template);
Collection<GroupLookupData> retrieveChildGroupsbyGroupId(Long groupId);
} }
@@ -17,6 +17,8 @@ import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSourc
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
import org.mifosplatform.organisation.office.data.OfficeLookup; import org.mifosplatform.organisation.office.data.OfficeLookup;
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService; import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
import org.mifosplatform.organisation.staff.data.StaffData;
import org.mifosplatform.organisation.staff.exception.StaffNotFoundException;
import org.mifosplatform.portfolio.client.data.ClientLookup; import org.mifosplatform.portfolio.client.data.ClientLookup;
import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; import org.mifosplatform.portfolio.client.service.ClientReadPlatformService;
import org.mifosplatform.portfolio.client.service.LoanStatusMapper; import org.mifosplatform.portfolio.client.service.LoanStatusMapper;
@@ -40,10 +42,10 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final ClientReadPlatformService clientReadPlatformService; private final ClientReadPlatformService clientReadPlatformService;
private final OfficeReadPlatformService officeReadPlatformService; private final OfficeReadPlatformService officeReadPlatformService;
@Autowired @Autowired
public GroupReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource, public GroupReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
ClientReadPlatformService clientReadPlatformService, final OfficeReadPlatformService officeReadPlatformService ) { ClientReadPlatformService clientReadPlatformService, final OfficeReadPlatformService officeReadPlatformService) {
this.context = context; this.context = context;
this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate = new JdbcTemplate(dataSource);
this.clientReadPlatformService = clientReadPlatformService; this.clientReadPlatformService = clientReadPlatformService;
@@ -90,17 +92,34 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
GroupLookupMapper rm = new GroupLookupMapper(); GroupLookupMapper rm = new GroupLookupMapper();
String sql = "select " + rm.groupLookupSchema() + " where g.office_id = ? and level_id = ? and g.is_deleted=0"; String sql = "select " + rm.groupLookupSchema() + " from m_group g where g.office_id = ? and level_id = ? and g.is_deleted=0";
return this.jdbcTemplate.query(sql, rm, new Object[] { officeId, levelId }); return this.jdbcTemplate.query(sql, rm, new Object[] { officeId, levelId });
} catch (EmptyResultDataAccessException e) { } catch (EmptyResultDataAccessException e) {
// TODO need throw proper exception // TODO need throw proper exception
throw new GroupNotFoundException(officeId); throw new GroupNotFoundException(officeId);
} }
} }
@Override
public Collection<GroupLookupData> retrieveChildGroupsbyGroupId(final Long groupId) {
try {
this.context.authenticatedUser();
GroupLookupMapper rm = new GroupLookupMapper();
String sql = "select " + rm.groupLookupSchema() + " from m_group pg join m_group g where pg.id = g.parent_id and pg.id = ? and g.is_deleted=0";
return this.jdbcTemplate.query(sql, rm, new Object[] { groupId });
} catch (EmptyResultDataAccessException e) {
throw new GroupNotFoundException(groupId);
}
}
@Override @Override
public GroupLevelData retrieveGroupLevelDetails(final Long levelId) { public GroupLevelData retrieveGroupLevelDetails(final Long levelId) {
@@ -119,9 +138,9 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
} }
@Override @Override
public GroupData retrieveNewGroupDetails(final Long officeId , final Long levelId) { public GroupData retrieveNewGroupDetails(final Long officeId, final Long levelId) {
GroupLevelData groupLevelData = this.retrieveGroupLevelDetails(levelId); GroupLevelData groupLevelData = this.retrieveGroupLevelDetails(levelId);
if (groupLevelData == null) { throw new GroupLevelNotFoundException(levelId); } if (groupLevelData == null) { throw new GroupLevelNotFoundException(levelId); }
@@ -131,23 +150,78 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
allowedClients = new ArrayList<ClientLookup>( allowedClients = new ArrayList<ClientLookup>(
this.clientReadPlatformService.retrieveAllIndividualClientsForLookupByOfficeId(officeId)); this.clientReadPlatformService.retrieveAllIndividualClientsForLookupByOfficeId(officeId));
} }
List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>(officeReadPlatformService.retrieveAllOfficesForLookup()); List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>(officeReadPlatformService.retrieveAllOfficesForLookup());
List<GroupLookupData> allowedParentGroups = null; List<GroupLookupData> allowedParentGroups = null;
if(groupLevelData.getParentLevelId() != null){ if (groupLevelData.getParentLevelId() != null) {
allowedParentGroups = new ArrayList<GroupLookupData>(this.retrieveAllGroupsbyOfficeIdAndLevelId(officeId , groupLevelData.getParentLevelId())); allowedParentGroups = new ArrayList<GroupLookupData>(this.retrieveAllGroupsbyOfficeIdAndLevelId(officeId,
groupLevelData.getParentLevelId()));
}
List<StaffData> allowedStaffs = new ArrayList<StaffData>(this.retrieveStaffsbyOfficeId(officeId));
return new GroupData(officeId, allowedClients, allowedOffices, allowedParentGroups, groupLevelData, allowedStaffs);
}
@Override
public GroupData retrieveGroupDetails(final Long groupId, final boolean template) {
GroupData group = this.retrieveGroup(groupId);
final Collection<ClientLookup> clientMembers = this.retrieveClientMembers(groupId);
Collection<ClientLookup> availableClients = null;
Collection<OfficeLookup> allowedOffices = null;
Collection<GroupLookupData> allowedParentGroups = null;
GroupLevelData groupLevelData = this.retrieveGroupLevelDetails(group.getGroupLevel());;
Collection<StaffData> allowedStaffs = null;
Collection<GroupLookupData> childGroups = this.retrieveChildGroupsbyGroupId(groupId);
group = new GroupData(group, clientMembers, availableClients, allowedOffices, allowedParentGroups, groupLevelData, allowedStaffs , childGroups);
if (template) {
if (groupLevelData.isCanHaveClients()) {
availableClients = this.clientReadPlatformService.retrieveAllIndividualClientsForLookupByOfficeId(group.getOfficeId());
availableClients.removeAll(group.clientMembers());
}
allowedOffices = officeReadPlatformService.retrieveAllOfficesForLookup();
if (groupLevelData.getParentLevelId() != null) {
allowedParentGroups = this.retrieveAllGroupsbyOfficeIdAndLevelId(group.getOfficeId(),
groupLevelData.getParentLevelId());
}
allowedStaffs = this.retrieveStaffsbyOfficeId(group.getOfficeId());
group = new GroupData(group, group.clientMembers(), availableClients, allowedOffices, allowedParentGroups, groupLevelData,
allowedStaffs , childGroups);
} }
return group;
return new GroupData(officeId, allowedClients, allowedOffices , allowedParentGroups , groupLevelData); }
@Override
public Collection<StaffData> retrieveStaffsbyOfficeId(final Long officeId) {
try {
this.context.authenticatedUser();
StaffDataMapper rm = new StaffDataMapper();
String sql = "select " + rm.staffDataSchema() + " where o.id = ?";
return this.jdbcTemplate.query(sql, rm, new Object[] { officeId });
} catch (EmptyResultDataAccessException e) {
// TODO throw Staff not found in given office
throw new StaffNotFoundException(officeId);
}
} }
private static final class GroupDataMapper implements RowMapper<GroupData> { private static final class GroupDataMapper implements RowMapper<GroupData> {
public String groupSchema() { public String groupSchema() {
return "g.office_id as officeId, o.name as officeName, g.id as id, g.external_id as externalId, " return "g.office_id as officeId, g.level_id as groupLevel , o.name as officeName, g.id as id, g.external_id as externalId, "
+ "g.name as name from m_group g join m_office o on o.id = g.office_id"; + "g.name as name from m_group g join m_office o on o.id = g.office_id";
} }
@@ -157,19 +231,18 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
Long id = rs.getLong("id"); Long id = rs.getLong("id");
String name = rs.getString("name"); String name = rs.getString("name");
String externalId = rs.getString("externalId"); String externalId = rs.getString("externalId");
Long officeId = rs.getLong("officeId"); Long officeId = rs.getLong("officeId");
String officeName = rs.getString("officeName"); String officeName = rs.getString("officeName");
Long groupLevel = rs.getLong("groupLevel");
return new GroupData(id, officeId, officeName, name, externalId); return new GroupData(id, officeId, officeName, name, externalId, groupLevel);
} }
} }
private static final class GroupLookupMapper implements RowMapper<GroupLookupData> { private static final class GroupLookupMapper implements RowMapper<GroupLookupData> {
public String groupLookupSchema() { public String groupLookupSchema() {
return "g.id as id, g.name as name from m_group g"; return "g.id as id, g.name as name ";
} }
@Override @Override
@@ -186,8 +259,8 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
private static final class GroupLevelDataMapper implements RowMapper<GroupLevelData> { private static final class GroupLevelDataMapper implements RowMapper<GroupLevelData> {
public String groupLevelSchema() { public String groupLevelSchema() {
return "gl.id as id, gl.parent_id as parentLevelId , gl.level_name as levelName , gl.super_parent as superParent ," + return "gl.id as id, gl.parent_id as parentLevelId , gl.level_name as levelName , gl.super_parent as superParent ,"
" gl.recursable as recursable , gl.can_have_clients as canHaveClients from m_group_level gl"; + " gl.recursable as recursable , gl.can_have_clients as canHaveClients from m_group_level gl";
} }
@Override @Override
@@ -205,6 +278,29 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
} }
private static final class StaffDataMapper implements RowMapper<StaffData> {
public String staffDataSchema() {
return "s.id as id , s.is_loan_officer as isLoanOfficer , s.office_id as officeId , s.firstname as firstname, "
+ "s.lastname as lastname , s.display_name as displayName , o.name as officeName from m_staff s join m_office o on s.office_id =o.id ";
}
@Override
public StaffData mapRow(ResultSet rs, @SuppressWarnings("unused") int rowNum) throws SQLException {
Long id = rs.getLong("id");
String firstname = rs.getString("firstname");
String lastname = rs.getString("lastname");
String displayName = rs.getString("displayName");
Long officeId = rs.getLong("officeId");
String officeName = rs.getString("officeName");
boolean isLoanOfficer = rs.getBoolean("isLoanOfficer");
return StaffData.instance(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer);
}
}
@Override @Override
public Collection<ClientLookup> retrieveClientMembers(Long groupId) { public Collection<ClientLookup> retrieveClientMembers(Long groupId) {