Skip to content

Commit

Permalink
Merge branch 'hotfix-1.1.13'
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed Mar 31, 2023
2 parents 27bb17c + b82fe2f commit 914413d
Show file tree
Hide file tree
Showing 63 changed files with 1,565 additions and 1,453 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<name>baseCode</name>
<groupId>baseCode</groupId>
<artifactId>baseCode</artifactId>
<version>1.1.12</version>
<version>1.1.13</version>
<inceptionYear>2003</inceptionYear>
<description>
<![CDATA[Data structures, math and statistics tools, and utilities that are often needed across projects.]]>
Expand Down
59 changes: 0 additions & 59 deletions src/ubic/basecode/ontology/OntologyUtil.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
* 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.basecode.ontology.providers;
package ubic.basecode.ontology.jena;

import com.hp.hpl.jena.ontology.OntModel;
import ubic.basecode.ontology.OntologyLoader;

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

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* The basecode project
*
*
* Copyright (c) 2007-2019 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
Expand All @@ -16,32 +16,68 @@
* limitations under the License.
*
*/
package ubic.basecode.ontology.model;
package ubic.basecode.ontology.jena;

import com.hp.hpl.jena.ontology.OntResource;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.vocabulary.OWL2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ubic.basecode.ontology.model.OntologyResource;

import java.util.Comparator;
import java.util.Objects;

/**
* @author pavlidis
*
*/
public abstract class AbstractOntologyResource implements OntologyResource {

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

private static final long serialVersionUID = 1L;

private transient final OntResource res;

protected AbstractOntologyResource( OntResource resource ) {
this.res = resource;
}

@Override
public String getUri() {
return res.getURI();
}

public String getLabel() {
String label = res.getLabel( "EN" );
if ( label == null ) {
label = res.getLabel( null );
}
if ( label == null ) {
label = res.getLocalName();
}
if ( label == null ) {
label = res.getURI();
}
return label;
}

@Override
public boolean isObsolete() {
return res.hasLiteral( OWL2.deprecated, true );
}

@Override
public int compareTo( OntologyResource other ) {
return this.getUri().compareTo( other.getUri() );
return Objects.compare( getUri(), other.getUri(), Comparator.nullsLast( Comparator.naturalOrder() ) );
}

@Override
public boolean equals( Object obj ) {
if ( this == obj ) return true;
if ( obj == null ) return false;
if ( getClass() != obj.getClass() ) return false;
final AbstractOntologyResource other = ( AbstractOntologyResource ) obj;
final OntologyResource other = ( OntologyResource ) obj;
if ( getLabel() == null ) {
if ( other.getLabel() != null ) return false;
} else if ( !getLabel().equals( other.getLabel() ) ) return false;
Expand All @@ -51,16 +87,17 @@ public boolean equals( Object obj ) {
return true;
}

@Override
public abstract String getUri();

@Override
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = PRIME * result + ( ( getLabel() == null ) ? 0 : getLabel().hashCode() );
result = PRIME * result + ( ( getUri() == null ) ? 0 : getUri().hashCode() );
return result;
return Objects.hash( getLabel(), getUri() );
}

}
@Override
public String toString() {
String s = getLabel();
if ( s == null ) {
s = res.toString();
}
return s;
}
}
Loading

0 comments on commit 914413d

Please sign in to comment.