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
  • Constructor Details

    • RdfStore

      public RdfStore()
  • Method Details

    • getOutputFormat

      public OutputFormat getOutputFormat()
      Returns:
      the outputFormat
    • setOutputFormat

      public void setOutputFormat(OutputFormat outputFormat)
      Parameters:
      outputFormat - the outputFormat to set
    • exists

      public boolean exists(String documentUri, String id)
      Specified by:
      exists in interface org.spdx.storage.IModelStore
    • getIdType

      public org.spdx.storage.IModelStore.IdType getIdType(String id)
      Specified by:
      getIdType in interface org.spdx.storage.IModelStore
    • create

      public void create(String documentUri, String id, String type) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      create in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • getPropertyValueNames

      public List<String> getPropertyValueNames(String documentUri, String id) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      getPropertyValueNames in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • setValue

      public void setValue(String documentUri, String id, String propertyName, Object value) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      setValue in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • getValue

      public Optional<Object> getValue(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      getValue in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • getNextId

      public String getNextId(org.spdx.storage.IModelStore.IdType idType, String documentUri) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      getNextId in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • removeProperty

      public void removeProperty(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      removeProperty in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • getDocumentUris

      public List<String> getDocumentUris()
      Specified by:
      getDocumentUris in interface org.spdx.storage.IModelStore
    • getAllItems

      public java.util.stream.Stream<org.spdx.library.model.TypedValue> getAllItems(String documentUri, String typeFilter) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      getAllItems in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • removeValueFromCollection

      public boolean removeValueFromCollection(String documentUri, String id, String propertyName, Object value) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      removeValueFromCollection in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • collectionSize

      public int collectionSize(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      collectionSize in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • collectionContains

      public boolean collectionContains(String documentUri, String id, String propertyName, Object value) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      collectionContains in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • clearValueCollection

      public void clearValueCollection(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      clearValueCollection in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • addValueToCollection

      public boolean addValueToCollection(String documentUri, String id, String propertyName, Object value) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      addValueToCollection in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • listValues

      public Iterator<Object> listValues(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      listValues in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • isCollectionMembersAssignableTo

      public boolean isCollectionMembersAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      isCollectionMembersAssignableTo in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • isPropertyValueAssignableTo

      public boolean isPropertyValueAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      isPropertyValueAssignableTo in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • isCollectionProperty

      public boolean isCollectionProperty(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      isCollectionProperty in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • leaveCriticalSection

      public void leaveCriticalSection(org.spdx.storage.IModelStore.IModelStoreLock lock)
      Specified by:
      leaveCriticalSection in interface org.spdx.storage.IModelStore
    • enterCriticalSection

      public org.spdx.storage.IModelStore.IModelStoreLock enterCriticalSection(String documentUri, boolean readLockRequested) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      enterCriticalSection in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • loadModelFromFile

      public String loadModelFromFile(String fileNameOrUrl, boolean overwrite) throws org.spdx.library.InvalidSPDXAnalysisException, IOException
      Load a document from a file or URL
      Parameters:
      fileNameOrUrl -
      overwrite - if true, overwrite any existing documents with the same document URI
      Returns:
      the DocumentURI of the SPDX document
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
      IOException
    • getSpdxDocNode

      public static org.apache.jena.graph.Node getSpdxDocNode(org.apache.jena.rdf.model.Model model)
      Returns:
      the spdx doc node from the model
    • getDocumentNamespace

      public static String getDocumentNamespace(org.apache.jena.rdf.model.Model model) throws org.spdx.library.InvalidSPDXAnalysisException
      Parameters:
      model - model containing a single document
      Returns:
      the document namespace for the document stored in the model
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • serialize

      public void serialize(String documentUri, OutputStream stream) throws org.spdx.library.InvalidSPDXAnalysisException, IOException
      Specified by:
      serialize in interface org.spdx.storage.ISerializableModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
      IOException
    • deSerialize

      public String deSerialize(InputStream stream, boolean overwrite) throws org.spdx.library.InvalidSPDXAnalysisException, IOException
      Specified by:
      deSerialize in interface org.spdx.storage.ISerializableModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
      IOException
    • deSerialize

      public String deSerialize(InputStream stream, boolean overwrite, String documentNamespace) throws org.spdx.library.InvalidSPDXAnalysisException, IOException
      Deserialize an RDF stream without an enclosing document
      Parameters:
      stream -
      documentNamespace -
      Returns:
      the documentNamespace
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
      IOException
    • getCaseSensisitiveId

      public Optional<String> getCaseSensisitiveId(String documentUri, String caseInsensisitiveId)
      Specified by:
      getCaseSensisitiveId in interface org.spdx.storage.IModelStore
    • getTypedValue

      public Optional<org.spdx.library.model.TypedValue> getTypedValue(String documentUri, String id) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      getTypedValue in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • delete

      public void delete(String documentUri, String id) throws org.spdx.library.InvalidSPDXAnalysisException
      Specified by:
      delete in interface org.spdx.storage.IModelStore
      Throws:
      org.spdx.library.InvalidSPDXAnalysisException
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception