Removing rdfs:label from search index document field ALLTEXT. Moving vivo specific DocumentModifiers out of vitro. NIHVIVO-2975
This commit is contained in:
parent
0c31c08fb0
commit
827ea6d7e9
6 changed files with 358 additions and 0 deletions
|
@ -0,0 +1,67 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
package edu.cornell.mannlib.vitro.webapp.search.solr;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
||||
|
||||
public class VivoInformationResourceContextNodeFieldsTest extends AbstractTestClass {
|
||||
|
||||
String TEST_NO_LABLE_N3_FILE = "VivoInformationResourceContextNodeFieldsTest.n3";
|
||||
String RDFS_LABEL_VALUE = "Test Document X";
|
||||
String DOCUMENT_URI = "http://example.com/vivo/individual/n7474";
|
||||
|
||||
|
||||
@Test
|
||||
public void testNoLabel() throws IOException{
|
||||
//Test that rdfs:label is NOT added by the VivoInformationResourceContextNodeFields
|
||||
|
||||
//setup a model & wdf with test RDF file
|
||||
InputStream stream = VivoInformationResourceContextNodeFieldsTest.class.getResourceAsStream(TEST_NO_LABLE_N3_FILE);
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
model.read(stream, null, "N3");
|
||||
stream.close();
|
||||
|
||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM,model);
|
||||
ontModel.prepare();
|
||||
Assert.assertTrue("ontModel had no statements" , ontModel.size() > 0 );
|
||||
|
||||
WebappDaoFactory wadf = new WebappDaoFactoryJena(ontModel);
|
||||
Individual ind = wadf.getIndividualDao().getIndividualByURI(DOCUMENT_URI);
|
||||
Assert.assertNotNull(ind);
|
||||
|
||||
SolrInputDocument doc = new SolrInputDocument();
|
||||
doc.addField("ALLTEXT", "");
|
||||
|
||||
VivoInformationResourceContextNodeFields vircnf = new VivoInformationResourceContextNodeFields(ontModel);
|
||||
vircnf.modifyDocument(ind, doc, new StringBuffer());
|
||||
|
||||
Collection values = doc.getFieldValues("ALLTEXT");
|
||||
for( Object value : values){
|
||||
Assert.assertFalse("rdf:label erroneously added by document modifier:", value.toString().contains(RDFS_LABEL_VALUE));
|
||||
}
|
||||
|
||||
VivoAgentContextNodeFields vacnf = new VivoAgentContextNodeFields(ontModel);
|
||||
vacnf.modifyDocument(ind, doc, new StringBuffer());
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
@prefix dc: <http://purl.org/dc/elements/1.1/> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
@prefix vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> .
|
||||
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
||||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
||||
|
||||
<http://example.com/vivo/individual/n7474>
|
||||
a <http://purl.org/ontology/bibo/Document> , owl:Thing , <http://purl.org/ontology/bibo/AudioDocument> , <http://vivoweb.org/ontology/core#InformationResource> ;
|
||||
rdfs:label "Test Document X"@en-US ;
|
||||
<http://purl.org/dc/terms/creator>
|
||||
<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n4782> ;
|
||||
<http://purl.org/dc/terms/title>
|
||||
"Test Document X"@en-US ;
|
||||
vitro:modTime "2011-11-01T11:11:49"^^xsd:dateTime ;
|
||||
vitro:mostSpecificType
|
||||
<http://purl.org/ontology/bibo/AudioDocument> ;
|
||||
<http://vivoweb.org/ontology/core#informationResourceInAuthorship>
|
||||
<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n7484> .
|
Loading…
Add table
Add a link
Reference in a new issue