MIFOSX-365: Simplify 'Data Tables' functionality
This commit is contained in:
+14
-13
@@ -61,22 +61,26 @@ public class DatatableCommandFromApiJsonDeserializer {
|
|||||||
baseDataValidator.reset().parameter("type").value(type).notBlank()
|
baseDataValidator.reset().parameter("type").value(type).notBlank()
|
||||||
.isOneOfTheseValues(supportedColumnTypes);
|
.isOneOfTheseValues(supportedColumnTypes);
|
||||||
|
|
||||||
final Integer length = fromApiJsonHelper.extractIntegerSansLocaleNamed("length", column);
|
|
||||||
if (type != null && type.equals("String")) {
|
if (type != null && type.equals("String")) {
|
||||||
if (length != null) {
|
if (fromApiJsonHelper.parameterExists("length", column)) {
|
||||||
baseDataValidator.reset().parameter("length").value(length).notBlank()
|
final String lengthStr = fromApiJsonHelper.extractStringNamed("length", column);
|
||||||
.positiveAmount();
|
if (lengthStr != null && !StringUtils.isWhitespace(lengthStr)
|
||||||
|
&& StringUtils.isNumeric(lengthStr) && StringUtils.isNotBlank(lengthStr)) {
|
||||||
|
Integer length = Integer.parseInt(lengthStr);
|
||||||
|
baseDataValidator.reset().parameter("length").value(length).positiveAmount();
|
||||||
|
} else if (StringUtils.isBlank(lengthStr) || StringUtils.isWhitespace(lengthStr)) {
|
||||||
|
baseDataValidator.reset().parameter("length").failWithCode("must.be.provided.when.type.is.String");
|
||||||
|
} else if (!StringUtils.isNumeric(lengthStr)) {
|
||||||
|
baseDataValidator.reset().parameter("length").failWithCode("not.greater.than.zero");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
baseDataValidator.reset().parameter("length").value(length)
|
baseDataValidator.reset().parameter("length").failWithCode("must.be.provided.when.type.is.String");
|
||||||
.cantBeBlankWhenParameterProvidedIs("type", type);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
baseDataValidator.reset().parameter("length").value(length)
|
baseDataValidator.reset().parameter("length").mustBeBlankWhenParameterProvidedIs("type", type);
|
||||||
.mustBeBlankWhenParameterProvidedIs("type", type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final String code = fromApiJsonHelper.extractStringNamed("code", column);
|
final String code = fromApiJsonHelper.extractStringNamed("code", column);
|
||||||
|
|
||||||
if (type != null && type.equals("Dropdown")) {
|
if (type != null && type.equals("Dropdown")) {
|
||||||
if (code != null) {
|
if (code != null) {
|
||||||
baseDataValidator.reset().parameter("code").value(code).notBlank()
|
baseDataValidator.reset().parameter("code").value(code).notBlank()
|
||||||
@@ -125,9 +129,6 @@ public class DatatableCommandFromApiJsonDeserializer {
|
|||||||
baseDataValidator.reset().parameter("name").value(name).notBlank()
|
baseDataValidator.reset().parameter("name").value(name).notBlank()
|
||||||
.isNotOneOfTheseValues("id", fkColumnName).matchesRegularExpression(DATATABLE_COLUMN_NAME_REGEX_PATTERN);
|
.isNotOneOfTheseValues("id", fkColumnName).matchesRegularExpression(DATATABLE_COLUMN_NAME_REGEX_PATTERN);
|
||||||
|
|
||||||
final String type = fromApiJsonHelper.extractStringNamed("type", column);
|
|
||||||
baseDataValidator.reset().parameter("type").value(type).notBlank().isOneOfTheseValues(supportedColumnTypes);
|
|
||||||
|
|
||||||
validateType(baseDataValidator, column);
|
validateType(baseDataValidator, column);
|
||||||
|
|
||||||
final Boolean mandatory = fromApiJsonHelper.extractBooleanNamed("mandatory", column);
|
final Boolean mandatory = fromApiJsonHelper.extractBooleanNamed("mandatory", column);
|
||||||
|
|||||||
Reference in New Issue
Block a user