Skip to content

Commit af27f36

Browse files
committed
Merge branch 'hotfix-1.1.16'
2 parents 0af40fa + 14eb541 commit af27f36

24 files changed

Lines changed: 550 additions & 383 deletions

pom.xml

Lines changed: 5 additions & 2 deletions
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.15</version>
8+
<version>1.1.16</version>
99
<inceptionYear>2003</inceptionYear>
1010
<description>
1111
<![CDATA[Data structures, math and statistics tools, and utilities that are often needed across projects.]]>
@@ -275,6 +275,7 @@
275275
<resource>
276276
<directory>src</directory>
277277
<includes>
278+
<include>**/*.owl.gz</include>
278279
<include>**/*.properties</include>
279280
</includes>
280281
<filtering>false</filtering>
@@ -384,14 +385,16 @@
384385
<artifactId>maven-surefire-plugin</artifactId>
385386
<version>2.22.2</version>
386387
<configuration>
387-
<argLine>-enableassertions -Xmx1024m -Djava.awt.headless=true</argLine>
388+
<argLine>-enableassertions -Djava.awt.headless=true</argLine>
388389
<reportsDirectory>target/surefire-reports</reportsDirectory>
389390
<redirectTestOutputToFile>true</redirectTestOutputToFile>
390391
<includes>
391392
<include>**/Test*.java</include>
392393
<include>**/*Test.java</include>
393394
</includes>
394395
<excludes>
396+
<!-- these tests should be run manually since they require external data -->
397+
<exclude>**/providers/*Test.java</exclude>
395398
<exclude>**/AllTests.java</exclude>
396399
<exclude>**/gui/Test*.java</exclude>
397400
<exclude>**/AbstractTest*.java</exclude>
1.6 MB
Binary file not shown.
1.57 KB
Binary file not shown.

src/ontology.properties

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
# set to true to enable specific ontologies
22
load.diseaseOntology=false
33
load.fmaOntology=false
44
load.chebiOntology=false
@@ -32,11 +32,9 @@ url.uberonOntology=http://purl.obolibrary.org/obo/uberon.owl
3232
url.efOntology=https://www.ebi.ac.uk/efo/efo.owl
3333
url.obiOntology=http://purl.obolibrary.org/obo/obi.owl
3434

35-
3635
# no longer actively used.
37-
url.nifstdOntology=http://ontology.neuinfo.org/NIF/nif-gemma.owl
3836
url.fmaOntology=http://purl.obolibrary.org/obo/fma.owl
3937

40-
ontology.index.dir=ontology.index.dir
38+
ontology.index.dir=
4139
ontology.cache.dir=
4240
ncbo.api.key=

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import com.hp.hpl.jena.ontology.OntModel;
1818

19-
import javax.annotation.Nullable;
2019
import java.io.InputStream;
2120

2221
/**
@@ -27,13 +26,17 @@
2726
*/
2827
public abstract class AbstractOntologyMemoryBackedService extends AbstractOntologyService {
2928

29+
protected boolean getProcessImport() {
30+
return true;
31+
}
32+
3033
@Override
3134
protected OntModel loadModel() {
32-
return OntologyLoader.loadMemoryModel( this.getOntologyUrl(), this.getOntologyName() );
35+
return OntologyLoader.loadMemoryModel( this.getOntologyUrl(), this.getCacheName(), this.getProcessImport() );
3336
}
3437

3538
@Override
3639
protected OntModel loadModelFromStream( InputStream is ) {
37-
return OntologyLoader.loadMemoryModel( is, this.getOntologyUrl() );
40+
return OntologyLoader.loadMemoryModel( is, this.getOntologyUrl(), this.getProcessImport() );
3841
}
3942
}

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import ubic.basecode.util.Configuration;
4545

4646
import javax.annotation.Nullable;
47+
import java.io.IOException;
4748
import java.io.InputStream;
4849
import java.util.*;
4950
import java.util.concurrent.locks.Lock;
@@ -108,6 +109,15 @@ private void initialize( @Nullable InputStream stream, boolean forceLoad, boolea
108109
String ontologyName = getOntologyName();
109110
String cacheName = getCacheName();
110111

112+
// Detect configuration problems.
113+
if ( StringUtils.isBlank( ontologyUrl ) ) {
114+
throw new IllegalStateException( "URL not defined for %s: ontology cannot be loaded. (" + this + ")" );
115+
}
116+
117+
if ( cacheName == null && forceIndexing ) {
118+
throw new IllegalArgumentException( String.format( "No cache directory is set for %s, cannot force indexing.", this ) );
119+
}
120+
111121
boolean loadOntology = isEnabled();
112122

113123
// If loading ontologies is disabled in the configuration, return
@@ -117,16 +127,6 @@ private void initialize( @Nullable InputStream stream, boolean forceLoad, boolea
117127
return;
118128
}
119129

120-
// Detect configuration problems.
121-
if ( StringUtils.isBlank( ontologyUrl ) ) {
122-
throw new IllegalStateException( "URL not defined for %s: ontology cannot be loaded. (" + this + ")" );
123-
}
124-
125-
// This thread indexes ontology and creates local cache for uri->ontology terms mappings.
126-
if ( !forceIndexing ) {
127-
log.info( "{} index will *not* be refreshed unless the ontology has changed or the index is missing", this );
128-
}
129-
130130
log.info( "Loading ontology: {}...", this );
131131
StopWatch loadTime = StopWatch.createStarted();
132132

@@ -150,22 +150,18 @@ private void initialize( @Nullable InputStream stream, boolean forceLoad, boolea
150150
.filterKeep( new RestrictionWithOnPropertyFilter( additionalProperties ) )
151151
.toSet();
152152

153-
//Checks if the current ontology has changed since it was last loaded.
154-
boolean changed = cacheName == null || OntologyLoader.hasChanged( cacheName );
155-
boolean indexExists = cacheName != null && OntologyIndexer.getSubjectIndex( cacheName ) != null;
156-
boolean forceReindexing = forceLoad && forceIndexing;
157-
158-
/*
159-
* Indexing is slow, don't do it if we don't have to.
160-
*/
161-
boolean force = forceReindexing || changed || !indexExists;
162-
163153
// indexing is lengthy, don't bother if we're interrupted
164154
if ( checkIfInterrupted() )
165155
return;
166156

167157
if ( cacheName != null ) {
168-
index = OntologyIndexer.indexOntology( cacheName, model, force );
158+
//Checks if the current ontology has changed since it was last loaded.
159+
boolean changed = OntologyLoader.hasChanged( cacheName );
160+
boolean indexExists = OntologyIndexer.getSubjectIndex( cacheName ) != null;
161+
boolean forceReindexing = forceLoad && forceIndexing;
162+
// indexing is slow, don't do it if we don't have to.
163+
index = OntologyIndexer.indexOntology( cacheName, model,
164+
forceReindexing || changed || !indexExists );
169165
} else {
170166
index = null;
171167
}
@@ -183,7 +179,11 @@ private void initialize( @Nullable InputStream stream, boolean forceLoad, boolea
183179
this.isInitialized = true;
184180
if ( cacheName != null ) {
185181
// now that the terms have been replaced, we can clear old caches
186-
OntologyLoader.deleteOldCache( cacheName );
182+
try {
183+
OntologyLoader.deleteOldCache( cacheName );
184+
} catch ( IOException e ) {
185+
log.error( String.format( String.format( "Failed to delete old cache directory for %s.", this ), e ) );
186+
}
187187
}
188188
} finally {
189189
lock.unlock();

0 commit comments

Comments
 (0)