Package cz.vutbr.fit.layout.rdf
Class RDFArtifactRepository
- java.lang.Object
-
- cz.vutbr.fit.layout.rdf.RDFArtifactRepository
-
- All Implemented Interfaces:
ArtifactRepository
public class RDFArtifactRepository extends Object implements ArtifactRepository
Implementation of an ArtifactRepository on top of an RDFStorage.- Author:
- burgetr
-
-
Field Summary
Fields Modifier and Type Field Description static String
METADATA_SUFFIX
-
Constructor Summary
Constructors Constructor Description RDFArtifactRepository(RDFStorage storage)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addArtifact(Artifact artifact)
Adds an artifact to the repository.void
addModelBuilder(org.eclipse.rdf4j.model.IRI artifactType, ModelBuilder builder)
void
addModelLoader(org.eclipse.rdf4j.model.IRI artifactType, ModelLoader builder)
void
clear()
Removes all artifacts from the repository.void
clearContext(org.eclipse.rdf4j.model.IRI contextIri)
void
clearMetadata()
org.eclipse.rdf4j.model.IRI
createArtifactIri(Artifact artifact)
Generates a unique IRI for a new artifact based on the strategy of the given repository.static RDFArtifactRepository
createHTTP(String serverUrl, String repositoryId)
static RDFArtifactRepository
createMemory(String path)
static RDFArtifactRepository
createNative(String path)
void
disconnect()
Disconnects the repository.Artifact
getArtifact(org.eclipse.rdf4j.model.IRI artifactIri)
Obtains an artifact from the repository.Collection<Artifact>
getArtifactInfo()
Obtains the basic information about the artifacts.Collection<Artifact>
getArtifactInfoOld()
Collection<org.eclipse.rdf4j.model.IRI>
getArtifactIRIs()
Obtains a list of all artifact IRIs in the repository.Collection<org.eclipse.rdf4j.model.IRI>
getArtifactIRIs(org.eclipse.rdf4j.model.IRI pageIri)
Gets the artifact IRIs for a source page onlyorg.eclipse.rdf4j.model.Model
getArtifactModel(org.eclipse.rdf4j.model.IRI artifactIri)
IRIDecoder
getIriDecoder()
Gets an IRI encoder / decoder usable with this repository.IRIFactory
getIriFactory()
Gets the IRI factory used for creating the IRIs when building a RDF graph.org.eclipse.rdf4j.model.IRI
getMetadataIRI(org.eclipse.rdf4j.model.IRI artifactIri)
ModelBuilder
getModelBuilder(org.eclipse.rdf4j.model.IRI artifactType)
ModelLoader
getModelLoader(org.eclipse.rdf4j.model.IRI artifactType)
RDFStorage
getStorage()
Collection<Tag>
getTags()
void
init()
Checks the repository status and initializes the metadata when necessaryprotected void
initDefaultModelBuilders()
boolean
initMetadata()
Initializes the repository metadata using the default OWL resource files.boolean
isInitialized()
Checks whether the storage has been initialized - it seems to contain the appropriate metadataboolean
isReadOnly()
Checks if the repository should be treated as read-only.void
removeArtifact(org.eclipse.rdf4j.model.IRI artifactIri)
Removes an artifact and all its derived artifacts from the repository.void
replaceArtifact(org.eclipse.rdf4j.model.IRI artifactIri, Artifact artifact)
Sets an IRI to a artifact and stores it into the repository while replacing the eventual existing artifact with that IRI.void
setIriFactory(IRIFactory iriFactory)
Configures the IRI factory used for creating the IRIs when building a RDF graph.void
setReadOnly(boolean readOnly)
-
-
-
Field Detail
-
METADATA_SUFFIX
public static String METADATA_SUFFIX
-
-
Constructor Detail
-
RDFArtifactRepository
public RDFArtifactRepository(RDFStorage storage)
-
-
Method Detail
-
createMemory
public static RDFArtifactRepository createMemory(String path)
-
createNative
public static RDFArtifactRepository createNative(String path)
-
createHTTP
public static RDFArtifactRepository createHTTP(String serverUrl, String repositoryId)
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:ArtifactRepository
Checks if the repository should be treated as read-only. If true is returned, all modification operations such as adding or removing artifacts should fail with a StorageException.- Specified by:
isReadOnly
in interfaceArtifactRepository
- Returns:
true
when the repository is read-only,false
otherwise.
-
setReadOnly
public void setReadOnly(boolean readOnly)
-
disconnect
public void disconnect()
Description copied from interface:ArtifactRepository
Disconnects the repository.- Specified by:
disconnect
in interfaceArtifactRepository
-
getStorage
public RDFStorage getStorage()
-
getIriDecoder
public IRIDecoder getIriDecoder()
Description copied from interface:ArtifactRepository
Gets an IRI encoder / decoder usable with this repository.- Specified by:
getIriDecoder
in interfaceArtifactRepository
- Returns:
-
getIriFactory
public IRIFactory getIriFactory()
Gets the IRI factory used for creating the IRIs when building a RDF graph.
-
setIriFactory
public void setIriFactory(IRIFactory iriFactory)
Configures the IRI factory used for creating the IRIs when building a RDF graph.- Parameters:
iriFactory
-
-
init
public void init()
Checks the repository status and initializes the metadata when necessary
-
isInitialized
public boolean isInitialized()
Checks whether the storage has been initialized - it seems to contain the appropriate metadata- Returns:
true
when the repository is ready to use
-
initMetadata
public boolean initMetadata()
Initializes the repository metadata using the default OWL resource files.- Returns:
true
when the repository was initialized sucessfully.
-
clearMetadata
public void clearMetadata()
-
getArtifactIRIs
public Collection<org.eclipse.rdf4j.model.IRI> getArtifactIRIs() throws StorageException
Description copied from interface:ArtifactRepository
Obtains a list of all artifact IRIs in the repository.- Specified by:
getArtifactIRIs
in interfaceArtifactRepository
- Returns:
- The list of all artifacts.
- Throws:
StorageException
-
getArtifactIRIs
public Collection<org.eclipse.rdf4j.model.IRI> getArtifactIRIs(org.eclipse.rdf4j.model.IRI pageIri) throws StorageException
Gets the artifact IRIs for a source page only- Parameters:
pageIri
- the source page IRI- Returns:
- the list of artifact IRIs
- Throws:
StorageException
-
getArtifactInfo
public Collection<Artifact> getArtifactInfo() throws StorageException
Description copied from interface:ArtifactRepository
Obtains the basic information about the artifacts. Note that the resulting objects are not necessarily the complete artifacts. UseArtifactRepository.getArtifact(IRI)
to load the complete artifacts of the appropriate types.- Specified by:
getArtifactInfo
in interfaceArtifactRepository
- Returns:
- A collection of objects that represent the available artifacts.
- Throws:
StorageException
-
getArtifactInfoOld
public Collection<Artifact> getArtifactInfoOld()
-
getArtifact
public Artifact getArtifact(org.eclipse.rdf4j.model.IRI artifactIri)
Description copied from interface:ArtifactRepository
Obtains an artifact from the repository.- Specified by:
getArtifact
in interfaceArtifactRepository
- Parameters:
artifactIri
- the artifact IRI- Returns:
- the artifact or
null
when there is no such artifact available
-
getArtifactModel
public org.eclipse.rdf4j.model.Model getArtifactModel(org.eclipse.rdf4j.model.IRI artifactIri)
-
addArtifact
public void addArtifact(Artifact artifact)
Description copied from interface:ArtifactRepository
Adds an artifact to the repository. If the artifact IRI isnull
a new IRI is generated usingArtifactRepository.createArtifactIri(Artifact)
.- Specified by:
addArtifact
in interfaceArtifactRepository
- Parameters:
artifact
- the artifact to add
-
createArtifactIri
public org.eclipse.rdf4j.model.IRI createArtifactIri(Artifact artifact)
Description copied from interface:ArtifactRepository
Generates a unique IRI for a new artifact based on the strategy of the given repository.- Specified by:
createArtifactIri
in interfaceArtifactRepository
- Parameters:
artifact
- the artifact to generate to IRI for- Returns:
- The generated IRI
-
replaceArtifact
public void replaceArtifact(org.eclipse.rdf4j.model.IRI artifactIri, Artifact artifact)
Description copied from interface:ArtifactRepository
Sets an IRI to a artifact and stores it into the repository while replacing the eventual existing artifact with that IRI.- Specified by:
replaceArtifact
in interfaceArtifactRepository
- Parameters:
artifactIri
- the target IRIartifact
- the artifact to store
-
removeArtifact
public void removeArtifact(org.eclipse.rdf4j.model.IRI artifactIri)
Description copied from interface:ArtifactRepository
Removes an artifact and all its derived artifacts from the repository.- Specified by:
removeArtifact
in interfaceArtifactRepository
- Parameters:
artifactIri
- the artifact IRI
-
getMetadataIRI
public org.eclipse.rdf4j.model.IRI getMetadataIRI(org.eclipse.rdf4j.model.IRI artifactIri)
-
clear
public void clear()
Description copied from interface:ArtifactRepository
Removes all artifacts from the repository.- Specified by:
clear
in interfaceArtifactRepository
-
clearContext
public void clearContext(org.eclipse.rdf4j.model.IRI contextIri)
-
initDefaultModelBuilders
protected void initDefaultModelBuilders()
-
addModelBuilder
public void addModelBuilder(org.eclipse.rdf4j.model.IRI artifactType, ModelBuilder builder)
-
getModelBuilder
public ModelBuilder getModelBuilder(org.eclipse.rdf4j.model.IRI artifactType)
-
addModelLoader
public void addModelLoader(org.eclipse.rdf4j.model.IRI artifactType, ModelLoader builder)
-
getModelLoader
public ModelLoader getModelLoader(org.eclipse.rdf4j.model.IRI artifactType)
-
getTags
public Collection<Tag> getTags() throws StorageException
- Throws:
StorageException
-
-