Merge pull request #1004 from Musoni/MIFOSX-1400

abillity to modify client submission date
This commit is contained in:
Vishwas Babu A J
2014-10-03 21:50:25 -07:00
3 changed files with 27 additions and 1 deletions
@@ -78,8 +78,10 @@ public class ClientApiConstants {
public static final Set<String> CLIENT_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName, public static final Set<String> CLIENT_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
dateFormatParamName, accountNoParamName, externalIdParamName, mobileNoParamName, firstnameParamName, middlenameParamName, dateFormatParamName, accountNoParamName, externalIdParamName, mobileNoParamName, firstnameParamName, middlenameParamName,
lastnameParamName, fullnameParamName, activeParamName, activationDateParamName, staffIdParamName, savingsProductIdParamName, lastnameParamName, fullnameParamName, activeParamName, activationDateParamName, staffIdParamName, savingsProductIdParamName,
dateOfBirthParamName, genderIdParamName, clientTypeIdParamName, clientClassificationIdParamName)); dateOfBirthParamName, genderIdParamName, clientTypeIdParamName, clientClassificationIdParamName,submittedOnDateParamName));
/** /**
* These parameters will match the class level parameters of * These parameters will match the class level parameters of
@@ -324,6 +324,7 @@ public final class ClientDataValidator {
final Boolean active = this.fromApiJsonHelper.extractBooleanNamed(ClientApiConstants.activeParamName, element); final Boolean active = this.fromApiJsonHelper.extractBooleanNamed(ClientApiConstants.activeParamName, element);
if (active != null) { if (active != null) {
atLeastOneParameterPassedForUpdate = true;
if (active.booleanValue()) { if (active.booleanValue()) {
final LocalDate joinedDate = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.activationDateParamName, final LocalDate joinedDate = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.activationDateParamName,
element); element);
@@ -344,6 +345,7 @@ public final class ClientDataValidator {
.longGreaterThanZero(); .longGreaterThanZero();
} }
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.dateOfBirthParamName, element)) { if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.dateOfBirthParamName, element)) {
atLeastOneParameterPassedForUpdate = true; atLeastOneParameterPassedForUpdate = true;
final LocalDate dateOfBirth = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.dateOfBirthParamName, element); final LocalDate dateOfBirth = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.dateOfBirthParamName, element);
@@ -371,12 +373,21 @@ public final class ClientDataValidator {
baseDataValidator.reset().parameter(ClientApiConstants.clientClassificationIdParamName).value(clientClassification) baseDataValidator.reset().parameter(ClientApiConstants.clientClassificationIdParamName).value(clientClassification)
.integerGreaterThanZero(); .integerGreaterThanZero();
} }
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.submittedOnDateParamName, element)) {
atLeastOneParameterPassedForUpdate = true;
final LocalDate submittedDate = this.fromApiJsonHelper.extractLocalDateNamed(ClientApiConstants.submittedOnDateParamName,
element);
baseDataValidator.reset().parameter(ClientApiConstants.submittedOnDateParamName).value(submittedDate).notNull();
}
if (!atLeastOneParameterPassedForUpdate) { if (!atLeastOneParameterPassedForUpdate) {
final Object forceError = null; final Object forceError = null;
baseDataValidator.reset().anyOfNotNull(forceError); baseDataValidator.reset().anyOfNotNull(forceError);
} }
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
} }
@@ -446,6 +446,7 @@ public final class Client extends AbstractPersistable<Long> {
actualChanges.put(ClientApiConstants.savingsProductIdParamName, newValue); actualChanges.put(ClientApiConstants.savingsProductIdParamName, newValue);
} }
if (command.isChangeInLongParameterNamed(ClientApiConstants.genderIdParamName, genderId())) { if (command.isChangeInLongParameterNamed(ClientApiConstants.genderIdParamName, genderId())) {
final Long newValue = command.longValueOfParameterNamed(ClientApiConstants.genderIdParamName); final Long newValue = command.longValueOfParameterNamed(ClientApiConstants.genderIdParamName);
actualChanges.put(ClientApiConstants.genderIdParamName, newValue); actualChanges.put(ClientApiConstants.genderIdParamName, newValue);
@@ -461,6 +462,7 @@ public final class Client extends AbstractPersistable<Long> {
actualChanges.put(ClientApiConstants.clientClassificationIdParamName, newValue); actualChanges.put(ClientApiConstants.clientClassificationIdParamName, newValue);
} }
final String dateFormatAsInput = command.dateFormat(); final String dateFormatAsInput = command.dateFormat();
final String localeAsInput = command.locale(); final String localeAsInput = command.locale();
@@ -485,6 +487,16 @@ public final class Client extends AbstractPersistable<Long> {
this.dateOfBirth = newValue.toDate(); this.dateOfBirth = newValue.toDate();
} }
if (command.isChangeInLocalDateParameterNamed(ClientApiConstants.submittedOnDateParamName,getSubmittedOnDate())) {
final String valueAsInput = command.stringValueOfParameterNamed(ClientApiConstants.submittedOnDateParamName);
actualChanges.put(ClientApiConstants.submittedOnDateParamName, valueAsInput);
actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput);
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.submittedOnDateParamName);
this.submittedOnDate = newValue.toDate();
}
validate(); validate();
deriveDisplayName(); deriveDisplayName();
@@ -492,6 +504,7 @@ public final class Client extends AbstractPersistable<Long> {
return actualChanges; return actualChanges;
} }
private void validateNameParts(final List<ApiParameterError> dataValidationErrors) { private void validateNameParts(final List<ApiParameterError> dataValidationErrors) {
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("client"); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("client");