VIVO-870 Move the DocumentModifiers into the configuration.
This commit is contained in:
parent
2d2c5032cc
commit
20bf51d7c9
6 changed files with 132 additions and 397 deletions
|
@ -29,25 +29,140 @@
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.CalculateParameters> ,
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.CalculateParameters> ,
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||||
|
|
||||||
:vivodocumentModifier_valuesFromVcards
|
:vivodocumentModifier_PreferredTitle
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VIVOValuesFromVcards> ,
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||||
|
rdfs:label "Preferred title" ;
|
||||||
|
:hasTargetField "ALLTEXT" ;
|
||||||
|
:hasTargetField "ALLTEXTUNSTEMMED" ;
|
||||||
|
:hasTargetField "PREFERRED_TITLE" ;
|
||||||
|
:hasSparqlQuery """
|
||||||
|
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
|
||||||
|
PREFIX obo: <http://purl.obolibrary.org/obo/>
|
||||||
|
SELECT ?title
|
||||||
|
WHERE {
|
||||||
|
?uri obo:ARG_2000028 ?card .
|
||||||
|
?card a vcard:Individual .
|
||||||
|
?card vcard:hasTitle ?titleHolder .
|
||||||
|
?titleHolder vcard:title ?title .
|
||||||
|
}
|
||||||
|
""" .
|
||||||
|
|
||||||
:vivodocumentModifier_ISFBasicFields
|
:vivodocumentModifier_EmailAddress
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFBasicFields> ,
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||||
|
rdfs:label "Email address" ;
|
||||||
|
:hasTargetField "ALLTEXT" ;
|
||||||
|
:hasTargetField "ALLTEXTUNSTEMMED" ;
|
||||||
|
:hasSparqlQuery """
|
||||||
|
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
|
||||||
|
PREFIX obo: <http://purl.obolibrary.org/obo/>
|
||||||
|
SELECT ?email
|
||||||
|
WHERE {
|
||||||
|
?uri obo:ARG_2000028 ?card .
|
||||||
|
?card a vcard:Individual .
|
||||||
|
?card vcard:hasEmail ?emailHolder .
|
||||||
|
?emailHolder vcard:email ?email .
|
||||||
|
}
|
||||||
|
""" .
|
||||||
|
:vivodocumentModifier_NamesAcrossContextNodes
|
||||||
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||||
|
rdfs:label "Names of objects across context nodes" ;
|
||||||
|
:hasSparqlQuery """
|
||||||
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
|
PREFIX core: <http://vivoweb.org/ontology/core#>
|
||||||
|
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
||||||
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
|
PREFIX obo: <http://purl.obolibrary.org/obo/>
|
||||||
|
SELECT (str(?rawresult) as ?result)
|
||||||
|
WHERE {
|
||||||
|
?uri core:relatedBy ?rel .
|
||||||
|
?rel rdf:type ?type .
|
||||||
|
?rel core:relates ?other .
|
||||||
|
?other rdfs:label ?rawresult .
|
||||||
|
FILTER ( ?type IN ( core:Position, core:Authorship, core:Collaboration, core:Affiliation ) )
|
||||||
|
}
|
||||||
|
""" .
|
||||||
|
|
||||||
:vivodocumentModifier_ISFAdvisingFields
|
:vivodocumentModifier_MembershipFields
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFAdvisingFields> ,
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||||
|
rdfs:label "Add people to organization and vice versa." ;
|
||||||
|
:hasSparqlQuery """
|
||||||
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
|
PREFIX core: <http://vivoweb.org/ontology/core#>
|
||||||
|
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
||||||
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
|
PREFIX obo: <http://purl.obolibrary.org/obo/>
|
||||||
|
SELECT (str(?rawresult) as ?result)
|
||||||
|
WHERE {
|
||||||
|
?uri rdf:type foaf:Organization .
|
||||||
|
?role core:roleContributesTo ?uri .
|
||||||
|
?person obo:RO_0000053 ?role .
|
||||||
|
?person rdfs:label ?rawresult .
|
||||||
|
}
|
||||||
|
""" ;
|
||||||
|
:hasSparqlQuery """
|
||||||
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
|
PREFIX core: <http://vivoweb.org/ontology/core#>
|
||||||
|
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
||||||
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
|
PREFIX obo: <http://purl.obolibrary.org/obo/>
|
||||||
|
SELECT (str(?rawresult) as ?result)
|
||||||
|
WHERE {
|
||||||
|
?uri rdf:type foaf:Person .
|
||||||
|
?uri obo:RO_0000053 / core:roleContributesTo / rdfs:label ?rawresult .
|
||||||
|
}
|
||||||
|
""" .
|
||||||
|
|
||||||
:vivodocumentModifier_ISFEducationFields
|
:vivodocumentModifier_EducationFields
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFEducationFields> ,
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||||
|
rdfs:label "Labels for a degree and the granting organization." ;
|
||||||
|
:hasSparqlQuery """
|
||||||
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
|
PREFIX core: <http://vivoweb.org/ontology/core#>
|
||||||
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
|
SELECT (str(?rawresult) as ?result)
|
||||||
|
WHERE {
|
||||||
|
?uri core:relates ?deg .
|
||||||
|
?deg rdf:type core:AwardedDegree .
|
||||||
|
?deg rdfs:label ?rawresult .
|
||||||
|
}
|
||||||
|
""" ;
|
||||||
|
:hasSparqlQuery """
|
||||||
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
|
PREFIX core: <http://vivoweb.org/ontology/core#>
|
||||||
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
|
SELECT (str(?rawresult) as ?result)
|
||||||
|
WHERE {
|
||||||
|
?uri core:relates ?deg .
|
||||||
|
?deg rdf:type core:AwardedDegree .
|
||||||
|
?deg core:assignedBy ?org .
|
||||||
|
?org rdfs:label ?rawresult .
|
||||||
|
}
|
||||||
|
""" .
|
||||||
|
|
||||||
:vivodocumentModifier_ISFMemberFields
|
:vivodocumentModifier_AdvisingFields
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFMemberFields> ,
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||||
|
rdfs:label "Labels for people in an advising relationship." ;
|
||||||
|
:hasSparqlQuery """
|
||||||
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
|
PREFIX core: <http://vivoweb.org/ontology/core#>
|
||||||
|
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
||||||
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
|
PREFIX obo: <http://purl.obolibrary.org/obo/>
|
||||||
|
SELECT (str(?rawresult) as ?result)
|
||||||
|
WHERE {
|
||||||
|
?uri core:relatedBy ?rel .
|
||||||
|
?rel rdf:type core:AdvisingRelationship .
|
||||||
|
?rel core:relates ?other .
|
||||||
|
?other rdfs:label ?rawresult .
|
||||||
|
FILTER( ?other != ?uri )
|
||||||
|
}
|
||||||
|
""" .
|
||||||
|
|
||||||
:vivodocumentModifier_Grants_Projects_ForPerson
|
:vivodocumentModifier_Grants_Projects_ForPerson
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||||
|
|
|
@ -1,145 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding;
|
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.ALLTEXT;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.ALLTEXTUNSTEMMED;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.PREFERRED_TITLE;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.configuration.ContextModelsUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If there are any VCards on this Individual with Title objects, store the text
|
|
||||||
* in the Preferred Title search field, and the ALL_TEXT field.
|
|
||||||
*
|
|
||||||
* If there are any VCards on this Individual with EMail objects, store the text
|
|
||||||
* in the ALL_TEXT field.
|
|
||||||
*/
|
|
||||||
public class VIVOValuesFromVcards implements DocumentModifier, ContextModelsUser {
|
|
||||||
private static final Log log = LogFactory
|
|
||||||
.getLog(VIVOValuesFromVcards.class);
|
|
||||||
|
|
||||||
private static final String PREFERRED_TITLE_QUERY = ""
|
|
||||||
+ "prefix vcard: <http://www.w3.org/2006/vcard/ns#> \n"
|
|
||||||
+ "prefix obo: <http://purl.obolibrary.org/obo/> \n\n"
|
|
||||||
+ "SELECT ?title WHERE { \n" //
|
|
||||||
+ " ?uri obo:ARG_2000028 ?card . \n"
|
|
||||||
+ " ?card a vcard:Individual . \n"
|
|
||||||
+ " ?card vcard:hasTitle ?titleHolder . \n"
|
|
||||||
+ " ?titleHolder vcard:title ?title . \n" //
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
private static final ResultParser PREFERRED_TITLE_PARSER = new ResultParser() {
|
|
||||||
@Override
|
|
||||||
public void parse(String uri, QuerySolution solution, SearchInputDocument doc) {
|
|
||||||
String title = getLiteralValue(solution, "title");
|
|
||||||
if (StringUtils.isNotBlank(title)) {
|
|
||||||
doc.addField(PREFERRED_TITLE, title);
|
|
||||||
doc.addField(ALLTEXT, title);
|
|
||||||
doc.addField(ALLTEXTUNSTEMMED, title);
|
|
||||||
log.debug("Preferred Title for " + uri + ": '" + title + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final String EMAIL_QUERY = ""
|
|
||||||
+ "prefix vcard: <http://www.w3.org/2006/vcard/ns#> \n"
|
|
||||||
+ "prefix obo: <http://purl.obolibrary.org/obo/> \n\n"
|
|
||||||
+ "SELECT ?email WHERE { \n" //
|
|
||||||
+ " ?uri obo:ARG_2000028 ?card . \n"
|
|
||||||
+ " ?card a vcard:Individual . \n"
|
|
||||||
+ " ?card vcard:hasEmail ?emailHolder . \n"
|
|
||||||
+ " ?emailHolder vcard:email ?email . \n" //
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
private static final ResultParser EMAIL_PARSER = new ResultParser() {
|
|
||||||
@Override
|
|
||||||
public void parse(String uri, QuerySolution solution,
|
|
||||||
SearchInputDocument doc) {
|
|
||||||
String email = getLiteralValue(solution, "email");
|
|
||||||
if (StringUtils.isNotBlank(email)) {
|
|
||||||
doc.addField(ALLTEXT, email);
|
|
||||||
doc.addField(ALLTEXTUNSTEMMED, email);
|
|
||||||
log.debug("Email for " + uri + ": '" + email + "'");
|
|
||||||
}
|
|
||||||
}};
|
|
||||||
|
|
||||||
private RDFService rdfService;
|
|
||||||
private boolean shutdown = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContextModels(ContextModelAccess models) {
|
|
||||||
this.rdfService = models.getRDFService();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modifyDocument(Individual individual, SearchInputDocument doc) {
|
|
||||||
if (individual == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
processQuery(individual, PREFERRED_TITLE_QUERY, PREFERRED_TITLE_PARSER,
|
|
||||||
doc);
|
|
||||||
processQuery(individual, EMAIL_QUERY, EMAIL_PARSER, doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processQuery(Individual individual, String queryTemplate,
|
|
||||||
ResultParser resultParser, SearchInputDocument doc) {
|
|
||||||
String uri = "<" + individual.getURI() + "> ";
|
|
||||||
String query = queryTemplate.replaceAll("\\?uri", uri);
|
|
||||||
|
|
||||||
try {
|
|
||||||
ResultSet results = RDFServiceUtils.sparqlSelectQuery(query,
|
|
||||||
rdfService);
|
|
||||||
if (results != null) {
|
|
||||||
while (results.hasNext()) {
|
|
||||||
log.debug("Next solution");
|
|
||||||
QuerySolution solution = results.nextSolution();
|
|
||||||
resultParser.parse(uri, solution, doc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!shutdown) {
|
|
||||||
log.error("problem while running query '" + query + "'", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void shutdown() {
|
|
||||||
shutdown = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return this.getClass().getSimpleName() + "[]";
|
|
||||||
}
|
|
||||||
|
|
||||||
private abstract static class ResultParser {
|
|
||||||
public abstract void parse(String uri, QuerySolution solution, SearchInputDocument doc);
|
|
||||||
|
|
||||||
String getLiteralValue(QuerySolution solution, String name) {
|
|
||||||
RDFNode node = solution.get(name);
|
|
||||||
if ((node != null) && (node.isLiteral())) {
|
|
||||||
String value = node.asLiteral().getString();
|
|
||||||
if (StringUtils.isNotBlank(value)) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DocumentModifier for adding rdfs:labels of individuals related via
|
|
||||||
* a advising relationship.
|
|
||||||
*
|
|
||||||
* @author bdc34
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class VivoISFAdvisingFields extends ContextNodeFields {
|
|
||||||
|
|
||||||
private static String VIVONS = "http://vivoweb.org/ontology/core#";
|
|
||||||
|
|
||||||
protected static final String prefix =
|
|
||||||
" prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
|
||||||
+ " prefix core: <" + VIVONS + "> \n"
|
|
||||||
+ " prefix foaf: <http://xmlns.com/foaf/0.1/> \n"
|
|
||||||
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
|
||||||
+ " prefix obo: <http://purl.obolibrary.org/obo/> \n" ;
|
|
||||||
|
|
||||||
static List<String> queries = new ArrayList<String>();
|
|
||||||
static{
|
|
||||||
queries.add( makeQueryForPeople() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public VivoISFAdvisingFields(){
|
|
||||||
super(queries);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This query will get all the labels for the other
|
|
||||||
* person in the relationship.
|
|
||||||
*/
|
|
||||||
private static String makeQueryForPeople(){
|
|
||||||
return prefix +
|
|
||||||
"SELECT \n" +
|
|
||||||
"(str(?rawresult) as ?result) WHERE \n" +
|
|
||||||
"{\n" +
|
|
||||||
" ?uri core:relatedBy ?rel . \n" +
|
|
||||||
" ?rel rdf:type core:AdvisingRelationship . \n" +
|
|
||||||
" ?rel core:relates ?other . \n" +
|
|
||||||
" ?other rdfs:label ?rawresult . \n" +
|
|
||||||
" FILTER( ?other != ?uri ) \n" +
|
|
||||||
"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DocumentModifier to populate Search index fields for the basic ISF relationships.
|
|
||||||
*
|
|
||||||
* This will add the all rdfs:labels of the related individuals to the search document.
|
|
||||||
*
|
|
||||||
* @author bdc34
|
|
||||||
*/
|
|
||||||
public class VivoISFBasicFields extends ContextNodeFields {
|
|
||||||
|
|
||||||
private static String VIVONS = "http://vivoweb.org/ontology/core#";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtypes of vivo:Relationship that get handled by this class.
|
|
||||||
*/
|
|
||||||
private static String[] RELATIONSHIP_TYPES = {
|
|
||||||
VIVONS + "Position",
|
|
||||||
VIVONS + "Authorship",
|
|
||||||
VIVONS + "Collaboration",
|
|
||||||
VIVONS + "Affiliation"
|
|
||||||
};
|
|
||||||
|
|
||||||
static List<String> queries = new ArrayList<String>();
|
|
||||||
|
|
||||||
public VivoISFBasicFields(){
|
|
||||||
super(queries);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static final String prefix =
|
|
||||||
" prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
|
||||||
+ " prefix core: <" + VIVONS + "> \n"
|
|
||||||
+ " prefix foaf: <http://xmlns.com/foaf/0.1/> \n"
|
|
||||||
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
|
||||||
+ " prefix obo: <http://purl.obolibrary.org/obo/> \n" ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static {
|
|
||||||
|
|
||||||
/* make a string of the RELATIONSHIP_TYPES for use in
|
|
||||||
* a SPARQL IN clause */
|
|
||||||
String types = "";
|
|
||||||
for( int i = 0 ; i < RELATIONSHIP_TYPES.length ; i++ ){
|
|
||||||
types += "<" + RELATIONSHIP_TYPES[i] + ">";
|
|
||||||
if( i != RELATIONSHIP_TYPES.length - 1 ){
|
|
||||||
types += ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
queries.add(
|
|
||||||
prefix +
|
|
||||||
"SELECT \n" +
|
|
||||||
"(str(?rawresult) as ?result) WHERE \n" +
|
|
||||||
"{\n" +
|
|
||||||
" ?uri core:relatedBy ?rel . \n" +
|
|
||||||
" ?rel rdf:type ?type . \n" +
|
|
||||||
" ?rel core:relates ?other . \n" +
|
|
||||||
" ?other rdfs:label ?rawresult . \n" +
|
|
||||||
" FILTER ( ?type IN ( " + types + " ) )\n" +
|
|
||||||
"}" );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class VivoISFEducationFields extends ContextNodeFields {
|
|
||||||
private static String VIVONS = "http://vivoweb.org/ontology/core#";
|
|
||||||
|
|
||||||
protected static final String prefix =
|
|
||||||
" prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
|
||||||
+ " prefix core: <" + VIVONS + "> \n"
|
|
||||||
+ " prefix foaf: <http://xmlns.com/foaf/0.1/> \n"
|
|
||||||
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
|
||||||
+ " prefix obo: <http://purl.obolibrary.org/obo/> \n" ;
|
|
||||||
|
|
||||||
public VivoISFEducationFields(){
|
|
||||||
super(queries);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This query will get all the labels for the degree.
|
|
||||||
*/
|
|
||||||
private static String queryForDegree =
|
|
||||||
prefix +
|
|
||||||
"SELECT \n" +
|
|
||||||
"(str(?rawresult) as ?result) WHERE \n" +
|
|
||||||
"{\n" +
|
|
||||||
" ?uri core:relates ?deg . \n" +
|
|
||||||
" ?deg rdf:type core:AwardedDegree . \n" +
|
|
||||||
" ?deg rdfs:label ?rawresult . \n" +
|
|
||||||
"}";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This will get all labels for the organization.
|
|
||||||
*/
|
|
||||||
private static String queryForOrganization =
|
|
||||||
prefix +
|
|
||||||
"SELECT \n" +
|
|
||||||
"(str(?rawresult) as ?result) WHERE \n" +
|
|
||||||
"{\n" +
|
|
||||||
" ?uri core:relates ?deg . \n" +
|
|
||||||
" ?deg rdf:type core:AwardedDegree . \n" +
|
|
||||||
" ?deg core:assignedBy ?org . \n" +
|
|
||||||
" ?org rdfs:label ?rawresult . \n" +
|
|
||||||
"}";
|
|
||||||
|
|
||||||
static List<String> queries = new ArrayList<String>();
|
|
||||||
|
|
||||||
static{
|
|
||||||
queries.add( queryForDegree );
|
|
||||||
queries.add( queryForOrganization );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class will:
|
|
||||||
* add people's names to organization's search Documents.
|
|
||||||
* add organization names to people's search Documents.
|
|
||||||
*
|
|
||||||
* @author bdc34
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class VivoISFMemberFields extends ContextNodeFields {
|
|
||||||
private static String VIVONS = "http://vivoweb.org/ontology/core#";
|
|
||||||
|
|
||||||
protected static final String prefix =
|
|
||||||
" prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
|
||||||
+ " prefix core: <" + VIVONS + "> \n"
|
|
||||||
+ " prefix foaf: <http://xmlns.com/foaf/0.1/> \n"
|
|
||||||
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
|
||||||
+ " prefix obo: <http://purl.obolibrary.org/obo/> \n" ;
|
|
||||||
|
|
||||||
public VivoISFMemberFields(){
|
|
||||||
super(queries);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add people's names to organization's search Documents.
|
|
||||||
*/
|
|
||||||
private static String peopleForOrganization =
|
|
||||||
prefix +
|
|
||||||
"SELECT (str(?rawresult) as ?result) WHERE {\n" +
|
|
||||||
" ?uri rdf:type foaf:Organization . \n" +
|
|
||||||
" ?role core:roleContributesTo ?uri . \n" +
|
|
||||||
" ?person obo:RO_0000053 ?role . \n" +
|
|
||||||
" ?person rdfs:label ?rawresult .\n" +
|
|
||||||
"}";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add organization names to people's search Documents.
|
|
||||||
*/
|
|
||||||
private static String organizationForPeople =
|
|
||||||
prefix +
|
|
||||||
"SELECT (str(?rawresult) as ?result) WHERE {\n" +
|
|
||||||
" ?uri rdf:type foaf:Person . \n" +
|
|
||||||
" ?uri obo:RO_0000053 / core:roleContributesTo / rdfs:label ?rawresult . \n" +
|
|
||||||
"}";
|
|
||||||
|
|
||||||
|
|
||||||
static List<String> queries = new ArrayList<String>();
|
|
||||||
|
|
||||||
static{
|
|
||||||
queries.add( peopleForOrganization );
|
|
||||||
queries.add( organizationForPeople );
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue