This commit is contained in:
Mykhaylo
2020-06-19 18:45:37 +02:00
parent 056a0fbdae
commit f9f0067294
3 changed files with 11 additions and 4 deletions

View File

@@ -463,7 +463,7 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService
try {
configReader = new SubmissionConfigReader();
SubmissionConfig submissionName = configReader.getSubmissionConfigByCollection(collection.getHandle());
ma = controllerFormDefinitions.get(submissionName.getSubmissionName()).get(fieldKey);
ma = controllerFormDefinitions.get(fieldKey).get(submissionName.getSubmissionName());
} catch (SubmissionConfigReaderException e) {
// the system is in an illegal state as the submission definition is not valid
throw new IllegalStateException(e);

View File

@@ -13,6 +13,7 @@ import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;
import org.dspace.app.util.DCInputsReader;
import org.dspace.app.util.DCInputsReaderException;
@@ -107,14 +108,18 @@ public class DCInputAuthority extends SelfNamedPlugin implements ChoiceAuthority
init();
int dflt = -1;
int index = 0;
Choice v[] = new Choice[values.length];
for (int i = 0; i < values.length; ++i) {
v[i] = new Choice(values[i], values[i], labels[i]);
if (query == null || StringUtils.containsIgnoreCase(values[i], query)) {
v[index] = new Choice(values[i], values[i], labels[i]);
index++;
}
if (values[i].equalsIgnoreCase(query)) {
dflt = i;
}
}
return new Choices(v, 0, v.length, Choices.CF_AMBIGUOUS, false, dflt);
return new Choices(v, 0, index, Choices.CF_AMBIGUOUS, false, dflt);
}
@Override

View File

@@ -86,7 +86,9 @@ public class VocabularyEntryLinkRepository extends AbstractDSpaceRestRepository
Choices choices = cas.getMatches(fieldKey, filter, collection, Math.toIntExact(pageable.getOffset()),
pageable.getPageSize(), context.getCurrentLocale().toString());
for (Choice value : choices.values) {
results.add(authorityUtils.convertEntry(value, name, projection));
if (value != null) {
results.add(authorityUtils.convertEntry(value, name, projection));
}
}
return new PageImpl<>(results, pageable, results.size());
}