Skip to content

Commit 2118b18

Browse files
committed
Merge branch 'hotfix-1.1.18'
2 parents c67f90d + 629a722 commit 2118b18

43 files changed

Lines changed: 107 additions & 147 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<name>baseCode</name>
66
<groupId>baseCode</groupId>
77
<artifactId>baseCode</artifactId>
8-
<version>1.1.17</version>
8+
<version>1.1.18</version>
99
<inceptionYear>2003</inceptionYear>
1010
<description>
1111
<![CDATA[Data structures, math and statistics tools, and utilities that are often needed across projects.]]>

src/ubic/basecode/ontology/jena/AbstractOntologyMemoryBackedService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*/
1515
package ubic.basecode.ontology.jena;
1616

17-
import com.hp.hpl.jena.ontology.OntModel;
1817
import com.hp.hpl.jena.ontology.OntModelSpec;
18+
import ubic.basecode.ontology.model.OntologyModel;
1919
import ubic.basecode.util.Configuration;
2020

2121
import java.io.IOException;
@@ -35,13 +35,13 @@ protected String getOntologyUrl() {
3535
}
3636

3737
@Override
38-
protected OntModel loadModel( boolean processImports, InferenceMode inferenceMode ) throws IOException {
39-
return OntologyLoader.loadMemoryModel( this.getOntologyUrl(), this.getCacheName(), processImports, this.getSpec( inferenceMode ) );
38+
protected OntologyModel loadModel( boolean processImports, InferenceMode inferenceMode ) throws IOException {
39+
return new OntologyModelImpl( OntologyLoader.loadMemoryModel( this.getOntologyUrl(), this.getCacheName(), processImports, this.getSpec( inferenceMode ) ) );
4040
}
4141

4242
@Override
43-
protected OntModel loadModelFromStream( InputStream is, boolean processImports, InferenceMode inferenceMode ) {
44-
return OntologyLoader.loadMemoryModel( is, this.getOntologyUrl(), processImports, this.getSpec( inferenceMode ) );
43+
protected OntologyModel loadModelFromStream( InputStream is, boolean processImports, InferenceMode inferenceMode ) throws IOException {
44+
return new OntologyModelImpl( OntologyLoader.loadMemoryModel( is, this.getOntologyUrl(), processImports, this.getSpec( inferenceMode ) ) );
4545
}
4646

4747
private OntModelSpec getSpec( InferenceMode inferenceMode ) {

src/ubic/basecode/ontology/jena/AbstractOntologyResource.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,15 @@
3333
/**
3434
* @author pavlidis
3535
*/
36-
public abstract class AbstractOntologyResource implements OntologyResource {
36+
abstract class AbstractOntologyResource implements OntologyResource {
3737

3838
protected static Logger log = LoggerFactory.getLogger( AbstractOntologyResource.class );
3939

40-
private static final long serialVersionUID = 1L;
41-
4240
private static final Comparator<OntologyResource> comparator = Comparator
4341
.comparing( OntologyResource::getScore, nullsLast( reverseOrder() ) )
4442
.thenComparing( OntologyResource::getUri, nullsLast( naturalOrder() ) );
4543

46-
private transient final OntResource res;
44+
private final OntResource res;
4745
@Nullable
4846
private final Double score;
4947

src/ubic/basecode/ontology/jena/AbstractOntologyService.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,14 @@
2424
import com.hp.hpl.jena.rdf.arp.ParseException;
2525
import com.hp.hpl.jena.rdf.model.Property;
2626
import com.hp.hpl.jena.rdf.model.Resource;
27-
import com.hp.hpl.jena.shared.JenaException;
2827
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
2928
import org.apache.commons.lang3.RandomStringUtils;
3029
import org.apache.commons.lang3.StringUtils;
3130
import org.apache.commons.lang3.time.StopWatch;
3231
import org.slf4j.Logger;
3332
import org.slf4j.LoggerFactory;
34-
import ubic.basecode.ontology.jena.search.OntologyIndexer;
35-
import ubic.basecode.ontology.jena.search.OntologySearch;
36-
import ubic.basecode.ontology.jena.search.SearchIndex;
37-
import ubic.basecode.ontology.jena.vocabulary.BFO;
38-
import ubic.basecode.ontology.jena.vocabulary.RO;
3933
import ubic.basecode.ontology.model.OntologyIndividual;
34+
import ubic.basecode.ontology.model.OntologyModel;
4035
import ubic.basecode.ontology.model.OntologyResource;
4136
import ubic.basecode.ontology.model.OntologyTerm;
4237
import ubic.basecode.ontology.providers.OntologyService;
@@ -201,7 +196,12 @@ private void initialize( @Nullable InputStream stream, boolean forceLoad, boolea
201196
return;
202197

203198
try {
204-
model = stream != null ? loadModelFromStream( stream, processImports, inferenceMode ) : loadModel( processImports, inferenceMode ); // can take a while.
199+
OntologyModel m = stream != null ? loadModelFromStream( stream, processImports, inferenceMode ) : loadModel( processImports, inferenceMode ); // can take a while.
200+
if ( m instanceof OntologyModelImpl ) {
201+
model = ( ( OntologyModelImpl ) m ).getOntModel();
202+
} else {
203+
throw new RuntimeException( "Only Jena-based ontology models are supported." );
204+
}
205205
} catch ( Exception e ) {
206206
if ( isCausedByInterrupt( e ) ) {
207207
return;
@@ -491,7 +491,7 @@ public Collection<OntologyIndividual> getTermIndividuals( String uri ) {
491491

492492
@Override
493493
public Set<OntologyTerm> getParents( Collection<OntologyTerm> terms, boolean direct,
494-
boolean includeAdditionalProperties, boolean keepObsoletes ) {
494+
boolean includeAdditionalProperties, boolean keepObsoletes ) {
495495
Lock lock = rwLock.readLock();
496496
try {
497497
lock.lock();
@@ -510,7 +510,7 @@ public Set<OntologyTerm> getParents( Collection<OntologyTerm> terms, boolean dir
510510

511511
@Override
512512
public Set<OntologyTerm> getChildren( Collection<OntologyTerm> terms, boolean direct,
513-
boolean includeAdditionalProperties, boolean keepObsoletes ) {
513+
boolean includeAdditionalProperties, boolean keepObsoletes ) {
514514
Lock lock = rwLock.readLock();
515515
try {
516516
lock.lock();
@@ -615,13 +615,13 @@ public void waitForInitializationThread() throws InterruptedException {
615615
* Delegates the call as to load the model into memory or leave it on disk. Simply delegates to either
616616
* OntologyLoader.loadMemoryModel( url ); OR OntologyLoader.loadPersistentModel( url, spec );
617617
*/
618-
protected abstract OntModel loadModel( boolean processImports, InferenceMode inferenceMode ) throws JenaException, IOException;
618+
protected abstract OntologyModel loadModel( boolean processImports, InferenceMode inferenceMode ) throws IOException;
619619

620620

621621
/**
622622
* Load a model from a given input stream.
623623
*/
624-
protected abstract OntModel loadModelFromStream( InputStream stream, boolean processImports, InferenceMode inferenceMode ) throws JenaException, IOException;
624+
protected abstract OntologyModel loadModelFromStream( InputStream stream, boolean processImports, InferenceMode inferenceMode ) throws IOException;
625625

626626
/**
627627
* A name for caching this ontology, or null to disable caching.
@@ -633,6 +633,17 @@ protected String getCacheName() {
633633
return getOntologyName();
634634
}
635635

636+
private OntModelSpec getSpec( InferenceMode inferenceMode ) {
637+
switch ( inferenceMode ) {
638+
case TRANSITIVE:
639+
return OntModelSpec.OWL_MEM_TRANS_INF;
640+
case NONE:
641+
return OntModelSpec.OWL_MEM;
642+
default:
643+
throw new UnsupportedOperationException( String.format( "Unsupported inference level %s.", inferenceMode ) );
644+
}
645+
}
646+
636647
@Override
637648
public void index( boolean force ) {
638649
String cacheName = getCacheName();

src/ubic/basecode/ontology/jena/AnnotationPropertyImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.hp.hpl.jena.rdf.model.Resource;
2323
import com.hp.hpl.jena.rdf.model.Statement;
2424
import com.hp.hpl.jena.vocabulary.RDFS;
25-
import ubic.basecode.ontology.jena.vocabulary.OBO;
2625
import ubic.basecode.ontology.model.AnnotationProperty;
2726

2827
import javax.annotation.Nullable;
@@ -32,7 +31,7 @@
3231
*
3332
* @author pavlidis
3433
*/
35-
public class AnnotationPropertyImpl extends AbstractOntologyResource implements AnnotationProperty {
34+
class AnnotationPropertyImpl extends AbstractOntologyResource implements AnnotationProperty {
3635

3736
private final String contents;
3837

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package ubic.basecode.ontology.jena.vocabulary;
1+
package ubic.basecode.ontology.jena;
22

33
import com.hp.hpl.jena.rdf.model.Property;
44
import com.hp.hpl.jena.rdf.model.ResourceFactory;
55

6-
public class BFO {
6+
class BFO {
77
public static final Property partOf = ResourceFactory.createProperty( "http://purl.obolibrary.org/obo/BFO_0000050" );
88
}

src/ubic/basecode/ontology/jena/BnodeFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* @param <T>
1010
*/
11-
public class BnodeFilter<T extends Resource> extends Filter<T> {
11+
class BnodeFilter<T extends Resource> extends Filter<T> {
1212

1313
@Override
1414
public boolean accept( T o ) {

src/ubic/basecode/ontology/jena/DatatypePropertyImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525
*/
2626
class DatatypePropertyImpl extends OntologyPropertyImpl implements DatatypeProperty {
2727

28-
/**
29-
*
30-
*/
31-
private static final long serialVersionUID = 1L;
32-
3328
private final Class<?> type;
3429

3530
public DatatypePropertyImpl( com.hp.hpl.jena.ontology.DatatypeProperty resource ) {

src/ubic/basecode/ontology/jena/search/IndexerSelector.java renamed to src/ubic/basecode/ontology/jena/IndexerSelector.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
* limitations under the License.
1717
*
1818
*/
19-
package ubic.basecode.ontology.jena.search;
19+
package ubic.basecode.ontology.jena;
2020

2121
import com.hp.hpl.jena.rdf.model.*;
2222
import com.hp.hpl.jena.vocabulary.OWL2;
2323
import com.hp.hpl.jena.vocabulary.RDFS;
24-
import ubic.basecode.ontology.jena.vocabulary.OBO;
2524

2625
import java.util.Collection;
2726
import java.util.HashSet;
@@ -32,7 +31,7 @@
3231
*
3332
* @author paul
3433
*/
35-
public class IndexerSelector implements Selector {
34+
class IndexerSelector implements Selector {
3635

3736
private static final Collection<Property> wantedForIndexing;
3837

src/ubic/basecode/ontology/jena/JenaUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import static com.hp.hpl.jena.reasoner.ReasonerRegistry.makeDirect;
1818

19-
public class JenaUtils {
19+
class JenaUtils {
2020

2121
public static Collection<OntClass> getParents( OntModel model, Collection<OntClass> ontClasses, boolean direct, @Nullable Set<Restriction> additionalRestrictions ) {
2222
ontClasses = ontClasses.stream()

0 commit comments

Comments
 (0)