Skip to content

Commit 914413d

Browse files
committed
Merge branch 'hotfix-1.1.13'
2 parents 27bb17c + b82fe2f commit 914413d

63 files changed

Lines changed: 1565 additions & 1453 deletions

File tree

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.12</version>
8+
<version>1.1.13</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/OntologyUtil.java

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/ubic/basecode/ontology/providers/AbstractOntologyMemoryBackedService.java renamed to src/ubic/basecode/ontology/jena/AbstractOntologyMemoryBackedService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
1313
* specific language governing permissions and limitations under the License.
1414
*/
15-
package ubic.basecode.ontology.providers;
15+
package ubic.basecode.ontology.jena;
1616

1717
import com.hp.hpl.jena.ontology.OntModel;
18-
import ubic.basecode.ontology.OntologyLoader;
1918

2019
/**
2120
* This class has some stuff that's specific to in-memory ontologies. Unlike database backed ontologies we don't use a
@@ -29,5 +28,4 @@ public abstract class AbstractOntologyMemoryBackedService extends AbstractOntolo
2928
protected synchronized OntModel loadModel() {
3029
return OntologyLoader.loadMemoryModel( this.getOntologyUrl(), this.getOntologyName() );
3130
}
32-
3331
}

src/ubic/basecode/ontology/model/AbstractOntologyResource.java renamed to src/ubic/basecode/ontology/jena/AbstractOntologyResource.java

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* The basecode project
3-
*
3+
*
44
* Copyright (c) 2007-2019 University of British Columbia
5-
*
5+
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
88
* You may obtain a copy of the License at
@@ -16,32 +16,68 @@
1616
* limitations under the License.
1717
*
1818
*/
19-
package ubic.basecode.ontology.model;
19+
package ubic.basecode.ontology.jena;
2020

21+
import com.hp.hpl.jena.ontology.OntResource;
22+
import com.hp.hpl.jena.rdf.model.Resource;
23+
import com.hp.hpl.jena.vocabulary.OWL2;
2124
import org.slf4j.Logger;
2225
import org.slf4j.LoggerFactory;
26+
import ubic.basecode.ontology.model.OntologyResource;
27+
28+
import java.util.Comparator;
29+
import java.util.Objects;
2330

2431
/**
2532
* @author pavlidis
26-
*
2733
*/
2834
public abstract class AbstractOntologyResource implements OntologyResource {
2935

3036
protected static Logger log = LoggerFactory.getLogger( AbstractOntologyResource.class );
3137

3238
private static final long serialVersionUID = 1L;
3339

40+
private transient final OntResource res;
41+
42+
protected AbstractOntologyResource( OntResource resource ) {
43+
this.res = resource;
44+
}
45+
46+
@Override
47+
public String getUri() {
48+
return res.getURI();
49+
}
50+
51+
public String getLabel() {
52+
String label = res.getLabel( "EN" );
53+
if ( label == null ) {
54+
label = res.getLabel( null );
55+
}
56+
if ( label == null ) {
57+
label = res.getLocalName();
58+
}
59+
if ( label == null ) {
60+
label = res.getURI();
61+
}
62+
return label;
63+
}
64+
65+
@Override
66+
public boolean isObsolete() {
67+
return res.hasLiteral( OWL2.deprecated, true );
68+
}
69+
3470
@Override
3571
public int compareTo( OntologyResource other ) {
36-
return this.getUri().compareTo( other.getUri() );
72+
return Objects.compare( getUri(), other.getUri(), Comparator.nullsLast( Comparator.naturalOrder() ) );
3773
}
3874

3975
@Override
4076
public boolean equals( Object obj ) {
4177
if ( this == obj ) return true;
4278
if ( obj == null ) return false;
4379
if ( getClass() != obj.getClass() ) return false;
44-
final AbstractOntologyResource other = ( AbstractOntologyResource ) obj;
80+
final OntologyResource other = ( OntologyResource ) obj;
4581
if ( getLabel() == null ) {
4682
if ( other.getLabel() != null ) return false;
4783
} else if ( !getLabel().equals( other.getLabel() ) ) return false;
@@ -51,16 +87,17 @@ public boolean equals( Object obj ) {
5187
return true;
5288
}
5389

54-
@Override
55-
public abstract String getUri();
56-
5790
@Override
5891
public int hashCode() {
59-
final int PRIME = 31;
60-
int result = 1;
61-
result = PRIME * result + ( ( getLabel() == null ) ? 0 : getLabel().hashCode() );
62-
result = PRIME * result + ( ( getUri() == null ) ? 0 : getUri().hashCode() );
63-
return result;
92+
return Objects.hash( getLabel(), getUri() );
6493
}
6594

66-
}
95+
@Override
96+
public String toString() {
97+
String s = getLabel();
98+
if ( s == null ) {
99+
s = res.toString();
100+
}
101+
return s;
102+
}
103+
}

0 commit comments

Comments
 (0)