FINERACT-243 : Constitution Type Required Field
This commit is contained in:
+7
-1
@@ -40,7 +40,6 @@ import org.joda.time.format.DateTimeFormatter;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
@@ -126,6 +125,13 @@ public final class JsonCommand {
|
||||
return this.parsedCommand;
|
||||
}
|
||||
|
||||
public JsonElement jsonElement(final String paramName) {
|
||||
if (this.parsedCommand.getAsJsonObject().has(paramName)) {
|
||||
return this.parsedCommand.getAsJsonObject().get(paramName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String jsonFragment(final String paramName) {
|
||||
String jsonFragment = null;
|
||||
if (this.parsedCommand.getAsJsonObject().has(paramName)) {
|
||||
|
||||
+2
-2
@@ -250,7 +250,7 @@ public final class ClientDataValidator {
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.constitutionIdParamName, element)) {
|
||||
final Integer constitution = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(ClientApiConstants.constitutionIdParamName,
|
||||
element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.constitutionIdParamName).value(constitution).notNull().integerGreaterThanZero();
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.constitutionIdParamName).value(constitution).ignoreIfNull().integerGreaterThanZero();
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.mainBusinessLineIdParamName, element)) {
|
||||
@@ -532,7 +532,7 @@ public final class ClientDataValidator {
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.constitutionIdParamName, element)) {
|
||||
atLeastOneParameterPassedForUpdate = true;
|
||||
final Integer constitutionId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(ClientApiConstants.constitutionIdParamName, element);
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.constitutionIdParamName).value(constitutionId).notNull().integerGreaterThanZero();
|
||||
baseDataValidator.reset().parameter(ClientApiConstants.constitutionIdParamName).value(constitutionId).ignoreIfNull().integerGreaterThanZero();
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ClientApiConstants.mainBusinessLineIdParamName, element)) {
|
||||
|
||||
+13
-2
@@ -497,7 +497,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
final ClientNonPerson clientNonPersonForUpdate = this.clientNonPersonRepository.findOneByClientId(clientId);
|
||||
if(clientNonPersonForUpdate != null)
|
||||
{
|
||||
final JsonElement clientNonPersonElement = this.fromApiJsonHelper.parse(command.jsonFragment(ClientApiConstants.clientNonPersonDetailsParamName));
|
||||
final JsonElement clientNonPersonElement = command.jsonElement(ClientApiConstants.clientNonPersonDetailsParamName);
|
||||
final Map<String, Object> clientNonPersonChanges = clientNonPersonForUpdate.update(JsonCommand.fromExistingCommand(command, clientNonPersonElement));
|
||||
|
||||
if (clientNonPersonChanges.containsKey(ClientApiConstants.constitutionIdParamName)) {
|
||||
@@ -525,8 +525,19 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
}
|
||||
|
||||
changes.putAll(clientNonPersonChanges);
|
||||
} else {
|
||||
final Integer legalFormParamValue = command.integerValueOfParameterNamed(ClientApiConstants.legalFormIdParamName);
|
||||
boolean isEntity = false;
|
||||
if (legalFormParamValue != null) {
|
||||
final LegalForm legalForm = LegalForm.fromInt(legalFormParamValue);
|
||||
if (legalForm != null) {
|
||||
isEntity = legalForm.isEntity();
|
||||
}
|
||||
}
|
||||
if (isEntity) {
|
||||
extractAndCreateClientNonPerson(clientForUpdate, command);
|
||||
}
|
||||
}
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
.withOfficeId(clientForUpdate.officeId()) //
|
||||
|
||||
Reference in New Issue
Block a user