VIVO-870 Start moving DocumentModifiers into the configuration.
Create the SimpleSparqlQueryDocumentModifier. Use it to replace VivoISFGrantFields and VivoInformationResourceContextNodeFields.
This commit is contained in:
parent
86f9714fb6
commit
2d2c5032cc
5 changed files with 182 additions and 352 deletions
|
@ -1,4 +1,6 @@
|
|||
@prefix : <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
|
||||
|
||||
#
|
||||
# Specify the SearchIndexExcluders, DocumentModifiers and IndexingUriFinders for VIVO.
|
||||
|
@ -13,6 +15,16 @@
|
|||
|
||||
# ------------------------------------
|
||||
|
||||
:uriFinder_forContextNodes
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.AdditionalURIsForContextNodes> .
|
||||
|
||||
:uriFinder_forVCards
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.AdditionalUrisForVCards> .
|
||||
|
||||
# ------------------------------------
|
||||
|
||||
:vivodocumentModifier_calculateParameters
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.CalculateParameters> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||
|
@ -33,24 +45,180 @@
|
|||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFEducationFields> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||
|
||||
:vivodocumentModifier_ISFGrantFields
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFGrantFields> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||
|
||||
:vivodocumentModifier_ISFMemberFields
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFMemberFields> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||
|
||||
:vivodocumentModifier_informationResourceContextNodeFields
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoInformationResourceContextNodeFields> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||
:vivodocumentModifier_Grants_Projects_ForPerson
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||
rdfs:label "Grants and projects for person" ;
|
||||
:hasTypeRestriction "http://xmlns.com/foaf/0.1/Person" ;
|
||||
: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#>
|
||||
SELECT (str(?rawresult) as ?result)
|
||||
WHERE {
|
||||
?grant core:relates ?uri .
|
||||
?grant rdf:type core:Grant .
|
||||
?grant 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 obo:RO_0000053 ?role .
|
||||
?role obo:BFO_0000054 ?project .
|
||||
?project rdf:type core:Project .
|
||||
?project rdfs:label ?rawresult .
|
||||
}
|
||||
""" .
|
||||
|
||||
:vivodocumentModifier_People_Organizations_Projects_ForGrant
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||
rdfs:label "People, organizations, and projects for grant" ;
|
||||
:hasTypeRestriction "http://vivoweb.org/ontology/core#Grant" ;
|
||||
: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#>
|
||||
SELECT (str(?rawresult) as ?result)
|
||||
WHERE {
|
||||
?uri core:relates ?person .
|
||||
?person rdf:type foaf:Person .
|
||||
?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#>
|
||||
SELECT (str(?rawresult) as ?result) WHERE {
|
||||
?uri core:relates ?org .
|
||||
?org rdf:type foaf:Organization .
|
||||
?org 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#>
|
||||
PREFIX obo: <http://purl.obolibrary.org/obo/>
|
||||
SELECT (str(?rawresult) as ?result) WHERE {
|
||||
?uri core:relates ?role .
|
||||
?role obo:BFO_0000054 ?project .
|
||||
?project rdf:type core:Project .
|
||||
?project rdfs:label ?rawresult .
|
||||
}
|
||||
""" .
|
||||
|
||||
# ------------------------------------
|
||||
:vivodocumentModifier_Grants_People_ForProject
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||
rdfs:label "Grants and people for project" ;
|
||||
:hasTypeRestriction "http://vivoweb.org/ontology/core#Project" ;
|
||||
: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 {
|
||||
?role obo:BFO_0000054 ?uri .
|
||||
?grant core:relates ?role .
|
||||
?grant rdf:type core:Grant .
|
||||
?grant rdfs:label ?rawresult .
|
||||
}
|
||||
""" ;
|
||||
:hasSparqlQuery """
|
||||
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||
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 {
|
||||
?role obo:BFO_0000054 ?uri .
|
||||
?role obo:RO_0000053 ?person .
|
||||
?person rdf:type foaf:Person .
|
||||
?person rdfs:label ?rawresult .
|
||||
}
|
||||
""" .
|
||||
|
||||
:uriFinder_forContextNodes
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.AdditionalURIsForContextNodes> .
|
||||
:vivodocumentModifier_GrantsForOrganization
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||
rdfs:label "Grants for organization" ;
|
||||
:hasTypeRestriction "http://xmlns.com/foaf/0.1/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 {
|
||||
?grant core:relates ?uri .
|
||||
?grant rdf:type core:Grant .
|
||||
?grant rdfs:label ?rawresult .
|
||||
}
|
||||
""" .
|
||||
|
||||
:uriFinder_forVCards
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.AdditionalUrisForVCards> .
|
||||
:vivodocumentModifier_InformationResources
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||
rdfs:label "Authors, featured, editors, and subject area for InformationResource" ;
|
||||
:hasTypeRestriction "http://purl.obolibrary.org/IAO_0000030" ;
|
||||
: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#>
|
||||
SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {
|
||||
?uri core:relatedBy ?a .
|
||||
?a rdf:type core:Authorship .
|
||||
?a core:relates ?b .
|
||||
?b rdf:type foaf:Agent .
|
||||
?b rdfs:label ?ContextNodeProperty .
|
||||
}
|
||||
""" ;
|
||||
:hasSparqlQuery """
|
||||
PREFIX core: <http://vivoweb.org/ontology/core#>
|
||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||
SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {
|
||||
?uri core:features ?i .
|
||||
?i rdfs:label ?ContextNodeProperty .
|
||||
}
|
||||
""" ;
|
||||
: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#>
|
||||
SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {
|
||||
?uri core:relatedBy ?e .
|
||||
?e rdf:type core:Editorship .
|
||||
?e core:relates ?i .
|
||||
?i rdf:type foaf:Agent .
|
||||
?i rdfs:label ?ContextNodeProperty .
|
||||
}
|
||||
""" ;
|
||||
:hasSparqlQuery """
|
||||
PREFIX owl: <http://www.w3.org/2002/07/owl#>
|
||||
PREFIX vitroDisplay: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#>
|
||||
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 obo: <http://purl.obolibrary.org/>
|
||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||
PREFIX localNav: <http://vitro.mannlib.cornell.edu/ns/localnav#>
|
||||
PREFIX bibo: <http://purl.org/ontology/bibo/>
|
||||
SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {
|
||||
?uri core:hasSubjectArea ?f .
|
||||
?f rdfs:label ?ContextNodeProperty .
|
||||
}
|
||||
""" .
|
||||
|
|
|
@ -1,158 +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 DocumentModifier is for the ISF style grants.
|
||||
* It will
|
||||
* add people's names to the grant's search Document
|
||||
* add the grant's name to the people's search Document
|
||||
* add the grant's name to the Organization's search Document
|
||||
* add the organization's name to the grant's search Document
|
||||
* add the grant's names to the project's search Document
|
||||
* add the people's names to the project's search Document
|
||||
* add the project's name to the grant's search Document
|
||||
* add the project's name to the people's search Document
|
||||
*/
|
||||
public class VivoISFGrantFields 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 VivoISFGrantFields(){
|
||||
super(queries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query to add people's names to the grant's search Document.
|
||||
* ?uri is the URI of a grant.
|
||||
*/
|
||||
private static String peopleForGrant =
|
||||
prefix +
|
||||
"SELECT (str(?rawresult) as ?result) WHERE {\n" +
|
||||
" ?uri rdf:type core:Grant . \n" +
|
||||
" ?uri core:relates ?person . \n" +
|
||||
" ?person rdf:type foaf:Person . \n" +
|
||||
" ?person rdfs:label ?rawresult . \n" +
|
||||
"}";
|
||||
|
||||
/**
|
||||
* Query to add the grant's name to the people's search Document.
|
||||
* ?uri is the URI of a person.
|
||||
*/
|
||||
private static String grantsForPerson =
|
||||
prefix +
|
||||
"SELECT \n" +
|
||||
"(str(?rawresult) as ?result) WHERE \n" +
|
||||
"{\n" +
|
||||
" ?uri rdf:type foaf:Person . \n" +
|
||||
" ?grant core:relates ?uri . \n" +
|
||||
" ?grant rdf:type core:Grant . \n" +
|
||||
" ?grant rdfs:label ?rawresult . \n" +
|
||||
"}";
|
||||
|
||||
/**
|
||||
* Query to add the grant's name to the Organization's search Document.
|
||||
* ?uri is the URI of an Organization.
|
||||
*/
|
||||
private static String grantsForOrganization =
|
||||
prefix +
|
||||
"SELECT (str(?rawresult) as ?result) WHERE {\n" +
|
||||
" ?uri rdf:type foaf:Organization . \n" +
|
||||
" ?grant core:relates ?uri . \n" +
|
||||
" ?grant rdf:type core:Grant . \n" +
|
||||
" ?grant rdfs:label ?rawresult . \n" +
|
||||
"}";
|
||||
|
||||
/**
|
||||
* Query to add the organization's name to the grant's search Document.
|
||||
* ?uri is the URI of a grant.
|
||||
*/
|
||||
private static String organizationsForGrant =
|
||||
prefix +
|
||||
"SELECT (str(?rawresult) as ?result) WHERE {\n" +
|
||||
" ?uri rdf:type core:Grant . \n" +
|
||||
" ?uri core:relates ?org . \n" +
|
||||
" ?org rdf:type foaf:Organization . \n" +
|
||||
" ?org rdfs:label ?rawresult . \n" +
|
||||
"}";
|
||||
|
||||
/**
|
||||
* Query to add the grant's names to the project's search Document.
|
||||
* ?uir is the URI of a Project.
|
||||
*/
|
||||
private static String grantsForProject =
|
||||
prefix +
|
||||
"SELECT (str(?rawresult) as ?result) WHERE {\n" +
|
||||
" ?uri rdf:type core:Project . \n" +
|
||||
" ?role obo:BFO_0000054 ?uri . \n" +
|
||||
" ?grant core:relates ?role . \n" +
|
||||
" ?grant rdf:type core:Grant . \n" +
|
||||
" ?grant rdfs:label ?rawresult . \n" +
|
||||
"}";
|
||||
|
||||
/**
|
||||
* Query to add the people's names to the project's search Document.
|
||||
* ?uri is the URI of a Project.
|
||||
*/
|
||||
private static String peopleForProject =
|
||||
prefix +
|
||||
"SELECT (str(?rawresult) as ?result) WHERE {\n" +
|
||||
" ?uri rdf:type core:Project . \n" +
|
||||
" ?role obo:BFO_0000054 ?uri . \n" +
|
||||
" ?role obo:RO_0000053 ?person . \n" +
|
||||
" ?person rdf:type foaf:Person . \n" +
|
||||
" ?person rdfs:label ?rawresult . \n" +
|
||||
"}";
|
||||
|
||||
/**
|
||||
* Query to add the project's name to the grant's search Document.
|
||||
* ?uri is the URI of a grant.
|
||||
*/
|
||||
private static String projectsForGrant =
|
||||
prefix +
|
||||
"SELECT \n" +
|
||||
"(str(?rawresult) as ?result) WHERE \n" +
|
||||
"{\n" +
|
||||
" ?uri rdf:type core:Grant. \n" +
|
||||
" ?uri core:relates ?role . \n" +
|
||||
" ?role obo:BFO_0000054 ?project . \n" +
|
||||
" ?project rdf:type core:Project . \n" +
|
||||
" ?project rdfs:label ?rawresult . \n" +
|
||||
"}";
|
||||
|
||||
/**
|
||||
* Query to add the project's name to the people's search Document.
|
||||
* ?uri is the URI of a person.
|
||||
*/
|
||||
private static String projectsForPerson =
|
||||
prefix +
|
||||
"SELECT (str(?rawresult) as ?result) WHERE {\n" +
|
||||
" ?uri rdf:type foaf:Person . \n" +
|
||||
" ?uri obo:RO_0000053 ?role . \n" +
|
||||
" ?role obo:BFO_0000054 ?project . \n" +
|
||||
" ?project rdf:type core:Project . \n" +
|
||||
" ?project rdfs:label ?rawresult . \n" +
|
||||
"}";
|
||||
|
||||
static List<String> queries = new ArrayList<String>();
|
||||
|
||||
static{
|
||||
queries.add( peopleForGrant );
|
||||
queries.add( grantsForPerson );
|
||||
queries.add( grantsForOrganization );
|
||||
queries.add( organizationsForGrant );
|
||||
queries.add( grantsForProject );
|
||||
queries.add( peopleForProject );
|
||||
queries.add( projectsForGrant );
|
||||
queries.add( projectsForPerson );
|
||||
}
|
||||
}
|
|
@ -1,82 +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;
|
||||
|
||||
/**
|
||||
* Class that adds text from context nodes to search index Documents for
|
||||
* obo:IAO_0000030 individuals.
|
||||
*
|
||||
* @author bdc34
|
||||
*
|
||||
*/
|
||||
public class VivoInformationResourceContextNodeFields extends ContextNodeFields{
|
||||
|
||||
static List<String> queriesForInformationResource = new ArrayList<String>();
|
||||
|
||||
public VivoInformationResourceContextNodeFields(){
|
||||
super(queriesForInformationResource);
|
||||
}
|
||||
|
||||
protected static final String prefix =
|
||||
"prefix owl: <http://www.w3.org/2002/07/owl#> "
|
||||
+ " prefix vitroDisplay: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> "
|
||||
+ " 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 obo: <http://purl.obolibrary.org/> "
|
||||
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
|
||||
+ " prefix localNav: <http://vitro.mannlib.cornell.edu/ns/localnav#> "
|
||||
+ " prefix bibo: <http://purl.org/ontology/bibo/> ";
|
||||
|
||||
|
||||
//queries for obo:IAO_0000030
|
||||
static {
|
||||
|
||||
/* linked author labels */
|
||||
|
||||
queriesForInformationResource
|
||||
.add(prefix
|
||||
+ "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {"
|
||||
+ "?uri rdf:type obo:IAO_0000030 . "
|
||||
+ "?uri core:relatedBy ?a . "
|
||||
+ "?a rdf:type core:Authorship ."
|
||||
+ "?a core:relates ?b ."
|
||||
+ "?b rdf:type foaf:Agent ."
|
||||
+ "?b rdfs:label ?ContextNodeProperty .}");
|
||||
|
||||
/* features */
|
||||
|
||||
queriesForInformationResource
|
||||
.add(prefix
|
||||
+ "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {"
|
||||
+ "?uri rdf:type obo:IAO_0000030 . "
|
||||
+ "?uri core:features ?i . ?i rdfs:label ?ContextNodeProperty ."
|
||||
+ "}");
|
||||
|
||||
/* editor */
|
||||
|
||||
queriesForInformationResource
|
||||
.add(prefix
|
||||
+ "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {"
|
||||
+ "?uri rdf:type obo:IAO_0000030 . "
|
||||
+ "?uri core:relatedBy ?e . "
|
||||
+ "?e rdf:type core:Editorship ."
|
||||
+ "?e core:relates ?i ."
|
||||
+ "?i rdf:type foaf:Agent ."
|
||||
+ "?i rdfs:label ?ContextNodeProperty ."
|
||||
+ "}");
|
||||
|
||||
/* subject area */
|
||||
|
||||
queriesForInformationResource
|
||||
.add(prefix
|
||||
+ "SELECT (str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {"
|
||||
+ "?uri rdf:type obo:IAO_0000030 . "
|
||||
+ "?uri core:hasSubjectArea ?f . ?f rdfs:label ?ContextNodeProperty ."
|
||||
+ "}");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,79 +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.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccessStub;
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.modules.ApplicationStub;
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineStub;
|
||||
import stubs.javax.servlet.ServletContextStub;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
||||
|
||||
public class VivoInformationResourceContextNodeFieldsTest extends AbstractTestClass {
|
||||
|
||||
String TEST_NO_LABLE_N3_FILE = "VivoInformationResourceContextNodeFieldsTest.n3";
|
||||
String RDFS_LABEL_VALUE = "Test Document X";
|
||||
String DOCUMENT_URI = "http://example.com/vivo/individual/n7474";
|
||||
|
||||
@Test
|
||||
public void testNoLabel() throws IOException{
|
||||
ApplicationStub.setup(new ServletContextStub(), new SearchEngineStub());
|
||||
|
||||
//Test that rdfs:label is NOT added by the VivoInformationResourceContextNodeFields
|
||||
|
||||
//setup a model & wdf with test RDF file
|
||||
InputStream stream = VivoInformationResourceContextNodeFieldsTest.class.getResourceAsStream(TEST_NO_LABLE_N3_FILE);
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
model.read(stream, null, "N3");
|
||||
stream.close();
|
||||
|
||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM,model);
|
||||
ontModel.prepare();
|
||||
Assert.assertTrue("ontModel had no statements" , ontModel.size() > 0 );
|
||||
|
||||
WebappDaoFactory wadf = new WebappDaoFactoryJena(ontModel);
|
||||
Individual ind = wadf.getIndividualDao().getIndividualByURI(DOCUMENT_URI);
|
||||
Assert.assertNotNull(ind);
|
||||
|
||||
ContextModelAccessStub contextModels = new ContextModelAccessStub();
|
||||
contextModels.setRDFService(WhichService.CONTENT, new RDFServiceModel(ontModel));
|
||||
|
||||
SearchInputDocument doc = ApplicationUtils.instance().getSearchEngine().createInputDocument();
|
||||
doc.addField("ALLTEXT", "");
|
||||
|
||||
VivoInformationResourceContextNodeFields vircnf = new VivoInformationResourceContextNodeFields();
|
||||
vircnf.setContextModels(contextModels);
|
||||
vircnf.modifyDocument(ind, doc);
|
||||
|
||||
Collection<Object> values = doc.getField("ALLTEXT").getValues();
|
||||
for( Object value : values){
|
||||
Assert.assertFalse("rdf:label erroneously added by document modifier:", value.toString().contains(RDFS_LABEL_VALUE));
|
||||
}
|
||||
|
||||
VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields();
|
||||
vacnf.setContextModels(contextModels);
|
||||
vacnf.modifyDocument(ind, doc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
@prefix dc: <http://purl.org/dc/elements/1.1/> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
@prefix vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> .
|
||||
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
||||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
||||
|
||||
<http://example.com/vivo/individual/n7474>
|
||||
a <http://purl.org/ontology/bibo/Document> , owl:Thing , <http://purl.org/ontology/bibo/AudioDocument> , <http://vivoweb.org/ontology/core#InformationResource> ;
|
||||
rdfs:label "Test Document X"@en-US ;
|
||||
<http://purl.org/dc/terms/creator>
|
||||
<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n4782> ;
|
||||
<http://purl.org/dc/terms/title>
|
||||
"Test Document X"@en-US ;
|
||||
vitro:modTime "2011-11-01T11:11:49"^^xsd:dateTime ;
|
||||
vitro:mostSpecificType
|
||||
<http://purl.org/ontology/bibo/AudioDocument> ;
|
||||
<http://vivoweb.org/ontology/core#informationResourceInAuthorship>
|
||||
<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n7484> .
|
Loading…
Add table
Add a link
Reference in a new issue