Merge branch 'maint-rel-1.6' into develop
This commit is contained in:
commit
63ca6c86e9
2 changed files with 45 additions and 29 deletions
|
@ -1,44 +1,57 @@
|
||||||
/* $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.documentBuilding;
|
package edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.search.solr.documentBuilding.IndividualToSolrDocument.DONT_EXCLUDE;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exclude individuals with types from the Vitro namespace from the
|
* Exclude individuals with most specific types from the Vitro namespace from
|
||||||
* search index. (Other than old vitro Flag types).
|
* the search index. (Other than old vitro Flag types).
|
||||||
*/
|
*/
|
||||||
public class ExcludeNonFlagVitro implements SearchIndexExcluder {
|
public class ExcludeNonFlagVitro implements SearchIndexExcluder {
|
||||||
|
private static final Log log = LogFactory.getLog(ExcludeNonFlagVitro.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String checkForExclusion(Individual ind) {
|
public String checkForExclusion(Individual ind) {
|
||||||
if( ind != null && ind.getVClasses() != null ) {
|
if (ind == null) {
|
||||||
String excludeMsg = skipIfVitro(ind, ind.getVClasses() );
|
return DONT_EXCLUDE;
|
||||||
if( excludeMsg != null)
|
}
|
||||||
return excludeMsg;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String skipIfVitro(Individual ind, List<VClass> vclasses) {
|
List<String> mostSpecificTypeUris = ind.getMostSpecificTypeURIs();
|
||||||
for( VClass type: vclasses ){
|
if (mostSpecificTypeUris == null) {
|
||||||
if( type != null && type.getURI() != null ){
|
return DONT_EXCLUDE;
|
||||||
String typeURI = type.getURI();
|
}
|
||||||
|
|
||||||
if(typeURI.startsWith( VitroVocabulary.vitroURI )
|
String message = skipIfVitro(ind, mostSpecificTypeUris);
|
||||||
&& ! typeURI.startsWith(VitroVocabulary.vitroURI + "Flag") ){
|
if (!StringUtils.equals(DONT_EXCLUDE, message)) {
|
||||||
|
log.debug("msg=" + message + ", individual=" + ind.getURI() + " ("
|
||||||
|
+ ind.getLabel() + "), types=" + mostSpecificTypeUris);
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
return "Skipped " + ind.getURI()+" because in "
|
String skipIfVitro(Individual ind, List<String> mostSpecificTypeUris) {
|
||||||
+ VitroVocabulary.vitroURI + " namespace";
|
for (String typeUri : mostSpecificTypeUris) {
|
||||||
}
|
if (typeUri == null) {
|
||||||
}
|
continue;
|
||||||
}
|
}
|
||||||
return null;
|
if (typeUri.startsWith(VitroVocabulary.vitroURI + "Flag")) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
if (typeUri.startsWith(VitroVocabulary.vitroURI)) {
|
||||||
|
return "Skipped " + ind.getURI() + " because in "
|
||||||
|
+ VitroVocabulary.vitroURI + " namespace";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DONT_EXCLUDE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,9 @@ public class IndividualToSolrDocument {
|
||||||
for( SearchIndexExcluder excluder : excludes){
|
for( SearchIndexExcluder excluder : excludes){
|
||||||
try{
|
try{
|
||||||
String msg = excluder.checkForExclusion(ind);
|
String msg = excluder.checkForExclusion(ind);
|
||||||
|
log.debug("individual=" + ind.getURI() + " (" + ind.getLabel()
|
||||||
|
+ "), excluder=" + excluder + ", types="
|
||||||
|
+ ind.getMostSpecificTypeURIs() + ", msg=" + msg);
|
||||||
if( msg != DONT_EXCLUDE)
|
if( msg != DONT_EXCLUDE)
|
||||||
return msg;
|
return msg;
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue