updating Client crud service & Db schema for MifosX-35
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE `m_client`
|
||||||
|
ADD COLUMN `display_name` VARCHAR(100) NOT NULL AFTER `lastname`;
|
||||||
|
|
||||||
|
update m_client set display_name = concat_ws(' ',firstname,lastname);
|
||||||
@@ -22,22 +22,18 @@ public class ClientData {
|
|||||||
|
|
||||||
public ClientData(final Long officeId, final String officeName,
|
public ClientData(final Long officeId, final String officeName,
|
||||||
final Long id, final String firstname, final String lastname,
|
final Long id, final String firstname, final String lastname,
|
||||||
final String externalId, final LocalDate joinedDate) {
|
final String displayName, final String externalId,
|
||||||
|
final LocalDate joinedDate) {
|
||||||
this.officeId = officeId;
|
this.officeId = officeId;
|
||||||
this.officeName = officeName;
|
this.officeName = officeName;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.firstname = firstname;
|
this.firstname = firstname;
|
||||||
|
this.displayName = displayName;
|
||||||
|
|
||||||
StringBuilder nameBuilder = new StringBuilder(this.firstname);
|
/*** unset last name for business name **/
|
||||||
if (StringUtils.isNotBlank(nameBuilder.toString())) {
|
|
||||||
nameBuilder.append(' ');
|
|
||||||
}
|
|
||||||
nameBuilder.append(lastname);
|
|
||||||
|
|
||||||
this.displayName = nameBuilder.toString();
|
|
||||||
if (StringUtils.isBlank(this.firstname)) {
|
if (StringUtils.isBlank(this.firstname)) {
|
||||||
this.lastname = null;
|
this.lastname = null;
|
||||||
this.clientOrBusinessName = nameBuilder.toString();
|
this.clientOrBusinessName = lastname;
|
||||||
} else {
|
} else {
|
||||||
this.lastname = lastname;
|
this.lastname = lastname;
|
||||||
this.clientOrBusinessName = null;
|
this.clientOrBusinessName = null;
|
||||||
@@ -47,7 +43,8 @@ public class ClientData {
|
|||||||
this.joinedDate = joinedDate;
|
this.joinedDate = joinedDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientData(final Long officeId, final LocalDate joinedDate, final List<OfficeLookup> offices) {
|
public ClientData(final Long officeId, final LocalDate joinedDate,
|
||||||
|
final List<OfficeLookup> offices) {
|
||||||
this.id = null;
|
this.id = null;
|
||||||
this.officeId = officeId;
|
this.officeId = officeId;
|
||||||
this.officeName = null;
|
this.officeName = null;
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ public class Client extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Column(name = "lastname", length=50)
|
@Column(name = "lastname", length=50)
|
||||||
private String lastName;
|
private String lastName;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Column(name = "display_name", length=50)
|
||||||
|
private String displayName;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "joining_date")
|
@Column(name = "joining_date")
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
@@ -71,6 +75,12 @@ public class Client extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
this.firstName = null;
|
this.firstName = null;
|
||||||
}
|
}
|
||||||
this.lastName = lastName.trim();
|
this.lastName = lastName.trim();
|
||||||
|
//populate display name
|
||||||
|
if(this.firstName!=null){
|
||||||
|
this.displayName = this.firstName + " " + this.lastName;
|
||||||
|
}else{
|
||||||
|
this.displayName = this.lastName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean identifiedBy(final String identifier) {
|
public boolean identifiedBy(final String identifier) {
|
||||||
@@ -89,6 +99,9 @@ public class Client extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
if (StringUtils.isNotBlank(command.getClientOrBusinessName())) {
|
if (StringUtils.isNotBlank(command.getClientOrBusinessName())) {
|
||||||
this.firstName = null;
|
this.firstName = null;
|
||||||
this.lastName = command.getClientOrBusinessName().trim();
|
this.lastName = command.getClientOrBusinessName().trim();
|
||||||
|
this.displayName = this.lastName;
|
||||||
|
}else{
|
||||||
|
deriveDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(command.getExternalId())) {
|
if (StringUtils.isNotBlank(command.getExternalId())) {
|
||||||
@@ -115,6 +128,10 @@ public class Client extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
if (command.isClientOrBusinessNameChanged() && StringUtils.isNotBlank(command.getClientOrBusinessName())) {
|
if (command.isClientOrBusinessNameChanged() && StringUtils.isNotBlank(command.getClientOrBusinessName())) {
|
||||||
this.lastName = command.getClientOrBusinessName();
|
this.lastName = command.getClientOrBusinessName();
|
||||||
this.firstName = null;
|
this.firstName = null;
|
||||||
|
this.displayName = this.lastName;
|
||||||
|
}else if(command.isFirstnameChanged() || command.isLastnameChanged()) {
|
||||||
|
//do not want to enter this condition for business names
|
||||||
|
deriveDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.isExternalIdChanged()) {
|
if (command.isExternalIdChanged()) {
|
||||||
@@ -122,6 +139,10 @@ public class Client extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deriveDisplayName() {
|
||||||
|
this.displayName = this.firstName + " " + this.lastName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete is a <i>soft delete</i>. Updates flag on client so it wont appear in query/report results.
|
* Delete is a <i>soft delete</i>. Updates flag on client so it wont appear in query/report results.
|
||||||
*
|
*
|
||||||
|
|||||||
+4
-3
@@ -131,8 +131,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String clientSchema() {
|
public String clientSchema() {
|
||||||
return "c.office_id as officeId, c.id as id, c.firstname as firstname, c.lastname as lastname, c.external_id as externalId, " +
|
return "c.office_id as officeId, c.id as id, c.firstname as firstname, c.lastname as lastname, c.display_name as displayName, " +
|
||||||
"c.joining_date as joinedDate from m_client c";
|
"c.external_id as externalId, c.joining_date as joinedDate from m_client c";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -146,13 +146,14 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
firstname = "";
|
firstname = "";
|
||||||
}
|
}
|
||||||
String lastname = rs.getString("lastname");
|
String lastname = rs.getString("lastname");
|
||||||
|
String displayName = rs.getString("displayName");
|
||||||
String externalId = rs.getString("externalId");
|
String externalId = rs.getString("externalId");
|
||||||
LocalDate joinedDate = JdbcSupport.getLocalDate(rs, "joinedDate");
|
LocalDate joinedDate = JdbcSupport.getLocalDate(rs, "joinedDate");
|
||||||
|
|
||||||
String officeName = fromOfficeList(this.offices, officeId);
|
String officeName = fromOfficeList(this.offices, officeId);
|
||||||
|
|
||||||
return new ClientData(officeId, officeName, id, firstname,
|
return new ClientData(officeId, officeName, id, firstname,
|
||||||
lastname, externalId, joinedDate);
|
lastname, displayName, externalId, joinedDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String fromOfficeList(final List<OfficeData> officeList,
|
private String fromOfficeList(final List<OfficeData> officeList,
|
||||||
|
|||||||
Reference in New Issue
Block a user