/*
 * The Gemma project
 * 
 * Copyright (c) 2007 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.gemma.ontology;

import java.util.Collection;

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

import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.query.larq.IndexLARQ;

import junit.framework.TestCase;

/**
 * @author pavlidis
 * @version $Id$
 */
public class OntologyIndexerTest extends TestCase {

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

    public final void testIndexing() throws Exception {
        String url = "http://www.berkeleybop.org/ontologies/obo-all/mged/mged.owl";
        OntModel model = OntologyLoader.getMemoryModel( url, OntModelSpec.OWL_MEM_RDFS_INF );
        IndexLARQ index = OntologyIndexer.indexOntology( url, "mged", model );
        Collection<OntologyTerm> name = OntologySearch.matchClasses( model, index, "bedding" );
        assertEquals( 1, name.size() );
    }

    public final void testIndexingDbModel() throws Exception {
        // MESH must be loaded into the DB for this to work in a reasonable amount of time!
        String url = "http://www.berkeleybop.org/ontologies/obo-all/mesh/mesh.owl";
        OntModel model = OntologyLoader.loadPersistentModel( url, false );

        // should be a one-time process
        // log.info( "Indexing..." );
        IndexLARQ index = OntologyIndexer.indexOntology( url, "mesh", model );
        index = OntologyIndexer.getSubjectIndex( "mesh" );

        log.info( "Searching ... " );
        Collection<OntologyTerm> name = OntologySearch.matchClasses( model, index, "anatomy" );
        assertEquals( 7, name.size() );
    }
}

@@ -1322,19 +1322,20 @@
 yLoader.
-get
+load
 MemoryMo
@@ -1433,21 +1433,16 @@
 ntology(
- url,
  %22mged%22,
@@ -1545,14 +1545,49 @@
 ddin
-g
+*
 %22 );%0A
+        log.info(name.toString());%0A
     
@@ -1629,24 +1629,26 @@
 %0A    %7D%0A%0A    
+/*
 public final
@@ -1942,24 +1942,33 @@
 , false );%0A%0A
+        %0A
         // s
@@ -2089,21 +2089,16 @@
 ntology(
- url,
  %22mesh%22,
@@ -2346,11 +2346,13 @@
 );%0A    %7D
+*/
 %0A%7D%0A

change so that Indexer reload ontology, just lists statements