Interface OntologyManager

All Known Implementing Classes:
OntologyManagerImpl

public interface OntologyManager
A class managing high level operations (such as recursive ontology import, gussing namespace-prefix mappings etc..) which are usually not automated by a triple store.

The namespace-prefix mapping has a double management

  • prefixes for imported ontologies are guessed by means of some heuristics and then directly added to the loaded triple store manager. These "guesses" will be typically shown with a lighter color on user interfaces, denoting their setting being chosen automatically
  • the namespace-prefix mapping APIs in this class allow for the definition of custom mappings. These are persisted on the project associated to this OntologyManager and will be reloaded each time the project is open. These custom mappings will usually be evident in the UI as user-specified mappings
Note that, at the level of this OntologyManager, there is no track of which mappings were already present in the loaded triple store and which ones have been guessed by OntologyManager. Only those explicitly selected by the user are made evident

Author:
Armando Stellato, Manuel Fiorelli
  • Method Details

    • getBaseURI

      String getBaseURI()
      Returns the base URI of the managed ontology
      Returns:
    • setBaseURI

      void setBaseURI(String baseURI)
      Sets the base URI of the managed ontology
      Parameters:
      baseURI -
    • getNSPrefixMappings

      Map<String,String> getNSPrefixMappings(boolean explicit) throws OntologyManagerException
      Returns the prefixed defined in the managed ontology. The returned Map is indexed by the prefixes. If the parameter explicit is set to true, then the returned Map contains only prefixed explicitly set through the OntologyManager.
      Parameters:
      explicit -
      Returns:
      Throws:
      OntologyManagerException
    • setNSPrefixMapping

      void setNSPrefixMapping(String prefix, String namespace) throws NSPrefixMappingUpdateException
      Defines a namespace prefix. This method shouldn't be invoked explicitly by client code.
      Parameters:
      prefix -
      namespace -
      Throws:
      NSPrefixMappingUpdateException
    • removeNSPrefixMapping

      void removeNSPrefixMapping(String namespace, boolean checkOnlyExplicit) throws NSPrefixMappingUpdateException
      Removes all prefix declarations for the supplied namespace
      Parameters:
      namespace -
      checkOnlyExplicit -
      Throws:
      NSPrefixMappingUpdateException
    • addOntologyImportFromLocalFile

      void addOntologyImportFromLocalFile(org.eclipse.rdf4j.repository.RepositoryConnection conn, @Nullable String baseURI, ImportModality modality, String fromLocalFilePath, @Nullable String toLocalFile, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws MalformedURLException, org.eclipse.rdf4j.common.exception.RDF4JException
      Imports an ontology from a local file, and optionally copies it to the ontology mirror.
      Parameters:
      conn -
      baseURI -
      modality -
      fromLocalFilePath -
      toLocalFile -
      transitiveImportAllowance -
      failedImports -
      Throws:
      MalformedURLException
      org.eclipse.rdf4j.common.exception.RDF4JException
    • addOntologyImportFromMirror

      void addOntologyImportFromMirror(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, ImportModality modality, String mirFileString, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws MalformedURLException, org.eclipse.rdf4j.common.exception.RDF4JException, OntologyManagerException
      Imports an ontology from the ontology mirror
      Parameters:
      conn -
      baseURI -
      modality -
      mirFileString -
      transitiveImportAllowance -
      failedImports -
      Throws:
      MalformedURLException
      org.eclipse.rdf4j.common.exception.RDF4JException
      OntologyManagerException
    • addOntologyImportFromWeb

      void addOntologyImportFromWeb(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseUriToBeImported, ImportModality modality, String url, @Nullable org.eclipse.rdf4j.rio.RDFFormat rdfFormat, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws MalformedURLException, org.eclipse.rdf4j.common.exception.RDF4JException, OntologyManagerException
      Imports an ontology from the web
      Parameters:
      conn -
      baseUriToBeImported -
      modality -
      url -
      rdfFormat -
      transitiveImportAllowance -
      failedImports -
      Throws:
      MalformedURLException
      org.eclipse.rdf4j.common.exception.RDF4JException
      OntologyManagerException
    • addOntologyImportFromWebToMirror

      void addOntologyImportFromWebToMirror(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, ImportModality modality, String sourceURL, String toLocalFile, org.eclipse.rdf4j.rio.RDFFormat rdfFormat, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws MalformedURLException, org.eclipse.rdf4j.common.exception.RDF4JException, OntologyManagerException
      Imports an ontology from the web and copies it to the ontology mirror
      Parameters:
      conn -
      baseURI -
      modality - TODO
      sourceURL -
      toLocalFile -
      rdfFormat -
      transitiveImportAllowance -
      failedImports -
      Throws:
      MalformedURLException
      org.eclipse.rdf4j.common.exception.RDF4JException
      OntologyManagerException
    • addOntologyImportFromLocalProject

      void addOntologyImportFromLocalProject(org.eclipse.rdf4j.repository.RepositoryConnection conn, ImportModality modality, Project sourceProject, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws MalformedURLException, org.eclipse.rdf4j.common.exception.RDF4JException, OntologyManagerException
      Imports an ontology from a local project
      Parameters:
      conn -
      modality - TODO
      sourceProject -
      transitiveImportAllowance -
      failedImports -
      Throws:
      MalformedURLException
      org.eclipse.rdf4j.common.exception.RDF4JException
      OntologyManagerException
    • disconnectImportedOntologyFromProject

      void disconnectImportedOntologyFromProject(org.eclipse.rdf4j.repository.RepositoryConnection managedConnection, String baseURI) throws STPropertyAccessException
      Disconnects an imported ontology from the source project
      Parameters:
      managedConnection -
      baseURI -
      Throws:
      STPropertyAccessException
    • getUserOntologyImportTree

      Collection<OntologyImport> getUserOntologyImportTree(org.eclipse.rdf4j.repository.RepositoryConnection conn)
      Returns a hierarchical representation of user ontology Imports.
      Parameters:
      conn -
      Returns:
    • removeOntologyImport

      void removeOntologyImport(org.eclipse.rdf4j.repository.RepositoryConnection conn, String uriToBeRemoved) throws IOException
      Removes an ontology import
      Parameters:
      conn -
      uriToBeRemoved -
      Throws:
      IOException
    • getImportStatus

      ImportStatus getImportStatus(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, boolean canonicalComparison)
      Returns the status of an ontology import. It is possible to indicate whether comparisons should be based on canonical names (i.e. stripping terminating #).The only relevant information is ImportStatus.getValue()
      Parameters:
      baseURI -
      canonicalComparison -
      Returns:
    • downloadImportedOntologyFromWeb

      void downloadImportedOntologyFromWeb(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, String altURL, org.eclipse.rdf4j.rio.RDFFormat rdfFormat, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws MalformedURLException, ImportManagementException, org.eclipse.rdf4j.common.exception.RDF4JException, IOException
      Downloads an ontology that is a failed import from the web
      Parameters:
      conn -
      baseURI -
      altURL -
      rdfFormat -
      transitiveImportAllowance -
      failedImports -
      Throws:
      MalformedURLException
      ImportManagementException
      org.eclipse.rdf4j.common.exception.RDF4JException
      IOException
    • downloadImportedOntologyFromWebToMirror

      void downloadImportedOntologyFromWebToMirror(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, String altURL, String toLocalFile, org.eclipse.rdf4j.rio.RDFFormat rdfFormat, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws ImportManagementException, org.eclipse.rdf4j.common.exception.RDF4JException, MalformedURLException, IOException
      Downloads an ontology that is a failed import from the web to the ontology mirror
      Parameters:
      conn -
      baseURI -
      altURL -
      toLocalFile -
      rdfFormat -
      transitiveImportAllowance -
      failedImports -
      Throws:
      ImportManagementException
      org.eclipse.rdf4j.common.exception.RDF4JException
      MalformedURLException
      IOException
    • getImportedOntologyFromLocalFile

      void getImportedOntologyFromLocalFile(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, @Nullable String fromLocalFilePath, String toLocalFile, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws MalformedURLException, ImportManagementException, org.eclipse.rdf4j.common.exception.RDF4JException, IOException
      Retrieves an ontology that is a failed import from a local file and copies it to the ontology mirror
      Parameters:
      conn -
      baseURI -
      fromLocalFilePath -
      toLocalFile -
      transitiveImportAllowance -
      failedImports -
      Throws:
      MalformedURLException
      ImportManagementException
      org.eclipse.rdf4j.common.exception.RDF4JException
      IOException
    • getImportedOntologyFromMirror

      void getImportedOntologyFromMirror(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws MalformedURLException, ImportManagementException, org.eclipse.rdf4j.common.exception.RDF4JException, IOException
      Retrieves an ontology that is a failed import from the ontology mirror
      Parameters:
      conn -
      baseURI -
      transitiveImportAllowance -
      failedImports -
      Throws:
      MalformedURLException
      ImportManagementException
      org.eclipse.rdf4j.common.exception.RDF4JException
      IOException
    • getImportedOntologyFromLocalProject

      void getImportedOntologyFromLocalProject(org.eclipse.rdf4j.repository.RepositoryConnection managedConnection, String baseURI, Project sourceProject, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws ImportManagementException, org.eclipse.rdf4j.common.exception.RDF4JException, IOException
      Retrieves an ontology that is a failed import from a local project
      Parameters:
      sourceProject -
      transitiveImportAllowance -
      Throws:
      org.eclipse.rdf4j.common.exception.RDF4JException
      MalformedURLException
      OntologyManagerException
      ImportManagementException
      IOException
    • updateImportedOntologyFromWeb

      void updateImportedOntologyFromWeb(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, String altURL, org.eclipse.rdf4j.rio.RDFFormat rdfFormat, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws MalformedURLException, ImportManagementException, org.eclipse.rdf4j.common.exception.RDF4JException, IOException
      Updates an ontology import from the web
      Parameters:
      conn -
      baseURI -
      altURL -
      rdfFormat -
      transitiveImportAllowance -
      failedImports -
      Throws:
      MalformedURLException
      ImportManagementException
      org.eclipse.rdf4j.common.exception.RDF4JException
      IOException
    • updateImportedOntologyFromWebToMirror

      void updateImportedOntologyFromWebToMirror(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, String altURL, String toLocalFile, org.eclipse.rdf4j.rio.RDFFormat rdfFormat, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws ImportManagementException, org.eclipse.rdf4j.common.exception.RDF4JException, MalformedURLException, IOException
      Updates an ontology import from the web and stores it to the ontology mirror
      Parameters:
      conn -
      baseURI -
      altURL -
      toLocalFile -
      rdfFormat -
      transitiveImportAllowance -
      failedImports -
      Throws:
      ImportManagementException
      org.eclipse.rdf4j.common.exception.RDF4JException
      MalformedURLException
      IOException
    • updateImportedOntologyFromLocalFile

      void updateImportedOntologyFromLocalFile(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, @Nullable String fromLocalFilePath, String toLocalFile, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws MalformedURLException, ImportManagementException, org.eclipse.rdf4j.common.exception.RDF4JException, IOException
      Updates an ontology import from a local file and copies it to the ontology mirror
      Parameters:
      conn -
      baseURI -
      fromLocalFilePath -
      toLocalFile -
      transitiveImportAllowance -
      failedImports -
      Throws:
      MalformedURLException
      ImportManagementException
      org.eclipse.rdf4j.common.exception.RDF4JException
      IOException
    • updateImportedOntologyFromLocalProject

      void updateImportedOntologyFromLocalProject(org.eclipse.rdf4j.repository.RepositoryConnection managedConnection, String baseURI, String projectName, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws ImportManagementException, org.eclipse.rdf4j.common.exception.RDF4JException, IOException
      Updates an ontology import from a local project
      Parameters:
      managedConnection -
      baseURI -
      projectName -
      transitiveImportAllowance -
      failedImports -
      Throws:
      ImportManagementException
      org.eclipse.rdf4j.common.exception.RDF4JException
      IOException
    • updateImportedOntologyFromMirror

      void updateImportedOntologyFromMirror(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws MalformedURLException, ImportManagementException, org.eclipse.rdf4j.common.exception.RDF4JException, IOException
      Updates an ontology import from the ontology mirror
      Parameters:
      conn -
      baseURI -
      transitiveImportAllowance -
      failedImports -
      Throws:
      MalformedURLException
      ImportManagementException
      org.eclipse.rdf4j.common.exception.RDF4JException
      IOException
    • declareApplicationOntology

      void declareApplicationOntology(org.eclipse.rdf4j.model.IRI ont, boolean declareImport, boolean ng, boolean ns)
      It can be used by ST extensions to declare use of application ontologies for supporting their functionalities. The boolean parameters can be used to declare different facets of an application ontology. If no parameter is set to , this declaration has no effect.
      Parameters:
      declareImport - if true, declares an import with modality ImportModality.APPLICATION.
      ng - if true, this prevents triples in the namedgraph of this ontology to be shown (when ST is in user mode)
      ns - if true, this prevents triples having a predicate with namespace matching the name of ontology ont to be shown (again, when ST is in user mode)
      ont -
      ng -
      ns -
    • isApplicationOntNamespace

      boolean isApplicationOntNamespace(String ns)
      Checks whether ns is an application ontology
      Parameters:
      ns -
      Returns:
    • declareSupportOntology

      void declareSupportOntology(org.eclipse.rdf4j.model.IRI ont, boolean declareImport, boolean ng, boolean ns)
      It can be used to declare use of an ontology, the presence of which is required by the system to work properly. As an example, core modeling vocabularies are usually declared as such. The boolean parameters can be used to declare different facets of a support ontology. If no parameter is set to , this declaration has no effect.
      Parameters:
      declareImport - if true, declares an import with modality ImportModality.SUPPORT.
      ng - if true, this prevents triples in the namedgraph of this ontology to be shown (when ST is in user mode)
      ns - if true, this prevents triples having a predicate with namespace matching the name of ontology ont to be shown (again, when ST is in user mode)
      ont -
      ng -
      ns -
    • isSupportOntNamespace

      boolean isSupportOntNamespace(String ns)
      Checks whether ns is a support ontology
      Parameters:
      ns -
      Returns:
    • loadOntologyData

      void loadOntologyData(org.eclipse.rdf4j.repository.RepositoryConnection conn, File inputFile, String baseURI, org.eclipse.rdf4j.rio.RDFFormat format, org.eclipse.rdf4j.model.Resource graph, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports) throws FileNotFoundException, IOException, org.eclipse.rdf4j.common.exception.RDF4JException
      Adds RDF data directly to the ontology being edited (i.e. it is not a read-only import of an external ontology that the working ontology depends on, but a mass add of RDF triples to the main graph of the working ontology)
      Parameters:
      conn - a connection to the managed ontology
      inputFile - the RDF file from which RDF data is being loaded
      baseURI - the baseURI to be used when importing relative names from loaded RDF data
      format -
      graph -
      transitiveImportAllowance -
      failedImports -
      Throws:
      FileNotFoundException
      IOException
      org.eclipse.rdf4j.common.exception.RDF4JException
    • getRDFHandlerForLoadData

      org.eclipse.rdf4j.rio.RDFHandler getRDFHandlerForLoadData(org.eclipse.rdf4j.repository.RepositoryConnection conn, String baseURI, org.eclipse.rdf4j.model.Resource graph, TransitiveImportMethodAllowance transitiveImportAllowance, Set<org.eclipse.rdf4j.model.IRI> failedImports)
      Returns an RDFHandler that adds the data to the ontology being edited (i.e. it is not a read-only import of an external ontology that the working ontology depends on, but a mass add of RDF triples to the main graph of the working ontology)
      Parameters:
      conn - a connection to the managed ontology
      baseURI - the baseURI to be used when importing relative names from loaded RDF data
      graph -
      transitiveImportAllowance -
      failedImports -
      Throws:
      FileNotFoundException
      IOException
      org.eclipse.rdf4j.common.exception.RDF4JException
    • clearData

      void clearData() throws org.eclipse.rdf4j.common.exception.RDF4JException
      Clear the managed ontology
      Throws:
      org.eclipse.rdf4j.common.exception.RDF4JException
    • mirrorOntology

      void mirrorOntology(String baseURI, String toLocalFile) throws ImportManagementException, org.eclipse.rdf4j.common.exception.RDF4JException, OntologyManagerException
      Copies an ontology to the ontology mirror.
      Parameters:
      baseURI -
      toLocalFile -
      Throws:
      ImportManagementException
      org.eclipse.rdf4j.common.exception.RDF4JException
      OntologyManagerException
    • initializeMappingsPersistence

      void initializeMappingsPersistence(NSPrefixMappings nsPrefixMappingsPersistence)
      Initializes mapping persistence
      Parameters:
      nsPrefixMappingsPersistence -
    • getRepository

      org.eclipse.rdf4j.repository.Repository getRepository()
      Returns the underlying Repository
      Returns:
    • startOntModel

      void startOntModel(String baseURI, File repoDir, org.eclipse.rdf4j.repository.config.RepositoryConfig repoConfig) throws org.eclipse.rdf4j.common.exception.RDF4JException
      Starts the ontology manager
      Parameters:
      baseURI -
      repoDir -
      repoConfig -
      Throws:
      org.eclipse.rdf4j.common.exception.RDF4JException
    • computeCanonicalURI

      static org.eclipse.rdf4j.model.IRI computeCanonicalURI(org.eclipse.rdf4j.model.IRI iri)
    • computeURIVariants

      static List<String> computeURIVariants(String baseURI)
    • computeURIVariants

      static List<org.eclipse.rdf4j.model.IRI> computeURIVariants(org.eclipse.rdf4j.model.IRI baseURI)