Moving vivoSearchProhibited.n3 to ontologies/app/loadedAtStartup
Fixing a bug in the ContextNodeFields where initialBindings were no longer getting used so a critical variable in the SPARQL query was free. NIHVIVO-3853
This commit is contained in:
parent
0f68370d7c
commit
e184f2ade3
4 changed files with 42029 additions and 6 deletions
|
@ -93,6 +93,20 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
|
|||
" ?c rdf:type core:Relationship . " +
|
||||
" ?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:Relationship . " +
|
||||
" ?c core:advisor ?uri . " +
|
||||
" ?c core:advisee ?d . ?d rdfs:label ?label .}" );
|
||||
|
||||
queriesForAgent.add(prefix + "SELECT " +
|
||||
"(str(?label) as ?advisorLabel) WHERE {" +
|
||||
" ?uri rdf:type foaf:Agent ." +
|
||||
" ?c rdf:type core:Relationship . " +
|
||||
" ?c core:advisee ?uri . " +
|
||||
" ?c core:advisor ?d . ?d rdfs:label ?label .}" );
|
||||
|
||||
/* Author */
|
||||
|
||||
queriesForAgent.add(prefix + "SELECT " +
|
||||
|
@ -111,16 +125,15 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
|
|||
" ?c core:linkedInformationResource ?h . ?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 . "
|
||||
|
||||
"(str(?Description) as ?description) " +
|
||||
"WHERE {"
|
||||
+ " ?uri rdf:type foaf:Agent ; ?b ?c . "
|
||||
+ " ?c rdf:type core:AwardReceipt . "
|
||||
+ " OPTIONAL { ?c rdfs:label ?AwardLabel . } . "
|
||||
+ " OPTIONAL { ?c core:awardConferredBy ?d . ?d rdfs:label ?AwardConferredBy . } . "
|
||||
+ " OPTIONAL { ?c core:description ?Description . } . "
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,94 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.search.solr;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
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.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceFactorySingle;
|
||||
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 RDFServiceFactory rdfServiceFactory;
|
||||
|
||||
@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));
|
||||
|
||||
RDFService rdfService = new RDFServiceModel(m);
|
||||
rdfServiceFactory = new RDFServiceFactorySingle(rdfService);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJane(){
|
||||
Individual ind = new IndividualImpl();
|
||||
ind.setURI(SPCA);
|
||||
|
||||
VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(rdfServiceFactory);
|
||||
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(rdfServiceFactory);
|
||||
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(rdfServiceFactory);
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue