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 StringMETADATA_SUFFIX
-
Constructor Summary
Constructors Constructor Description RDFArtifactRepository(RDFStorage storage)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddArtifact(Artifact artifact)Adds an artifact to the repository.voidaddModelBuilder(org.eclipse.rdf4j.model.IRI artifactType, ModelBuilder builder)voidaddModelLoader(org.eclipse.rdf4j.model.IRI artifactType, ModelLoader builder)voidclear()Removes all artifacts from the repository.voidclearContext(org.eclipse.rdf4j.model.IRI contextIri)voidclearMetadata()org.eclipse.rdf4j.model.IRIcreateArtifactIri(Artifact artifact)Generates a unique IRI for a new artifact based on the strategy of the given repository.static RDFArtifactRepositorycreateHTTP(String serverUrl, String repositoryId)static RDFArtifactRepositorycreateMemory(String path)static RDFArtifactRepositorycreateNative(String path)voiddisconnect()Disconnects the repository.ArtifactgetArtifact(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.ModelgetArtifactModel(org.eclipse.rdf4j.model.IRI artifactIri)IRIDecodergetIriDecoder()Gets an IRI encoder / decoder usable with this repository.IRIFactorygetIriFactory()Gets the IRI factory used for creating the IRIs when building a RDF graph.org.eclipse.rdf4j.model.IRIgetMetadataIRI(org.eclipse.rdf4j.model.IRI artifactIri)ModelBuildergetModelBuilder(org.eclipse.rdf4j.model.IRI artifactType)ModelLoadergetModelLoader(org.eclipse.rdf4j.model.IRI artifactType)RDFStoragegetStorage()Collection<Tag>getTags()voidinit()Checks the repository status and initializes the metadata when necessaryprotected voidinitDefaultModelBuilders()booleaninitMetadata()Initializes the repository metadata using the default OWL resource files.booleanisInitialized()Checks whether the storage has been initialized - it seems to contain the appropriate metadatabooleanisReadOnly()Checks if the repository should be treated as read-only.voidremoveArtifact(org.eclipse.rdf4j.model.IRI artifactIri)Removes an artifact and all its derived artifacts from the repository.voidreplaceArtifact(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.voidsetIriFactory(IRIFactory iriFactory)Configures the IRI factory used for creating the IRIs when building a RDF graph.voidsetReadOnly(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:ArtifactRepositoryChecks 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:
isReadOnlyin interfaceArtifactRepository- Returns:
truewhen the repository is read-only,falseotherwise.
-
setReadOnly
public void setReadOnly(boolean readOnly)
-
disconnect
public void disconnect()
Description copied from interface:ArtifactRepositoryDisconnects the repository.- Specified by:
disconnectin interfaceArtifactRepository
-
getStorage
public RDFStorage getStorage()
-
getIriDecoder
public IRIDecoder getIriDecoder()
Description copied from interface:ArtifactRepositoryGets an IRI encoder / decoder usable with this repository.- Specified by:
getIriDecoderin 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:
truewhen the repository is ready to use
-
initMetadata
public boolean initMetadata()
Initializes the repository metadata using the default OWL resource files.- Returns:
truewhen the repository was initialized sucessfully.
-
clearMetadata
public void clearMetadata()
-
getArtifactIRIs
public Collection<org.eclipse.rdf4j.model.IRI> getArtifactIRIs() throws StorageException
Description copied from interface:ArtifactRepositoryObtains a list of all artifact IRIs in the repository.- Specified by:
getArtifactIRIsin 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:ArtifactRepositoryObtains 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:
getArtifactInfoin 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:ArtifactRepositoryObtains an artifact from the repository.- Specified by:
getArtifactin interfaceArtifactRepository- Parameters:
artifactIri- the artifact IRI- Returns:
- the artifact or
nullwhen 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:ArtifactRepositoryAdds an artifact to the repository. If the artifact IRI isnulla new IRI is generated usingArtifactRepository.createArtifactIri(Artifact).- Specified by:
addArtifactin interfaceArtifactRepository- Parameters:
artifact- the artifact to add
-
createArtifactIri
public org.eclipse.rdf4j.model.IRI createArtifactIri(Artifact artifact)
Description copied from interface:ArtifactRepositoryGenerates a unique IRI for a new artifact based on the strategy of the given repository.- Specified by:
createArtifactIriin 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:ArtifactRepositorySets an IRI to a artifact and stores it into the repository while replacing the eventual existing artifact with that IRI.- Specified by:
replaceArtifactin interfaceArtifactRepository- Parameters:
artifactIri- the target IRIartifact- the artifact to store
-
removeArtifact
public void removeArtifact(org.eclipse.rdf4j.model.IRI artifactIri)
Description copied from interface:ArtifactRepositoryRemoves an artifact and all its derived artifacts from the repository.- Specified by:
removeArtifactin 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:ArtifactRepositoryRemoves all artifacts from the repository.- Specified by:
clearin 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
-
-