NIHVIVO-3357 - updated autocomplete generator and autocomplete template: generator returns empty list in case only owl:Thing returned, as Solr search doesn't create the index using this class, and updated freemarker template so that the type parameter for autocomplete is only passed in case the types list from the generator is not empty. Also added similar logic for parameter value for "multiple types"

This commit is contained in:
hjkhjk54 2012-01-06 17:40:49 +00:00
parent 9d520d14b5
commit 225a254b71
2 changed files with 26 additions and 2 deletions

View file

@ -7,6 +7,15 @@
<#assign rangeOptionsExist = true/>
</#if>
<#assign objectTypes = editConfiguration.pageData.objectTypes />
<#assign objectTypesSize = objectTypes?length />
<#assign objectTypesExist = false />
<#assign multipleTypes = false />
<#if (objectTypesSize > 1)>
<#assign objectTypesExist = true />
</#if>
<#if objectTypes?contains(",")>
<#assign multipleTypes = true/>
</#if>
<#assign sparqlForAcFilter = editConfiguration.pageData.sparqlForAcFilter />
<#assign editMode = editConfiguration.pageData.editMode />
<#assign propertyNameForDisplay = "" />
@ -88,12 +97,18 @@
<#assign sparqlQueryUrl = "${urls.base}/ajax/sparqlQuery" >
<script type="text/javascript">
<#--Passing in object types only if there are any types returned, otherwise
the parameter should not be passed at all to the solr search.
Also multiple types parameter set to true only if more than one type returned-->
<script type="text/javascript">
var customFormData = {
acUrl: '${urls.base}/autocomplete?tokenize=true',
<#if objectTypesExist = true>
acType: '${objectTypes}',
</#if>
<#if multipleTypes = true>
acMultipleTypes: 'true',
</#if>
submitButtonTextType: 'simple',
editMode: '${editMode}',
typeName:'${propertyNameForDisplay}',

View file

@ -59,9 +59,18 @@ public class AutocompleteObjectPropertyFormGenerator extends DefaultObjectProper
for(VClass v: vclasses) {
types.add(v.getURI());
}
//if types array contains only owl:Thing, the search will not return any results
//In this case, return an empty array
if(isOWLThing(types)) {
return new ArrayList<String>();
}
return types;
}
private boolean isOWLThing(List<String> types) {
return(types.size() == 1 && types.get(0).equals(VitroVocabulary.OWL_THING));
}
public EditMode getEditMode(VitroRequest vreq) {
//In this case, the original jsp didn't rely on FrontEndEditingUtils
//but instead relied on whether or not the object Uri existed