Package org.spdx.spdxRdfStore
Class RdfStore
java.lang.Object
org.spdx.spdxRdfStore.RdfStore
- All Implemented Interfaces:
AutoCloseable
,org.spdx.storage.IModelStore
,org.spdx.storage.ISerializableModelStore
public class RdfStore
extends Object
implements org.spdx.storage.IModelStore, org.spdx.storage.ISerializableModelStore
Model Store implemented using RDF
- Author:
- Gary O'Neall
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.spdx.storage.IModelStore
org.spdx.storage.IModelStore.IdType, org.spdx.storage.IModelStore.IModelStoreLock, org.spdx.storage.IModelStore.ModelUpdate
-
Constructor Summary
ConstructorsConstructorDescriptionRdfStore()
Creates an uninitialized RDF store - the documentUri must be set or a stream deserialized before any other methods are calledRdfStore
(InputStream stream) Create an RDF store and initialize it with an SPDX document deserialized from stream Note that the stream must contain one and only one SPDX document in SPDX version 2.X formatRdfStore
(InputStream stream, String documentUri) Create an RDF store and initialize it with a data deserialized from stream using the documentUri for ID prefixes -
Method Summary
Modifier and TypeMethodDescriptionboolean
addValueToCollection
(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) void
clearValueCollection
(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) void
close()
boolean
collectionContains
(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) int
collectionSize
(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) void
create
(org.spdx.core.TypedValue typedValue) void
org.spdx.library.model.v2.SpdxDocument
deSerialize
(InputStream stream, boolean overwrite) void
deSerialize
(InputStream stream, boolean overwrite, String documentNamespace) Deserialize an RDF stream without an enclosing documentorg.spdx.storage.IModelStore.IModelStoreLock
enterCriticalSection
(boolean readLockRequested) boolean
Stream
<org.spdx.core.TypedValue> getAllItems
(String prefix, String typeFilter) getCaseSensitiveId
(String documentUri, String caseInsensisitiveId) getDocumentNamespaces
(org.apache.jena.rdf.model.Model model) org.spdx.storage.IModelStore.IdType
getNextId
(org.spdx.storage.IModelStore.IdType idType) List
<org.spdx.storage.PropertyDescriptor> getPropertyValueDescriptors
(String objectUri) static List
<org.apache.jena.graph.Node> getSpdxDocNodes
(org.apache.jena.rdf.model.Model model) Optional
<org.spdx.core.TypedValue> getTypedValue
(String objectUri) boolean
boolean
isCollectionMembersAssignableTo
(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz) boolean
isCollectionProperty
(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) boolean
boolean
isPropertyValueAssignableTo
(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz, String specVersion) void
leaveCriticalSection
(org.spdx.storage.IModelStore.IModelStoreLock lock) listValues
(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) loadModelFromFile
(String fileNameOrUrl, boolean overwrite) Load a document from a file or URLvoid
removeProperty
(String objectUri, org.spdx.storage.PropertyDescriptor prop) boolean
removeValueFromCollection
(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) void
serialize
(OutputStream stream) void
serialize
(OutputStream stream, org.spdx.core.CoreModelObject spdxDocument) void
setDocumentUri
(String documentUri, boolean overwrite) void
setDontStoreLicenseDetails
(boolean dontStoreLicenseDetails) void
setOutputFormat
(OutputFormat outputFormat) void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.spdx.storage.IModelStore
getCaseSensisitiveId
-
Constructor Details
-
RdfStore
Create an RDF store and initialize it with an SPDX document deserialized from stream Note that the stream must contain one and only one SPDX document in SPDX version 2.X format- Parameters:
stream
- input stream of a model- Throws:
org.spdx.core.InvalidSPDXAnalysisException
- on SPDX parsing errors
-
RdfStore
public RdfStore()Creates an uninitialized RDF store - the documentUri must be set or a stream deserialized before any other methods are called -
RdfStore
public RdfStore(InputStream stream, String documentUri) throws org.spdx.core.InvalidSPDXAnalysisException Create an RDF store and initialize it with a data deserialized from stream using the documentUri for ID prefixes- Parameters:
stream
- stream of an RDF model- Throws:
org.spdx.core.InvalidSPDXAnalysisException
- on SPDX parsing errors
-
RdfStore
- Parameters:
documentUri
- URI for the SPDX document used in this store
-
-
Method Details
-
getOutputFormat
- Returns:
- the outputFormat
-
getDocumentUri
- Returns:
- the document URI
-
setDocumentUri
public void setDocumentUri(@Nullable String documentUri, boolean overwrite) throws org.spdx.core.InvalidSPDXAnalysisException - Parameters:
documentUri
- document URI to setoverwrite
- setting a different document URI will overwrite an existing model - this flag will allow it to be overwritten- Throws:
org.spdx.core.InvalidSPDXAnalysisException
- if the document URI already exists and override is set to false
-
setOutputFormat
- Parameters:
outputFormat
- the outputFormat to set
-
isDontStoreLicenseDetails
public boolean isDontStoreLicenseDetails()- Returns:
- the dontStoreLicenseDetails - if true, listed license properties will not be stored in the RDF store
-
setDontStoreLicenseDetails
public void setDontStoreLicenseDetails(boolean dontStoreLicenseDetails) - Parameters:
dontStoreLicenseDetails
- the dontStoreLicenseDetails to set - if true, listed license properties will not be stored in the RDF store
-
exists
- Specified by:
exists
in interfaceorg.spdx.storage.IModelStore
-
isAnon
- Specified by:
isAnon
in interfaceorg.spdx.storage.IModelStore
-
getIdType
- Specified by:
getIdType
in interfaceorg.spdx.storage.IModelStore
-
create
public void create(org.spdx.core.TypedValue typedValue) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
create
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getPropertyValueDescriptors
public List<org.spdx.storage.PropertyDescriptor> getPropertyValueDescriptors(String objectUri) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
getPropertyValueDescriptors
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
setValue
public void setValue(String objectUri, org.spdx.storage.PropertyDescriptor prop, Object value) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
setValue
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getValue
public Optional<Object> getValue(String objectUri, org.spdx.storage.PropertyDescriptor prop) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
getValue
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getNextId
public String getNextId(org.spdx.storage.IModelStore.IdType idType) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
getNextId
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
removeProperty
public void removeProperty(String objectUri, org.spdx.storage.PropertyDescriptor prop) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
removeProperty
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getAllItems
public Stream<org.spdx.core.TypedValue> getAllItems(@Nullable String prefix, String typeFilter) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
getAllItems
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
removeValueFromCollection
public boolean removeValueFromCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
removeValueFromCollection
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
collectionSize
public int collectionSize(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
collectionSize
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
collectionContains
public boolean collectionContains(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
collectionContains
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
clearValueCollection
public void clearValueCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
clearValueCollection
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
addValueToCollection
public boolean addValueToCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
addValueToCollection
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
listValues
public Iterator<Object> listValues(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
listValues
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
isCollectionMembersAssignableTo
public boolean isCollectionMembersAssignableTo(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
isCollectionMembersAssignableTo
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
isPropertyValueAssignableTo
public boolean isPropertyValueAssignableTo(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz, String specVersion) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
isPropertyValueAssignableTo
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
isCollectionProperty
public boolean isCollectionProperty(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
isCollectionProperty
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
leaveCriticalSection
public void leaveCriticalSection(org.spdx.storage.IModelStore.IModelStoreLock lock) - Specified by:
leaveCriticalSection
in interfaceorg.spdx.storage.IModelStore
-
enterCriticalSection
public org.spdx.storage.IModelStore.IModelStoreLock enterCriticalSection(boolean readLockRequested) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
enterCriticalSection
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
loadModelFromFile
public String loadModelFromFile(String fileNameOrUrl, boolean overwrite) throws org.spdx.core.InvalidSPDXAnalysisException, IOException Load a document from a file or URL- Parameters:
fileNameOrUrl
- file name or URL of a serialized RDF modeloverwrite
- if true, overwrite any existing documents with the same document URI- Returns:
- the DocumentURI of the SPDX document
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
- on SPDX parsing errorsIOException
- on IO error
-
getSpdxDocNodes
public static List<org.apache.jena.graph.Node> getSpdxDocNodes(org.apache.jena.rdf.model.Model model) - Returns:
- the spdx doc nodes from the model
-
getDocumentNamespaces
public static List<String> getDocumentNamespaces(org.apache.jena.rdf.model.Model model) throws org.spdx.core.InvalidSPDXAnalysisException - Parameters:
model
- model containing a single document- Returns:
- the document namespace for the document stored in the model
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
- on SPDX parsing errors
-
serialize
- Specified by:
serialize
in interfaceorg.spdx.storage.ISerializableModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
serialize
public void serialize(OutputStream stream, @Nullable org.spdx.core.CoreModelObject spdxDocument) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
serialize
in interfaceorg.spdx.storage.ISerializableModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
deSerialize
public org.spdx.library.model.v2.SpdxDocument deSerialize(InputStream stream, boolean overwrite) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
deSerialize
in interfaceorg.spdx.storage.ISerializableModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
deSerialize
public void deSerialize(InputStream stream, boolean overwrite, String documentNamespace) throws org.spdx.core.InvalidSPDXAnalysisException Deserialize an RDF stream without an enclosing document- Parameters:
stream
- stream containing the SPDX datadocumentNamespace
- document namespace to use- Throws:
org.spdx.core.InvalidSPDXAnalysisException
- on SPDX parsing errors
-
getCaseSensitiveId
- Specified by:
getCaseSensitiveId
in interfaceorg.spdx.storage.IModelStore
-
getTypedValue
public Optional<org.spdx.core.TypedValue> getTypedValue(String objectUri) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
getTypedValue
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
delete
- Specified by:
delete
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-