VIVO-870 Move VivoAgentContextNodeFields into the configuration.
Delete VivoAgentContextNodeFields and its tests and the data files for the tests.
This commit is contained in:
parent
4eeb0f5c09
commit
c85aed6943
8 changed files with 209 additions and 48915 deletions
|
@ -85,6 +85,215 @@
|
|||
}
|
||||
""" .
|
||||
|
||||
:vivodocumentModifier_AgentContextNodeFields
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||
rdfs:label "Add many fields to agents." ;
|
||||
:hasTypeRestriction "http://xmlns.com/foaf/0.1/foaf:Agent" ;
|
||||
: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/>
|
||||
SELECT (str(?ContextNodeProperty) as ?contextNodeProperty)
|
||||
WHERE {
|
||||
?uri ?b ?c .
|
||||
?c rdf:type core:Position .
|
||||
?c core:hrJobTitle ?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 ?b ?c .
|
||||
?c rdf:type core:Position .
|
||||
?c core:relates ?i .
|
||||
?i rdf:type foaf:Organization .
|
||||
?i rdfs:label ?ContextNodeProperty .
|
||||
}
|
||||
""" ;
|
||||
:hasSparqlQuery """
|
||||
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||
PREFIX core: <http://vivoweb.org/ontology/core#>
|
||||
SELECT (str(?ContextNodeProperty) as ?contextNodeProperty)
|
||||
WHERE {
|
||||
?uri ?b ?c .
|
||||
?c rdf:type core:Position .
|
||||
?c core:titleOrRole ?ContextNodeProperty .
|
||||
}
|
||||
""" ;
|
||||
: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(?HRJobTitle) as ?hrJobTitle)
|
||||
(str(?PositionInOrganization) as ?positionInOrganization)
|
||||
(str(?TitleOrRole) as ?titleOrRole)
|
||||
WHERE {
|
||||
?uri ?b ?c .
|
||||
?c rdf:type core:Position .
|
||||
OPTIONAL { ?c core:hrJobTitle ?HRJobTitle . } .
|
||||
OPTIONAL { ?c core:relates ?i .
|
||||
?i rdf:type foaf:Organization .
|
||||
?i rdfs:label ?PositionInOrganization . } .
|
||||
OPTIONAL { ?c core:titleOrRole ?TitleOrRole . } .
|
||||
}
|
||||
""" ;
|
||||
: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(?ContextNodeProperty) as ?contextNodeProperty)
|
||||
WHERE {
|
||||
?uri ?b ?c .
|
||||
?c rdf:type core:AdvisingRelationship .
|
||||
?c rdfs:label ?ContextNodeProperty .
|
||||
}
|
||||
""" ;
|
||||
: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(?ContextNodeProperty) as ?contextNodeProperty)
|
||||
WHERE {
|
||||
?uri ?b ?c .
|
||||
?c rdf:type core:AdvisingRelationship .
|
||||
?c core:degreeCandidacy ?e .
|
||||
?e 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#>
|
||||
PREFIX obo: <http://purl.obolibrary.org/obo/>
|
||||
SELECT (str(?label) as ?adviseeLabel)
|
||||
WHERE {
|
||||
?c rdf:type core:AdvisingRelationship .
|
||||
?c core:relates ?uri .
|
||||
?uri obo:RO_0000053 ?advisorRole .
|
||||
?advisorRole rdf:type core:AdvisorRole .
|
||||
?c core:relates ?d .
|
||||
?d rdf:type foaf:Person .
|
||||
?d obo:RO_0000053 ?adviseeRole .
|
||||
?adviseeRole rdf:type core:AdviseeRole .
|
||||
?d rdfs:label ?label .
|
||||
}
|
||||
""" ;
|
||||
: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(?label) as ?advisorLabel)
|
||||
WHERE {
|
||||
?c rdf:type core:AdvisingRelationship .
|
||||
?c core:relates ?uri .
|
||||
?uri obo:RO_0000053 ?adviseeRole .
|
||||
?adviseeRole rdf:type core:AdviseeRole .
|
||||
?c core:relates ?d .
|
||||
?d rdf:type foaf:Person .
|
||||
?d obo:RO_0000053 ?advisorRole .
|
||||
?advisorRole rdf:type core:AdvisorRole .
|
||||
?d 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#>
|
||||
PREFIX obo: <http://purl.obolibrary.org/obo/>
|
||||
SELECT (str(?ContextNodeProperty) as ?contextNodeProperty)
|
||||
WHERE {
|
||||
?uri ?b ?c .
|
||||
?c rdf:type core:Authorship .
|
||||
?c core:relates ?f .
|
||||
?f rdf:type foaf:Person .
|
||||
?f rdfs:label ?ContextNodeProperty .
|
||||
FILTER( ?f != ?uri )
|
||||
}
|
||||
""" ;
|
||||
: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(?ContextNodeProperty) as ?contextNodeProperty)
|
||||
WHERE {
|
||||
?uri ?b ?c .
|
||||
?c rdf:type core:Authorship .
|
||||
?c core:relates ?h .
|
||||
?h rdf:type obo:IAO_0000030 .
|
||||
?h 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#>
|
||||
PREFIX obo: <http://purl.obolibrary.org/obo/>
|
||||
SELECT (str(?AwardLabel) as ?awardLabel)
|
||||
(str(?AwardConferredBy) as ?awardConferredBy)
|
||||
(str(?Description) as ?description)
|
||||
WHERE {
|
||||
?uri ?b ?c .
|
||||
?c rdf:type core:AwardReceipt .
|
||||
OPTIONAL { ?c core:relates ?e . ?e rdf:type core:Award . ?e rdfs:label ?AwardLabel . } .
|
||||
OPTIONAL { ?c core:assignedBy ?d . ?d rdf:type foaf:Organization . ?d rdfs:label ?AwardConferredBy . } .
|
||||
OPTIONAL { ?c core:description ?Description . } .
|
||||
}
|
||||
""" ;
|
||||
: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(?OrganizationLabel) as ?organizationLabel)
|
||||
WHERE {
|
||||
?uri ?b ?c .
|
||||
?c rdf:type obo:BFO_0000023 ;
|
||||
core:roleContributesTo ?Organization .
|
||||
?Organization rdf:type core:Organization .
|
||||
?Organization rdfs:label ?OrganizationLabel .
|
||||
}
|
||||
""" ;
|
||||
: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(?AcademicDegreeLabel) as ?academicDegreeLabel)
|
||||
(str(?AcademicDegreeAbbreviation) as ?academicDegreeAbbreviation)
|
||||
(str(?MajorField) as ?majorField)
|
||||
(str(?DepartmentOrSchool) as ?departmentOrSchool)
|
||||
(str(?TrainingAtOrganizationLabel) as ?trainingAtOrganizationLabel)
|
||||
WHERE {
|
||||
?uri ?b ?c .
|
||||
?c rdf:type core:EducationalProcess .
|
||||
OPTIONAL { ?c core:relates ?d .
|
||||
?d rdf:type core:AwardedDegree .
|
||||
?d core:relates ?e .
|
||||
?e rdf:type core:AcademicDegree .
|
||||
?e rdfs:label ?AcademicDegreeLabel . } .
|
||||
OPTIONAL { ?c core:majorField ?MajorField .} .
|
||||
OPTIONAL { ?c core:departmentOrSchool ?DepartmentOrSchool . }
|
||||
OPTIONAL { ?c obo:RO_0000057 ?f .
|
||||
?f rdf:type foaf:organization .
|
||||
?f rdfs:label ?TrainingAtOrganizationLabel . } .
|
||||
}
|
||||
""" .
|
||||
|
||||
|
||||
:vivodocumentModifier_MembershipFields
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.SimpleSparqlQueryDocumentModifier> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||
|
|
|
@ -1,183 +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 Documents for
|
||||
* foaf:Agent individuals.
|
||||
*/
|
||||
public class VivoAgentContextNodeFields extends ContextNodeFields{
|
||||
|
||||
static List<String> queriesForAgent = new ArrayList<String>();
|
||||
|
||||
public VivoAgentContextNodeFields(){
|
||||
super(queriesForAgent);
|
||||
}
|
||||
|
||||
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 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/> "
|
||||
+ " prefix obo: <http://purl.obolibrary.org/obo/> \n" ;
|
||||
|
||||
|
||||
//queries for foaf:Agent
|
||||
static {
|
||||
|
||||
/* Positions for People */
|
||||
queriesForAgent.add(prefix +
|
||||
"SELECT " +
|
||||
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
|
||||
" ?uri rdf:type foaf:Agent . " +
|
||||
" ?uri ?b ?c . " +
|
||||
" ?c rdf:type core:Position . " +
|
||||
" ?c core:hrJobTitle ?ContextNodeProperty . }");
|
||||
|
||||
queriesForAgent.add(prefix + "SELECT " +
|
||||
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
|
||||
" ?uri rdf:type foaf:Agent . " +
|
||||
" ?uri ?b ?c . " +
|
||||
" ?c rdf:type core:Position . " +
|
||||
" ?c core:relates ?i . " +
|
||||
" ?i rdf:type foaf:Organization . " +
|
||||
" ?i rdfs:label ?ContextNodeProperty . }");
|
||||
|
||||
queriesForAgent.add(prefix + "SELECT " +
|
||||
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
|
||||
" ?uri rdf:type foaf:Agent . " +
|
||||
" ?uri ?b ?c . " +
|
||||
" ?c rdf:type core:Position . " +
|
||||
" ?c core:titleOrRole ?ContextNodeProperty . }");
|
||||
|
||||
/* HR Job Title */
|
||||
|
||||
queriesForAgent.add(prefix +
|
||||
"SELECT " +
|
||||
"(str(?HRJobTitle) as ?hrJobTitle) " +
|
||||
"(str(?PositionInOrganization) as ?positionInOrganization) " +
|
||||
"(str(?TitleOrRole) as ?titleOrRole) WHERE {"
|
||||
|
||||
+ "?uri rdf:type foaf:Agent ; ?b ?c . "
|
||||
+ " ?c rdf:type core:Position . "
|
||||
|
||||
+ " OPTIONAL { ?c core:hrJobTitle ?HRJobTitle . } . "
|
||||
+ " OPTIONAL { ?c core:relates ?i . ?i rdf:type foaf:Organization . ?i rdfs:label ?PositionInOrganization . } . "
|
||||
+ " OPTIONAL { ?c core:titleOrRole ?TitleOrRole . } . "
|
||||
+ " }");
|
||||
|
||||
/* Advisor */
|
||||
|
||||
queriesForAgent.add(prefix + "SELECT " +
|
||||
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
|
||||
" ?uri rdf:type foaf:Agent ; ?b ?c . " +
|
||||
" ?c rdf:type core:AdvisingRelationship . " +
|
||||
" ?c rdfs:label ?ContextNodeProperty . }");
|
||||
|
||||
queriesForAgent.add(prefix + "SELECT " +
|
||||
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
|
||||
" ?uri rdf:type foaf:Agent ; ?b ?c . " +
|
||||
" ?c rdf:type core:AdvisingRelationship . " +
|
||||
" ?c core:degreeCandidacy ?e . ?e rdfs:label ?ContextNodeProperty . }");
|
||||
|
||||
queriesForAgent.add(prefix + "SELECT " +
|
||||
"(str(?label) as ?adviseeLabel) WHERE {" +
|
||||
" ?uri rdf:type foaf:Agent ." +
|
||||
" ?c rdf:type core:AdvisingRelationship . " +
|
||||
" ?c core:relates ?uri . " +
|
||||
" ?uri obo:RO_0000053 ?advisorRole . " +
|
||||
" ?advisorRole rdf:type core:AdvisorRole . " +
|
||||
" ?c core:relates ?d . " +
|
||||
" ?d rdf:type foaf:Person . " +
|
||||
" ?d obo:RO_0000053 ?adviseeRole . " +
|
||||
" ?adviseeRole rdf:type core:AdviseeRole . " +
|
||||
" ?d rdfs:label ?ContextNodeProperty . }");
|
||||
|
||||
queriesForAgent.add(prefix + "SELECT " +
|
||||
"(str(?label) as ?advisorLabel) WHERE {" +
|
||||
" ?uri rdf:type foaf:Agent ." +
|
||||
" ?c rdf:type core:AdvisingRelationship . " +
|
||||
" ?c core:relates ?uri . " +
|
||||
" ?uri obo:RO_0000053 ?adviseeRole . " +
|
||||
" ?adviseeRole rdf:type core:AdviseeRole . " +
|
||||
" ?c core:relates ?d . " +
|
||||
" ?d rdf:type foaf:Person . " +
|
||||
" ?d obo:RO_0000053 ?advisorRole . " +
|
||||
" ?advisorRole rdf:type core:AdvisorRole . " +
|
||||
" ?d rdfs:label ?ContextNodeProperty . }");
|
||||
|
||||
/* Author */
|
||||
|
||||
queriesForAgent.add(prefix + "SELECT " +
|
||||
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
|
||||
" ?uri rdf:type foaf:Agent ; ?b ?c . " +
|
||||
" ?c rdf:type core:Authorship . " +
|
||||
" ?c core:relates ?f . " +
|
||||
" ?f rdf:type foaf:Person . " +
|
||||
" ?f rdfs:label ?ContextNodeProperty . " +
|
||||
" FILTER( ?f != ?uri ) " +
|
||||
"}");
|
||||
|
||||
queriesForAgent.add(prefix + "SELECT " +
|
||||
"(str(?ContextNodeProperty) as ?contextNodeProperty) WHERE {" +
|
||||
" ?uri rdf:type foaf:Agent ; ?b ?c . " +
|
||||
" ?c rdf:type core:Authorship . " +
|
||||
" ?c core:relates ?h . " +
|
||||
" ?h rdf:type obo:IAO_0000030 . ?h rdfs:label ?ContextNodeProperty . }");
|
||||
|
||||
/* Award */
|
||||
|
||||
queriesForAgent.add(prefix +
|
||||
"SELECT " +
|
||||
"(str(?AwardLabel) as ?awardLabel) " +
|
||||
"(str(?AwardConferredBy) as ?awardConferredBy) " +
|
||||
"(str(?Description) as ?description) " +
|
||||
"WHERE {"
|
||||
+ " ?uri rdf:type foaf:Agent ; ?b ?c . "
|
||||
+ " ?c rdf:type core:AwardReceipt . "
|
||||
+ " OPTIONAL { ?c core:relates ?e . ?e rdf:type core:Award . ?e rdfs:label ?AwardLabel . } . "
|
||||
+ " OPTIONAL { ?c core:assignedBy ?d . ?d rdf:type foaf:Organization . ?d rdfs:label ?AwardConferredBy . } . "
|
||||
+ " OPTIONAL { ?c core:description ?Description . } . "
|
||||
+ " }");
|
||||
|
||||
/* Role In Organization */
|
||||
|
||||
queriesForAgent.add(prefix +
|
||||
"SELECT (str(?OrganizationLabel) as ?organizationLabel) WHERE {"
|
||||
+ " ?uri rdf:type foaf:Agent ; ?b ?c . "
|
||||
+ " ?c rdf:type obo:BFO_0000023 ; core:roleContributesTo ?Organization ."
|
||||
+ " ?Organization rdf:type core:Organization . "
|
||||
+ " ?Organization rdfs:label ?OrganizationLabel . "
|
||||
+ " }");
|
||||
|
||||
/* Academic Degree / Educational Training */
|
||||
|
||||
queriesForAgent.add(prefix +
|
||||
"SELECT " +
|
||||
"(str(?AcademicDegreeLabel) as ?academicDegreeLabel) " +
|
||||
"(str(?AcademicDegreeAbbreviation) as ?academicDegreeAbbreviation) " +
|
||||
"(str(?MajorField) as ?majorField) " +
|
||||
"(str(?DepartmentOrSchool) as ?departmentOrSchool) " +
|
||||
"(str(?TrainingAtOrganizationLabel) as ?trainingAtOrganizationLabel) WHERE {"
|
||||
|
||||
+ " ?uri rdf:type foaf:Agent ; ?b ?c . "
|
||||
+ " ?c rdf:type core:EducationalProcess . "
|
||||
|
||||
+ "OPTIONAL { ?c core:relates ?d . "
|
||||
+ " ?d rdf:type core:AwardedDegree . "
|
||||
+ " ?d core:relates ?e . "
|
||||
+ " ?e rdf:type core:AcademicDegree . "
|
||||
+ " ?e rdfs:label ?AcademicDegreeLabel . } . "
|
||||
+ "OPTIONAL { ?c core:majorField ?MajorField .} ."
|
||||
+ " OPTIONAL { ?c core:departmentOrSchool ?DepartmentOrSchool . }"
|
||||
+ " OPTIONAL { ?c obo:RO_0000057 ?f . ?f rdf:type foaf:organization . ?f rdfs:label ?TrainingAtOrganizationLabel . } . "
|
||||
+"}");
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,98 +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 org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccessStub;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
||||
|
||||
|
||||
public class VivoAgentContextNodeFieldsTest extends AbstractTestClass{
|
||||
|
||||
static String SPCA = "http://vivo.mydomain.edu/individual/n8087";
|
||||
static ContextModelAccessStub contextModels;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup(){
|
||||
Model m = ModelFactory.createDefaultModel();
|
||||
InputStream stream = VivoAgentContextNodeFieldsTest
|
||||
.class.getResourceAsStream("./NIHVIVO3853_DataSet1.rdf");
|
||||
|
||||
long preloadSize = m.size();
|
||||
|
||||
m.read(stream, null);
|
||||
assertTrue("expected to load statements from file", m.size() > preloadSize );
|
||||
|
||||
assertTrue("expect statements about SPCA",
|
||||
m.contains(ResourceFactory.createResource(SPCA),(Property) null,(RDFNode) null));
|
||||
|
||||
contextModels = new ContextModelAccessStub();
|
||||
contextModels.setRDFService(WhichService.CONTENT, new RDFServiceModel(m));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJane(){
|
||||
Individual ind = new IndividualImpl();
|
||||
ind.setURI(SPCA);
|
||||
|
||||
VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields();
|
||||
vacnf.setContextModels(contextModels);
|
||||
StringBuffer sb = vacnf.getValues( ind );
|
||||
|
||||
assertNotNull( sb );
|
||||
String values = sb.toString();
|
||||
|
||||
boolean hasJane = values.toLowerCase().indexOf("jane") > 0;
|
||||
assertTrue("expected to have jane because SPCA advises jane", hasJane);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWonder(){
|
||||
Individual ind = new IndividualImpl();
|
||||
ind.setURI(SPCA);
|
||||
|
||||
VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields();
|
||||
vacnf.setContextModels(contextModels);
|
||||
StringBuffer sb = vacnf.getValues( ind );
|
||||
|
||||
assertNotNull( sb );
|
||||
String values = sb.toString();
|
||||
|
||||
boolean hasWonder = values.toLowerCase().indexOf("wonders") > 0;
|
||||
assertTrue("expected to have jane because SPCA won wonders award", hasWonder);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChimp(){
|
||||
Individual ind = new IndividualImpl();
|
||||
ind.setURI(SPCA);
|
||||
|
||||
VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields();
|
||||
vacnf.setContextModels(contextModels);
|
||||
StringBuffer sb = vacnf.getValues( ind );
|
||||
|
||||
assertNotNull( sb );
|
||||
String values = sb.toString();
|
||||
|
||||
boolean hasNotChimp = ! (values.toLowerCase().indexOf("chimp") > 0);
|
||||
assertTrue("expected to not have chimp because jane won chimp award, not SPCA", hasNotChimp);
|
||||
}
|
||||
}
|
|
@ -1,83 +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 org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccessStub;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
||||
|
||||
/**
|
||||
* Second test for VivoAgentContextNodeFields. This is duplicated
|
||||
* due to using a different data set in the test.
|
||||
*
|
||||
*/
|
||||
public class VivoAgentContextNodeFieldsTest2 extends AbstractTestClass{
|
||||
|
||||
static String HISTORY_DEPT = "http://vivo.colorado.edu/deptid_10238" ;
|
||||
static ContextModelAccessStub contextModels;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup(){
|
||||
Model m = ModelFactory.createDefaultModel();
|
||||
InputStream stream = VivoAgentContextNodeFieldsTest2
|
||||
.class.getResourceAsStream("./VIVO146_DataSet1.n3");
|
||||
assertTrue("Expected to find RDF data file " , stream != null );
|
||||
|
||||
long preloadSize = m.size();
|
||||
|
||||
m.read(stream, null, "N3");
|
||||
assertTrue("expected to load statements from file", m.size() > preloadSize );
|
||||
|
||||
System.out.println("size of m : " + m.size());
|
||||
|
||||
assertTrue("expect statements about HISTORY_DEPT",
|
||||
m.contains(ResourceFactory.createResource(HISTORY_DEPT),(Property) null,(RDFNode) null));
|
||||
|
||||
contextModels = new ContextModelAccessStub();
|
||||
contextModels.setRDFService(WhichService.CONTENT, new RDFServiceModel(m));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test how many times history is returned for context nodes
|
||||
* of the History department.
|
||||
*/
|
||||
@Test
|
||||
public void testHistory(){
|
||||
Individual ind = new IndividualImpl();
|
||||
ind.setURI(HISTORY_DEPT);
|
||||
|
||||
VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields();
|
||||
vacnf.setContextModels(contextModels);
|
||||
StringBuffer sb = vacnf.getValues( ind );
|
||||
|
||||
assertNotNull( sb );
|
||||
String value = sb.toString();
|
||||
|
||||
assertTrue("Expected to get some text back from "
|
||||
+ "VivoAgentContextNodeFields but got none" , !value.trim().isEmpty());
|
||||
|
||||
int count = StringUtils.countMatches(value.toLowerCase(),"history");
|
||||
System.out.println("histories: " + count);
|
||||
System.out.println("'" + value + "'");
|
||||
// assertTrue("expected to have jane because SPCA advises jane", hasJane);
|
||||
}
|
||||
}
|
|
@ -27,7 +27,6 @@ utilities/ISF-transition/obsoleteUris
|
|||
# 7498 89730 2277668 first_pass.output
|
||||
#
|
||||
|
||||
test/edu/cornell/mannlib/vitro/webapp/search/solr/NIHVIVO3853_DataSet1.rdf
|
||||
productMods/WEB-INF/ontologies/update/oldVersion/vivo-event-1.5.owl
|
||||
productMods/WEB-INF/ontologies/update/oldAnnotations/vivo-core-1.5-annotations.rdf
|
||||
productMods/WEB-INF/ontologies/update/diff.tab.txt
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
# 7498 89730 2277668 first_pass.output
|
||||
#
|
||||
|
||||
test/edu/cornell/mannlib/vitro/webapp/search/solr/NIHVIVO3853_DataSet1.rdf
|
||||
productMods/WEB-INF/ontologies/update/oldVersion/vivo-event-1.5.owl
|
||||
productMods/WEB-INF/ontologies/update/oldAnnotations/vivo-core-1.5-annotations.rdf
|
||||
productMods/WEB-INF/ontologies/update/diff.tab.txt
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue