Package org.incenp.obofoundry.sssom.owl
Class OWLHelper
java.lang.Object
org.incenp.obofoundry.sssom.owl.OWLHelper
A class of helper methods to work with OWL ontologies.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Modes of operation for theupdateMappingSet(MappingSet, OWLOntology, String, boolean, EnumSet)
method. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
annotate
(MappingSet ms, org.semanticweb.owlapi.model.OWLOntology ontology) Annotates an ontology with annotations derived from the metadata of a mapping set.static void
annotate
(MappingSet ms, org.semanticweb.owlapi.model.OWLOntology ontology, boolean setOntologyIRI, IMetadataTransformer<MappingSet, org.semanticweb.owlapi.model.IRI> mapper) Annotates an ontology with annotations derived from the metadata of a mapping set.static org.semanticweb.owlapi.model.OWLOntology
exportToOWL
(MappingSet ms, org.semanticweb.owlapi.model.OWLOntologyManager mgr) Exports a mapping set as an ontology.static String
getLabel
(org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.model.IRI entity, String language, boolean strict) Gets the label of an OWL entity, if any.static boolean
isObsolete
(org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.model.IRI entity) Checks whether an entity is marked as obsolete in the specified ontology.static void
updateMappingSet
(MappingSet ms, org.semanticweb.owlapi.model.OWLOntology ontology, String language, boolean strict) Updates the subject label, object label, subject source, and object source in the mapping set using informations from the specified ontology.static void
updateMappingSet
(MappingSet ms, org.semanticweb.owlapi.model.OWLOntology ontology, String language, boolean langStrict, EnumSet<OWLHelper.UpdateMode> mode) Generic helper method to update a mapping set from a specified ontology.
-
Constructor Details
-
OWLHelper
public OWLHelper()
-
-
Method Details
-
getLabel
public static String getLabel(org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.model.IRI entity, String language, boolean strict) Gets the label of an OWL entity, if any.- Parameters:
ontology
- The ontology to get the label from.entity
- The entity whose label we are looking for.language
- The language tag of the label. May benull
if the caller is happy to get any label regardless of the language. May be the empty string to specifically request a language-neutral label.strict
- Iftrue
, return only a label with the specified language tag, ornull
if no such label could be found; otherwise, may return a language-neutral label.- Returns:
- The entity's label, or
null
if no label was found.
-
isObsolete
public static boolean isObsolete(org.semanticweb.owlapi.model.OWLOntology ontology, org.semanticweb.owlapi.model.IRI entity) Checks whether an entity is marked as obsolete in the specified ontology. Of note, this method does not check for existence; if the entity does not exist in the ontology, it will returnfalse
, as if the entity existed and was not obsolete.- Parameters:
ontology
- The ontology in which to look up the entity.entity
- The entity to look up.- Returns:
true
if the entity is obsolete, otherwisefalse
.
-
updateMappingSet
public static void updateMappingSet(MappingSet ms, org.semanticweb.owlapi.model.OWLOntology ontology, String language, boolean strict) Updates the subject label, object label, subject source, and object source in the mapping set using informations from the specified ontology.- Parameters:
ms
- The mapping set to update.ontology
- The ontology to use a source for the updated metadata.language
- If non-null
, update labels from labels in the ontology that have a matching language tag, or no language tag at all.strict
- Iftrue
, do not fall back to using language-neutral labels.
-
updateMappingSet
public static void updateMappingSet(MappingSet ms, org.semanticweb.owlapi.model.OWLOntology ontology, String language, boolean langStrict, EnumSet<OWLHelper.UpdateMode> mode) Generic helper method to update a mapping set from a specified ontology. What exactly is updated is specified by theOWLHelper.UpdateMode
flag values.- Parameters:
ms
- The mapping set to update.ontology
- The ontology against which to update the mapping set.language
- If non-null
, when updating labels, use labels in the ontology that have a matching language tag, or no language tag at all.langStrict
- Iftrue
, do not fall back to using language-neutral labels.mode
- What to update in the mapping set.
-
annotate
Annotates an ontology with annotations derived from the metadata of a mapping set.- Parameters:
ms
- The mapping set whose metadata are to be used to annotate the ontology.ontology
- The ontology to be annotated.
-
annotate
public static void annotate(MappingSet ms, org.semanticweb.owlapi.model.OWLOntology ontology, boolean setOntologyIRI, IMetadataTransformer<MappingSet, org.semanticweb.owlapi.model.IRI> mapper) Annotates an ontology with annotations derived from the metadata of a mapping set.- Parameters:
ms
- The mapping set whose metadata are to be used to annotate the ontology.ontology
- The ontology to be annotated.setOntologyIRI
- Iftrue
, themapping_set_id
slot will be set as the ontology IRI; otherwise, it will be set as an annotation like all the other slots.mapper
- The mapper indicating which properties to use to render each metadata slot.
-
exportToOWL
public static org.semanticweb.owlapi.model.OWLOntology exportToOWL(MappingSet ms, org.semanticweb.owlapi.model.OWLOntologyManager mgr) throws org.semanticweb.owlapi.model.OWLOntologyCreationException Exports a mapping set as an ontology.- Parameters:
ms
- The mapping set to export.mgr
- The ontology manager to which the newly created ontology will be attached.- Returns:
- The newly created ontology.
- Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException
- If the manager cannot creates the ontology for any reason.
-