diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index e6264ee8f..47902bb85 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -1933,6 +1933,13 @@ function executeAjaxRequest(url, verbType, jsonData, basicAuthKey, successFuncti business that doesnt suit the firstname,middlename,lastname structure. +
diff --git a/mifosng-db/migrations/core_db/V127__mobile_no_fields.sql b/mifosng-db/migrations/core_db/V127__mobile_no_fields.sql
new file mode 100644
index 000000000..b5d23bde6
--- /dev/null
+++ b/mifosng-db/migrations/core_db/V127__mobile_no_fields.sql
@@ -0,0 +1,8 @@
+ALTER TABLE `m_client`
+ADD COLUMN `mobile_no` VARCHAR(50) NULL DEFAULT NULL AFTER `display_name`,
+ADD UNIQUE INDEX `mobile_no_UNIQUE` (`mobile_no` ASC);
+
+
+ALTER TABLE `m_staff`
+ADD COLUMN `mobile_no` VARCHAR(50) NULL DEFAULT NULL AFTER `display_name`,
+ADD UNIQUE INDEX `mobile_no_UNIQUE` (`mobile_no` ASC);
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/PlatformSecurityContext.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/PlatformSecurityContext.java
index 3e6f98d60..f38f6dfd0 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/PlatformSecurityContext.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/PlatformSecurityContext.java
@@ -13,5 +13,5 @@ public interface PlatformSecurityContext {
void validateAccessRights(String resourceOfficeHierarchy);
- String OfficeHierarchy();
+ String officeHierarchy();
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java
index 56b53baef..efd5d379f 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java
@@ -48,7 +48,7 @@ public class SpringSecurityPlatformSecurityContext implements PlatformSecurityCo
}
@Override
- public String OfficeHierarchy() {
+ public String officeHierarchy() {
return authenticatedUser().getOffice().getHierarchy();
}
-}
+}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessage.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessage.java
index e33a49f88..d07099ea1 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessage.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessage.java
@@ -41,7 +41,7 @@ public class SmsMessage extends AbstractPersistable {
@Column(name = "status_enum", nullable = false)
private Integer statusType;
- @Column(name = "mobile_no", nullable = false)
+ @Column(name = "mobile_no", nullable = false, length=50)
private String mobileNo;
@Column(name = "message", nullable = false)
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageAssembler.java
index e3bbf09a8..f8715c461 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageAssembler.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/sms/domain/SmsMessageAssembler.java
@@ -52,21 +52,20 @@ public class SmsMessageAssembler {
if (this.fromApiJsonHelper.parameterExists(SmsApiConstants.groupIdParamName, element)) {
final Long groupId = this.fromApiJsonHelper.extractLongNamed(SmsApiConstants.groupIdParamName, element);
group = this.groupRepository.findOneWithNotFoundDetection(groupId);
- mobileNo = "+353 87 3455667";
}
Client client = null;
if (this.fromApiJsonHelper.parameterExists(SmsApiConstants.clientIdParamName, element)) {
final Long clientId = this.fromApiJsonHelper.extractLongNamed(SmsApiConstants.clientIdParamName, element);
client = this.clientRepository.findOneWithNotFoundDetection(clientId);
- mobileNo = "+353 87 3455667"; // get from entity
+ mobileNo = client.mobileNo();
}
Staff staff = null;
if (this.fromApiJsonHelper.parameterExists(SmsApiConstants.staffIdParamName, element)) {
final Long staffId = this.fromApiJsonHelper.extractLongNamed(SmsApiConstants.staffIdParamName, element);
staff = this.staffRepository.findOneWithNotFoundDetection(staffId);
- mobileNo = "+353 87 3455667"; // get from entity
+ mobileNo = staff.mobileNo();
}
final String message = this.fromApiJsonHelper.extractStringNamed(SmsApiConstants.messageParamName, element);
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java
index b28cc638b..6501b86d8 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/api/StaffApiResource.java
@@ -49,7 +49,7 @@ public class StaffApiResource {
* {@link StaffData}.
*/
private final Set RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList("id", "firstname", "lastname", "displayName",
- "officeId", "officeName", "loanOfficerFlag", "externalId", "allowedOffices"));
+ "officeId", "officeName", "loanOfficerFlag", "externalId", "mobileNo", "allowedOffices"));
private final String resourceNameForPermissions = "STAFF";
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/StaffData.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/StaffData.java
index 2356341e4..fb04a8d73 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/StaffData.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/data/StaffData.java
@@ -15,33 +15,37 @@ import org.mifosplatform.organisation.office.data.OfficeData;
public class StaffData {
private final Long id;
+ private final String externalId;
+
private final String firstname;
private final String lastname;
private final String displayName;
+ private final String mobileNo;
+
private final Long officeId;
private final String officeName;
private final Boolean isLoanOfficer;
- private final String externalId;
@SuppressWarnings("unused")
private final Collection allowedOffices;
public static StaffData templateData(final StaffData staff, final Collection allowedOffices) {
return new StaffData(staff.id, staff.firstname, staff.lastname, staff.displayName, staff.officeId, staff.officeName,
- staff.isLoanOfficer, staff.externalId, allowedOffices);
+ staff.isLoanOfficer, staff.externalId, staff.mobileNo, allowedOffices);
}
public static StaffData lookup(final Long id, final String displayName) {
- return new StaffData(id, null, null, displayName, null, null, null, null, null);
+ return new StaffData(id, null, null, displayName, null, null, null, null, null, null);
}
public static StaffData instance(final Long id, final String firstname, final String lastname, final String displayName,
- final Long officeId, final String officeName, final Boolean isLoanOfficer, final String externalId) {
- return new StaffData(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId, null);
+ final Long officeId, final String officeName, final Boolean isLoanOfficer, final String externalId, final String mobileNo) {
+ return new StaffData(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId, mobileNo, null);
}
private StaffData(final Long id, final String firstname, final String lastname, final String displayName, final Long officeId,
- final String officeName, final Boolean isLoanOfficer, final String externalId, final Collection allowedOffices) {
+ final String officeName, final Boolean isLoanOfficer, final String externalId, final String mobileNo,
+ final Collection allowedOffices) {
this.id = id;
this.firstname = firstname;
this.lastname = lastname;
@@ -50,6 +54,7 @@ public class StaffData {
this.isLoanOfficer = isLoanOfficer;
this.externalId = externalId;
this.officeId = officeId;
+ this.mobileNo = mobileNo;
this.allowedOffices = allowedOffices;
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/domain/Staff.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/domain/Staff.java
index f8bf51002..bad2cbdbc 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/domain/Staff.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/domain/Staff.java
@@ -23,7 +23,8 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity
@Table(name = "m_staff", uniqueConstraints = { @UniqueConstraint(columnNames = { "display_name" }, name = "display_name"),
- @UniqueConstraint(columnNames = { "external_id" }, name = "external_id_UNIQUE") })
+ @UniqueConstraint(columnNames = { "external_id" }, name = "external_id_UNIQUE"),
+ @UniqueConstraint(columnNames = { "mobile_no" }, name = "mobile_no_UNIQUE") })
public class Staff extends AbstractPersistable {
@Column(name = "firstname", length = 50)
@@ -35,15 +36,16 @@ public class Staff extends AbstractPersistable {
@Column(name = "display_name", length = 100)
private String displayName;
+ @Column(name = "mobile_no", length = 50, nullable = false, unique = true)
+ private String mobileNo;
+
@Column(name = "external_id", length = 100, nullable = true, unique = true)
private String externalId;
- // Office to which this employee belongs
@ManyToOne
@JoinColumn(name = "office_id", nullable = false)
private Office office;
- // Flag determines if employee is a loan Officer
@Column(name = "is_loan_officer ", nullable = false)
private boolean loanOfficer;
@@ -65,27 +67,26 @@ public class Staff extends AbstractPersistable {
final String externalIdParamName = "externalId";
final String externalId = command.stringValueOfParameterNamedAllowingNull(externalIdParamName);
+ final String mobileNoParamName = "mobileNo";
+ final String mobileNo = command.stringValueOfParameterNamedAllowingNull(mobileNoParamName);
+
final String isLoanOfficerParamName = "isLoanOfficer";
final boolean isLoanOfficer = command.booleanPrimitiveValueOfParameterNamed(isLoanOfficerParamName);
- return new Staff(staffOffice, firstname, lastname, externalId, isLoanOfficer);
- }
-
- public static Staff createNew(final Office staffOffice, final String firstname, final String lastname, final String externalId,
- final boolean isLoanOfficer) {
- return new Staff(staffOffice, firstname, lastname, externalId, isLoanOfficer);
+ return new Staff(staffOffice, firstname, lastname, externalId, mobileNo, isLoanOfficer);
}
protected Staff() {
//
}
- private Staff(final Office staffOffice, final String firstname, final String lastname, final String externalId,
+ private Staff(final Office staffOffice, final String firstname, final String lastname, final String externalId, final String mobileNo,
final boolean isLoanOfficer) {
this.office = staffOffice;
this.firstname = StringUtils.defaultIfEmpty(firstname, null);
this.lastname = StringUtils.defaultIfEmpty(lastname, null);
- this.externalId = externalId;
+ this.externalId = StringUtils.defaultIfEmpty(externalId, null);
+ this.mobileNo = StringUtils.defaultIfEmpty(mobileNo, null);
this.loanOfficer = isLoanOfficer;
deriveDisplayName(firstname);
}
@@ -141,6 +142,13 @@ public class Staff extends AbstractPersistable {
this.externalId = newValue;
}
+ final String mobileNoParamName = "mobileNo";
+ if (command.isChangeInStringParameterNamed(mobileNoParamName, this.mobileNo)) {
+ final String newValue = command.stringValueOfParameterNamed(mobileNoParamName);
+ actualChanges.put(mobileNoParamName, newValue);
+ this.mobileNo = StringUtils.defaultIfEmpty(newValue, null);
+ }
+
final String isLoanOfficerParamName = "isLoanOfficer";
if (command.isChangeInBooleanParameterNamed(isLoanOfficerParamName, this.loanOfficer)) {
final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(isLoanOfficerParamName);
@@ -179,6 +187,10 @@ public class Staff extends AbstractPersistable {
return this.displayName;
}
+ public String mobileNo() {
+ return this.mobileNo;
+ }
+
public Office office() {
return this.office;
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/serialization/StaffCommandFromApiJsonDeserializer.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/serialization/StaffCommandFromApiJsonDeserializer.java
index 15837b578..fe6763110 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/serialization/StaffCommandFromApiJsonDeserializer.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/serialization/StaffCommandFromApiJsonDeserializer.java
@@ -19,6 +19,7 @@ import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
+import org.mifosplatform.portfolio.client.api.ClientApiConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -32,7 +33,7 @@ public final class StaffCommandFromApiJsonDeserializer {
* The parameters supported for this command.
*/
private final Set supportedParameters = new HashSet(Arrays.asList("firstname", "lastname", "officeId", "externalId",
- "isLoanOfficer"));
+ "mobileNo", "isLoanOfficer"));
private final FromJsonHelper fromApiJsonHelper;
@@ -61,6 +62,12 @@ public final class StaffCommandFromApiJsonDeserializer {
final String lastname = this.fromApiJsonHelper.extractStringNamed("lastname", element);
baseDataValidator.reset().parameter("lastname").value(lastname).notBlank().notExceedingLengthOf(50);
+ if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.mobileNoParamName, element)) {
+ final String mobileNo = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.mobileNoParamName, element);
+ baseDataValidator.reset().parameter(ClientApiConstants.mobileNoParamName).value(mobileNo).ignoreIfNull()
+ .notExceedingLengthOf(50);
+ }
+
if (this.fromApiJsonHelper.parameterExists("isLoanOfficer", element)) {
final Boolean loanOfficerFlag = this.fromApiJsonHelper.extractBooleanNamed("isLoanOfficer", element);
baseDataValidator.reset().parameter("isLoanOfficer").value(loanOfficerFlag).notNull();
@@ -94,6 +101,11 @@ public final class StaffCommandFromApiJsonDeserializer {
baseDataValidator.reset().parameter("lastname").value(lastname).notBlank().notExceedingLengthOf(50);
}
+ if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.mobileNoParamName, element)) {
+ final String mobileNo = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.mobileNoParamName, element);
+ baseDataValidator.reset().parameter(ClientApiConstants.mobileNoParamName).value(mobileNo).notExceedingLengthOf(50);
+ }
+
if (this.fromApiJsonHelper.parameterExists("isLoanOfficer", element)) {
final Boolean loanOfficerFlag = this.fromApiJsonHelper.extractBooleanNamed("isLoanOfficer", element);
baseDataValidator.reset().parameter("isLoanOfficer").value(loanOfficerFlag).notNull();
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffReadPlatformServiceImpl.java
index 9c41a9dca..9f431abf6 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffReadPlatformServiceImpl.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffReadPlatformServiceImpl.java
@@ -38,7 +38,7 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
public String schema() {
return " s.id as id,s.office_id as officeId, o.name as officeName, s.firstname as firstname, s.lastname as lastname,"
- + " s.display_name as displayName, s.is_loan_officer as isLoanOfficer, s.external_id as externalId from m_staff s "
+ + " s.display_name as displayName, s.is_loan_officer as isLoanOfficer, s.external_id as externalId, s.mobile_no as mobileNo from m_staff s "
+ " join m_office o on o.id = s.office_id";
}
@@ -53,8 +53,9 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
final boolean isLoanOfficer = rs.getBoolean("isLoanOfficer");
final String officeName = rs.getString("officeName");
final String externalId = rs.getString("externalId");
+ final String mobileNo = rs.getString("mobileNo");
- return StaffData.instance(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId);
+ return StaffData.instance(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId, mobileNo);
}
}
@@ -65,7 +66,8 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
final StringBuilder sqlBuilder = new StringBuilder(200);
sqlBuilder.append("s.id as id, s.office_id as officeId, ohierarchy.name as officeName,");
sqlBuilder.append("s.firstname as firstname, s.lastname as lastname,");
- sqlBuilder.append("s.display_name as displayName, s.is_loan_officer as isLoanOfficer, s.external_id as externalId ");
+ sqlBuilder
+ .append("s.display_name as displayName, s.is_loan_officer as isLoanOfficer, s.external_id as externalId, s.mobile_no as mobileNo ");
sqlBuilder.append("from m_office o ");
sqlBuilder.append("join m_office ohierarchy on o.hierarchy like concat(ohierarchy.hierarchy, '%') ");
sqlBuilder.append("join m_staff s on s.office_id = ohierarchy.id ");
@@ -90,8 +92,9 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
final String officeName = rs.getString("officeName");
final boolean isLoanOfficer = rs.getBoolean("isLoanOfficer");
final String externalId = rs.getString("externalId");
+ final String mobileNo = rs.getString("mobileNo");
- return StaffData.instance(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId);
+ return StaffData.instance(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, externalId, mobileNo);
}
}
@@ -149,8 +152,6 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
public StaffData retrieveStaff(final Long staffId) {
try {
- this.context.authenticatedUser();
-
final StaffMapper rm = new StaffMapper();
final String sql = "select " + rm.schema() + " where s.id = ?";
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java
index d46504561..5db2ef828 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/staff/service/StaffWritePlatformServiceJpaRepositoryImpl.java
@@ -12,7 +12,6 @@ import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
-import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
import org.mifosplatform.organisation.office.domain.Office;
import org.mifosplatform.organisation.office.domain.OfficeRepository;
import org.mifosplatform.organisation.office.exception.OfficeNotFoundException;
@@ -32,16 +31,13 @@ public class StaffWritePlatformServiceJpaRepositoryImpl implements StaffWritePla
private final static Logger logger = LoggerFactory.getLogger(StaffWritePlatformServiceJpaRepositoryImpl.class);
- private final PlatformSecurityContext context;
private final StaffCommandFromApiJsonDeserializer fromApiJsonDeserializer;
private final StaffRepository staffRepository;
private final OfficeRepository officeRepository;
@Autowired
- public StaffWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
- final StaffCommandFromApiJsonDeserializer fromApiJsonDeserializer, final StaffRepository staffRepository,
- final OfficeRepository officeRepository) {
- this.context = context;
+ public StaffWritePlatformServiceJpaRepositoryImpl(final StaffCommandFromApiJsonDeserializer fromApiJsonDeserializer,
+ final StaffRepository staffRepository, final OfficeRepository officeRepository) {
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
this.staffRepository = staffRepository;
this.officeRepository = officeRepository;
@@ -52,8 +48,6 @@ public class StaffWritePlatformServiceJpaRepositoryImpl implements StaffWritePla
public CommandProcessingResult createStaff(final JsonCommand command) {
try {
- this.context.authenticatedUser();
-
this.fromApiJsonDeserializer.validateForCreate(command.json());
final Long officeId = command.longValueOfParameterNamed("officeId");
@@ -80,8 +74,6 @@ public class StaffWritePlatformServiceJpaRepositoryImpl implements StaffWritePla
public CommandProcessingResult updateStaff(final Long staffId, final JsonCommand command) {
try {
- this.context.authenticatedUser();
-
this.fromApiJsonDeserializer.validateForUpdate(command.json());
final Staff staffForUpdate = this.staffRepository.findOne(staffId);
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java
index 3b4235520..dc30c9bf7 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientApiConstants.java
@@ -25,6 +25,7 @@ public class ClientApiConstants {
public static final String groupIdParamName = "groupId";
public static final String accountNoParamName = "accountNo";
public static final String externalIdParamName = "externalId";
+ public static final String mobileNoParamName = "mobileNo";
public static final String firstnameParamName = "firstname";
public static final String middlenameParamName = "middlename";
public static final String lastnameParamName = "lastname";
@@ -53,12 +54,13 @@ public class ClientApiConstants {
public static final String staffOptionsParamName = "staffOptions";
public static final Set CLIENT_CREATE_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(localeParamName,
- dateFormatParamName, groupIdParamName, accountNoParamName, externalIdParamName, firstnameParamName, middlenameParamName,
- lastnameParamName, fullnameParamName, officeIdParamName, activeParamName, activationDateParamName, staffIdParamName));
+ dateFormatParamName, groupIdParamName, accountNoParamName, externalIdParamName, mobileNoParamName, firstnameParamName,
+ middlenameParamName, lastnameParamName, fullnameParamName, officeIdParamName, activeParamName, activationDateParamName,
+ staffIdParamName));
public static final Set CLIENT_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet(Arrays.asList(localeParamName,
- dateFormatParamName, accountNoParamName, externalIdParamName, firstnameParamName, middlenameParamName, lastnameParamName,
- fullnameParamName, activeParamName, activationDateParamName, staffIdParamName));
+ dateFormatParamName, accountNoParamName, externalIdParamName, mobileNoParamName, firstnameParamName, middlenameParamName,
+ lastnameParamName, fullnameParamName, activeParamName, activationDateParamName, staffIdParamName));
/**
* These parameters will match the class level parameters of
@@ -66,7 +68,7 @@ public class ClientApiConstants {
* match those of request parameters.
*/
public static final Set CLIENT_RESPONSE_DATA_PARAMETERS = new HashSet(Arrays.asList(idParamName, accountNoParamName,
- externalIdParamName, statusParamName, activeParamName, activationDateParamName, firstnameParamName, middlenameParamName,
+ externalIdParamName, mobileNoParamName, statusParamName, activeParamName, activationDateParamName, firstnameParamName, middlenameParamName,
lastnameParamName, fullnameParamName, displayNameParamName, officeIdParamName, officeNameParamName, transferOfficeIdParamName,
trasnferOfficeNameParamName, hierarchyParamName, imageKeyParamName, imagePresentParamName, groupsParamName,
officeOptionsParamName, staffOptionsParamName));
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientCommand.java
deleted file mode 100644
index 97232cac5..000000000
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/command/ClientCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-package org.mifosplatform.portfolio.client.command;
-
-import org.joda.time.LocalDate;
-
-public class ClientCommand {
-
- @SuppressWarnings("unused")
- private final String accountNo;
- private final String externalId;
- private final String firstname;
- private final String middlename;
- private final String lastname;
- private final String fullname;
- private final Long officeId;
- private final LocalDate joinedDate;
-
- public ClientCommand(final String accountNo, final String externalId, final String firstname, final String middlename,
- final String lastname, final String fullname, final Long officeId, final LocalDate joinedDate) {
- this.accountNo = accountNo;
- this.externalId = externalId;
- this.firstname = firstname;
- this.middlename = middlename;
- this.lastname = lastname;
- this.fullname = fullname;
- this.officeId = officeId;
- this.joinedDate = joinedDate;
- }
-
- public String getExternalId() {
- return this.externalId;
- }
-
- public String getFirstname() {
- return this.firstname;
- }
-
- public String getMiddlename() {
- return this.middlename;
- }
-
- public String getLastname() {
- return this.lastname;
- }
-
- public String getFullname() {
- return this.fullname;
- }
-
- public Long getOfficeId() {
- return this.officeId;
- }
-
- public LocalDate getJoiningDate() {
- return this.joinedDate;
- }
-}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java
index 585b408cd..d9ec36283 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java
@@ -37,6 +37,7 @@ final public class ClientData implements Comparable {
private final String lastname;
private final String fullname;
private final String displayName;
+ private final String mobileNo;
private final Long officeId;
private final String officeName;
@@ -59,25 +60,25 @@ final public class ClientData implements Comparable {
public static ClientData template(final Long officeId, final LocalDate joinedDate, final Collection officeOptions,
final Collection staffOptions, final Collection closureReasons) {
- return new ClientData(null, null, officeId, null, null, null, null, null, null, null, null, null, null, joinedDate, null, null,
- null, officeOptions, null, staffOptions, closureReasons);
+ return new ClientData(null, null, officeId, null, null, null, null, null, null, null, null, null, null, null, joinedDate, null,
+ null, null, officeOptions, null, staffOptions, closureReasons);
}
public static ClientData templateOnTop(final ClientData clientData, final ClientData templateData) {
return new ClientData(clientData.accountNo, clientData.status, clientData.officeId, clientData.officeName,
clientData.transferToOfficeId, clientData.transferToOfficeName, clientData.id, clientData.firstname, clientData.middlename,
- clientData.lastname, clientData.fullname, clientData.displayName, clientData.externalId, clientData.activationDate,
- clientData.imageId, clientData.staffId, clientData.staffName, templateData.officeOptions, clientData.groups,
- templateData.staffOptions, null);
+ clientData.lastname, clientData.fullname, clientData.displayName, clientData.externalId, clientData.mobileNo,
+ clientData.activationDate, clientData.imageId, clientData.staffId, clientData.staffName, templateData.officeOptions,
+ clientData.groups, templateData.staffOptions, null);
}
public static ClientData setParentGroups(final ClientData clientData, final Collection parentGroups) {
return new ClientData(clientData.accountNo, clientData.status, clientData.officeId, clientData.officeName,
clientData.transferToOfficeId, clientData.transferToOfficeName, clientData.id, clientData.firstname, clientData.middlename,
- clientData.lastname, clientData.fullname, clientData.displayName, clientData.externalId, clientData.activationDate,
- clientData.imageId, clientData.staffId, clientData.staffName, clientData.officeOptions, parentGroups,
- clientData.staffOptions, null);
+ clientData.lastname, clientData.fullname, clientData.displayName, clientData.externalId, clientData.mobileNo,
+ clientData.activationDate, clientData.imageId, clientData.staffId, clientData.staffName, clientData.officeOptions,
+ parentGroups, clientData.staffOptions, null);
}
public static ClientData clientIdentifier(final Long id, final String accountNo, final EnumOptionData status, final String firstname,
@@ -85,26 +86,26 @@ final public class ClientData implements Comparable {
final String officeName) {
return new ClientData(accountNo, status, officeId, officeName, null, null, id, firstname, middlename, lastname, fullname,
- displayName, null, null, null, null, null, null, null, null, null);
+ displayName, null, null, null, null, null, null, null, null, null, null);
}
public static ClientData lookup(final Long id, final String displayName, final Long officeId, final String officeName) {
return new ClientData(null, null, officeId, officeName, null, null, id, null, null, null, null, displayName, null, null, null,
- null, null, null, null, null, null);
+ null, null, null, null, null, null, null);
}
public static ClientData instance(final String accountNo, final EnumOptionData status, final Long officeId, final String officeName,
final Long transferToOfficeId, final String transferToOfficeName, final Long id, final String firstname,
final String middlename, final String lastname, final String fullname, final String displayName, final String externalId,
- final LocalDate activationDate, final Long imageId, final Long staffId, final String staffName) {
+ final String mobileNo, final LocalDate activationDate, final Long imageId, final Long staffId, final String staffName) {
return new ClientData(accountNo, status, officeId, officeName, transferToOfficeId, transferToOfficeName, id, firstname, middlename,
- lastname, fullname, displayName, externalId, activationDate, imageId, staffId, staffName, null, null, null, null);
+ lastname, fullname, displayName, externalId, mobileNo, activationDate, imageId, staffId, staffName, null, null, null, null);
}
private ClientData(final String accountNo, final EnumOptionData status, final Long officeId, final String officeName,
final Long transferToOfficeId, final String transferToOfficeName, final Long id, final String firstname,
final String middlename, final String lastname, final String fullname, final String displayName, final String externalId,
- final LocalDate activationDate, final Long imageId, final Long staffId, final String staffName,
+ final String mobileNo, final LocalDate activationDate, final Long imageId, final Long staffId, final String staffName,
final Collection allowedOffices, final Collection groups,
final Collection staffOptions, final Collection closureReasons) {
this.accountNo = accountNo;
@@ -125,6 +126,7 @@ final public class ClientData implements Comparable {
this.fullname = StringUtils.defaultIfEmpty(fullname, null);
this.displayName = StringUtils.defaultIfEmpty(displayName, null);
this.externalId = StringUtils.defaultIfEmpty(externalId, null);
+ this.mobileNo = StringUtils.defaultIfEmpty(mobileNo, null);
this.activationDate = activationDate;
this.imageId = imageId;
if (imageId != null) {
@@ -174,6 +176,7 @@ final public class ClientData implements Comparable {
return new CompareToBuilder() //
.append(this.id, obj.id) //
.append(this.displayName, obj.displayName) //
+ .append(this.mobileNo, obj.mobileNo) //
.toComparison();
}
@@ -186,6 +189,7 @@ final public class ClientData implements Comparable {
return new EqualsBuilder() //
.append(this.id, rhs.id) //
.append(this.displayName, rhs.displayName) //
+ .append(this.mobileNo, rhs.mobileNo) //
.isEquals();
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java
index 38582b7d6..32b04cdf2 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientDataValidator.java
@@ -115,6 +115,12 @@ public final class ClientDataValidator {
.notExceedingLengthOf(100);
}
+ if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.mobileNoParamName, element)) {
+ final String mobileNo = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.mobileNoParamName, element);
+ baseDataValidator.reset().parameter(ClientApiConstants.mobileNoParamName).value(mobileNo).ignoreIfNull()
+ .notExceedingLengthOf(50);
+ }
+
final Boolean active = this.fromApiJsonHelper.extractBooleanNamed(ClientApiConstants.activeParamName, element);
if (active != null) {
if (active.booleanValue()) {
@@ -276,6 +282,12 @@ public final class ClientDataValidator {
baseDataValidator.reset().parameter(ClientApiConstants.externalIdParamName).value(externalId).notExceedingLengthOf(100);
}
+ if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.mobileNoParamName, element)) {
+ atLeastOneParameterPassedForUpdate = true;
+ final String mobileNo = this.fromApiJsonHelper.extractStringNamed(ClientApiConstants.mobileNoParamName, element);
+ baseDataValidator.reset().parameter(ClientApiConstants.mobileNoParamName).value(mobileNo).notExceedingLengthOf(50);
+ }
+
final Boolean active = this.fromApiJsonHelper.extractBooleanNamed(ClientApiConstants.activeParamName, element);
if (active != null) {
if (active.booleanValue()) {
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java
index f76c8f35b..116605480 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/domain/Client.java
@@ -47,7 +47,8 @@ import org.mifosplatform.portfolio.group.domain.Group;
import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity
-@Table(name = "m_client", uniqueConstraints = { @UniqueConstraint(columnNames = { "account_no" }, name = "account_no_UNIQUE") })
+@Table(name = "m_client", uniqueConstraints = { @UniqueConstraint(columnNames = { "account_no" }, name = "account_no_UNIQUE"), //
+ @UniqueConstraint(columnNames = { "mobile_no" }, name = "mobile_no_UNIQUE") })
public final class Client extends AbstractPersistable {
@Column(name = "account_no", length = 20, unique = true, nullable = false)
@@ -94,6 +95,9 @@ public final class Client extends AbstractPersistable {
@Column(name = "display_name", length = 100, nullable = false)
private String displayName;
+ @Column(name = "mobile_no", length = 50, nullable = false, unique = true)
+ private String mobileNo;
+
@Column(name = "external_id", length = 100, nullable = true, unique = true)
private String externalId;
@@ -121,6 +125,7 @@ public final class Client extends AbstractPersistable {
final String accountNo = command.stringValueOfParameterNamed(ClientApiConstants.accountNoParamName);
final String externalId = command.stringValueOfParameterNamed(ClientApiConstants.externalIdParamName);
+ final String mobileNo = command.stringValueOfParameterNamed(ClientApiConstants.mobileNoParamName);
final String firstname = command.stringValueOfParameterNamed(ClientApiConstants.firstnameParamName);
final String middlename = command.stringValueOfParameterNamed(ClientApiConstants.middlenameParamName);
@@ -142,7 +147,7 @@ public final class Client extends AbstractPersistable {
}
return new Client(status, clientOffice, clientParentGroup, accountNo, firstname, middlename, lastname, fullname, activationDate,
- officeJoiningDate, externalId, staff);
+ officeJoiningDate, externalId, mobileNo, staff);
}
protected Client() {
@@ -151,7 +156,7 @@ public final class Client extends AbstractPersistable {
private Client(final ClientStatus status, final Office office, final Group clientParentGroup, final String accountNo,
final String firstname, final String middlename, final String lastname, final String fullname, final LocalDate activationDate,
- final LocalDate officeJoiningDate, final String externalId, final Staff staff) {
+ final LocalDate officeJoiningDate, final String externalId, final String mobileNo, final Staff staff) {
if (StringUtils.isBlank(accountNo)) {
this.accountNumber = new RandomPasswordGenerator(19).generate();
this.accountNumberRequiresAutoGeneration = true;
@@ -165,6 +170,13 @@ public final class Client extends AbstractPersistable {
} else {
this.externalId = null;
}
+
+ if (StringUtils.isNotBlank(mobileNo)) {
+ this.mobileNo = mobileNo.trim();
+ } else {
+ this.mobileNo = null;
+ }
+
if (activationDate != null) {
this.activationDate = activationDate.toDateMidnight().toDate();
}
@@ -323,6 +335,12 @@ public final class Client extends AbstractPersistable {
this.externalId = StringUtils.defaultIfEmpty(newValue, null);
}
+ if (command.isChangeInStringParameterNamed(ClientApiConstants.mobileNoParamName, this.mobileNo)) {
+ final String newValue = command.stringValueOfParameterNamed(ClientApiConstants.mobileNoParamName);
+ actualChanges.put(ClientApiConstants.mobileNoParamName, newValue);
+ this.mobileNo = StringUtils.defaultIfEmpty(newValue, null);
+ }
+
if (command.isChangeInStringParameterNamed(ClientApiConstants.firstnameParamName, this.firstname)) {
final String newValue = command.stringValueOfParameterNamed(ClientApiConstants.firstnameParamName);
actualChanges.put(ClientApiConstants.firstnameParamName, newValue);
@@ -463,6 +481,14 @@ public final class Client extends AbstractPersistable {
return this.image;
}
+ public String mobileNo() {
+ return this.mobileNo;
+ }
+
+ public void setMobileNo(final String mobileNo) {
+ this.mobileNo = mobileNo;
+ }
+
public String getDisplayName() {
return this.displayName;
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java
index ad2c2921a..0cebe021f 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java
@@ -93,7 +93,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
@Override
public Page retrieveAll(final SearchParameters searchParameters) {
- final String userOfficeHierarchy = this.context.OfficeHierarchy();
+ final String userOfficeHierarchy = this.context.officeHierarchy();
final String underHierarchySearchString = userOfficeHierarchy + "%";
// if (searchParameters.isScopedByOfficeHierarchy()) {
@@ -183,8 +183,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
@Override
public ClientData retrieveOne(final Long clientId) {
try {
- final AppUser currentUser = this.context.authenticatedUser();
- final String hierarchy = currentUser.getOffice().getHierarchy();
+ final String hierarchy = this.context.officeHierarchy();
final String hierarchySearchString = hierarchy + "%";
final String sql = "select " + this.clientMapper.schema()
@@ -262,6 +261,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
sqlBuilder.append("c.transfer_to_office_id as transferToOfficeId, transferToOffice.name as transferToOfficeName, ");
sqlBuilder.append("c.firstname as firstname, c.middlename as middlename, c.lastname as lastname, ");
sqlBuilder.append("c.fullname as fullname, c.display_name as displayName, ");
+ sqlBuilder.append("c.mobile_no as mobileNo, ");
sqlBuilder.append("c.activation_date as activationDate, c.image_id as imageId, ");
sqlBuilder.append("c.staff_id as staffId, s.display_name as staffName ");
sqlBuilder.append("from m_client c ");
@@ -298,13 +298,15 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
final String fullname = rs.getString("fullname");
final String displayName = rs.getString("displayName");
final String externalId = rs.getString("externalId");
+ final String mobileNo = rs.getString("mobileNo");
+
final LocalDate activationDate = JdbcSupport.getLocalDate(rs, "activationDate");
final Long imageId = JdbcSupport.getLong(rs, "imageId");
final Long staffId = JdbcSupport.getLong(rs, "staffId");
final String staffName = rs.getString("staffName");
return ClientData.instance(accountNo, status, officeId, officeName, transferToOfficeId, transferToOfficeName, id, firstname,
- middlename, lastname, fullname, displayName, externalId, activationDate, imageId, staffId, staffName);
+ middlename, lastname, fullname, displayName, externalId, mobileNo, activationDate, imageId, staffId, staffName);
}
}
@@ -335,6 +337,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
builder.append("c.transfer_to_office_id as transferToOfficeId, transferToOffice.name as transferToOfficeName, ");
builder.append("c.firstname as firstname, c.middlename as middlename, c.lastname as lastname, ");
builder.append("c.fullname as fullname, c.display_name as displayName, ");
+ builder.append("c.mobile_no as mobileNo, ");
builder.append("c.activation_date as activationDate, c.image_id as imageId, ");
builder.append("c.staff_id as staffId, s.display_name as staffName ");
builder.append("from m_client c ");
@@ -369,13 +372,14 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
final String fullname = rs.getString("fullname");
final String displayName = rs.getString("displayName");
final String externalId = rs.getString("externalId");
+ final String mobileNo = rs.getString("mobileNo");
final LocalDate activationDate = JdbcSupport.getLocalDate(rs, "activationDate");
final Long imageId = JdbcSupport.getLong(rs, "imageId");
final Long staffId = JdbcSupport.getLong(rs, "staffId");
final String staffName = rs.getString("staffName");
return ClientData.instance(accountNo, status, officeId, officeName, transferToOfficeId, transferToOfficeName, id, firstname,
- middlename, lastname, fullname, displayName, externalId, activationDate, imageId, staffId, staffName);
+ middlename, lastname, fullname, displayName, externalId, mobileNo, activationDate, imageId, staffId, staffName);
}
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
index 1285b4e27..4110617e0 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
@@ -136,8 +136,6 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
public CommandProcessingResult createClient(final JsonCommand command) {
try {
- this.context.authenticatedUser();
-
this.fromApiJsonDeserializer.validateForCreate(command.json());
final Long officeId = command.longValueOfParameterNamed(ClientApiConstants.officeIdParamName);
@@ -188,8 +186,6 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
public CommandProcessingResult updateClient(final Long clientId, final JsonCommand command) {
try {
- this.context.authenticatedUser();
-
this.fromApiJsonDeserializer.validateForUpdate(command.json());
final Client clientForUpdate = this.clientRepository.findOneWithNotFoundDetection(clientId);