Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
082c5d9
Browse filter results
litvinovg Sep 16, 2024
169c7ee
improved regular expression for alphabetical index
litvinovg Sep 30, 2024
4777618
fixed access modifiers
litvinovg Oct 11, 2024
22c58ce
fixed identations
litvinovg Oct 11, 2024
ede23d2
added else block
litvinovg Oct 11, 2024
95c0269
Limit default search results by all the possible values for the filte…
litvinovg Oct 17, 2024
366a116
limit results to all possible values by default
litvinovg Oct 17, 2024
0bd3925
converted getInput function to macro
litvinovg Oct 18, 2024
972b75d
converted getLabel function into macro. Turned off autocomplete
litvinovg Oct 18, 2024
8649399
extracted javascript for search results
litvinovg Oct 18, 2024
1a062ef
Simplified check for any selected value
litvinovg Oct 18, 2024
36851a8
refactored paged results
litvinovg Oct 18, 2024
cc8bd14
Support additional filters on page
litvinovg Oct 18, 2024
2bd645d
removed boostrap 3 dependency from search results page
litvinovg Oct 21, 2024
af58a68
get real filter value counts
litvinovg Oct 23, 2024
ccba00b
prevent hidden filter values from being displayed
litvinovg Oct 23, 2024
70e25e7
disable additional filters by default
litvinovg Oct 23, 2024
e57e830
fixes for date range filters
litvinovg Oct 24, 2024
d54516d
sort options
litvinovg Oct 28, 2024
15de4b4
show range options in case it is already selected
litvinovg Oct 28, 2024
406e0df
Improvements for page template
litvinovg Nov 8, 2024
8718b3f
style fixes
litvinovg Nov 11, 2024
62a40a5
Fix to return button to clean querytext value
litvinovg Nov 19, 2024
7732ab5
fixed checkstyle violation
litvinovg Nov 19, 2024
6665e0c
search: refactored filter, group, value display. Display filter value…
litvinovg Nov 26, 2024
b98649b
checkstyle fixes
litvinovg Nov 26, 2024
b3abb14
updated ontology
litvinovg Nov 26, 2024
76a20ee
removed not needed statement from ontology
litvinovg Nov 26, 2024
9ed766b
Do not show inactive values without results. Hide empty filters on cu…
litvinovg Nov 26, 2024
7113edb
download results from custom search page
litvinovg Nov 26, 2024
0f3f2df
simplified freemarker macro
litvinovg Nov 27, 2024
1e51655
fixed adding labels to filter values and querytext filter
litvinovg Nov 27, 2024
dcac07a
Removed redundant query for SearchFilterValuesDataGetter
litvinovg Nov 27, 2024
789c4ef
checkstyle fix
litvinovg Nov 27, 2024
0e286d8
set font size for download search results text
litvinovg Nov 28, 2024
4683c0c
Added sorting object type to sort filter values
litvinovg Dec 6, 2024
5d58e7b
reduced produced html
litvinovg Dec 17, 2024
8467b1d
fixes for mistakes found in review
litvinovg Jan 7, 2025
d53f191
Created :rank and :direction search ontology properties, SortDirectio…
litvinovg Jan 8, 2025
0c380eb
renamed missed display into displayed
litvinovg Jan 10, 2025
ac66143
Use 'browse' short view for search enchanced pages
litvinovg Feb 19, 2025
319b103
Hide empty filters and empty filter groups on search results page
litvinovg Mar 20, 2025
21f8f37
Fixed search filtering
litvinovg Mar 31, 2025
5912a47
Facet controller
litvinovg Apr 3, 2025
2532cc3
Added language to search forms
litvinovg Apr 4, 2025
2c5b584
Added hasVar property to limit variables to be added into search inde…
litvinovg Apr 8, 2025
da13545
Fixed inconsistent variable name in browse search filter values.
litvinovg Apr 22, 2025
1abcdde
Fixed floating for alphabetical index for Vitro theme
litvinovg May 6, 2025
14935c2
Fix: fixed variable name for 'Browse search filter values' title
litvinovg May 8, 2025
66d5b97
Removed content types capitalization
litvinovg May 8, 2025
de6d254
Padding for browsing options
litvinovg May 8, 2025
0bf6a65
Removed duplicate empty li elements, added text in case no results wa…
litvinovg May 8, 2025
c62c30b
Error message in case of no results and selected letter on search enh…
litvinovg May 8, 2025
ab09596
Replaced arrows with checkboxes in front of facet options, style fixes
litvinovg May 8, 2025
7692f1a
Added suggestion in case of zero results with selected letter.
litvinovg May 8, 2025
0d72fb0
Removed filter type from selected facet label.
litvinovg May 8, 2025
423f39e
Updated code to new tooltips
litvinovg May 9, 2025
4dcf3e9
Layout fixes, download text image fixes
litvinovg May 9, 2025
605945a
Moved initial letter regular expression into filter configuration.
litvinovg May 13, 2025
1b02ad0
Style fixes
litvinovg May 13, 2025
083b613
Style improvements for no individual message.
litvinovg May 15, 2025
c42f893
Uppercased not found letter, added italic style
litvinovg May 15, 2025
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 @@ -137,6 +137,7 @@ public class DisplayVocabulary {

/* URI of property for Fixed HTML Generator */
public static final String FIXED_HTML_VALUE = DISPLAY_NS + "htmlValue";
public static final String SEARCH_FILTER_VALUE = DISPLAY_NS + "searchFilter";


/* URI of property for Search Query Generator */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class VitroVocabulary {
public static final String VITRO_AUTH = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#";
public static final String VITRO_PUBLIC = "http://vitro.mannlib.cornell.edu/ns/vitro/public#";
public static final String VITRO_PUBLIC_ONTOLOGY = "http://vitro.mannlib.cornell.edu/ns/vitro/public";
public static final String VITRO_SEARCH_INDIVIDUAL ="https://vivoweb.org/ontology/vitro-search-individual/";
// TODO change the following before 1.6 release
public static final String PROPERTY_CONFIG_DATA = "http://vitro.mannlib.cornell.edu/ns/vitro/siteConfig/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ private void addRequiredPageData(VitroRequest vreq, Map<String, Object> data) {
MenuManagementDataUtils.includeRequiredSystemData(vreq.getSession().getServletContext(), data);
data.put("classGroup", new ArrayList<String>());
data.put("classGroups", DataGetterUtils.getClassGroups(vreq));
data.put("searchFilter", new ArrayList<String>());
data.put("searchFilters", DataGetterUtils.getSearchFilters(vreq));
//for search individuals data get getter
data.put("classes", this.getAllVClasses(vreq));
data.put("availablePermissions", this.getAvailablePermissions(vreq));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,37 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData;
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter;
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter;
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchFilterValuesDataGetter;
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchIndividualsDataGetter;
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter;

/*
* This class determines what n3 should be returned for a particular data getter and can be overwritten or extended in VIVO.
*/
public class ProcessDataGetterN3Map {
private static final Log log = LogFactory.getLog(ProcessDataGetterN3Map.class);

private static HashMap<String, String> dataGetterMap;
private static HashMap<String, Class> dataGetterMap;

static {
dataGetterMap = new HashMap<String, String>();
dataGetterMap.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessSparqlDataGetterN3");
dataGetterMap.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessClassGroupDataGetterN3");
dataGetterMap.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessIndividualsForClassesDataGetterN3");
dataGetterMap.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessFixedHTMLN3");
dataGetterMap.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchIndividualsDataGetter", "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessSearchIndividualsDataGetterN3");
dataGetterMap = new HashMap<String, Class>();
dataGetterMap.put(SparqlQueryDataGetter.class.getCanonicalName(), ProcessSparqlDataGetterN3.class);
dataGetterMap.put(ClassGroupPageData.class.getCanonicalName(), ProcessClassGroupDataGetterN3.class);
dataGetterMap.put(SearchFilterValuesDataGetter.class.getCanonicalName(), ProcessSearchFilterValuesDataGetterN3.class);
dataGetterMap.put(IndividualsForClassesDataGetter.class.getCanonicalName(), ProcessIndividualsForClassesDataGetterN3.class);
dataGetterMap.put(FixedHTMLDataGetter.class.getCanonicalName(), ProcessFixedHTMLN3.class);
dataGetterMap.put(SearchIndividualsDataGetter.class.getCanonicalName(), ProcessSearchIndividualsDataGetterN3.class);
}

public static HashMap<String, String> getDataGetterTypeToProcessorMap() {
public static HashMap<String, Class> getDataGetterTypeToProcessorMap() {
return dataGetterMap;
}

public static void replaceDataGetterMap(HashMap<String, String> newMap) {
dataGetterMap = new HashMap<String, String>();
public static void replaceDataGetterMap(HashMap<String, Class> newMap) {
dataGetterMap = new HashMap<String, Class>();
dataGetterMap.putAll(newMap);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,28 @@ public class ProcessDataGetterN3Utils {
private static final Log log = LogFactory.getLog(ProcessDataGetterN3Utils.class);

public static ProcessDataGetterN3 getDataGetterProcessorN3(String dataGetterClass, ObjectNode jsonObject) {
HashMap<String, String> map = ProcessDataGetterN3Map.getDataGetterTypeToProcessorMap();
HashMap<String, Class> map = ProcessDataGetterN3Map.getDataGetterTypeToProcessorMap();
//
if(map.containsKey(dataGetterClass)) {
String processorClass = map.get(dataGetterClass);
Class<?> processorClass = map.get(dataGetterClass);
try {
ProcessDataGetterN3 pn = instantiateClass(processorClass, jsonObject);
return pn;
} catch(Exception ex) {
log.error("Exception occurred in trying to get processor class for n3 for " + dataGetterClass, ex);
return null;
}
}
} else {
log.error(ProcessDataGetterN3Map.class.getSimpleName() + " doesn't contain processor class for n3 for " + dataGetterClass);
return null;
}
return null;

}

private static ProcessDataGetterN3 instantiateClass(String processorClass, ObjectNode jsonObject) {
private static ProcessDataGetterN3 instantiateClass(Class<?> processorClass, ObjectNode jsonObject) {
ProcessDataGetterN3 pn = null;
try {
Class<?> clz = Class.forName(processorClass);
Constructor<?>[] ctList = clz.getConstructors();
Constructor<?>[] ctList = processorClass.getConstructors();
for (Constructor<?> ct: ctList) {
Class<?>[] parameterTypes =ct.getParameterTypes();
if(parameterTypes.length > 0 && parameterTypes[0].isAssignableFrom(jsonObject.getClass())) {
Expand All @@ -47,7 +49,7 @@ private static ProcessDataGetterN3 instantiateClass(String processorClass, Objec
}

} catch(Exception ex) {
log.error("Error occurred instantiating " + processorClass, ex);
log.error("Error occurred instantiating " + processorClass.getCanonicalName(), ex);
}
return pn;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/* $This file is distributed under the terms of the license in LICENSE$ */

package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils;

import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.SEARCH_FILTER_VALUE;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.servlet.ServletContext;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchFilterValuesDataGetter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jena.ontology.OntModel;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.Resource;

//Returns the appropriate n3 based on data getter
public class ProcessSearchFilterValuesDataGetterN3 extends ProcessDataGetterAbstract {
private static String classType = "java:" + SearchFilterValuesDataGetter.class.getCanonicalName();
public static String searchFilterVarBase = "filterUri";
private Log log = LogFactory.getLog(ProcessSearchFilterValuesDataGetterN3.class);

public ProcessSearchFilterValuesDataGetterN3() {
}

public List<String> retrieveN3Required(int counter) {
return retrieveN3ForTypeAndFilter(counter);
}

public List<String> retrieveN3Optional(int counter) {
return null;
}

public List<String> retrieveN3ForTypeAndFilter(int counter) {
String n3ForType = getN3ForTypePartial(counter);
String n3 = n3ForType + "; \n" + "<" + DisplayVocabulary.SEARCH_FILTER_VALUE + "> "
+ getN3VarName(searchFilterVarBase, counter) + " .";
List<String> n3List = new ArrayList<String>();
n3List.add(getPrefixes() + n3);
return n3List;
}

public String getN3ForTypePartial(int counter) {
String dataGetterVar = getDataGetterVar(counter);
String classTypeVar = getN3VarName(classTypeVarBase, counter);
String n3 = dataGetterVar + " a " + classTypeVar;
return n3;
}

public List<String> retrieveLiteralsOnForm(int counter) {
// no literals, just the class group URI
List<String> literalsOnForm = new ArrayList<String>();
return literalsOnForm;
}

public List<String> retrieveUrisOnForm(int counter) {
List<String> urisOnForm = new ArrayList<String>();
urisOnForm.add(getVarName(searchFilterVarBase, counter));
urisOnForm.add(getVarName(classTypeVarBase, counter));
return urisOnForm;
}

public List<FieldVTwo> retrieveFields(int counter) {
List<FieldVTwo> fields = new ArrayList<FieldVTwo>();
fields.add(new FieldVTwo().setName(getVarName(searchFilterVarBase, counter)));
fields.add(new FieldVTwo().setName(getVarName(classTypeVarBase, counter)));
return fields;
}

public List<String> getLiteralVarNamesBase() {
return Arrays.asList();
}

public List<String> getUriVarNamesBase() {
return Arrays.asList(searchFilterVarBase, classTypeVarBase);
}

public String getClassType() {
return classType;
}

public void populateExistingValues(String dataGetterURI, int counter, OntModel queryModel) {
// First, put dataGetterURI within scope as well
this.populateExistingDataGetterURI(dataGetterURI, counter);
// Put in type
this.populateExistingClassType(this.getClassType(), counter);
// Sparql queries for values to be executed
// And then placed in the correct place/literal or uri
String querystr = getExistingValuesClassGroup(dataGetterURI);
QueryExecution qe = null;
try {
Query query = QueryFactory.create(querystr);
qe = QueryExecutionFactory.create(query, queryModel);
ResultSet results = qe.execSelect();
while (results.hasNext()) {
QuerySolution qs = results.nextSolution();
Resource classGroupResource = qs.getResource(searchFilterVarBase);
// Put both literals in existing literals
existingUriValues.put(this.getVarName(searchFilterVarBase, counter),
new ArrayList<String>(Arrays.asList(classGroupResource.getURI())));
}
} catch (Exception ex) {
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
}
}

protected String getExistingValuesClassGroup(String dataGetterURI) {
String query = getSparqlPrefix() + "\n" +
"SELECT ?filterUri ?filterName WHERE {" +
"<" + dataGetterURI + "> <" + SEARCH_FILTER_VALUE + "> ?filterUri .\n" +
"?filterUri <" + VitroVocabulary.LABEL + "> ?filterName .\n" +
"}";
return query;
}

public ObjectNode getExistingValuesJSON(String dataGetterURI, OntModel queryModel, ServletContext context) {
ObjectNode jObject = new ObjectMapper().createObjectNode();
jObject.put("dataGetterClass", classType);
jObject.put(classTypeVarBase, classType);
getExistingSearchFilters(dataGetterURI, jObject, queryModel);
return jObject;
}

private void getExistingSearchFilters(String dataGetterURI, ObjectNode jObject, OntModel queryModel) {
String querystr = getExistingValuesClassGroup(dataGetterURI);
QueryExecution qe = null;
try {
Query query = QueryFactory.create(querystr);
qe = QueryExecutionFactory.create(query, queryModel);
ResultSet results = qe.execSelect();
while (results.hasNext()) {
QuerySolution qs = results.nextSolution();
Resource filterUri = qs.getResource(searchFilterVarBase);
Literal name = qs.getLiteral("filterName");
jObject.put("searchFilterUri", filterUri.getURI());
jObject.put("searchFilterName", name.getLexicalForm());
}
} catch (Exception ex) {
log.error("Exception occurred in retrieving existing values with query " + querystr, ex);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,26 @@ public enum Order {
* @return A negative value means that no limit has been specified.
*/
int getFacetMinCount();

/**
* @param text is the text a facet field should contain.
* @return this query
*/
SearchQuery setFacetTextToMatch(String text);

/**
* @return The text a facet field.
*/
String getFacetTextToMatch();

/**
* @param ignoreCase defines whether the text of a facet field should be compared case insensitively.
* @return this query
*/
SearchQuery setFacetTextCompareCaseInsensitive(boolean ignoreCase);

/**
* @return defines whether the text of a facet field should be compared case insensitively.
*/
boolean isFacetTextCompareCaseInsensitive();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,18 @@ public class FilterValue {

private String id;
private String name = "";
private int order;

private int rank;
private long count;

private boolean selected = false;

private boolean isDefaultValue;
private boolean displayed = false;

private boolean publiclyAvailable = true;

public boolean isPubliclyAvailable() {
return publiclyAvailable;
public boolean isDisplayed() {
return displayed;
}

public void setPubliclyAvailable(RDFNode rdfNode) {
if (rdfNode != null && rdfNode.isLiteral()) {
publiclyAvailable = rdfNode.asLiteral().getBoolean();
} else {
publiclyAvailable = false;
}
public void setDisplayed(boolean value) {
displayed = value;
}

public FilterValue(String id) {
Expand All @@ -50,13 +42,13 @@ public void setName(RDFNode rdfNode) {
}
}

public Integer getOrder() {
return order;
public Integer getRank() {
return rank;
}

public void setOrder(RDFNode rdfNode) {
public void setRank(RDFNode rdfNode) {
if (rdfNode != null) {
order = rdfNode.asLiteral().getInt();
rank = rdfNode.asLiteral().getInt();
}
}

Expand All @@ -76,7 +68,7 @@ public void setSelected(boolean value) {
this.selected = value;
}

public boolean getSelected() {
public boolean isSelected() {
return selected;
}

Expand Down
Loading