Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public List<ValidationError> validate(Context context, InProgressSubmission<?> o
List<ValidationError> errors = new ArrayList<>();

DCInputSet inputConfig = getDCInputSet(config);
String documentTypeValue = getDocumentTypeValue(obj);
String documentTypeAuthority = getDocumentTypeAuthority(obj);

// Get list of all field names (including qualdrop names) allowed for this dc.type
List<String> allowedFieldNames = inputConfig.populateAllowedFieldNames(documentTypeValue);
List<String> allowedFieldNames = inputConfig.populateAllowedFieldNames(documentTypeAuthority);

for (DCInput[] row : inputConfig.getFields()) {
for (DCInput input : row) {
Expand All @@ -93,7 +93,7 @@ public List<ValidationError> validate(Context context, InProgressSubmission<?> o

// 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) && (!allowedFieldNames.contains(fullFieldname)
if (!input.isAllowedFor(documentTypeAuthority) && (!allowedFieldNames.contains(fullFieldname)
&& !allowedFieldNames.contains(input.getFieldName()))) {
removeMetadataValues(context, obj.getItem(), mdv);
} else {
Expand All @@ -118,18 +118,18 @@ public List<ValidationError> validate(Context context, InProgressSubmission<?> o
for (String fieldName : fieldsName) {
boolean valuesRemoved = false;
List<MetadataValue> mdv = itemService.getMetadataByMetadataString(obj.getItem(), fieldName);
if (!input.isAllowedFor(documentTypeValue)) {
if (!input.isAllowedFor(documentTypeAuthority)) {
// Check the lookup list. If no other inputs of the same field name allow this type,
// then remove. Otherwise, do not
if (!(allowedFieldNames.contains(fieldName))) {
removeMetadataValues(context, obj.getItem(), mdv);
valuesRemoved = true;
log.debug("Stripping metadata values for " + input.getFieldName() + " on type "
+ documentTypeValue + " as it is allowed by another input of the same field " +
+ documentTypeAuthority + " as it is allowed by another input of the same field " +
"name");
} else {
log.debug("Not removing unallowed metadata values for " + input.getFieldName() + " on type "
+ documentTypeValue + " as it is allowed by another input of the same field " +
+ documentTypeAuthority + " as it is allowed by another input of the same field " +
"name");
}
}
Expand All @@ -139,7 +139,7 @@ public List<ValidationError> validate(Context context, InProgressSubmission<?> o
&& !valuesRemoved) {
// Is the input required for *this* type? In other words, are we looking at a required
// input that is also allowed for this document type
if (input.isAllowedFor(documentTypeValue)) {
if (input.isAllowedFor(documentTypeAuthority)) {
// since this field is missing add to list of error
// fields
addError(errors, ERROR_VALIDATION_REQUIRED,
Expand All @@ -153,10 +153,10 @@ public List<ValidationError> validate(Context context, InProgressSubmission<?> o
return errors;
}

private String getDocumentTypeValue(InProgressSubmission<?> obj) {
private String getDocumentTypeAuthority(InProgressSubmission<?> obj) {
String documentTypeField = configurationService.getProperty("submit.type-bind.field", "dc.type");
List<MetadataValue> documentType = itemService.getMetadataByMetadataString(obj.getItem(), documentTypeField);
return documentType.size() > 0 ? documentType.get(0).getValue() : "";
return !documentType.isEmpty() ? documentType.get(0).getAuthority() : "";
}

private DCInputSet getDCInputSet(SubmissionStepConfig config) {
Expand Down