public abstract class STOntologyManager<T extends RDFModel> extends Object
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
Modifier and Type | Field and Description |
---|---|
protected HashSet<String> |
applicationOntologiesNamespace
This set contains namespaces of ontologies adopted by the application or its extension to model their
own behavior.
|
protected HashSet<ARTURIResource> |
applicationOntologiesNG
This set contains named graphs adopted by the application or its extension to model their own behavior.
|
protected HashMap<ARTURIResource,ImportStatus> |
importsStatusMap
importStatusMap is a map pointing to structures (ImportStatus) telling the import status (LOCAL, WEB,
NULL, FAILED) of a ontology which should be imported by the main graph, and the location of its file in
case it is a LOCAL import
Some notes: I was thinking about making this map a persistence object.
|
protected static org.slf4j.Logger |
logger |
protected T |
model |
protected OWLArtModelFactory<? extends ModelConfiguration> |
modelFactory |
protected NSPrefixMappings |
nsPrefixMappings |
protected Project<T> |
proj |
protected com.google.common.collect.HashMultimap<ImportModality,ARTResource> |
refreshedOntologies
this map tells whether a given ontology import has been refreshed or not
this information can't be accessed: through supportOntologies/applicationOntologies/listofExplicitOWLImports: since these are declarations of the intention to import an ontology, but do not reflect its true import of data by checking availability of the ontology as a Named Graph in the ontology triples. |
protected HashSet<String> |
supportOntologiesNamespace
Triples with predicate having a namespace contained in this set should be never shown to the user
(whether he is in user or admin mode)
typical examples of ontologies in this set are those needed by specific triple stores to handle reasoning note that these ontologies are declared to be support ontologies, but the developer must still check whether they are imported or not |
protected HashSet<ARTURIResource> |
supportOntologiesNG
this set contains named graphs containing triples that should be never shown to the user (whether he is
in user or admin mode)
typical examples of ontologies in this set are those needed by specific triple stores to handle reasoning note that these ontologies are declared to be support ontologies, but the developer must still check whether they are imported or not |
protected File |
tripleStoreDir |
Modifier | Constructor and Description |
---|---|
protected |
STOntologyManager(Project<T> project,
ModelFactory<? extends ModelConfiguration> fact) |
Modifier and Type | Method and Description |
---|---|
void |
addOntologyImportFromLocalFile(String baseURI,
String fromLocalFilePath,
String toLocalFile)
as for
addOntologyImportFromLocalFile(baseURI, fromLocalFilePath, toLocalFile, true) |
void |
addOntologyImportFromLocalFile(String baseURI,
String fromLocalFilePath,
String toLocalFile,
ImportModality modality,
boolean updateImportStatement) |
void |
addOntologyImportFromMirror(String baseURI,
String mirFileString)
as for
addOntologyImportFromMirror(baseURI, mirFileString, true) |
void |
addOntologyImportFromMirror(String baseURI,
String mirFileString,
ImportModality modality,
boolean updateImportStatement) |
void |
addOntologyImportFromWeb(String baseURI,
String sourceURL,
RDFFormat rdfFormat)
as for
#addOntologyImportFromWeb(String, String, {@link ImportModality.USER}, |
void |
addOntologyImportFromWeb(String baseURI,
String sourceURL,
RDFFormat rdfFormat,
ImportModality modality,
boolean updateImportStatement)
imports an ontology from the Web
|
void |
addOntologyImportFromWebToMirror(String baseURI,
String sourceURL,
String toLocalFile,
RDFFormat rdfFormat)
as for
addOntologyImportFromWebToMirror(baseURI, sourceURL, toLocalFile, true) |
void |
addOntologyImportFromWebToMirror(String baseURI,
String sourceURL,
String toLocalFile,
RDFFormat rdfFormat,
ImportModality modality,
boolean updateImportStatement)
as for
addOntologyImportFromWeb(String, String, RDFFormat, ImportModality, boolean) with the
exception that the imported ontology is stored in the mirror |
protected boolean |
availableNG(ARTResource ont)
tells if named graph
ont is present in the current ontology |
void |
clearData() |
Set<ARTURIResource> |
computeImportsClosure(ARTURIResource ont)
computes and returns the transitive closure of the owl:imports relationship over the managed ontology
starting from import
ont |
protected void |
computeImportsClosure(ARTURIResource ont,
HashSet<ARTURIResource> importClosure)
computes the transitive closure of the owl:imports relationship over the managed ontology starting from
import
ont , storing all computed imports in importClosure |
Set<ARTURIResource> |
computeImportsClosure(Set<ImportModality> mods)
computes and returns the transitive closure of the owl:imports relationship over the managed ontology
along all ontology imports declared under modalities
mods |
void |
declareApplicationOntology(ARTURIResource ont,
boolean ng,
boolean ns)
can be used by ST extensions to declare use of application ontologies for supporting their
functionalities
if ng is true, this prevents triples in the namedgraph of this ontology to be shown
(when ST is in user mode)if ns is 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)One of the two boolean arguments must obviously be true, otherwise this declaration has no effect |
protected abstract void |
declareSupportOntologies()
need to be implemented by specific Ontology Manager to declare support ontologies which need to be
loaded by them.
|
protected void |
declareSupportOntology(ARTURIResource ont,
boolean ng,
boolean ns)
can be used by implementations of this class to declare use of support ontologies for supporting their
functionalities
if ng is true, this prevents triples in the namedgraph of this ontology to be shownif ns is true, this prevents triples having a predicate with namespace matching the
name of ontology ont to be shownOne of the two boolean arguments must obviously be true, otherwise this declaration has no effect |
void |
downloadImportedOntologyFromWeb(String baseURI,
String altURL)
downloads an ontology which is in the import list as a FAILED import from web (needs to specify an
alternative URL, because the baseURI failed)
|
void |
downloadImportedOntologyFromWebToMirror(String baseURI,
String altURL,
String toLocalFile)
downloads an ontology which is in the import list as a FAILED import from web to the mirror (needs to
specify an alternative URL, because the baseURI failed)
|
Collection<ARTURIResource> |
getApplicationOntologies() |
Collection<ARTURIResource> |
getDeclaredImports(ImportModality mod)
retrieves the list of imports for the given
ImportModality note that these are imports declared (it is not assured that they have been imported successfully) for example, getImportSet(ImportModality.USER) retrieves the set of all ontology imports
set by the user
|
abstract String |
getId() |
void |
getImportedOntologyFromLocalFile(String baseURI,
String fromLocalFilePath,
String toLocalFile)
downloads an ontology which is in the import list as a FAILED import, from a local file
|
ImportStatus |
getImportStatus(String baseURI) |
Map<String,String> |
getNSPrefixMappings(boolean explicit) |
T |
getOntModel() |
Collection<ARTURIResource> |
getOntologyImports()
gets the set of ontologies imported by the user
|
static Set<ImportModality> |
getOtherModalities(ImportModality mod) |
OWLModel |
getOWLModel()
this is really not general at the moment.
|
Collection<ARTURIResource> |
getSupportOntologies() |
static OntTempFile |
getTempFileEntry()
this method is used to get the path of a new temp file to be used for whatever reason (the file is
stored in the default temp file directory of Semantic Turkey
|
void |
guessMissingPrefix(String ns) |
void |
guessMissingPrefixes() |
boolean |
hasDeclaredImport(ARTURIResource ont,
ImportModality mod)
checks if ontology
ont has been explicitly imported with modality mod in the
managed ontology |
void |
initializeMappingsPersistence(NSPrefixMappings nsPrefixMappings) |
boolean |
isApplicationNG(ARTURIResource ontology) |
boolean |
isApplicationOntNamespace(String ns) |
boolean |
isImportedInAnotherModality(ARTURIResource ont,
ImportModality mod) |
protected boolean |
isRefreshedOntology(ARTURIResource ont) |
boolean |
isSupportNG(ARTURIResource ontology) |
boolean |
isSupportOntNamespace(String ns) |
void |
loadOntologyData(File inputFile,
String baseURI,
RDFFormat format) |
void |
loadOntologyData(File inputFile,
String baseURI,
RDFFormat format,
ARTResource graph)
this method 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)
|
void |
mirrorOntology(String baseURI,
String toLocalFile)
mirrors an ontology which has already been successfully imported from the web
|
void |
printImportsStatus() |
void |
removeDeclaredImport(ARTURIResource ont,
ImportModality mod)
removes an ontology import declaration from the given ImportModality
mod . |
void |
removeImportDeclaration(ARTURIResource ont)
as for
removeDeclaredImport(ARTURIResource, ImportModality) with second argument =
ImportModality.USER this method thus removes an import declared by the user |
void |
removeNSPrefixMapping(String namespace) |
void |
removeOntologyImport(String uriToBeRemoved)
|
void |
removeOntologyImport(String uriToBeRemoved,
ImportModality mod)
removes an import from the managed ontology.
|
void |
renameNG(ARTURIResource oldNG,
ARTURIResource newNG)
renames an existing NG to a new name (actually, moves all o the data from the old one to the new one,
and deletes the triples in the old one)
|
void |
setNSPrefixMapping(String prefix,
String namespace) |
T |
startOntModel(String baseuri,
File directoryFile,
ModelConfiguration modelConfiguration) |
Document |
writeRDFonDOMDocument(OWLModel r) |
void |
writeRDFOnFile(File outPutFile,
RDFFormat format)
as
writeRDFOnFile(File, RDFFormat, boolean) with last argument = false; |
void |
writeRDFOnFile(File outPutFile,
RDFFormat format,
boolean multigraph) |
protected static org.slf4j.Logger logger
protected OWLArtModelFactory<? extends ModelConfiguration> modelFactory
protected NSPrefixMappings nsPrefixMappings
protected File tripleStoreDir
protected com.google.common.collect.HashMultimap<ImportModality,ARTResource> refreshedOntologies
protected HashSet<ARTURIResource> supportOntologiesNG
protected HashSet<String> supportOntologiesNamespace
protected HashSet<ARTURIResource> applicationOntologiesNG
protected HashSet<String> applicationOntologiesNamespace
protected HashMap<ARTURIResource,ImportStatus> importsStatusMap
the second one gets all imports in a row, so it is faster, but the first one allows you to stop other imports should another import they depend on be no more able to work
I would use the first one, but I should also make sure that, when an import is explicitly removed, then all imports depending exclusively on it are also removed. They *should*, since they are written in the imported ontology, which is on another named graph, and which is deleted when the import is removed. So I only need to check that the cascade of imported ontologies is removed (and only if these are not in turn imported by another part of the imported tree)
protected STOntologyManager(Project<T> project, ModelFactory<? extends ModelConfiguration> fact)
public T startOntModel(String baseuri, File directoryFile, ModelConfiguration modelConfiguration) throws ModelCreationException
baseuri
- the baseuri of the repositoryrepositoryDirectory
- the baseuri ofRepositoryCreationException
ModelCreationException
public abstract String getId()
public void clearData() throws ModelCreationException, ModelUpdateException
public void initializeMappingsPersistence(NSPrefixMappings nsPrefixMappings) throws ModelUpdateException, ModelAccessException
public Collection<ARTURIResource> getDeclaredImports(ImportModality mod) throws ModelAccessException
retrieves the list of imports for the given ImportModality
note that these are imports declared (it is not assured that they have been imported successfully)
for example, getImportSet(ImportModality.USER)
retrieves the set of all ontology imports
set by the user
mod
- ModelAccessException
public Collection<ARTURIResource> getOntologyImports() throws ModelAccessException
ModelAccessException
public boolean hasDeclaredImport(ARTURIResource ont, ImportModality mod) throws ModelAccessException
ont
has been explicitly imported with modality mod
in the
managed ontologyont
- mod
- ModelAccessException
public boolean isImportedInAnotherModality(ARTURIResource ont, ImportModality mod) throws ModelAccessException
ModelAccessException
protected boolean availableNG(ARTResource ont) throws ModelAccessException
ont
is present in the current ontologyont
- ModelAccessException
protected boolean isRefreshedOntology(ARTURIResource ont)
public Collection<ARTURIResource> getApplicationOntologies()
public Collection<ARTURIResource> getSupportOntologies()
public boolean isSupportNG(ARTURIResource ontology)
public boolean isSupportOntNamespace(String ns)
public boolean isApplicationNG(ARTURIResource ontology)
public boolean isApplicationOntNamespace(String ns)
public void declareApplicationOntology(ARTURIResource ont, boolean ng, boolean ns)
ng
is true, this prevents triples in the namedgraph of this ontology to be shown
(when ST is in user
mode)ns
is 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
- protected void declareSupportOntology(ARTURIResource ont, boolean ng, boolean ns)
ng
is true, this prevents triples in the namedgraph of this ontology to be shownns
is true, this prevents triples having a predicate with namespace matching the
name of ontology ont
to be shownont
- ng
- ns
- protected abstract void declareSupportOntologies()
public void addOntologyImportFromLocalFile(String baseURI, String fromLocalFilePath, String toLocalFile) throws MalformedURLException, ModelUpdateException
addOntologyImportFromLocalFile(baseURI, fromLocalFilePath, toLocalFile, true)
baseURI
- fromLocalFilePath
- toLocalFile
- MalformedURLException
ModelUpdateException
public void addOntologyImportFromLocalFile(String baseURI, String fromLocalFilePath, String toLocalFile, ImportModality modality, boolean updateImportStatement) throws MalformedURLException, ModelUpdateException
public void addOntologyImportFromMirror(String baseURI, String mirFileString) throws MalformedURLException, ModelUpdateException
addOntologyImportFromMirror(baseURI, mirFileString, true)
baseURI
- mirFileString
- MalformedURLException
ModelUpdateException
public void addOntologyImportFromMirror(String baseURI, String mirFileString, ImportModality modality, boolean updateImportStatement) throws ModelUpdateException
ModelUpdateException
public void addOntologyImportFromWeb(String baseURI, String sourceURL, RDFFormat rdfFormat) throws MalformedURLException, ModelUpdateException
#addOntologyImportFromWeb(String, String, {@link ImportModality.USER}, true
)
baseURI
- sourceURL
- MalformedURLException
ModelUpdateException
public void addOntologyImportFromWeb(String baseURI, String sourceURL, RDFFormat rdfFormat, ImportModality modality, boolean updateImportStatement) throws ModelUpdateException
baseURI
- the baseuri of the ontology to be imported.sourceURL
- the alternative url, in case the baseuri is not the physical location for the ontologyrdfFormat
- the serialization format of the rdf content to be parsed. null
will result in
the format being inferred from file extension or mime type, as for OWLART APImodality
- one of ImportModality.USER
or ImportModality.APPLICATION
updateImportStatement
- this tells if the method is (likely to be) invoked (variable set to true
) to
explicitly import an ontology (such as when invoked following a import
user
request) or (variable set to false
) when an ontology needs to be added for
whatever reason (like reloading it from the web because it is already available as a
WEB import
)ModelUpdateException
public void addOntologyImportFromWebToMirror(String baseURI, String sourceURL, String toLocalFile, RDFFormat rdfFormat) throws MalformedURLException, ModelUpdateException
addOntologyImportFromWebToMirror(baseURI, sourceURL, toLocalFile, true)
baseURI
- sourceURL
- toLocalFile
- MalformedURLException
ModelUpdateException
public void addOntologyImportFromWebToMirror(String baseURI, String sourceURL, String toLocalFile, RDFFormat rdfFormat, ImportModality modality, boolean updateImportStatement) throws MalformedURLException, ModelUpdateException
addOntologyImportFromWeb(String, String, RDFFormat, ImportModality, boolean)
with the
exception that the imported ontology is stored in the mirrorpublic void renameNG(ARTURIResource oldNG, ARTURIResource newNG) throws ModelAccessException, ModelUpdateException
oldNG
- newNG
- ModelAccessException
ModelUpdateException
public void removeDeclaredImport(ARTURIResource ont, ImportModality mod) throws ModelUpdateException
mod
. Note that this
removes only the import declaration, though it does not remove the RDF data (if any) associated to that
named graphont
- mod
- ModelUpdateException
public void removeImportDeclaration(ARTURIResource ont) throws ModelUpdateException
removeDeclaredImport(ARTURIResource, ImportModality)
with second argument =
ImportModality.USER
ont
- mod
- ModelUpdateException
public void removeOntologyImport(String uriToBeRemoved) throws IOException, ModelUpdateException, ModelAccessException
uriToBeRemoved
- IOException
ModelUpdateException
ModelAccessException
public void removeOntologyImport(String uriToBeRemoved, ImportModality mod) throws IOException, ModelUpdateException, ModelAccessException
uriToBeRemoved
from the import declaration for USER ontologies or from the
list of APPLICATION ontologiesuriToBeRemoved
and is not
imported by other ontologies nor available as an APPLICATION ontologyuriToBeRemoved
- mod
- IOException
ModelUpdateException
ModelAccessException
public static Set<ImportModality> getOtherModalities(ImportModality mod)
public Set<ARTURIResource> computeImportsClosure(Set<ImportModality> mods) throws ModelAccessException, ModelUpdateException
mods
mods
- ModelAccessException
ModelUpdateException
public Set<ARTURIResource> computeImportsClosure(ARTURIResource ont) throws ModelAccessException
ont
ont
- ModelAccessException
protected void computeImportsClosure(ARTURIResource ont, HashSet<ARTURIResource> importClosure) throws ModelAccessException
ont
, storing all computed imports in importClosure
ont
- importClosure
- ModelAccessException
public void downloadImportedOntologyFromWebToMirror(String baseURI, String altURL, String toLocalFile) throws ModelUpdateException, ImportManagementException
method
- baseURI
- fromLocalFilePath
- localFile
- RepositoryUpdateException
ImportManagementException
ModelUpdateException
public void downloadImportedOntologyFromWeb(String baseURI, String altURL) throws MalformedURLException, ModelUpdateException, ImportManagementException
altURL
- MalformedURLException
RepositoryUpdateException
ImportManagementException
ModelUpdateException
public void getImportedOntologyFromLocalFile(String baseURI, String fromLocalFilePath, String toLocalFile) throws MalformedURLException, ModelUpdateException, ImportManagementException
altURL
- fromLocalFilePath
- toLocalFile
- MalformedURLException
RepositoryUpdateException
ImportManagementException
ModelUpdateException
public void mirrorOntology(String baseURI, String toLocalFile) throws ImportManagementException, ModelUpdateException
ImportManagementException
RepositoryUpdateException
ModelUpdateException
public ImportStatus getImportStatus(String baseURI)
public void printImportsStatus()
public void loadOntologyData(File inputFile, String baseURI, RDFFormat format, ARTResource graph) throws FileNotFoundException, IOException, ModelAccessException, ModelUpdateException, UnsupportedRDFFormatException
inputFile
- the RDF file from which RDF data is being loadedbaseURI
- the baseURI to be used when importing relative names from loaded RDF dataFileNotFoundException
IOException
ModelAccessException
ModelUpdateException
UnsupportedRDFFormatException
public void loadOntologyData(File inputFile, String baseURI, RDFFormat format) throws FileNotFoundException, IOException, ModelAccessException, ModelUpdateException, UnsupportedRDFFormatException
public void writeRDFOnFile(File outPutFile, RDFFormat format) throws IOException, ModelAccessException, UnsupportedRDFFormatException
writeRDFOnFile(File, RDFFormat, boolean)
with last argument = false;outPutFile
- format
- UnsupportedRDFFormatException
ModelAccessException
IOException
Exception
public void writeRDFOnFile(File outPutFile, RDFFormat format, boolean multigraph) throws IOException, ModelAccessException, UnsupportedRDFFormatException
public Document writeRDFonDOMDocument(OWLModel r) throws Exception
Exception
public Map<String,String> getNSPrefixMappings(boolean explicit) throws ModelAccessException
explicit
- specifies if the full mapping provided by the OWL Art API implementation or the sole
mappings expressed by the user should be returnedModelAccessException
public void setNSPrefixMapping(String prefix, String namespace) throws NSPrefixMappingUpdateException, ModelUpdateException
public void removeNSPrefixMapping(String namespace) throws NSPrefixMappingUpdateException, ModelUpdateException
public void guessMissingPrefixes() throws ModelAccessException, ModelUpdateException
public void guessMissingPrefix(String ns) throws ModelAccessException, ModelUpdateException
public static OntTempFile getTempFileEntry()
public T getOntModel()
public OWLModel getOWLModel()
SKOSModel.getOWLModel()
methodCopyright © 2016 ART Group, University of Rome, Tor Vergata. All rights reserved.