mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-08 02:24:18 +00:00
[TLC-254] type bind qualdrop fixes
This commit is contained in:
@@ -83,6 +83,9 @@ public class MetadataValidation extends AbstractValidation {
|
|||||||
String fullFieldname = input.getFieldName() + "." + inputPairs.get(i);
|
String fullFieldname = input.getFieldName() + "." + inputPairs.get(i);
|
||||||
if (input.isAllowedFor(documentTypeValue)) {
|
if (input.isAllowedFor(documentTypeValue)) {
|
||||||
isAllowedLookup.put(fullFieldname, true);
|
isAllowedLookup.put(fullFieldname, true);
|
||||||
|
// For the purposes of qualdrop, we have to add the field name without the qualifier
|
||||||
|
// too, or a required qualdrop will get confused and incorrectly reject a value
|
||||||
|
isAllowedLookup.put(input.getFieldName(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -103,12 +106,32 @@ public class MetadataValidation extends AbstractValidation {
|
|||||||
List<String> fieldsName = new ArrayList<String>();
|
List<String> fieldsName = new ArrayList<String>();
|
||||||
|
|
||||||
if (input.isQualdropValue()) {
|
if (input.isQualdropValue()) {
|
||||||
|
boolean foundResult = false;
|
||||||
List<Object> inputPairs = input.getPairs();
|
List<Object> inputPairs = input.getPairs();
|
||||||
//starting from the second element of the list and skipping one every time because the display
|
//starting from the second element of the list and skipping one every time because the display
|
||||||
// values are also in the list and before the stored values.
|
// values are also in the list and before the stored values.
|
||||||
for (int i = 1; i < inputPairs.size(); i += 2) {
|
for (int i = 1; i < inputPairs.size(); i += 2) {
|
||||||
String fullFieldname = input.getFieldName() + "." + (String) inputPairs.get(i);
|
String fullFieldname = input.getFieldName() + "." + (String) inputPairs.get(i);
|
||||||
fieldsName.add(fullFieldname);
|
List<MetadataValue> mdv = itemService.getMetadataByMetadataString(obj.getItem(), fullFieldname);
|
||||||
|
|
||||||
|
// Check the lookup list. If no other inputs of the same field name allow this type,
|
||||||
|
// then remove. This includes field name without qualifier.
|
||||||
|
if (!input.isAllowedFor(documentTypeValue) && (!isAllowedLookup.containsKey(fullFieldname)
|
||||||
|
&& !isAllowedLookup.containsKey(input.getFieldName()))) {
|
||||||
|
itemService.removeMetadataValues(ContextUtil.obtainCurrentRequestContext(),
|
||||||
|
obj.getItem(), mdv);
|
||||||
|
} else {
|
||||||
|
validateMetadataValues(mdv, input, config, isAuthorityControlled, fieldKey, errors);
|
||||||
|
if (mdv.size() > 0 && input.isVisible(DCInput.SUBMISSION_SCOPE)) {
|
||||||
|
foundResult = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (input.isRequired() && !foundResult) {
|
||||||
|
// for this required qualdrop no value was found, add to the list of error fields
|
||||||
|
addError(errors, ERROR_VALIDATION_REQUIRED,
|
||||||
|
"/" + WorkspaceItemRestRepository.OPERATION_PATH_SECTIONS + "/" + config.getId() + "/" +
|
||||||
|
input.getFieldName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fieldsName.add(input.getFieldName());
|
fieldsName.add(input.getFieldName());
|
||||||
|
Reference in New Issue
Block a user