RDF.PropertyMap (RDF.ex v0.9.0) View Source

A bidirectional mappings from atom names to RDF.IRIs of properties.

These mapping can be used in all functions of the RDF data structures to provide the meaning of the predicate terms in input statements or define how the IRIs of predicates should be mapped with the value mapping functions like RDF.Description.values/2 etc. The :context option of these functions either take a RDF.PropertyMap directly or anything from which a RDF.PropertyMap can be created with new/1.

Because the mapping is bidirectional each term and IRI can be used only in one mapping of a RDF.PropertyMap.

RDF.PropertyMap implements the Enumerable protocol and the Access behaviour.

Link to this section Summary

Functions

Adds a set of property mappings to property_map.

Adds a property mapping between term and iri to property_map.

Adds a set of property mappings to property_map and raises an error on conflicts.

Deletes the property mapping for term from property_map.

Drops the given terms from the property_map.

Returns the IRI for the given term in property_map.

Returns whether a mapping for the given term is defined in property_map.

Creates an empty RDF.PropertyMap.

Creates a new RDF.PropertyMap with initial mappings.

Adds a set of property mappings to property_map overwriting all existing mappings.

Adds a property mapping between term and iri to property_map overwriting existing mappings.

Returns the term for the given namespace in prefix_map.

Returns whether a mapping for the given iri is defined in property_map.

Link to this section Types

Specs

coercible_term() :: atom() | String.t()

Specs

input() :: t() | map() | keyword() | RDF.Vocabulary.Namespace.t()

Specs

t() :: %RDF.PropertyMap{
  iris: %{required(atom()) => RDF.IRI.t()},
  terms: %{required(RDF.IRI.t()) => atom()}
}

Link to this section Functions

Link to this function

add(property_map, vocab_namespace)

View Source

Specs

add(t(), input()) :: {:ok, t()} | {:error, String.t()}

Adds a set of property mappings to property_map.

The mappings can be passed in various ways:

  • as keyword lists or maps where terms for the RDF properties can be given as atoms or strings, while the property IRIs can be given as RDF.IRIs or strings
  • a strict RDF.Vocabulary.Namespace from which all lowercased terms are added with their respective IRI; since IRIs can also be once in a RDF.PropertyMap a defined alias term is preferred over an original term
  • another RDF.PropertyMap from which all mappings are merged

Unless a mapping for any of the terms or IRIs in the input already exists, an :ok tuple is returned, otherwise an :error tuple.

Link to this function

add(property_map, term, iri)

View Source

Specs

add(t(), coercible_term(), RDF.IRI.coercible()) ::
  {:ok, t()} | {:error, String.t()}

Adds a property mapping between term and iri to property_map.

Unless another mapping for term or iri already exists, an :ok tuple is returned, otherwise an :error tuple.

Link to this function

add!(property_map, mappings)

View Source

Specs

add!(t(), input()) :: t()

Adds a set of property mappings to property_map and raises an error on conflicts.

See add/2 for the different forms in which mappings can be provided.

Link to this function

delete(property_map, term)

View Source

Specs

delete(t(), coercible_term()) :: t()

Deletes the property mapping for term from property_map.

If no mapping for term exists, property_map is returned unchanged.

Link to this function

drop(property_map, terms)

View Source

Specs

drop(t(), [coercible_term()]) :: t()

Drops the given terms from the property_map.

If terms contains terms that are not in property_map, they're simply ignored.

Specs

iri(t(), coercible_term()) :: RDF.IRI.t() | nil

Returns the IRI for the given term in property_map.

Returns nil, when the given term is not present in property_map.

Link to this function

iri_defined?(property_map, term)

View Source

Specs

iri_defined?(t(), coercible_term()) :: boolean()

Returns whether a mapping for the given term is defined in property_map.

Specs

new() :: t()

Creates an empty RDF.PropertyMap.

Specs

new(input()) :: t()

Creates a new RDF.PropertyMap with initial mappings.

See add/2 for the different forms in which mappings can be provided.

Link to this function

put(property_map, mappings)

View Source

Specs

put(t(), input()) :: t()

Adds a set of property mappings to property_map overwriting all existing mappings.

See add/2 for the different forms in which mappings can be provided.

Note, that not just all mappings with the used terms in the input mappings are overwritten, but also all mappings with IRIs in the input mappings

Link to this function

put(property_map, term, iri)

View Source

Specs

put(t(), coercible_term(), RDF.IRI.coercible()) :: t()

Adds a property mapping between term and iri to property_map overwriting existing mappings.

Specs

term(t(), RDF.IRI.coercible()) :: atom() | nil

Returns the term for the given namespace in prefix_map.

Returns nil, when the given namespace is not present in prefix_map.

Link to this function

term_defined?(property_map, iri)

View Source

Specs

term_defined?(t(), RDF.IRI.coercible()) :: boolean()

Returns whether a mapping for the given iri is defined in property_map.