VIVO-869 Drastically simplify the search configuration.

Create LabelsAcrossContextNodes to replace AdditionalURIsForContextNodes. It's more configurable.
Create SelectQueryUriFinder to replace AdditionalUrisForVCards. It's more configurable.
Rename SimpleSparqlQueryDocumentModifier to SelectQueryDocumentModifier, to conform.
Radically simplify the VIVO search configuration, omitting all special cases except those for VCards.
This commit is contained in:
j2blake 2015-02-06 15:22:28 -05:00
parent 431847165b
commit 7a47c6b75d
6 changed files with 916 additions and 1997 deletions

View file

@ -0,0 +1,492 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.searchindex.extensions;
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createPlainLiteral;
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createProperty;
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createResource;
import static com.hp.hpl.jena.rdf.model.ResourceFactory.createStatement;
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONTENT;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.ALLTEXT;
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.ALLTEXTUNSTEMMED;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Before;
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.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS;
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.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputField;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
/**
* TODO
*/
public class LabelsAcrossContextNodesTest extends AbstractTestClass {
// Types
private static final String CORE_ACADEMIC_DEGREE = "http://vivoweb.org/ontology/core#AcademicDegree";
private static final String CORE_ADVISING_RELATIONSHIP = "http://vivoweb.org/ontology/core#AdvisingRelationship";
private static final String CORE_POSITION = "http://vivoweb.org/ontology/core#Position";
private static final String FOAF_PERSON = "http://xmlns.com/foaf/0.1/#Person";
private static final String FOAF_ORGANIZATION = "http://xmlns.com/foaf/0.1/#Organization";
// Individuals
// Note: Person3 has no label and so no effect, but doesn't cause a problem.
private static final String URI_PERSON1 = "http://ns#Person1";
private static final String NAME_PERSON1 = "Person1";
private static final String URI_PERSON2 = "http://ns#Person2";
private static final String NAME_PERSON2 = "Person2";
private static final String URI_PERSON3 = "http://ns#Person3";
private static final String NAME_PERSON3 = null;
private static final String URI_PERSON4 = "http://ns#Person4";
private static final String NAME_PERSON4 = "Person4";
private static final String URI_ORGANIZATION1 = "http://ns#Organization1";
private static final String NAME_ORGANIZATION1 = "Organization1";
// Context nodes
private static final String URI_POSITION1 = "http://ns#Position1";
private static final String NAME_POSITION1 = "Position1";
private static final String URI_POSITION2 = "http://ns#Position2";
private static final String NAME_POSITION2 = "Position2";
private static final String URI_ADVISING1 = "http://ns#Advising1";
private static final String NAME_ADVISING1 = "Advising1";
private static final String URI_ADVISING2 = "http://ns#Advising2";
private static final String NAME_ADVISING2 = "Advising2";
// Properties
private static final String CORE_RELATED_BY = "http://vivoweb.org/ontology/core#relatedBy";
private static final String CORE_RELATES = "http://vivoweb.org/ontology/core#relates";
private static final String CORE_ASSIGNED_BY = "http://vivoweb.org/ontology/core#assignedBy";
private Model m;
private RDFService rdfService;
private LabelsAcrossContextNodes lacn;
private MockSearchInputDocument doc;
private List<String> foundUris;
/**
* Create these relationships (where "r/r" denotes "relatedBy/relates"
* combination.
*
* <pre>
* Person1 r/r Position1 r/r Organization1
* Person1 r/r AdvisingRelationship1 r/r Person2
* Person1 r/r AdvisingRelationship2 r/r Person3(no label!)
* Person2 r/r Position2 r/r Organization1
* Person4
* </pre>
*/
@Before
public void populateModel() {
m = ModelFactory.createDefaultModel();
addIndividual(URI_PERSON1, NAME_PERSON1, FOAF_PERSON);
addIndividual(URI_PERSON2, NAME_PERSON2, FOAF_PERSON);
addIndividual(URI_PERSON3, NAME_PERSON3, FOAF_PERSON);
addIndividual(URI_PERSON4, NAME_PERSON4, FOAF_PERSON);
addIndividual(URI_ORGANIZATION1, NAME_ORGANIZATION1, FOAF_ORGANIZATION);
addIndividual(URI_POSITION1, NAME_POSITION1, CORE_POSITION);
addIndividual(URI_POSITION2, NAME_POSITION2, CORE_POSITION);
addIndividual(URI_ADVISING1, NAME_ADVISING1, CORE_ADVISING_RELATIONSHIP);
addIndividual(URI_ADVISING2, NAME_ADVISING2, CORE_ADVISING_RELATIONSHIP);
addRelationship(URI_PERSON1, URI_POSITION1, URI_ORGANIZATION1);
addRelationship(URI_PERSON1, URI_ADVISING1, URI_PERSON2);
addRelationship(URI_PERSON1, URI_ADVISING2, URI_PERSON3);
addRelationship(URI_PERSON2, URI_POSITION2, URI_ORGANIZATION1);
rdfService = new RDFServiceModel(m);
ContextModelAccessStub models = new ContextModelAccessStub();
models.setRDFService(CONTENT, rdfService);
lacn = new LabelsAcrossContextNodes();
lacn.setContextModels(models);
}
// ----------------------------------------------------------------------
// Test DocumentModifier
// ----------------------------------------------------------------------
/*
* If there is a type restriction and the individual does not meet it, no
* change.
*
* If contextNodeClasses are not specified, get labels from all context
* nodes. note that a partner without a label should just be a no-op.
*
* If contextNodeClasses are specified, accept some and ignore others.
*
* Confirm that the expected data is written to the text fields.
*/
@Test
public void noRestrictions_returnLabelsOfAllPartners() {
setTypeRestrictions();
setContextNodeTypes();
exerciseDocumentModifier(URI_PERSON1);
assertExpectedFieldValues(NAME_ORGANIZATION1, NAME_PERSON2);
}
@Test
public void typeRestrictionOnCorrectType_returnAll() {
setTypeRestrictions(FOAF_PERSON);
setContextNodeTypes();
exerciseDocumentModifier(URI_PERSON1);
assertExpectedFieldValues(NAME_ORGANIZATION1, NAME_PERSON2);
}
@Test
public void typeRestrictionOnWrongType_returnNothing() {
setTypeRestrictions(FOAF_ORGANIZATION);
setContextNodeTypes();
exerciseDocumentModifier(URI_PERSON1);
assertExpectedFieldValues();
}
@Test
public void limitByContextNodeType_returnLimited() {
setTypeRestrictions();
setContextNodeTypes(CORE_POSITION);
exerciseDocumentModifier(URI_PERSON1);
assertExpectedFieldValues(NAME_ORGANIZATION1);
}
@Test
public void inclusiveContextNodeTypes_returnAll() {
setTypeRestrictions();
setContextNodeTypes(CORE_POSITION, CORE_ADVISING_RELATIONSHIP);
exerciseDocumentModifier(URI_PERSON1);
assertExpectedFieldValues(NAME_ORGANIZATION1, NAME_PERSON2);
}
@Test
public void noContextNodes_noResultsNoProblem() {
setTypeRestrictions();
setContextNodeTypes();
exerciseDocumentModifier(URI_PERSON4);
assertExpectedFieldValues();
}
// ----------------------------------------------------------------------
// Test IndexingUriFinder
// ----------------------------------------------------------------------
/**
* <pre>
* If neither a label nor a relates, ignore it.
*
* If label, test if no partners, if some partners, if some partners restricted by type.
* test with both contextNodeClasses and not.
* Test with typeRestrictions or without.
*
* If relates, and fails contextNodeClasses, ignore it.
* Test with contextNodeClasses and without.
* Find partners, both with typeRestrictions and without.
* </pre>
*/
@Test
public void irrelevantStatement_returnsNothing() {
setTypeRestrictions();
setContextNodeTypes();
exerciseUriFinder(stmt(URI_POSITION1, CORE_ASSIGNED_BY, URI_PERSON4));
assertExpectedUris();
}
@Test
public void label_noPartners_returnsNothing() {
setTypeRestrictions();
setContextNodeTypes();
exerciseUriFinder(labelStmt(URI_PERSON4, "New Name"));
assertExpectedUris();
}
@Test
public void label_returnsAllPartners() {
setTypeRestrictions();
setContextNodeTypes();
exerciseUriFinder(labelStmt(URI_PERSON1, "New Name"));
assertExpectedUris(URI_PERSON2, URI_PERSON3, URI_ORGANIZATION1);
}
@Test
public void label_restrictByContextNode_returnEligiblePartners() {
setTypeRestrictions();
setContextNodeTypes(CORE_ADVISING_RELATIONSHIP);
exerciseUriFinder(labelStmt(URI_PERSON1, "New Name"));
assertExpectedUris(URI_PERSON2, URI_PERSON3);
}
@Test
public void label_restrictByContextNodes_returnEligiblePartners() {
setTypeRestrictions();
setContextNodeTypes(CORE_ADVISING_RELATIONSHIP, CORE_POSITION);
exerciseUriFinder(labelStmt(URI_PERSON1, "New Name"));
assertExpectedUris(URI_PERSON2, URI_PERSON3, URI_ORGANIZATION1);
}
@Test
public void label_typeRestriction_limitsResults() {
setTypeRestrictions(FOAF_PERSON);
setContextNodeTypes();
exerciseUriFinder(labelStmt(URI_PERSON1, "New Name"));
assertExpectedUris(URI_PERSON2, URI_PERSON3);
}
@Test
public void label_inclusiveTypeRestrictions_allResults() {
setTypeRestrictions(FOAF_PERSON, FOAF_ORGANIZATION);
setContextNodeTypes();
exerciseUriFinder(labelStmt(URI_PERSON1, "New Name"));
assertExpectedUris(URI_PERSON2, URI_PERSON3, URI_ORGANIZATION1);
}
@Test
public void label_prohibitiveTypeRestrictions_nothing() {
setTypeRestrictions(CORE_ACADEMIC_DEGREE);
setContextNodeTypes();
exerciseUriFinder(labelStmt(URI_PERSON1, "New Name"));
assertExpectedUris();
}
@Test
public void relates_returnsPartner() {
setTypeRestrictions();
setContextNodeTypes();
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
assertExpectedUris(URI_ORGANIZATION1);
}
@Test
public void relates_inclusiveTypeRestriction_returnsPartner() {
setTypeRestrictions(FOAF_ORGANIZATION);
setContextNodeTypes();
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
assertExpectedUris(URI_ORGANIZATION1);
}
@Test
public void relates_exclusiveTypeRestriction_returnsNothing() {
setTypeRestrictions(CORE_ADVISING_RELATIONSHIP);
setContextNodeTypes();
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
assertExpectedUris();
}
@Test
public void relates_inclusiveContextType_returnsPartner() {
setTypeRestrictions();
setContextNodeTypes(CORE_POSITION);
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
assertExpectedUris(URI_ORGANIZATION1);
}
@Test
public void relates_exclusiveContextType_returnsNothing() {
setTypeRestrictions();
setContextNodeTypes(CORE_ADVISING_RELATIONSHIP);
exerciseUriFinder(stmt(URI_POSITION1, CORE_RELATES, URI_PERSON1));
assertExpectedUris();
}
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
private void addIndividual(String uri, String label, String... types) {
Resource subject = createResource(uri);
if (label != null) {
m.add(subject, RDFS.label, label);
}
for (String type : types) {
m.add(subject, RDF.type, createResource(type));
}
}
private void addRelationship(String ind1Uri, String contextNodeUri,
String ind2Uri) {
Resource ind1 = createResource(ind1Uri);
Resource contextNode = createResource(contextNodeUri);
Resource ind2 = createResource(ind2Uri);
Property relatedBy = createProperty(CORE_RELATED_BY);
Property relates = createProperty(CORE_RELATES);
m.add(ind1, relatedBy, contextNode);
m.add(contextNode, relates, ind1);
m.add(ind2, relatedBy, contextNode);
m.add(contextNode, relates, ind2);
}
private void setTypeRestrictions(String... uris) {
for (String uri : uris) {
lacn.addTypeRestriction(uri);
}
}
private void setContextNodeTypes(String... uris) {
for (String uri : uris) {
lacn.addContextNodeClass(uri);
}
}
private void exerciseDocumentModifier(String individualUri) {
Individual ind = createIndividual(individualUri);
doc = new MockSearchInputDocument();
lacn.modifyDocument(ind, doc);
}
private Individual createIndividual(String individualUri) {
Individual ind = new IndividualImpl(individualUri);
List<VClass> vclasses = new ArrayList<>();
for (RDFNode node : m.listObjectsOfProperty(
createResource(individualUri), RDF.type).toList()) {
if (node.isURIResource()) {
vclasses.add(new VClass(node.asResource().getURI()));
}
}
ind.setVClasses(vclasses, false);
return ind;
}
private void assertExpectedFieldValues(String... values) {
List<String> expected = new ArrayList<>(Arrays.asList(values));
Collections.sort(expected);
List<String> actual1 = doc.getValues(ALLTEXT);
Collections.sort(actual1);
assertEquals("ALLTEXT", expected, actual1);
List<String> actual2 = doc.getValues(ALLTEXTUNSTEMMED);
Collections.sort(actual2);
assertEquals("ALLTEXTUNSTEMMED", expected, actual2);
}
private void exerciseUriFinder(Statement stmt) {
foundUris = lacn.findAdditionalURIsToIndex(stmt);
}
private Statement stmt(String subjectUri, String predicateUri,
String objectUri) {
return createStatement(createResource(subjectUri),
createProperty(predicateUri), createResource(objectUri));
}
private Statement labelStmt(String subjectUri, String labelText) {
return createStatement(createResource(subjectUri), RDFS.label,
createPlainLiteral(labelText));
}
private void assertExpectedUris(String... expectedArray) {
Set<String> expected = new HashSet<>(Arrays.asList(expectedArray));
Set<String> actual = new HashSet<>(foundUris);
assertEquals("found URIs", expected, actual);
}
// ----------------------------------------------------------------------
// Helper classes
// ----------------------------------------------------------------------
private static class MockSearchInputDocument implements SearchInputDocument {
// ----------------------------------------------------------------------
// Stub infrastructure
// ----------------------------------------------------------------------
private Map<String, List<String>> fieldValues = new HashMap<>();
public List<String> getValues(String fieldName) {
if (fieldValues.containsKey(fieldName)) {
return new ArrayList<>(fieldValues.get(fieldName));
} else {
return new ArrayList<>();
}
}
// ----------------------------------------------------------------------
// Stub methods
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Un-implemented methods
// ----------------------------------------------------------------------
@Override
public void addField(SearchInputField arg0) {
throw new RuntimeException("addField() not implemented.");
}
@Override
public void addField(String name, Object... values) {
List<String> stringValues = getValues(name);
for (Object value : values) {
stringValues.add(String.valueOf(value));
}
fieldValues.put(name, stringValues);
}
@Override
public void addField(String arg0, Collection<Object> arg1) {
throw new RuntimeException("addField() not implemented.");
}
@Override
public void addField(String arg0, float arg1, Object... arg2) {
throw new RuntimeException("addField() not implemented.");
}
@Override
public void addField(String arg0, float arg1, Collection<Object> arg2) {
throw new RuntimeException("addField() not implemented.");
}
@Override
public SearchInputField createField(String arg0) {
throw new RuntimeException("createField() not implemented.");
}
@Override
public float getDocumentBoost() {
throw new RuntimeException("getDocumentBoost() not implemented.");
}
@Override
public SearchInputField getField(String arg0) {
throw new RuntimeException("getField() not implemented.");
}
@Override
public Map<String, SearchInputField> getFieldMap() {
throw new RuntimeException("getFieldMap() not implemented.");
}
@Override
public void setDocumentBoost(float arg0) {
throw new RuntimeException("setDocumentBoost() not implemented.");
}
}
}

