View Javadoc
1   /*
2    * The baseCode project
3    *
4    * Copyright (c) 2013 University of British Columbia
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
7    * the License. You may obtain a copy of the License at
8    *
9    * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
12   * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
13   * specific language governing permissions and limitations under the License.
14   */
15  package ubic.basecode.ontology.providers;
16  
17  import com.hp.hpl.jena.ontology.OntModel;
18  import ubic.basecode.ontology.jena.AbstractOntologyMemoryBackedService;
19  import ubic.basecode.ontology.jena.OntologyLoader;
20  
21  import ubic.basecode.ontology.jena.AbstractOntologyService;
22  
23  import java.io.InputStream;
24  
25  /**
26   * A way to create ad hoc ontology services (in memory) for testing
27   *
28   * @author Paul
29   */
30  public class GenericOntologyService extends AbstractOntologyMemoryBackedService {
31  
32      private final String url;
33      private final String name;
34      private final boolean cache;
35  
36      public GenericOntologyService( String name, String url ) {
37          this( name, url, false );
38      }
39  
40      public GenericOntologyService( String name, String url, boolean cache ) {
41          this.name = name;
42          this.url = url;
43          this.cache = cache;
44      }
45  
46      @Override
47      protected String getOntologyName() {
48          return name;
49      }
50  
51      @Override
52      protected String getOntologyUrl() {
53          return url;
54      }
55  
56      @Override
57      protected String getCacheName() {
58          return this.cache ? this.name : null;
59      }
60  }