Class OWLHelper


  • public class OWLHelper
    extends Object
    A class of helper methods to work with OWL ontologies.
    • Constructor Detail

      • OWLHelper

        public OWLHelper()
    • Method Detail

      • 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 be null 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 - If true, return only a label with the specified language tag, or null 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 return false, 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, otherwise false.
      • 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 - If true, 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 the OWLHelper.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 - If true, do not fall back to using language-neutral labels.
        mode - What to update in the mapping set.
      • annotate

        public static void annotate​(MappingSet ms,
                                    org.semanticweb.owlapi.model.OWLOntology ontology)
        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 - If true, the mapping_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.