diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/AutocompleteController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/AutocompleteController.java index af4a5e2d1..afdb7755e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/AutocompleteController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/AutocompleteController.java @@ -45,6 +45,8 @@ public class AutocompleteController extends VitroAjaxController { private static final String PARAM_QUERY = "term"; private static final String PARAM_RDFTYPE = "type"; + private static final String PARAM_MULTIPLE_RDFTYPE = "multipleTypes"; + String NORESULT_MSG = ""; private static final int DEFAULT_MAX_HIT_COUNT = 1000; @@ -156,8 +158,9 @@ public class AutocompleteController extends VitroAjaxController { // Filter by type String typeParam = (String) vreq.getParameter(PARAM_RDFTYPE); + String multipleTypesParam = (String) vreq.getParameter(PARAM_MULTIPLE_RDFTYPE); if (typeParam != null) { - query.addFilterQuery(VitroSearchTermNames.RDFTYPE + ":\"" + typeParam + "\""); + addFilterQuery(query, typeParam, multipleTypesParam); } query.setFields(VitroSearchTermNames.NAME_RAW, VitroSearchTermNames.URI); // fields to retrieve @@ -168,7 +171,28 @@ public class AutocompleteController extends VitroAjaxController { return query; } - private void setNameQuery(SolrQuery query, String queryStr, HttpServletRequest request) { + private void addFilterQuery(SolrQuery query, String typeParam, String multipleTypesParam) { + if(multipleTypesParam == null || multipleTypesParam.equals("null") || multipleTypesParam.isEmpty()) { + //Single type parameter, process as usual + query.addFilterQuery(VitroSearchTermNames.RDFTYPE + ":\"" + typeParam + "\""); + } else { + //Types should be comma separated + String[] typeParams = typeParam.split(","); + int len = typeParams.length; + int i; + List filterQueries = new ArrayList(); + + for(i = 0; i < len; i++) { + filterQueries.add(VitroSearchTermNames.RDFTYPE + ":\"" + typeParams[i] + "\" "); + } + String filterQuery = StringUtils.join(filterQueries, " OR "); + query.addFilterQuery(filterQuery); + } + + + } + + private void setNameQuery(SolrQuery query, String queryStr, HttpServletRequest request) { if (StringUtils.isBlank(queryStr)) { log.error("No query string"); diff --git a/webapp/web/templates/freemarker/edit/forms/autoCompleteObjpropForm.ftl b/webapp/web/templates/freemarker/edit/forms/autoCompleteObjpropForm.ftl index 8326e5522..0e73ae645 100644 --- a/webapp/web/templates/freemarker/edit/forms/autoCompleteObjpropForm.ftl +++ b/webapp/web/templates/freemarker/edit/forms/autoCompleteObjpropForm.ftl @@ -1,92 +1,91 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> -<#-- autocomplete template for object properties --> +<#--Assign variables from editConfig--> +<#assign rangeOptions = editConfiguration.pageData.objectVar /> +<#assign rangeOptionsExist = false /> +<#if (rangeOptions?keys?size > 0)> + <#assign rangeOptionsExist = true/> + -<#-- NOTE the jsp contained the following which has not been converted +

${editConfiguration.formTitle}

- - - - +<#if editConfiguration.propertySelectFromExisting = true> + <#if rangeOptionsExist = true > + <#assign rangeOptionKeys = rangeOptions?keys /> +
+ + <#if editConfiguration.propertyPublicDescription?has_content> +

${editConfiguration.propertyPublicDescription}

+ + + + + <#---This section should become autocomplete instead--> +

+ + +

+ +
+

+ + + (Verify this match) +

+
---> - - - - -

${formTitle}

- - - - <#if predicate.offerCreateNewOption > - <#assign var="createNewUrl = "/editRequestDispatch?subjectUri=${param.subjectUri}&predicateUri=${param.predicateUri}&clearEditConfig=true&cmd=create > - - - <#if predicate.publicDescription?has_content > -

${predicate.publicDescription}

- -

- -

- -

- - or Cancel -

- - <#if predicate.offerCreateNewOption> -

If you don't find the appropriate entry on the selection list, - -

- - -
- - <#if ! param.objectUri?has_content > -
- - - - - - + + <#--The above section should be autocomplete--> + + +

+ + or + Cancel +

+ <#else> +

There are no entries in the system from which to select.

+ +<#if editConfiguration.propertyOfferCreateNewOption = true> +<#include "defaultOfferCreateNewOptionForm.ftl"> + + + +<#if editConfiguration.propertySelectFromExisting = false && editConfiguration.propertyOfferCreateNewOption = false> +

This property is currently configured to prohibit editing.

+ + + +<#if editConfiguration.includeDeletionForm = true> +<#include "defaultDeletePropertyForm.ftl"> + + + +<#assign sparqlQueryUrl = "${urls.base}/ajax/sparqlQuery" > + + + + + +${stylesheets.add('')} + ${stylesheets.add('')} + ${stylesheets.add('')} + + + ${scripts.add('', + '', + '', + '')}