Fix minor worldBuilder issue and a minor refactor

This commit is contained in:
George Kalampokis 2022-02-10 13:21:21 +02:00
parent 4740fbe8e0
commit fac6a93c0a
2 changed files with 8 additions and 2 deletions

View File

@ -664,12 +664,16 @@ public class DatasetManager {
for (String validator : datasetProfileValidators) {
if ((obj.has(validator) && (obj.getString(validator) == null || obj.getString(validator).trim().isEmpty())) && isElementVisible(nodeList, validator, visibilityRuleService)) {
if (obj.has(validator) && isNullOrEmpty(obj.getString(validator)) && isElementVisible(nodeList, validator, visibilityRuleService)) {
throw new Exception("Field value of " + validator + " must be filled.");
}
}
}
private boolean isNullOrEmpty(String value) {
return value == null || value.trim().isEmpty();
}
private boolean isElementVisible(NodeList nodeList, String id, VisibilityRuleService visibilityRuleService) {
Element fieldSet = null;
for (int i = 0; i < nodeList.getLength(); i++) {

View File

@ -27,7 +27,9 @@ import java.io.IOException;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAccessor;
@ -397,7 +399,7 @@ public class WordBuilder {
try {
instant = Instant.parse((String) field.getValue());
} catch (DateTimeParseException ex) {
instant = Instant.from(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).parse((String) field.getValue()));
instant = LocalDate.parse((String) field.getValue()).atStartOfDay().toInstant(ZoneOffset.UTC);
}
return field.getValue() != null ? DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(instant) : "";
}