NIHVIVO-646 Filter existing authors out of autocomplete query results in add authors to publication form
This commit is contained in:
parent
c9c3bf4e17
commit
1cdef7f6e4
2 changed files with 21 additions and 11 deletions
|
@ -16,25 +16,28 @@ public class PublicationHasAuthorValidator implements N3Validator {
|
|||
EditSubmission editSub) {
|
||||
Map<String,String> urisFromForm = editSub.getUrisFromForm();
|
||||
Map<String,Literal> literalsFromForm = editSub.getLiteralsFromForm();
|
||||
|
||||
Literal firstName = literalsFromForm.get("firstName");
|
||||
if( firstName.getLexicalForm() != null && "".equals(firstName.getLexicalForm()) )
|
||||
firstName = null;
|
||||
|
||||
Literal lastName = literalsFromForm.get("lastName");
|
||||
if( lastName.getLexicalForm() != null && "".equals(lastName.getLexicalForm()) )
|
||||
lastName = null;
|
||||
Map<String,String> errors = new HashMap<String,String>();
|
||||
|
||||
String personUri = urisFromForm.get("personUri");
|
||||
if ("".equals(personUri)) {
|
||||
personUri = null;
|
||||
}
|
||||
// If there's a personUri, then we're done. The firstName and lastName fields are
|
||||
// disabled and so don't get submitted.
|
||||
if (personUri != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String,String> errors = new HashMap<String,String>();
|
||||
Literal firstName = literalsFromForm.get("firstName");
|
||||
if( firstName != null && firstName.getLexicalForm() != null && "".equals(firstName.getLexicalForm()) )
|
||||
firstName = null;
|
||||
|
||||
Literal lastName = literalsFromForm.get("lastName");
|
||||
if( lastName != null && lastName.getLexicalForm() != null && "".equals(lastName.getLexicalForm()) )
|
||||
lastName = null;
|
||||
|
||||
if (personUri == null && lastName == null && firstName == null) {
|
||||
errors.put("lastName", MISSING_AUTHOR_ERROR);
|
||||
} else if (lastName != null && firstName == null) {
|
||||
if (lastName != null && firstName == null) {
|
||||
errors.put("firstName", MISSING_FIRST_NAME_ERROR);
|
||||
} else if (lastName == null && firstName != null) {
|
||||
errors.put("lastName", MISSING_LAST_NAME_ERROR);
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.search.controller;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -116,6 +117,9 @@ public class AutocompleteController extends FreeMarkerHttpServlet implements Sea
|
|||
Query query = getQuery(vreq, portalFlag, analyzer, indexDir, qtxt);
|
||||
log.debug("query for '" + qtxt +"' is " + query.toString());
|
||||
|
||||
// Get the list of uris that should be excluded from the results
|
||||
List<String> urisToExclude = Arrays.asList(vreq.getParameterValues("filter"));
|
||||
|
||||
if (query == null ) {
|
||||
doNoQuery(templateName, map);
|
||||
return;
|
||||
|
@ -157,6 +161,9 @@ public class AutocompleteController extends FreeMarkerHttpServlet implements Sea
|
|||
try{
|
||||
Document doc = searcherForRequest.doc(topDocs.scoreDocs[i].doc);
|
||||
String uri = doc.get(Entity2LuceneDoc.term.URI);
|
||||
if (urisToExclude.contains(uri)) {
|
||||
continue;
|
||||
}
|
||||
Individual ind = iDao.getIndividualByURI(uri);
|
||||
if (ind != null) {
|
||||
String name = ind.getName();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue