Ported patch from branch feature/20965

This commit is contained in:
Luca Frosini 2021-03-12 12:52:19 +01:00
parent 4ece53108f
commit 2f5885579b
1 changed files with 18 additions and 1 deletions

View File

@ -148,8 +148,12 @@ public class Validator {
// now validate fields
int metadataIndex = 0;
Map<String, MetadataField> metadataFieldMap = new HashMap<>();
for(MetadataField metadataField : metadataFields) {
metadataFieldMap.put(metadataField.getFieldName(), metadataField);
int categoryIdIndex = categoriesIds.indexOf(metadataField.getCategoryRef());
logger.debug("Found index for category " + metadataField.getCategoryRef() + " " + categoryIdIndex);
List<CustomField> validCFs = validateAgainstMetadataField(metadataIndex, categoryIdIndex,
@ -168,7 +172,20 @@ public class Validator {
Map.Entry<java.lang.String,java.lang.Integer> entry = (Map.Entry<java.lang.String,java.lang.Integer>) iteratorLowerBounds
.next();
int lowerBound = entry.getValue();
int upperBound = fieldsMandatoryUpperBoundMap.get(entry.getKey());
// int upperBound = fieldsMandatoryUpperBoundMap.get(entry.getKey());
String maxOccurs = metadataFieldMap.get(entry.getKey()).getMaxOccurs();
int upperBound = Integer.MAX_VALUE;
if(maxOccurs.compareTo("*")==0) {
upperBound = Integer.MAX_VALUE;
}else {
try {
upperBound = Integer.valueOf(maxOccurs);
}catch (Exception e) {
}
}
int inserted = numberFieldsMandatorySameKeyMap.get(entry.getKey());
logger.info("Field with key '" + entry.getKey() + "' has been found " + inserted