View file

@ -1,611 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.searchindex.indexing;
import static org.junit.Assert.assertTrue;
import java.io.StringReader;
import java.util.List;
import org.junit.Test;
import stubs.edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccessStub;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
public class AdditionalURIsForContextNodesTest {
private AdditionalURIsForContextNodes uriFinder;
@Test
public void testPositionChanges(){
String n3 =
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://vivoweb.org/ontology/core#relatedBy> <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#AcademicDepartment> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Department> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Organization> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#AcademicDepartment> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#DependentResource> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#DependentResource> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Position> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#FacultyPosition> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://vivoweb.org/ontology/core#relates> <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> <http://vivoweb.org/ontology/core#relates> <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://vivoweb.org/ontology/core#relatedBy> <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5431> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#FacultyMember> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#FacultyMember> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5398> <http://vivoweb.org/ontology/core#start> <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5425> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5398> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#DateTimeInterval> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5398> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5398> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#DateTimeInterval> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5425> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5425> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#DateTimeValue> . \n" +
"<http://vivoweb.org/ontology/core#AcademicDepartment> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://vivoweb.org/ontology/core#Position> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://vivoweb.org/ontology/core#FacultyMember> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://xmlns.com/foaf/0.1/Organization> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://xmlns.com/foaf/0.1/Person> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://xmlns.com/foaf/0.1/Agent> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://vivoweb.org/ontology/core#DateTimeInterval> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" +
"<http://vivoweb.org/ontology/core#Department> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . \n" ;
populateModelAndCreateUriFinder(n3);
//if the person changes then the org needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932");
assertTrue("did not find org for context node", uris.contains("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423" ));
//if the org changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5423");
assertTrue("did not find person for context node", uris.contains("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n932" ));
}
@Test
public void testPersonOnOrgChange() {
String n3 ="@prefix dc: <http://purl.org/dc/elements/1.1/> . \n" +
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . \n" +
"@prefix swrl: <http://www.w3.org/2003/11/swrl#> . \n" +
"@prefix vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> . \n" +
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . \n" +
"@prefix swrlb: <http://www.w3.org/2003/11/swrlb#> . \n" +
"@prefix owl: <http://www.w3.org/2002/07/owl#> . \n" +
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . \n" +
"@prefix core: <http://vivoweb.org/ontology/core#> . \n" +
"@prefix vivo: <http://vivo.library.cornell.edu/ns/0.1#> . \n" +
"@prefix obo: <http://purl.obolibrary.org/obo/> . \n" +
" " +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2577> \n" +
" a owl:Thing , core:Role , core:LeaderRole ; \n" +
" rdfs:label \"head\"^^xsd:string ; \n" +
" vitro:mostSpecificType \n" +
" core:LeaderRole ; \n" +
" core:dateTimeInterval \n" +
" <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2594> ; \n" +
" obo:RO_0000052 <http://vivo.scripps.edu/individual/n14979> ; \n" +
" core:roleContributesTo <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2592> . \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2592> \n" +
" a <http://xmlns.com/foaf/0.1/Organization> , owl:Thing , <http://xmlns.com/foaf/0.1/Agent> , core:ClinicalOrganization ; \n" +
" rdfs:label \"Organization XYZ\"^^xsd:string ; \n" +
" vitro:mostSpecificType \n" +
" core:ClinicalOrganization ; \n" +
" core:contributingRole <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2577> . \n" +
" <http://vivo.scripps.edu/individual/n14979> a <http://xmlns.com/foaf/0.1/Person> , owl:Thing , <http://xmlns.com/foaf/0.1/Agent> . \n";
//make a test model with an person, an authorship context node and a book
populateModelAndCreateUriFinder(n3);
//get additional uris for org
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2592");
assertTrue("did not find person for context node", uris.contains("http://vivo.scripps.edu/individual/n14979" ));
}
@Test
public void testLeaderRoleChanges(){
String n3=
"<http://vivo.scripps.edu/individual/n2027> <http://www.w3.org/2000/01/rdf-schema#label> \"1, Test\" . \n " +
// "<http://vivo.scripps.edu/individual/n2027> <http://xmlns.com/foaf/0.1/lastName> \"1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
// "<http://vivo.scripps.edu/individual/n2027> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n2027> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n2027> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n7067> . \n " +
"<http://vivo.scripps.edu/individual/n2027> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n2027> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n2027> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://www.w3.org/2000/01/rdf-schema#label> \"Leader Role\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n2027> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n7083> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://vivoweb.org/ontology/core#roleContributesTo> <http://vivo.scripps.edu/individual/n7080> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#LeaderRole> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#LeaderRole> . \n " +
"<http://vivo.scripps.edu/individual/n7067> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://www.w3.org/2000/01/rdf-schema#label> \"University1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://vivoweb.org/ontology/core#contributingRole> <http://vivo.scripps.edu/individual/n7067> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#University> .\n " +
"<http://vivo.scripps.edu/individual/n7080> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#University> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n7080> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Organization> . \n " ;
populateModelAndCreateUriFinder(n3);
//if the person changes then the university needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n2027");
assertTrue("did not find org for context node", uris.contains("http://vivo.scripps.edu/individual/n7080" ));
//if the university changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n7080");
assertTrue("did not find person for context node", uris.contains("http://vivo.scripps.edu/individual/n2027" ));
}
@Test
public void testMemberRoleChanges(){
String n3 =
"<http://vivo.scripps.edu/individual/n4519> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n6040> . \n " +
"<http://vivo.scripps.edu/individual/n4519> <http://www.w3.org/2000/01/rdf-schema#label> \"2, Test\" . \n " +
// "<http://vivo.scripps.edu/individual/n4519> <http://xmlns.com/foaf/0.1/lastName> \"2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
// "<http://vivo.scripps.edu/individual/n4519> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n4519> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n4519> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n4519> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n4519> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://www.w3.org/2000/01/rdf-schema#label> \"Member Role\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n6031> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://vivoweb.org/ontology/core#roleContributesTo> <http://vivo.scripps.edu/individual/n6004> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#MemberRole> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n4519> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#MemberRole> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n " +
"<http://vivo.scripps.edu/individual/n6040> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://www.w3.org/2000/01/rdf-schema#label> \"University2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://vivoweb.org/ontology/core#contributingRole> <http://vivo.scripps.edu/individual/n6040> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#University> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#University> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n6004> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Organization> . \n " ;
populateModelAndCreateUriFinder(n3);
//if the person changes then the university needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4519");
assertTrue("did not find org for context node", uris.contains("http://vivo.scripps.edu/individual/n6004" ));
//if the university changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n6004");
assertTrue("did not find person for context node", uris.contains("http://vivo.scripps.edu/individual/n4519" ));
}
@Test
public void testClinicalRoleChangesForProject(){
String n3 =
"<http://vivo.scripps.edu/individual/n4858> <http://www.w3.org/2000/01/rdf-schema#label> \"3, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n4858> <http://xmlns.com/foaf/0.1/lastName> \"3\"^^<http://www.w3.org/2001/XMLSchema#string> .\n" +
// "<http://vivo.scripps.edu/individual/n4858> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4858> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n5185> . \n" +
"<http://vivo.scripps.edu/individual/n4858> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n4858> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n4858> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n4858> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n4858> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://www.w3.org/2000/01/rdf-schema#label> \"Clinical Role\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n5180> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://purl.obolibrary.org/obo/BFO_0000054> <http://vivo.scripps.edu/individual/n5177> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#ClinicalRole> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n5185> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ClinicalRole> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://www.w3.org/2000/01/rdf-schema#label> \"Project1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://purl.obolibrary.org/obo/BFO_0000055> <http://vivo.scripps.edu/individual/n5185> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Project> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Project> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n5177> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Process> . \n" ;
populateModelAndCreateUriFinder(n3);
//if the person changes then the project needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4858");
assertTrue("did not find project for clinical role", uris.contains("http://vivo.scripps.edu/individual/n5177" ));
//if the project changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n5177");
assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n4858" ));
}
@Test
public void testClinicalRoleChangesForService(){
String n3 =
"<http://vivo.scripps.edu/individual/n5651> <http://www.w3.org/2000/01/rdf-schema#label> \"4, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n5651> <http://xmlns.com/foaf/0.1/lastName> \"4\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n5651> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n5651> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n4428> . \n" +
"<http://vivo.scripps.edu/individual/n5651> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5651> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n5651> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5651> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n5651> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://www.w3.org/2000/01/rdf-schema#label> \"Clinical Role 2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n4444> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://vivoweb.org/ontology/core#roleContributesTo> <http://vivo.scripps.edu/individual/n4442> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#ClinicalRole> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4428> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ClinicalRole> . \n" +
"<http://vivo.scripps.edu/individual/n4442> <http://www.w3.org/2000/01/rdf-schema#label> \"Service1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4442> <http://vivoweb.org/ontology/core#contributingRole> <http://vivo.scripps.edu/individual/n4428> . \n" +
"<http://vivo.scripps.edu/individual/n4442> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://purl.obolibrary.org/obo/ERO_0000005> . \n" +
"<http://vivo.scripps.edu/individual/n4442> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4442> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.obolibrary.org/obo/ERO_0000005> . \n" ;
populateModelAndCreateUriFinder(n3);
//if the person changes then the service needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n5651");
assertTrue("did not find service for clinical role", uris.contains("http://vivo.scripps.edu/individual/n4442" ));
//if the service changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4442");
assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n5651" ));
}
@Test
public void testPresenterRoleChangesForPresentation(){
String n3 =
"<http://vivo.scripps.edu/individual/n5596> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n1294> . \n" +
"<http://vivo.scripps.edu/individual/n5596> <http://www.w3.org/2000/01/rdf-schema#label> \"5, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n5596> <http://xmlns.com/foaf/0.1/lastName> \"5\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n5596> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n5596> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5596> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n5596> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5596> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n5596> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://www.w3.org/2000/01/rdf-schema#label> \"Presenter Role\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n1304> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://purl.obolibrary.org/obo/BFO_0000054> <http://vivo.scripps.edu/individual/n1305> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#PresenterRole> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#PresenterRole> . \n" +
"<http://vivo.scripps.edu/individual/n1294> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://www.w3.org/2000/01/rdf-schema#label> \"Presentation 1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://purl.obolibrary.org/obo/BFO_0000055> <http://vivo.scripps.edu/individual/n1294> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Presentation> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Presentation> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/NET/c4dm/event.owl#Event> . \n" +
"<http://vivo.scripps.edu/individual/n1305> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" ;
populateModelAndCreateUriFinder(n3);
//if the person changes then the presentation needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n5596");
assertTrue("did not find service for clinical role", uris.contains("http://vivo.scripps.edu/individual/n1305" ));
//if the presentation changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n1305");
assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n5596" ));
}
@Test
public void testPresenterRoleChangesForInvitedTalk(){
String n3 =
"<http://vivo.scripps.edu/individual/n4112> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n4144> . \n " +
"<http://vivo.scripps.edu/individual/n4112> <http://www.w3.org/2000/01/rdf-schema#label> \"6, Test\" . \n " +
// "<http://vivo.scripps.edu/individual/n4112> <http://xmlns.com/foaf/0.1/lastName> \"6\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
// "<http://vivo.scripps.edu/individual/n4112> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n4112> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n4112> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n4112> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n4112> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n4112> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://www.w3.org/2000/01/rdf-schema#label> \"Presenter Role 2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n4136> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://purl.obolibrary.org/obo/BFO_0000054> <http://vivo.scripps.edu/individual/n4107> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#PresenterRole> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#PresenterRole> . \n " +
"<http://vivo.scripps.edu/individual/n4144> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://www.w3.org/2000/01/rdf-schema#label> \"Invited Talk 1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://purl.obolibrary.org/obo/BFO_0000055> <http://vivo.scripps.edu/individual/n4144> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#InvitedTalk> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Presentation> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/NET/c4dm/event.owl#Event> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n4107> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#InvitedTalk> . \n " ;
populateModelAndCreateUriFinder(n3);
//if the person changes then the invited talk needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4112");
assertTrue("did not find invited talk for person", uris.contains("http://vivo.scripps.edu/individual/n4107" ));
//if the invited talk changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4107");
assertTrue("did not find person for invited talk", uris.contains("http://vivo.scripps.edu/individual/n4112" ));
}
@Test
public void testResearcherRoleForGrant(){
String n3 =
"<http://vivo.scripps.edu/individual/n4957> <http://www.w3.org/2000/01/rdf-schema#label> \"7, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n4957> <http://xmlns.com/foaf/0.1/lastName> \"7\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n4957> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4957> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n4288> . \n" +
"<http://vivo.scripps.edu/individual/n4957> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n4957> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n4957> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n4957> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://www.w3.org/2000/01/rdf-schema#label> \"Researcher Role\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n4251> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://vivoweb.org/ontology/core#relatedBy> <http://vivo.scripps.edu/individual/n4252> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#ResearcherRole> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n4957> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ResearcherRole> . \n" +
"<http://vivo.scripps.edu/individual/n4288> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://www.w3.org/2000/01/rdf-schema#label> \"Grant1\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://vivoweb.org/ontology/core#relates> <http://vivo.scripps.edu/individual/n4288> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Grant> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Agreement> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4252> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Grant> . \n" ;
populateModelAndCreateUriFinder(n3);
//if the person changes then the grant needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4957");
assertTrue("did not find service for clinical role", uris.contains("http://vivo.scripps.edu/individual/n4252" ));
//if the grant changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4252");
assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n4957" ));
}
@Test
public void testResearcherRoleForProject(){
String n3 =
"<http://vivo.scripps.edu/individual/n2029> <http://www.w3.org/2000/01/rdf-schema#label> \"8, Test\" . \n " +
// "<http://vivo.scripps.edu/individual/n2029> <http://xmlns.com/foaf/0.1/lastName> \"8\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
// "<http://vivo.scripps.edu/individual/n2029> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n2029> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n556> . \n " +
"<http://vivo.scripps.edu/individual/n2029> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n2029> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n " +
"<http://vivo.scripps.edu/individual/n2029> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n " +
"<http://vivo.scripps.edu/individual/n2029> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://www.w3.org/2000/01/rdf-schema#label> \"Researcher Role 2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n568> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://purl.obolibrary.org/obo/BFO_0000054> <http://vivo.scripps.edu/individual/n564> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#ResearcherRole> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n2029> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ResearcherRole> . \n " +
"<http://vivo.scripps.edu/individual/n556> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://www.w3.org/2000/01/rdf-schema#label> \"Project2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://purl.obolibrary.org/obo/BFO_0000055> <http://vivo.scripps.edu/individual/n556> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Project> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Project> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n " +
"<http://vivo.scripps.edu/individual/n564> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Process> . \n " ;
populateModelAndCreateUriFinder(n3);
//if the person changes then the project needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n2029");
assertTrue("did not find service for clinical role", uris.contains("http://vivo.scripps.edu/individual/n564" ));
//if the project changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n564");
assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n2029" ));
}
@Test
public void testPrincipalInvestigatorRoleChanges(){
String n3 =
"<http://vivo.scripps.edu/individual/n2368> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n1740> . \n" +
"<http://vivo.scripps.edu/individual/n2368> <http://www.w3.org/2000/01/rdf-schema#label> \"8, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n2368> <http://xmlns.com/foaf/0.1/lastName> \"8\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n2368> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n2368> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n2368> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n2368> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n2368> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n2368> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n1756> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://vivoweb.org/ontology/core#relatedBy> <http://vivo.scripps.edu/individual/n1742> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#PrincipalInvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#PrincipalInvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ResearcherRole> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1740> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#InvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://www.w3.org/2000/01/rdf-schema#label> \"Grant 2\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://vivoweb.org/ontology/core#relates> <http://vivo.scripps.edu/individual/n1740> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Grant> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Agreement> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1742> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Grant> . \n" ;
populateModelAndCreateUriFinder(n3);
//if the person changes then the grant needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n2368");
assertTrue("did not find grant for pi", uris.contains("http://vivo.scripps.edu/individual/n1742" ));
//if the grant changes then the person needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n1742");
assertTrue("did not find pi for grant", uris.contains("http://vivo.scripps.edu/individual/n2368" ));
}
@Test
public void testCoPrincipalInvestigatorRoleChanges(){
String n3 =
"<http://vivo.scripps.edu/individual/n1373> <http://www.w3.org/2000/01/rdf-schema#label> \"9, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n1373> <http://xmlns.com/foaf/0.1/lastName> \"9\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n1373> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n1373> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n1373> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n1373> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n1373> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n1373> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n4928> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n1373> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n4895> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://vivoweb.org/ontology/core#relatedBy> <http://vivo.scripps.edu/individual/n4931> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#CoPrincipalInvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#CoPrincipalInvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ResearcherRole> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4928> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#InvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://www.w3.org/2000/01/rdf-schema#label> \"Grant 3\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://vivoweb.org/ontology/core#relates> <http://vivo.scripps.edu/individual/n4928> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Grant> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Agreement> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n4931> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Grant> . \n" ;
populateModelAndCreateUriFinder(n3);
//if the copi changes then the grant needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n1373");
assertTrue("did not find grant for co-pi", uris.contains("http://vivo.scripps.edu/individual/n4931" ));
//if the grant changes then the copi needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4931");
assertTrue("did not find co-pi for grant", uris.contains("http://vivo.scripps.edu/individual/n1373" ));
}
@Test
public void testInvestigatorRoleChanges(){
String n3 =
"<http://vivo.scripps.edu/individual/n5282> <http://www.w3.org/2000/01/rdf-schema#label> \"10, Test\" . \n" +
// "<http://vivo.scripps.edu/individual/n5282> <http://xmlns.com/foaf/0.1/lastName> \"10\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
// "<http://vivo.scripps.edu/individual/n5282> <http://xmlns.com/foaf/0.1/firstName> \"Test\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n5282> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5282> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> . \n" +
"<http://vivo.scripps.edu/individual/n5282> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . \n" +
"<http://vivo.scripps.edu/individual/n5282> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n5282> <http://purl.obolibrary.org/obo/RO_0000053> <http://vivo.scripps.edu/individual/n157> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://vivoweb.org/ontology/core#dateTimeInterval> <http://vivo.scripps.edu/individual/n127> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://vivoweb.org/ontology/core#relatedBy> <http://vivo.scripps.edu/individual/n160> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#InvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://purl.obolibrary.org/obo/RO_0000052> <http://vivo.scripps.edu/individual/n5282> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Role> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#ResearcherRole> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n157> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#InvestigatorRole> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://www.w3.org/2000/01/rdf-schema#label> \"Grant 4\"^^<http://www.w3.org/2001/XMLSchema#string> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://vivoweb.org/ontology/core#relates> <http://vivo.scripps.edu/individual/n157> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType> <http://vivoweb.org/ontology/core#Grant> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Agreement> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Thing> . \n" +
"<http://vivo.scripps.edu/individual/n160> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://vivoweb.org/ontology/core#Grant> . \n" ;
populateModelAndCreateUriFinder(n3);
//if the investigator changes then the grant needs to be updated
List<String> uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n5282");
assertTrue("did not find grant for investigator", uris.contains("http://vivo.scripps.edu/individual/n160" ));
//if the grant changes then the investigator needs to be updated
uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n160");
assertTrue("did not find investigator for grant", uris.contains("http://vivo.scripps.edu/individual/n5282" ));
}
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
/**
* Build a Model from this N3 string, and create a URI Finder based on that
* Model.
*/
private void populateModelAndCreateUriFinder(String n3String) {
OntModel model = ModelFactory.createOntologyModel();
model.read(new StringReader(n3String), null, "N3");
ContextModelAccessStub cmas = new ContextModelAccessStub();
cmas.setRDFService(WhichService.CONTENT, new RDFServiceModel(model));
uriFinder = new AdditionalURIsForContextNodes();
uriFinder.setContextModels(cmas);
}
}