/*
 * The Gemma project
 * 
 * Copyright (c) 2008 University of British Columbia
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package ubic.basecode.ontology.search;

import java.util.ArrayList;
import java.util.Collection;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Selector;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.impl.PropertyImpl;
import com.hp.hpl.jena.vocabulary.RDFS;

/**
 * Used to limit which parts of ontologies get indexed for searching.
 * 
 * @author paul
 * @version $Id$
 */
public class IndexerSelector implements Selector {

    private static Log log = LogFactory.getLog( IndexerSelector.class );

    Collection<Property> badPredicates;

    public IndexerSelector() {
        // these are predicates that in general should not be useful for indexing
        badPredicates = new ArrayList<Property>();
        badPredicates.add( RDFS.comment );
        badPredicates.add( RDFS.seeAlso );
        badPredicates.add( RDFS.isDefinedBy );
        badPredicates.add( new PropertyImpl( "http://www.w3.org/2004/02/skos/core#example" ) );
        badPredicates.add( new PropertyImpl( "http://neurolex.org/wiki/Special:URIResolver/Property-3AExample" ) );
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.hp.hpl.jena.rdf.model.Selector#getObject()
     */
    @Override
    public RDFNode getObject() {
        return null;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.hp.hpl.jena.rdf.model.Selector#getPredicate()
     */
    @Override
    public Property getPredicate() {
        return null;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.hp.hpl.jena.rdf.model.Selector#getSubject()
     */
    @Override
    public Resource getSubject() {
        return null;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.hp.hpl.jena.rdf.model.Selector#isSimple()
     */
    @Override
    public boolean isSimple() {
        return false;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.hp.hpl.jena.rdf.model.Selector#test(com.hp.hpl.jena.rdf.model.Statement)
     */
    @Override
    public boolean test( Statement s ) {
        boolean retain = !( badPredicates.contains( s.getPredicate() ) );
        if ( !retain && log.isDebugEnabled() ) log.debug( "Removed: " + s.getPredicate() + " " + s.getObject() );

        return retain;
    }
}

@@ -699,25 +699,26 @@
 va.util.
-ArrayList
+Collection
 ;%0Aimport
@@ -728,26 +728,23 @@
 va.util.
-Collection
+HashSet
 ;%0A%0Aimpor
@@ -1043,60 +1043,8 @@
 nt;%0A
-import com.hp.hpl.jena.rdf.model.impl.PropertyImpl;%0A
 impo
@@ -1325,16 +1325,30 @@
 );%0A%0A    
+private final 
 Collecti
@@ -1350,24 +1350,22 @@
 lection%3C
-Property
+String
 %3E badPre
@@ -1519,26 +1519,22 @@
 new 
-ArrayList%3CProperty
+HashSet%3CString
 %3E();
@@ -1573,16 +1573,25 @@
 .comment
+.getURI()
  );%0A    
@@ -1625,16 +1625,25 @@
 .seeAlso
+.getURI()
  );%0A    
@@ -1681,16 +1681,25 @@
 efinedBy
+.getURI()
  );%0A    
@@ -1721,32 +1721,86 @@
 es.add( 
-new PropertyImpl
+%22http://www.w3.org/2002/07/owl#inverseOf%22 );%0A        badPredicates.add
 ( %22http:
@@ -1834,26 +1834,24 @@
 ore#example%22
- )
  );%0A        
@@ -1872,26 +1872,8 @@
 add(
- new PropertyImpl(
  %22ht
@@ -1936,16 +1936,377 @@
 ample%22 )
+;%0A        badPredicates.add( %22http://www.ebi.ac.uk/efo/definition%22 );%0A        badPredicates.add( %22http://www.ebi.ac.uk/efo/bioportal_provenance%22 );%0A        badPredicates.add( %22http://www.ebi.ac.uk/efo/gwas_trait%22 );%0A        badPredicates.add( %22http://www.ebi.ac.uk/efo/definition_editor%22 );%0A        badPredicates.add( %22http://www.ebi.ac.uk/efo/example_of_usage%22
  );%0A    
@@ -3289,14 +3289,24 @@
 te()
+.getURI()
  ) );%0A
+%0A
     

fix for 3269