-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Browse filter results on page #473
Open
litvinovg
wants to merge
37
commits into
vivo-project:main
Choose a base branch
from
litvinovg:browse-filter-results-page-option
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
3150cc0
Browse filter results
litvinovg 11f6643
improved regular expression for alphabetical index
litvinovg 5e1fb02
fixed access modifiers
litvinovg 2eea1d0
fixed identations
litvinovg 33538f8
added else block
litvinovg b566bca
Limit default search results by all the possible values for the filte…
litvinovg 5a4af67
limit results to all possible values by default
litvinovg 4c281bb
converted getInput function to macro
litvinovg 312f3da
converted getLabel function into macro. Turned off autocomplete
litvinovg 8233aff
extracted javascript for search results
litvinovg 461946f
Simplified check for any selected value
litvinovg 9a6569c
refactored paged results
litvinovg d6b6cb2
Support additional filters on page
litvinovg 6559e3d
removed boostrap 3 dependency from search results page
litvinovg 7c7bf91
get real filter value counts
litvinovg c6cbc04
prevent hidden filter values from being displayed
litvinovg af7a82e
disable additional filters by default
litvinovg cec25fe
fixes for date range filters
litvinovg b852b9c
sort options
litvinovg 6e8dd2e
show range options in case it is already selected
litvinovg 8fbfcac
Improvements for page template
litvinovg b44b68b
style fixes
litvinovg 8709c47
Fix to return button to clean querytext value
litvinovg 8aaf319
fixed checkstyle violation
litvinovg 52e4766
search: refactored filter, group, value display. Display filter value…
litvinovg 5c856dc
checkstyle fixes
litvinovg a180e13
updated ontology
litvinovg 92379ae
removed not needed statement from ontology
litvinovg 0a023ac
Do not show inactive values without results. Hide empty filters on cu…
litvinovg afee954
download results from custom search page
litvinovg cd98648
simplified freemarker macro
litvinovg 9539ff9
fixed adding labels to filter values and querytext filter
litvinovg d0a21e2
Removed redundant query for SearchFilterValuesDataGetter
litvinovg 2db1ce9
checkstyle fix
litvinovg 588776c
set font size for download search results text
litvinovg 064d82d
Added sorting object type to sort filter values
litvinovg 473b8fe
reduced produced html
litvinovg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
...it/n3editing/configuration/preprocessors/utils/ProcessSearchFilterValuesDataGetterN3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("filterUri", 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("filterUri", 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("filterUri", 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("filterUri"); | ||
// 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("filterUri"); | ||
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); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,18 +14,14 @@ public class FilterValue { | |
|
||
private boolean isDefaultValue; | ||
|
||
private boolean publiclyAvailable = true; | ||
private boolean display = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. displayed? isDisplayed()? setDisplayed(boolean value)? |
||
|
||
public boolean isPubliclyAvailable() { | ||
return publiclyAvailable; | ||
public boolean isDisplay() { | ||
return display; | ||
} | ||
|
||
public void setPubliclyAvailable(RDFNode rdfNode) { | ||
if (rdfNode != null && rdfNode.isLiteral()) { | ||
publiclyAvailable = rdfNode.asLiteral().getBoolean(); | ||
} else { | ||
publiclyAvailable = false; | ||
} | ||
public void setDisplay(boolean value) { | ||
display = value; | ||
} | ||
|
||
public FilterValue(String id) { | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProcessSearchFilterValuesDataGetterN3.searchFilterVarBase instead of "filterUri".