VIVO-742 Change client code to use SearchEngine interface.
Removed SolrQueryTest until I can see how to update it. Everything compiles and tests run, but haven't tried running VIVO yet.
This commit is contained in:
parent
cb204a3926
commit
d73c82cd55
6 changed files with 24 additions and 19 deletions
|
@ -18,9 +18,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ConstantFieldOptions;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaObjectPropetyOptions;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaSolrQueryOptions;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.IndividualsViaSolrQueryOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +120,6 @@ public class AddConceptThroughObjectPropertyGenerator extends DefaultObjectPrope
|
||||||
}
|
}
|
||||||
String[] typesArray = types.toArray(new String[types.size()]);
|
String[] typesArray = types.toArray(new String[types.size()]);
|
||||||
field.setOptions( new IndividualsViaSolrQueryOptions(
|
field.setOptions( new IndividualsViaSolrQueryOptions(
|
||||||
vreq.getSession().getServletContext(),
|
|
||||||
getSubjectUri(),
|
getSubjectUri(),
|
||||||
predicateUri,
|
predicateUri,
|
||||||
getObjectUri(),
|
getObjectUri(),
|
||||||
|
|
|
@ -10,7 +10,6 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.Query;
|
import com.hp.hpl.jena.query.Query;
|
||||||
|
@ -27,6 +26,7 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||||
import com.hp.hpl.jena.shared.Lock;
|
import com.hp.hpl.jena.shared.Lock;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.DocumentModifier;
|
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.DocumentModifier;
|
||||||
|
|
||||||
|
@ -241,17 +241,18 @@ public class CalculateParameters implements DocumentModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyDocument(Individual individual, SolrInputDocument doc, StringBuffer addUri) {
|
public void modifyDocument(Individual individual, SearchInputDocument doc, StringBuffer addUri) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
// calculate beta value.
|
// calculate beta value.
|
||||||
log.debug("Parameter calculation starts..");
|
log.debug("Parameter calculation starts..");
|
||||||
float beta = calculateBeta(individual.getURI());
|
float beta = calculateBeta(individual.getURI());
|
||||||
doc.addField(VitroSearchTermNames.BETA, beta);
|
doc.addField(VitroSearchTermNames.BETA, (Object) beta);
|
||||||
doc.setDocumentBoost(beta + doc.getDocumentBoost() );
|
doc.setDocumentBoost(beta + doc.getDocumentBoost() );
|
||||||
log.debug("Parameter calculation is done");
|
log.debug("Parameter calculation is done");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void shutdown(){
|
public void shutdown(){
|
||||||
shutdown=true;
|
shutdown=true;
|
||||||
}
|
}
|
||||||
|
@ -267,6 +268,7 @@ class TotalInd implements Runnable{
|
||||||
this.totalCountQuery = totalCountQuery;
|
this.totalCountQuery = totalCountQuery;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void run(){
|
public void run(){
|
||||||
int totalInd=0;
|
int totalInd=0;
|
||||||
Query query;
|
Query query;
|
||||||
|
|
|
@ -9,13 +9,13 @@ import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.PREFE
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||||
|
@ -44,7 +44,7 @@ public class VIVOValuesFromVcards implements DocumentModifier {
|
||||||
|
|
||||||
private static final ResultParser PREFERRED_TITLE_PARSER = new ResultParser() {
|
private static final ResultParser PREFERRED_TITLE_PARSER = new ResultParser() {
|
||||||
@Override
|
@Override
|
||||||
public void parse(String uri, QuerySolution solution, SolrInputDocument doc) {
|
public void parse(String uri, QuerySolution solution, SearchInputDocument doc) {
|
||||||
String title = getLiteralValue(solution, "title");
|
String title = getLiteralValue(solution, "title");
|
||||||
if (StringUtils.isNotBlank(title)) {
|
if (StringUtils.isNotBlank(title)) {
|
||||||
doc.addField(PREFERRED_TITLE, title);
|
doc.addField(PREFERRED_TITLE, title);
|
||||||
|
@ -68,7 +68,7 @@ public class VIVOValuesFromVcards implements DocumentModifier {
|
||||||
private static final ResultParser EMAIL_PARSER = new ResultParser() {
|
private static final ResultParser EMAIL_PARSER = new ResultParser() {
|
||||||
@Override
|
@Override
|
||||||
public void parse(String uri, QuerySolution solution,
|
public void parse(String uri, QuerySolution solution,
|
||||||
SolrInputDocument doc) {
|
SearchInputDocument doc) {
|
||||||
String email = getLiteralValue(solution, "email");
|
String email = getLiteralValue(solution, "email");
|
||||||
if (StringUtils.isNotBlank(email)) {
|
if (StringUtils.isNotBlank(email)) {
|
||||||
doc.addField(ALLTEXT, email);
|
doc.addField(ALLTEXT, email);
|
||||||
|
@ -85,7 +85,7 @@ public class VIVOValuesFromVcards implements DocumentModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyDocument(Individual individual, SolrInputDocument doc,
|
public void modifyDocument(Individual individual, SearchInputDocument doc,
|
||||||
StringBuffer addUri) {
|
StringBuffer addUri) {
|
||||||
if (individual == null)
|
if (individual == null)
|
||||||
return;
|
return;
|
||||||
|
@ -96,7 +96,7 @@ public class VIVOValuesFromVcards implements DocumentModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processQuery(Individual individual, String queryTemplate,
|
private void processQuery(Individual individual, String queryTemplate,
|
||||||
ResultParser resultParser, SolrInputDocument doc) {
|
ResultParser resultParser, SearchInputDocument doc) {
|
||||||
String uri = "<" + individual.getURI() + "> ";
|
String uri = "<" + individual.getURI() + "> ";
|
||||||
String query = queryTemplate.replaceAll("\\?uri", uri);
|
String query = queryTemplate.replaceAll("\\?uri", uri);
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class VIVOValuesFromVcards implements DocumentModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract static class ResultParser {
|
private abstract static class ResultParser {
|
||||||
public abstract void parse(String uri, QuerySolution solution, SolrInputDocument doc);
|
public abstract void parse(String uri, QuerySolution solution, SearchInputDocument doc);
|
||||||
|
|
||||||
String getLiteralValue(QuerySolution solution, String name) {
|
String getLiteralValue(QuerySolution solution, String name) {
|
||||||
RDFNode node = solution.get(name);
|
RDFNode node = solution.get(name);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.search.solr;
|
package edu.cornell.mannlib.vitro.webapp.search.solr;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.search.solr;
|
package edu.cornell.mannlib.vitro.webapp.search.solr;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,24 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import stubs.edu.cornell.mannlib.vitro.webapp.modules.ApplicationStub;
|
||||||
|
import stubs.edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineStub;
|
||||||
|
import stubs.javax.servlet.ServletContextStub;
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
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.RDFServiceFactorySingle;
|
||||||
|
@ -32,6 +37,7 @@ public class VivoInformationResourceContextNodeFieldsTest extends AbstractTestCl
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoLabel() throws IOException{
|
public void testNoLabel() throws IOException{
|
||||||
|
ApplicationStub.setup(new ServletContextStub(), new SearchEngineStub());
|
||||||
|
|
||||||
//Test that rdfs:label is NOT added by the VivoInformationResourceContextNodeFields
|
//Test that rdfs:label is NOT added by the VivoInformationResourceContextNodeFields
|
||||||
|
|
||||||
|
@ -51,13 +57,13 @@ public class VivoInformationResourceContextNodeFieldsTest extends AbstractTestCl
|
||||||
|
|
||||||
RDFService rdfService = new RDFServiceModel(ontModel);
|
RDFService rdfService = new RDFServiceModel(ontModel);
|
||||||
RDFServiceFactory rdfServiceFactory = new RDFServiceFactorySingle(rdfService);
|
RDFServiceFactory rdfServiceFactory = new RDFServiceFactorySingle(rdfService);
|
||||||
SolrInputDocument doc = new SolrInputDocument();
|
SearchInputDocument doc = ApplicationUtils.instance().getSearchEngine().createInputDocument();
|
||||||
doc.addField("ALLTEXT", "");
|
doc.addField("ALLTEXT", "");
|
||||||
|
|
||||||
VivoInformationResourceContextNodeFields vircnf = new VivoInformationResourceContextNodeFields(rdfServiceFactory);
|
VivoInformationResourceContextNodeFields vircnf = new VivoInformationResourceContextNodeFields(rdfServiceFactory);
|
||||||
vircnf.modifyDocument(ind, doc, new StringBuffer());
|
vircnf.modifyDocument(ind, doc, new StringBuffer());
|
||||||
|
|
||||||
Collection values = doc.getFieldValues("ALLTEXT");
|
Collection<Object> values = doc.getField("ALLTEXT").getValues();
|
||||||
for( Object value : values){
|
for( Object value : values){
|
||||||
Assert.assertFalse("rdf:label erroneously added by document modifier:", value.toString().contains(RDFS_LABEL_VALUE));
|
Assert.assertFalse("rdf:label erroneously added by document modifier:", value.toString().contains(RDFS_LABEL_VALUE));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue