Merge branch 'issue-vivo-15' into develop
This commit is contained in:
commit
1c4bb63016
4 changed files with 71 additions and 42 deletions
|
@ -860,7 +860,7 @@
|
||||||
class="solr.XmlUpdateRequestHandler">
|
class="solr.XmlUpdateRequestHandler">
|
||||||
<!-- Run the etag processor on each update request. -->
|
<!-- Run the etag processor on each update request. -->
|
||||||
<lst name="defaults">
|
<lst name="defaults">
|
||||||
<str name="update.processor">etag</str>
|
<str name="update.chain">etag</str>
|
||||||
</lst>
|
</lst>
|
||||||
</requestHandler>
|
</requestHandler>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.filtering;
|
package edu.cornell.mannlib.vitro.webapp.dao.filtering;
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_LITERAL;
|
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.*;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -58,6 +58,8 @@ public class IndividualFiltering implements Individual {
|
||||||
public List<DataProperty> getDataPropertyList() {
|
public List<DataProperty> getDataPropertyList() {
|
||||||
List<DataProperty> dprops = _innerIndividual.getDataPropertyList();
|
List<DataProperty> dprops = _innerIndividual.getDataPropertyList();
|
||||||
LinkedList<DataProperty> outdProps = new LinkedList<DataProperty>();
|
LinkedList<DataProperty> outdProps = new LinkedList<DataProperty>();
|
||||||
|
if( dprops == null )
|
||||||
|
return outdProps;
|
||||||
Filter.filter(dprops,_filters.getDataPropertyFilter(), outdProps);
|
Filter.filter(dprops,_filters.getDataPropertyFilter(), outdProps);
|
||||||
|
|
||||||
ListIterator<DataProperty> it = outdProps.listIterator();
|
ListIterator<DataProperty> it = outdProps.listIterator();
|
||||||
|
@ -83,6 +85,8 @@ public class IndividualFiltering implements Individual {
|
||||||
// the DataProperty with statements. - jblake
|
// the DataProperty with statements. - jblake
|
||||||
List<DataProperty> outdProps = new ArrayList<DataProperty>();
|
List<DataProperty> outdProps = new ArrayList<DataProperty>();
|
||||||
List<DataProperty> dprops = _innerIndividual.getPopulatedDataPropertyList();
|
List<DataProperty> dprops = _innerIndividual.getPopulatedDataPropertyList();
|
||||||
|
if( dprops == null )
|
||||||
|
return outdProps;
|
||||||
for (DataProperty dp: dprops) {
|
for (DataProperty dp: dprops) {
|
||||||
if (_filters.getDataPropertyStatementFilter().fn(
|
if (_filters.getDataPropertyStatementFilter().fn(
|
||||||
new DataPropertyStatementImpl(this._innerIndividual.getURI(), dp.getURI(), SOME_LITERAL))) {
|
new DataPropertyStatementImpl(this._innerIndividual.getURI(), dp.getURI(), SOME_LITERAL))) {
|
||||||
|
@ -106,6 +110,8 @@ public class IndividualFiltering implements Individual {
|
||||||
|
|
||||||
private List<DataPropertyStatement> filterDataPropertyStatements(List<DataPropertyStatement> dStmts) {
|
private List<DataPropertyStatement> filterDataPropertyStatements(List<DataPropertyStatement> dStmts) {
|
||||||
List<DataPropertyStatement> outDstmts = new LinkedList<DataPropertyStatement>();
|
List<DataPropertyStatement> outDstmts = new LinkedList<DataPropertyStatement>();
|
||||||
|
if( dStmts == null )
|
||||||
|
return outDstmts;
|
||||||
Filter.filter(dStmts,_filters.getDataPropertyStatementFilter(), outDstmts);
|
Filter.filter(dStmts,_filters.getDataPropertyStatementFilter(), outDstmts);
|
||||||
return outDstmts;
|
return outDstmts;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +120,7 @@ public class IndividualFiltering implements Individual {
|
||||||
public Map<String, DataProperty> getDataPropertyMap() {
|
public Map<String, DataProperty> getDataPropertyMap() {
|
||||||
Map<String,DataProperty> innerMap = _innerIndividual.getDataPropertyMap();
|
Map<String,DataProperty> innerMap = _innerIndividual.getDataPropertyMap();
|
||||||
if( innerMap == null )
|
if( innerMap == null )
|
||||||
return null;
|
return Collections.emptyMap();
|
||||||
|
|
||||||
Map<String,DataProperty> returnMap = new HashMap<String,DataProperty>();
|
Map<String,DataProperty> returnMap = new HashMap<String,DataProperty>();
|
||||||
for( String key : innerMap.keySet() ){
|
for( String key : innerMap.keySet() ){
|
||||||
|
@ -136,8 +142,6 @@ public class IndividualFiltering implements Individual {
|
||||||
@Override
|
@Override
|
||||||
public List<ObjectProperty> getObjectPropertyList() {
|
public List<ObjectProperty> getObjectPropertyList() {
|
||||||
List <ObjectProperty> oprops = _innerIndividual.getObjectPropertyList();
|
List <ObjectProperty> oprops = _innerIndividual.getObjectPropertyList();
|
||||||
// List<ObjectProperty> outOProps = new LinkedList<ObjectProperty>();
|
|
||||||
// Filter.filter(oprops, _filters.getObjectPropertyFilter(), outOProps);
|
|
||||||
return ObjectPropertyDaoFiltering.filterAndWrap(oprops, _filters);
|
return ObjectPropertyDaoFiltering.filterAndWrap(oprops, _filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,6 +467,9 @@ public class IndividualFiltering implements Individual {
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDataValues(String propertyUri) {
|
public List<String> getDataValues(String propertyUri) {
|
||||||
List<DataPropertyStatement> stmts = getDataPropertyStatements(propertyUri);
|
List<DataPropertyStatement> stmts = getDataPropertyStatements(propertyUri);
|
||||||
|
if( stmts == null )
|
||||||
|
return Collections.emptyList();
|
||||||
|
|
||||||
// Since the statements have been filtered, we can just take the data values without filtering.
|
// Since the statements have been filtered, we can just take the data values without filtering.
|
||||||
List<String> dataValues = new ArrayList<String>(stmts.size());
|
List<String> dataValues = new ArrayList<String>(stmts.size());
|
||||||
for (DataPropertyStatement stmt : stmts) {
|
for (DataPropertyStatement stmt : stmts) {
|
||||||
|
@ -474,6 +481,9 @@ public class IndividualFiltering implements Individual {
|
||||||
@Override
|
@Override
|
||||||
public String getDataValue(String propertyUri) {
|
public String getDataValue(String propertyUri) {
|
||||||
List<DataPropertyStatement> stmts = getDataPropertyStatements(propertyUri);
|
List<DataPropertyStatement> stmts = getDataPropertyStatements(propertyUri);
|
||||||
|
if( stmts == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
// Since the statements have been filtered, we can just take the first data value without filtering.
|
// Since the statements have been filtered, we can just take the first data value without filtering.
|
||||||
return stmts.isEmpty() ? null : stmts.get(0).getData();
|
return stmts.isEmpty() ? null : stmts.get(0).getData();
|
||||||
}
|
}
|
||||||
|
@ -481,6 +491,9 @@ public class IndividualFiltering implements Individual {
|
||||||
@Override
|
@Override
|
||||||
public DataPropertyStatement getDataPropertyStatement(String propertyUri) {
|
public DataPropertyStatement getDataPropertyStatement(String propertyUri) {
|
||||||
List<DataPropertyStatement> stmts = getDataPropertyStatements(propertyUri);
|
List<DataPropertyStatement> stmts = getDataPropertyStatements(propertyUri);
|
||||||
|
if( stmts == null )
|
||||||
|
return null;
|
||||||
|
|
||||||
// Since the statements have been filtered, we can just take the first data value without filtering.
|
// Since the statements have been filtered, we can just take the first data value without filtering.
|
||||||
return stmts.isEmpty() ? null : stmts.get(0);
|
return stmts.isEmpty() ? null : stmts.get(0);
|
||||||
}
|
}
|
||||||
|
@ -488,6 +501,9 @@ public class IndividualFiltering implements Individual {
|
||||||
@Override
|
@Override
|
||||||
public List<Individual> getRelatedIndividuals(String propertyUri) {
|
public List<Individual> getRelatedIndividuals(String propertyUri) {
|
||||||
List<ObjectPropertyStatement> stmts = getObjectPropertyStatements(propertyUri);
|
List<ObjectPropertyStatement> stmts = getObjectPropertyStatements(propertyUri);
|
||||||
|
if( stmts == null)
|
||||||
|
return Collections.emptyList();
|
||||||
|
|
||||||
// Since the statements have been filtered, we can just take the individuals without filtering.
|
// Since the statements have been filtered, we can just take the individuals without filtering.
|
||||||
List<Individual> relatedIndividuals = new ArrayList<Individual>(stmts.size());
|
List<Individual> relatedIndividuals = new ArrayList<Individual>(stmts.size());
|
||||||
for (ObjectPropertyStatement stmt : stmts) {
|
for (ObjectPropertyStatement stmt : stmts) {
|
||||||
|
@ -499,6 +515,9 @@ public class IndividualFiltering implements Individual {
|
||||||
@Override
|
@Override
|
||||||
public Individual getRelatedIndividual(String propertyUri) {
|
public Individual getRelatedIndividual(String propertyUri) {
|
||||||
List<ObjectPropertyStatement> stmts = getObjectPropertyStatements(propertyUri);
|
List<ObjectPropertyStatement> stmts = getObjectPropertyStatements(propertyUri);
|
||||||
|
if( stmts == null )
|
||||||
|
return null;
|
||||||
|
|
||||||
// Since the statements have been filtered, we can just take the first individual without filtering.
|
// Since the statements have been filtered, we can just take the first individual without filtering.
|
||||||
return stmts.isEmpty() ? null : stmts.get(0).getObject();
|
return stmts.isEmpty() ? null : stmts.get(0).getObject();
|
||||||
}
|
}
|
||||||
|
@ -507,4 +526,4 @@ public class IndividualFiltering implements Individual {
|
||||||
public boolean hasThumb() {
|
public boolean hasThumb() {
|
||||||
return _innerIndividual.hasThumb();
|
return _innerIndividual.hasThumb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.search.solr;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -19,7 +18,6 @@ import org.apache.solr.common.SolrInputDocument;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
|
import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.beans.IndexerIface;
|
import edu.cornell.mannlib.vitro.webapp.search.beans.IndexerIface;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.docbuilder.Obj2DocIface;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSolrDocument;
|
import edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSolrDocument;
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,7 +157,7 @@ public class SolrIndexer implements IndexerIface {
|
||||||
log.debug("could not remove documents from before build, " ,e);
|
log.debug("could not remove documents from before build, " ,e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
UpdateResponse res = server.commit();
|
server.commit();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if( ! shutdownRequested ){
|
if( ! shutdownRequested ){
|
||||||
log.debug("could not commit to solr server, " +
|
log.debug("could not commit to solr server, " +
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.shared.JenaException;
|
||||||
import com.hp.hpl.jena.vocabulary.OWL;
|
import com.hp.hpl.jena.vocabulary.OWL;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
|
@ -160,23 +161,28 @@ public class IndividualToSolrDocument {
|
||||||
//ALLTEXT, all of the 'full text'
|
//ALLTEXT, all of the 'full text'
|
||||||
StringBuffer allTextValue = new StringBuffer();
|
StringBuffer allTextValue = new StringBuffer();
|
||||||
|
|
||||||
//collecting data property statements
|
try{
|
||||||
List<DataPropertyStatement> dataPropertyStatements = ind.getDataPropertyStatements();
|
//collecting data property statements
|
||||||
if (dataPropertyStatements != null) {
|
List<DataPropertyStatement> dataPropertyStatements = ind.getDataPropertyStatements();
|
||||||
Iterator<DataPropertyStatement> dataPropertyStmtIter = dataPropertyStatements.iterator();
|
if (dataPropertyStatements != null) {
|
||||||
while (dataPropertyStmtIter.hasNext()) {
|
Iterator<DataPropertyStatement> dataPropertyStmtIter = dataPropertyStatements.iterator();
|
||||||
DataPropertyStatement dataPropertyStmt = dataPropertyStmtIter.next();
|
while (dataPropertyStmtIter.hasNext()) {
|
||||||
if(dataPropertyStmt.getDatapropURI().equals(label)){ // we don't want label to be added to alltext
|
DataPropertyStatement dataPropertyStmt = dataPropertyStmtIter.next();
|
||||||
continue;
|
if(dataPropertyStmt.getDatapropURI().equals(label)){ // we don't want label to be added to alltext
|
||||||
} else if(dataPropertyStmt.getDatapropURI().equals("http://vivoweb.org/ontology/core#preferredTitle")){
|
continue;
|
||||||
//add the preferredTitle field
|
} else if(dataPropertyStmt.getDatapropURI().equals("http://vivoweb.org/ontology/core#preferredTitle")){
|
||||||
String preferredTitle = null;
|
//add the preferredTitle field
|
||||||
doc.addField(term.PREFERRED_TITLE, ((preferredTitle=dataPropertyStmt.getData()) == null)?"":preferredTitle);
|
String preferredTitle = null;
|
||||||
log.debug("Preferred Title: " + dataPropertyStmt.getData());
|
doc.addField(term.PREFERRED_TITLE, ((preferredTitle=dataPropertyStmt.getData()) == null)?"":preferredTitle);
|
||||||
|
log.debug("Preferred Title: " + dataPropertyStmt.getData());
|
||||||
|
}
|
||||||
|
allTextValue.append(" ");
|
||||||
|
allTextValue.append(((t=dataPropertyStmt.getData()) == null)?"":t);
|
||||||
}
|
}
|
||||||
allTextValue.append(" ");
|
|
||||||
allTextValue.append(((t=dataPropertyStmt.getData()) == null)?"":t);
|
|
||||||
}
|
}
|
||||||
|
}catch(JenaException je){
|
||||||
|
//VIVO-15 Trap for characters that cause search indexing to abort
|
||||||
|
log.error(String.format("Continuing to index %s but could not get all dataproperties because %s",ind.getURI(),je.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
allTextValue.append(objectNames.toString());
|
allTextValue.append(objectNames.toString());
|
||||||
|
@ -209,25 +215,31 @@ public class IndividualToSolrDocument {
|
||||||
*/
|
*/
|
||||||
protected void addObjectPropertyText(Individual ind, SolrInputDocument doc,
|
protected void addObjectPropertyText(Individual ind, SolrInputDocument doc,
|
||||||
StringBuffer objectNames, StringBuffer addUri) {
|
StringBuffer objectNames, StringBuffer addUri) {
|
||||||
List<ObjectPropertyStatement> objectPropertyStatements = ind.getObjectPropertyStatements();
|
|
||||||
if (objectPropertyStatements != null) {
|
try{
|
||||||
Iterator<ObjectPropertyStatement> objectPropertyStmtIter = objectPropertyStatements.iterator();
|
List<ObjectPropertyStatement> objectPropertyStatements = ind.getObjectPropertyStatements();
|
||||||
while (objectPropertyStmtIter.hasNext()) {
|
if (objectPropertyStatements != null) {
|
||||||
ObjectPropertyStatement objectPropertyStmt = objectPropertyStmtIter.next();
|
Iterator<ObjectPropertyStatement> objectPropertyStmtIter = objectPropertyStatements.iterator();
|
||||||
if( "http://www.w3.org/2002/07/owl#differentFrom".equals(objectPropertyStmt.getPropertyURI()) ){
|
while (objectPropertyStmtIter.hasNext()) {
|
||||||
continue;
|
ObjectPropertyStatement objectPropertyStmt = objectPropertyStmtIter.next();
|
||||||
|
if( "http://www.w3.org/2002/07/owl#differentFrom".equals(objectPropertyStmt.getPropertyURI()) ){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
objectNames.append(" ");
|
||||||
|
String t=null;
|
||||||
|
objectNames.append(((t=objectPropertyStmt.getObject().getRdfsLabel()) == null)?"":t);
|
||||||
|
addUri.append(" ");
|
||||||
|
addUri.append(((t=objectPropertyStmt.getObject().getURI()) == null)?"":t);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug("could not index name of related object: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
}
|
||||||
objectNames.append(" ");
|
}catch(JenaException je){
|
||||||
String t=null;
|
//VIVO-15 Trap for characters that cause search indexing to abort
|
||||||
objectNames.append(((t=objectPropertyStmt.getObject().getRdfsLabel()) == null)?"":t);
|
log.error(String.format("Continuing to index %s but could not get all object properties because %s",ind.getURI(),je.getMessage()));
|
||||||
addUri.append(" ");
|
}
|
||||||
addUri.append(((t=objectPropertyStmt.getObject().getURI()) == null)?"":t);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug("could not index name of related object: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue