RDF.FragmentGraph (CPub v0.3.0) View Source

A set of RDF triples about the same subject or fragments of the subject.

Blank nodes are not permitted.

An RDF.FragmentGraph defines a grouping of RDF triples about a certain subject that is suitable for content-addressing (see https://openengiadina.net/papers/content-addressable-rdf.html)

It is similar to a RDF.Description but additionally allows statements with fragments of the base subject as subject (e.g. If ~Ihttp://example.com/ is the base subject of the RDF.FragmentGraph then statements with subject ~Ihttp://example.com/#a-fragment are also permitted).

RDF.FragmentGraph implements:

Link to this section Summary

Functions

Add object to a predicate of a fragemnt of the RDF.FragmentGraph.

Checks if the RDF.FragmentGraph contains a statement about given subject.

Returns a RDF.Description of the given subject with statements in RDF.FragmentGraph.

Fetches the description of the given subject.

Finalize the RDF.FragmentGraph with a custom finalizer. The default finalizer sets the base subject to the ERIS URN of the content.

Returns a fragment reference to id.

Create a new RDF Fragment Graph.

Returns a set of all objects in RDF.FragmentGraph

Pops the description of the given subject.

Retuns a set of all predicates in RDF.FragmentGraph

Returns a list of all statements in RDF.FragmentGraph.

Returns a set of all subjects in RDF.FragmentGraph.

Link to this section Types

Specs

coerce_options() :: [{:base_subject, RDF.IRI.t()}]

Specs

Specs

Specs

coercible_subject() :: RDF.IRI.coercible()

Specs

fragment_identifier() :: String.t()

Specs

fragment_statements() :: %{optional(fragment_identifier()) => statements()}

Specs

Specs

Specs

statements() :: %{optional(predicate()) => MapSet.t(object())}

Specs

subject() :: RDF.IRI.t()

Specs

t() :: %RDF.FragmentGraph{
  base_subject: subject(),
  fragment_statements: fragment_statements(),
  statements: statements()
}

Link to this section Functions

Specs

Add statement to RDF.FragmentGraph.

Link to this function

add_fragment_statement(fg, fragment_identifier, arg)

View Source

Specs

add_fragment_statement(
  t(),
  fragment_identifier(),
  {coercible_predicate(), coercible_object()}
) :: t()

Add object to a predicate of a fragemnt of the RDF.FragmentGraph.

Specs

coerce_iri(RDF.IRI.t(), coerce_options()) ::
  :base_subject | RDF.IRI.t() | RDF.FragmentGraph.FragmentReference.t()
Link to this function

delete(fg, statements, opts \\ [])

View Source

Specs

Delete statement(s) from RDF.FragmentGraph.

Link to this function

delete_fragment_statement(fg, fragment_identifier, arg)

View Source

Specs

delete_fragment_statement(
  t(),
  fragment_identifier(),
  {coercible_predicate(), coercible_object()}
) :: t()

Delete a fragment statement from the RDF.FragmentGraph.

Specs

describes?(t(), RDF.IRI.t()) :: bool()

Checks if the RDF.FragmentGraph contains a statement about given subject.

Link to this function

description(fg, subject)

View Source

Specs

description(t(), subject()) :: RDF.Description.t()

Returns a RDF.Description of the given subject with statements in RDF.FragmentGraph.

Specs

descriptions(t()) :: [RDF.Description.t()]

Specs

eris_finalizer(t()) :: String.t()

Specs

fetch(t(), RDF.Statement.coercible_subject()) ::
  {:ok, [RDF.Description.t()]} | :error

Fetches the description of the given subject.

When the subject can not be found :error is returned.

Link to this function

finalize(fg, finalizer \\ &eris_finalizer/1)

View Source

Specs

finalize(t(), (t() -> String.t())) :: t()

Finalize the RDF.FragmentGraph with a custom finalizer. The default finalizer sets the base subject to the ERIS URN of the content.

Returns a fragment reference to id.

This is a shortcut to RDF.FragmentGraph.FragmentReference.new(id).

Link to this function

get(fg, subject, default \\ nil)

View Source

Specs

graph(t()) :: RDF.Graph.t()

Return RDF.Graph for given RDF.FragmentGraph.

Specs

include?(t(), RDF.Statement.t(), keyword()) :: bool()

Specs

map(t(), ({atom(), subject() | predicate() | object()} -> any())) :: map()
Link to this function

merge(fg, data, opts \\ [])

View Source

Specs

merge(t(), RDF.Statement.t(), keyword()) :: RDF.Graph.t()

Specs

new() :: t()

Specs

new(RDF.IRI.coercible() | RDF.Data.t()) :: t()

Create a new RDF Fragment Graph.

Specs

objects(t()) :: MapSet.t(object())

Returns a set of all objects in RDF.FragmentGraph

Specs

pop(t()) :: {t() | nil, t()}

Specs

pop(t(), RDF.Statement.coercible_subject()) :: {t() | nil, t()}

Pops the description of the given subject.

Specs

predicates(t()) :: MapSet.t(predicate())

Retuns a set of all predicates in RDF.FragmentGraph

Link to this function

put(fg, input, opts \\ [])

View Source

Specs

put(t(), t() | RDF.Graph.input(), keyword()) :: t()
Link to this function

put_properties(fg, input, opts \\ [])

View Source

Specs

put_properties(t(), t() | RDF.Graph.input(), keyword()) :: t()

Specs

resources(t()) :: MapSet.t(subject() | predicate() | object())
Link to this function

set_base_subject(fg, new_base_subject)

View Source

Specs

set_base_subject(t(), RDF.IRI.coercible()) :: t()

Set the base subject of RDF.FragmentGraph.

Specs

statement_count(t()) :: non_neg_integer()

Specs

statements(t()) :: [RDF.Statement.t()]

Returns a list of all statements in RDF.FragmentGraph.

Specs

subject_count(t()) :: non_neg_integer()

Specs

subjects(t()) :: MapSet.t(subject())

Returns a set of all subjects in RDF.FragmentGraph.

Specs

values(
  t(),
  keyword()
) :: map()