Class DBResource

  • All Implemented Interfaces:
    Resource

    public class DBResource
    extends Object
    implements Resource
    A db-based implementation of the Trellis Resource API.
    • Method Detail

      • findResource

        public static CompletionStage<Resource> findResource​(DataSource ds,
                                                             IRI identifier,
                                                             Map<String,​IRI> extensions,
                                                             boolean includeLdpType)
        Try to load a Trellis resource.
        Parameters:
        ds - the datasource
        identifier - the identifier
        extensions - a map of extensions
        includeLdpType - whether to include the LDP type in the RDF body
        Returns:
        a Resource, if one exists
      • findResource

        public static CompletionStage<Resource> findResource​(org.jdbi.v3.core.Jdbi jdbi,
                                                             IRI identifier,
                                                             Map<String,​IRI> extensions,
                                                             boolean includeLdpType)
        Try to load a Trellis resource.
        Parameters:
        jdbi - the Jdbi object
        identifier - the identifier
        extensions - a map of extensions
        includeLdpType - whether to include the LDP type in the RDF body
        Returns:
        a Resource, if one exists
      • findResource

        public static CompletionStage<Resource> findResource​(org.jdbi.v3.core.Jdbi jdbi,
                                                             IRI identifier,
                                                             Map<String,​IRI> extensions,
                                                             boolean includeLdpType,
                                                             boolean supportDirectContainment,
                                                             boolean supportIndirectContainment)
        Try to load a Trellis resource.
        Parameters:
        jdbi - the Jdbi object
        identifier - the identifier
        extensions - a map of extensions
        includeLdpType - whether to include the LDP type in the RDF body
        supportDirectContainment - whether to support direct containment
        supportIndirectContainment - whether to support indirect containment
        Returns:
        a Resource, if one exists
      • isDeleted

        public boolean isDeleted()
        Identify whether this resource had previously been deleted.
        Returns:
        true if the resource previously existed
      • stream

        public Stream<Quad> stream()
        Description copied from interface: Resource
        Retrieve the RDF Quads for a resource.
        Specified by:
        stream in interface Resource
        Returns:
        the RDF quads
      • stream

        public Stream<Quad> stream​(Collection<IRI> graphNames)
        Description copied from interface: Resource
        Retrieve the RDF Quads for a set of named graphs.
        Specified by:
        stream in interface Resource
        Parameters:
        graphNames - the named graphs
        Returns:
        the RDF quads
      • getIdentifier

        public IRI getIdentifier()
        Description copied from interface: Resource
        Get an identifier for this resource.
        Specified by:
        getIdentifier in interface Resource
        Returns:
        the identifier
      • getInteractionModel

        public IRI getInteractionModel()
        Description copied from interface: Resource
        Get the LDP interaction model for this resource.
        Specified by:
        getInteractionModel in interface Resource
        Returns:
        the interaction model
      • getContainer

        public Optional<IRI> getContainer()
        Description copied from interface: Resource
        Get the container for this resource.
        Specified by:
        getContainer in interface Resource
        Returns:
        the identifier for a container, if one exists.
      • getMembershipResource

        public Optional<IRI> getMembershipResource()
        Description copied from interface: Resource
        Retrieve the membership resource if this is an LDP Direct or Indirect container.
        Specified by:
        getMembershipResource in interface Resource
        Returns:
        the membership resource
      • getMemberRelation

        public Optional<IRI> getMemberRelation()
        Description copied from interface: Resource
        Retrieve the member relation if this is an LDP Direct or Indirect container.
        Specified by:
        getMemberRelation in interface Resource
        Returns:
        the ldp:hasMemberRelation IRI
      • getMemberOfRelation

        public Optional<IRI> getMemberOfRelation()
        Description copied from interface: Resource
        Retrieve the member of relation IRI.
        Specified by:
        getMemberOfRelation in interface Resource
        Returns:
        the ldp:isMemberOfRelation IRI
      • getInsertedContentRelation

        public Optional<IRI> getInsertedContentRelation()
        Description copied from interface: Resource
        Retrieve the inserted content relation if this is an LDP Indirect container.
        Specified by:
        getInsertedContentRelation in interface Resource
        Returns:
        the inserted content relation
      • getModified

        public Instant getModified()
        Description copied from interface: Resource
        Get the last modified date.
        Specified by:
        getModified in interface Resource
        Returns:
        the last-modified date
      • hasMetadata

        public boolean hasMetadata​(IRI graphName)
        Description copied from interface: Resource
        Test whether this resource has an attached metadata resource.
        Specified by:
        hasMetadata in interface Resource
        Parameters:
        graphName - the name of the metadata graph
        Returns:
        true if this resource has an attached metadata resource; false otherwise
      • getMetadataGraphNames

        public Set<IRI> getMetadataGraphNames()
        Description copied from interface: Resource
        Retrieve a collection of attached metadata graph names.
        Specified by:
        getMetadataGraphNames in interface Resource
        Returns:
        a set of metadata resource graph names