From 7abaa39fa325c440da4bee6514235692b6eb526f Mon Sep 17 00:00:00 2001 From: briancaruso Date: Wed, 27 Jul 2011 12:58:04 +0000 Subject: [PATCH] Merge from 1.3 maint --- webapp/ontologies/app/listViewConfig.owl | 22 -------- .../freemarker/IndividualListController.java | 9 ++-- .../AdditionalURIsForTypeStatements.java | 29 +++++++++++ .../vitro/webapp/search/solr/SolrSetup.java | 2 + .../AdditionalURIsForTypeStatementsTest.java | 50 +++++++++++++++++++ 5 files changed, 86 insertions(+), 26 deletions(-) delete mode 100644 webapp/ontologies/app/listViewConfig.owl create mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForTypeStatements.java create mode 100644 webapp/test/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForTypeStatementsTest.java diff --git a/webapp/ontologies/app/listViewConfig.owl b/webapp/ontologies/app/listViewConfig.owl deleted file mode 100644 index e5f08a5ad..000000000 --- a/webapp/ontologies/app/listViewConfig.owl +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - -]> - - - - - listViewConfig-hasElement.xml - - - \ No newline at end of file diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java index 12bcaafbf..f3ae0acb5 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java @@ -319,14 +319,15 @@ public class IndividualListController extends FreemarkerHttpServlet { } SolrQuery query = new SolrQuery(queryText); - - query.setStart( page > 0 ? pageSize * page + 1 : 0 ) - .setRows( pageSize ); + + //page count starts at 1, row count starts at 0 + int startRow = (page-1) * pageSize ; + query.setStart( startRow ).setRows( pageSize ); // Need a single-valued field for sorting query.setSortField(VitroSearchTermNames.NAME_LOWERCASE_SINGLE_VALUED, SolrQuery.ORDER.asc); - log.debug("Query text is " + queryText); + log.debug("Query is " + query.toString()); return query; } catch (Exception ex){ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForTypeStatements.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForTypeStatements.java new file mode 100644 index 000000000..0be6a2834 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForTypeStatements.java @@ -0,0 +1,29 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ +/** + * + */ +package edu.cornell.mannlib.vitro.webapp.search.indexing; + +import java.util.Collections; +import java.util.List; + +import com.hp.hpl.jena.rdf.model.Statement; +import com.hp.hpl.jena.vocabulary.RDF; + +import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate; + +/** + * Adds URIs to index for type statement changes on individuals. + */ +public class AdditionalURIsForTypeStatements implements StatementToURIsToUpdate { + + @Override + public List findAdditionalURIsToIndex(Statement stmt) { + if( stmt != null && RDF.type.getURI().equals( stmt.getPredicate().getURI() )){ + return Collections.singletonList( stmt.getSubject().getURI() ); + }else{ + return Collections.emptyList(); + } + } + +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java index 23cf7c7ac..f6674df6f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java @@ -35,6 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate; import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForContextNodes; import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForDataProperties; import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForObjectProperties; +import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForTypeStatements; import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder; import edu.cornell.mannlib.vitro.webapp.search.indexing.SearchReindexingListener; import edu.cornell.mannlib.vitro.webapp.servlet.setup.AbortStartup; @@ -112,6 +113,7 @@ public class SolrSetup implements javax.servlet.ServletContextListener{ uriFinders.add( new AdditionalURIsForDataProperties() ); uriFinders.add( new AdditionalURIsForObjectProperties(jenaOntModel) ); uriFinders.add( new AdditionalURIsForContextNodes(jenaOntModel) ); + uriFinders.add( new AdditionalURIsForTypeStatements() ); IndexBuilder builder = new IndexBuilder( solrIndexer, wadf, uriFinders ); // to the servlet context so we can access it later in the webapp. diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForTypeStatementsTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForTypeStatementsTest.java new file mode 100644 index 000000000..fe9a6c9d7 --- /dev/null +++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForTypeStatementsTest.java @@ -0,0 +1,50 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ +/** + * + */ +package edu.cornell.mannlib.vitro.webapp.search.indexing; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.hp.hpl.jena.rdf.model.ResourceFactory; +import com.hp.hpl.jena.rdf.model.Statement; + +/** + * @author bdc34 + * + */ +public class AdditionalURIsForTypeStatementsTest { + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + } + + /** + * Test method for {@link edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForTypeStatements#findAdditionalURIsToIndex(com.hp.hpl.jena.rdf.model.Statement)}. + */ + @Test + public void testFindAdditionalURIsToIndex() { + AdditionalURIsForTypeStatements aufts = new AdditionalURIsForTypeStatements(); + + String subject = "http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n3270"; + Statement typeChangeStatement = ResourceFactory.createStatement( + ResourceFactory.createResource(subject), + ResourceFactory.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), + ResourceFactory.createResource( "http://caruso-laptop.mannlib.cornell.edu:8090/vivo/ontology/localOnt#LocalInternalClass")); + + + List uris = aufts.findAdditionalURIsToIndex( typeChangeStatement ); + + Assert.assertNotNull(uris); + Assert.assertTrue("Did not contain subject of type change statement", uris.contains(subject)); + } + +}