DCATR.GraphResolver behaviour (DCAT-R.ex v0.1.0)

Copy Markdown View Source

Behaviour for graph lookup via symbolic selectors.

This module provides graph access by ID or symbolic selector (e.g., :primary, :repository_manifest). Each container type defines its own selectors for commonly needed graphs.

Structural operations (member enumeration, directory traversal) are in DCATR.Directory.Type, while this behaviour adds named graph access on top.

Core Callback

Generated Functions

The __using__ macro generates:

  • graph/2 — calls resolve_graph_selector/2, falls back to find_graph/2 (from DCATR.Directory.Type)
  • has_graph?/2graph/2 != nil

Both are defoverridable.

Summary

Callbacks

Resolves a symbolic selector to a graph.

Types

container()

@type container() :: Grax.Schema.t()

id_or_selector()

@type id_or_selector() :: selector() | RDF.IRI.coercible()

selector()

@type selector() :: atom()

t()

@type t() :: module()

Callbacks

resolve_graph_selector(container, selector)

@callback resolve_graph_selector(container(), selector()) ::
  DCATR.Graph.t() | nil | :undefined

Resolves a symbolic selector to a graph.

Each container type defines selectors for its commonly needed graphs (e.g., :primary on repositories, :service_manifest on service data).

Return values

  • %DCATR.Graph{} - Selector resolved successfully to a graph
  • nil - Selector is recognized but references no graph (e.g., :primary when no primary graph is defined)
  • :undefined - Selector is not recognized by this implementation (enables delegation in hierarchies)

Implementations should only handle their own selectors and return :undefined for unknown ones.