MIFOSX-36 - Add/Edit Code values
This commit is contained in:
+2
-1
@@ -55,7 +55,8 @@ public class CodeValue extends AbstractPersistable<Long> {
|
||||
public static CodeValue fromJson(Code code, final JsonCommand command) {
|
||||
|
||||
final String label = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue());
|
||||
final Integer position = command.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue());
|
||||
Integer position = command.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue());
|
||||
if(position == null) position = new Integer(0);
|
||||
return new CodeValue(code, label, position.intValue());
|
||||
}
|
||||
|
||||
|
||||
+2
-9
@@ -50,10 +50,10 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
||||
final String name = this.fromApiJsonHelper.extractStringNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue(), element);
|
||||
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()).value(name).notBlank().notExceedingLengthOf(100);
|
||||
|
||||
final Integer position = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(),
|
||||
/*final Integer position = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(),
|
||||
element);
|
||||
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue()).value(position).notBlank()
|
||||
.integerGreaterThanZero();
|
||||
.integerGreaterThanZero();*/
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
}
|
||||
@@ -75,13 +75,6 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
||||
.notExceedingLengthOf(100);
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) {
|
||||
final Integer position = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(),
|
||||
element);
|
||||
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue()).value(position).notBlank()
|
||||
.integerGreaterThanZero();
|
||||
}
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -68,14 +68,14 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
||||
*/
|
||||
private void handleCodeValueDataIntegrityIssues(final JsonCommand command, final DataIntegrityViolationException dve) {
|
||||
final Throwable realCause = dve.getMostSpecificCause();
|
||||
if (realCause.getMessage().contains("code_value_duplicate")) {
|
||||
if (realCause.getMessage().contains("code_value")) {
|
||||
final String name = command.stringValueOfParameterNamed("name");
|
||||
throw new PlatformDataIntegrityException("error.msg.code.value.duplicate.label", "A code value with lable '" + name
|
||||
+ "' already exists");
|
||||
+ "' already exists", "name", name);
|
||||
}
|
||||
|
||||
logger.error(dve.getMessage(), dve);
|
||||
throw new PlatformDataIntegrityException("error.msg.cund.unknown.data.integrity.issue",
|
||||
throw new PlatformDataIntegrityException("error.msg.code.value.unknown.data.integrity.issue",
|
||||
"Unknown data integrity issue with resource: " + realCause.getMessage());
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
|
||||
return new CommandProcessingResultBuilder().withEntityId(codeValueId).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
logger.error(dve.getMessage(), dve);
|
||||
throw new PlatformDataIntegrityException("error.msg.cund.unknown.data.integrity.issue",
|
||||
throw new PlatformDataIntegrityException("error.msg.code.value.unknown.data.integrity.issue",
|
||||
"Unknown data integrity issue with resource: " + dve.getMostSpecificCause().getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user