use display name for groups.
This commit is contained in:
+30
-15
@@ -6,12 +6,20 @@ public class ClientLookup {
|
|||||||
|
|
||||||
private final Long id;
|
private final Long id;
|
||||||
private final String displayName;
|
private final String displayName;
|
||||||
private final Long officeId;
|
private final Long officeId;
|
||||||
private final String officeName;
|
private final String officeName;
|
||||||
|
|
||||||
|
public static ClientLookup template(final Long id, final String displayName, final Long officeId, final String officeName) {
|
||||||
|
return new ClientLookup(id, displayName, officeId, officeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ClientLookup create(final Long id, final String displayName) {
|
||||||
|
return new ClientLookup(id, displayName, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
public ClientLookup(final Long id, final String firstname, final String lastname, final Long officeId, final String officeName) {
|
public ClientLookup(final Long id, final String firstname, final String lastname, final Long officeId, final String officeName) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
StringBuilder displayNameBuilder = new StringBuilder(firstname);
|
StringBuilder displayNameBuilder = new StringBuilder(firstname);
|
||||||
if (StringUtils.isNotBlank(displayNameBuilder.toString())) {
|
if (StringUtils.isNotBlank(displayNameBuilder.toString())) {
|
||||||
displayNameBuilder.append(' ');
|
displayNameBuilder.append(' ');
|
||||||
@@ -23,6 +31,13 @@ public class ClientLookup {
|
|||||||
this.officeId = officeId;
|
this.officeId = officeId;
|
||||||
this.officeName = officeName;
|
this.officeName = officeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClientLookup(final Long id, final String displayName, final Long officeId, final String officeName) {
|
||||||
|
this.id = id;
|
||||||
|
this.displayName = displayName;
|
||||||
|
this.officeId = officeId;
|
||||||
|
this.officeName = officeName;
|
||||||
|
}
|
||||||
|
|
||||||
public ClientLookup(final Long id, final String firstname, final String lastname) {
|
public ClientLookup(final Long id, final String firstname, final String lastname) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -50,19 +65,19 @@ public class ClientLookup {
|
|||||||
return this.id.hashCode();
|
return this.id.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getOfficeId() {
|
public Long getOfficeId() {
|
||||||
return officeId;
|
return officeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOfficeName() {
|
public String getOfficeName() {
|
||||||
return officeName;
|
return officeName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+20
@@ -91,6 +91,26 @@ public final class ClientCommandFromApiJsonDeserializer extends AbstractFromApiJ
|
|||||||
final String externalId = fromApiJsonHelper.extractStringNamed(externalIdParameterName, element);
|
final String externalId = fromApiJsonHelper.extractStringNamed(externalIdParameterName, element);
|
||||||
baseDataValidator.reset().parameter(externalIdParameterName).value(externalId).ignoreIfNull().notExceedingLengthOf(100);
|
baseDataValidator.reset().parameter(externalIdParameterName).value(externalId).ignoreIfNull().notExceedingLengthOf(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String fullnameParameterName = "fullname";
|
||||||
|
if (fromApiJsonHelper.parameterExists(fullnameParameterName, element)) {
|
||||||
|
atLeastOneParameterPassedForUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String lastNameParameterName = "lastname";
|
||||||
|
if (fromApiJsonHelper.parameterExists(lastNameParameterName, element)) {
|
||||||
|
atLeastOneParameterPassedForUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String middleNameParameterName = "middlename";
|
||||||
|
if (fromApiJsonHelper.parameterExists(middleNameParameterName, element)) {
|
||||||
|
atLeastOneParameterPassedForUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String firstNameParameterName = "firstname";
|
||||||
|
if (fromApiJsonHelper.parameterExists(firstNameParameterName, element)) {
|
||||||
|
atLeastOneParameterPassedForUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
final String officeIdParameterName = "officeId";
|
final String officeIdParameterName = "officeId";
|
||||||
if (fromApiJsonHelper.parameterExists(officeIdParameterName, element)) {
|
if (fromApiJsonHelper.parameterExists(officeIdParameterName, element)) {
|
||||||
|
|||||||
+4
-8
@@ -162,23 +162,19 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
private static final class ClientLookupMapper implements RowMapper<ClientLookup> {
|
private static final class ClientLookupMapper implements RowMapper<ClientLookup> {
|
||||||
|
|
||||||
public String clientLookupSchema() {
|
public String clientLookupSchema() {
|
||||||
return "c.id as id, c.firstname as firstname, c.lastname as lastname, " + "c.office_id as officeId, o.name as officeName "
|
return "c.id as id, c.display_name as displayName, "
|
||||||
|
+ "c.office_id as officeId, o.name as officeName "
|
||||||
+ "from m_client c join m_office o on o.id = c.office_id where c.is_deleted=0 ";
|
+ "from m_client c join m_office o on o.id = c.office_id where c.is_deleted=0 ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientLookup mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
public ClientLookup mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||||
Long id = rs.getLong("id");
|
Long id = rs.getLong("id");
|
||||||
String firstname = rs.getString("firstname");
|
String displayName = rs.getString("displayName");
|
||||||
String lastname = rs.getString("lastname");
|
|
||||||
if (StringUtils.isBlank(firstname)) {
|
|
||||||
firstname = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
Long officeId = rs.getLong("officeId");
|
Long officeId = rs.getLong("officeId");
|
||||||
String officeName = rs.getString("officeName");
|
String officeName = rs.getString("officeName");
|
||||||
|
|
||||||
return new ClientLookup(id, firstname, lastname, officeId, officeName);
|
return ClientLookup.template(id, displayName, officeId, officeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
-39
@@ -34,9 +34,8 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
|||||||
private final OfficeReadPlatformService officeReadPlatformService;
|
private final OfficeReadPlatformService officeReadPlatformService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public GroupReadPlatformServiceImpl(final PlatformSecurityContext context,
|
public GroupReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||||
final TenantAwareRoutingDataSource dataSource, ClientReadPlatformService clientReadPlatformService,
|
ClientReadPlatformService clientReadPlatformService, final OfficeReadPlatformService officeReadPlatformService) {
|
||||||
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;
|
||||||
@@ -52,7 +51,7 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
|||||||
|
|
||||||
String sql = "select " + rm.groupSchema() + " where g.is_deleted=0";
|
String sql = "select " + rm.groupSchema() + " where g.is_deleted=0";
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(extraCriteria)){
|
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||||
sql += " and (" + extraCriteria + ")";
|
sql += " and (" + extraCriteria + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,16 +60,16 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GroupData retrieveGroup(final Long groupId) {
|
public GroupData retrieveGroup(final Long groupId) {
|
||||||
|
|
||||||
try{
|
try {
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
GroupMapper rm = new GroupMapper();
|
GroupMapper rm = new GroupMapper();
|
||||||
|
|
||||||
String sql = "select " + rm.groupSchema() + " where g.id = ? and g.is_deleted=0";
|
String sql = "select " + rm.groupSchema() + " where g.id = ? and g.is_deleted=0";
|
||||||
|
|
||||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] {groupId});
|
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { groupId });
|
||||||
} catch (EmptyResultDataAccessException e){
|
} catch (EmptyResultDataAccessException e) {
|
||||||
throw new GroupNotFoundException(groupId);
|
throw new GroupNotFoundException(groupId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,8 +88,8 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
|||||||
private static final class GroupMapper implements RowMapper<GroupData> {
|
private static final class GroupMapper 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, 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";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -109,32 +108,29 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ClientLookup> retrieveClientMembers(Long groupId){
|
public Collection<ClientLookup> retrieveClientMembers(Long groupId) {
|
||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
ClientMemberSummaryDataMapper rm = new ClientMemberSummaryDataMapper();
|
ClientMemberSummaryDataMapper rm = new ClientMemberSummaryDataMapper();
|
||||||
|
|
||||||
String sql = "select " + rm.clientMemberSummarySchema() + " where cm.is_deleted = 0 and pgc.group_id = ?";
|
String sql = "select " + rm.clientMemberSummarySchema() + " where cm.is_deleted = 0 and pgc.group_id = ?";
|
||||||
|
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] {groupId});
|
return this.jdbcTemplate.query(sql, rm, new Object[] { groupId });
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class ClientMemberSummaryDataMapper implements RowMapper<ClientLookup> {
|
private static final class ClientMemberSummaryDataMapper implements RowMapper<ClientLookup> {
|
||||||
|
|
||||||
public String clientMemberSummarySchema() {
|
public String clientMemberSummarySchema() {
|
||||||
return "cm.id, cm.firstname, cm.lastname from m_client cm INNER JOIN m_group_client pgc ON pgc.client_id = cm.id";
|
return "cm.id, cm.display_name as displayName from m_client cm INNER JOIN m_group_client pgc ON pgc.client_id = cm.id";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientLookup mapRow(ResultSet rs, @SuppressWarnings("unused") int rowNum) throws SQLException {
|
public ClientLookup mapRow(ResultSet rs, @SuppressWarnings("unused") int rowNum) throws SQLException {
|
||||||
Long id = rs.getLong("id");
|
Long id = rs.getLong("id");
|
||||||
String firstname = rs.getString("firstname");
|
String displayName = rs.getString("displayName");
|
||||||
String lastname = rs.getString("lastname");
|
|
||||||
if (StringUtils.isBlank(firstname)) {
|
return ClientLookup.create(id, displayName);
|
||||||
firstname = "";
|
|
||||||
}
|
|
||||||
return new ClientLookup(id, firstname, lastname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -156,7 +152,7 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
|||||||
|
|
||||||
String sql = "select " + rm.loanAccountSummarySchema() + " where l.group_id = ? and l.client_id is null";
|
String sql = "select " + rm.loanAccountSummarySchema() + " where l.group_id = ? and l.client_id is null";
|
||||||
|
|
||||||
List<GroupAccountSummaryData> results = this.jdbcTemplate.query(sql, rm, new Object[] {groupId});
|
List<GroupAccountSummaryData> results = this.jdbcTemplate.query(sql, rm, new Object[] { groupId });
|
||||||
if (results != null) {
|
if (results != null) {
|
||||||
for (GroupAccountSummaryData row : results) {
|
for (GroupAccountSummaryData row : results) {
|
||||||
|
|
||||||
@@ -181,7 +177,7 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
|||||||
|
|
||||||
sql = "select " + rm.loanAccountSummarySchema() + " where l.group_id = ? and l.client_id is not null";
|
sql = "select " + rm.loanAccountSummarySchema() + " where l.group_id = ? and l.client_id is not null";
|
||||||
|
|
||||||
results = this.jdbcTemplate.query(sql, rm, new Object[] {groupId});
|
results = this.jdbcTemplate.query(sql, rm, new Object[] { groupId });
|
||||||
if (results != null) {
|
if (results != null) {
|
||||||
for (GroupAccountSummaryData row : results) {
|
for (GroupAccountSummaryData row : results) {
|
||||||
|
|
||||||
@@ -218,29 +214,24 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
|||||||
|
|
||||||
String sql = "select " + rm.loanAccountSummarySchema() + " where l.group_id = ? and l.client_id is null and l.loan_officer_id = ?";
|
String sql = "select " + rm.loanAccountSummarySchema() + " where l.group_id = ? and l.client_id is null and l.loan_officer_id = ?";
|
||||||
|
|
||||||
List<GroupAccountSummaryData> loanAccounts = this.jdbcTemplate.query(sql, rm, new Object[] {groupId, loanOfficerId});
|
List<GroupAccountSummaryData> loanAccounts = this.jdbcTemplate.query(sql, rm, new Object[] { groupId, loanOfficerId });
|
||||||
|
|
||||||
return loanAccounts;
|
return loanAccounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class GroupLoanAccountSummaryDataMapper implements
|
private static final class GroupLoanAccountSummaryDataMapper implements RowMapper<GroupAccountSummaryData> {
|
||||||
RowMapper<GroupAccountSummaryData> {
|
|
||||||
|
|
||||||
public String loanAccountSummarySchema() {
|
public String loanAccountSummarySchema() {
|
||||||
|
|
||||||
StringBuilder accountsSummary = new StringBuilder("l.id as id, l.external_id as externalId,");
|
StringBuilder accountsSummary = new StringBuilder("l.id as id, l.external_id as externalId,");
|
||||||
accountsSummary
|
accountsSummary.append("l.product_id as productId, lp.name as productName,").append("l.loan_status_id as statusId ")
|
||||||
.append("l.product_id as productId, lp.name as productName,")
|
.append("from m_loan l ").append("LEFT JOIN m_product_loan AS lp ON lp.id = l.product_id ");
|
||||||
.append("l.loan_status_id as statusId ")
|
|
||||||
.append("from m_loan l ")
|
|
||||||
.append("LEFT JOIN m_product_loan AS lp ON lp.id = l.product_id ");
|
|
||||||
|
|
||||||
return accountsSummary.toString();
|
return accountsSummary.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GroupAccountSummaryData mapRow(final ResultSet rs,
|
public GroupAccountSummaryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||||
@SuppressWarnings("unused") final int rowNum) throws SQLException {
|
|
||||||
|
|
||||||
Long id = JdbcSupport.getLong(rs, "id");
|
Long id = JdbcSupport.getLong(rs, "id");
|
||||||
String externalId = rs.getString("externalId");
|
String externalId = rs.getString("externalId");
|
||||||
|
|||||||
Reference in New Issue
Block a user