@spec primary_graph(schema()) :: DCATR.DataGraph.t() | nil
Default implementation of primary_graph/1.
Returns the primary_graph field.
Behaviour for defining custom repository types with extensible graph catalogs.
DCATR.Repositorys are the core catalog layer in DCAT-R. This behaviour enables applications to
create specialized repository types with custom graph collections and selector logic.
A repository contains:
system_graphs/1 - Returns additional system-level graphsprimary_graph/1 - Returns the primary graph if one is designatedInherits from DCATR.Directory.Type:
Inherits from DCATR.GraphResolver:
:primary - Primary graph (when present):repository_manifest, :repo_manifest - Repository metadata graphCustom repository types should use DCATR.Repository.Type and define a Grax schema
extending DCATR.Repository:
defmodule MyApp.Repository do
use DCATR.Repository.Type
schema MyApp.NS.Repository < DCATR.Repository do
link history_graph: MyApp.NS.history(), type: MyApp.HistoryGraph
end
@impl true
def resolve_graph_selector(repo, :history), do: repo.history_graph
def resolve_graph_selector(repo, selector), do: super(repo, selector)
@impl true
def system_graphs(repo) do
[repo.history_graph | super(repo)]
end
endThe module automatically provides delegating implementations of all callbacks and convenience functions, all of which are overridable.
Returns the primary graph if one is designated.
Returns all system graphs in the repository.
Default implementation of DCATR.Directory.Type.directories/1 for repositories.
Default implementation of DCATR.Directory.Type.graphs/1 for repositories.
Default implementation of primary_graph/1.
Default implementation of DCATR.GraphResolver.resolve_graph_selector/2.
Default implementation of system_graphs/1.
@type schema() :: Grax.Schema.t()
@type t() :: module()
@callback primary_graph(repository :: schema()) :: DCATR.DataGraph.t() | nil
Returns the primary graph if one is designated.
Override to customize primary graph selection.
@callback system_graphs(repository :: schema()) :: [DCATR.SystemGraph.t()]
Returns all system graphs in the repository.
System graphs are repository-level graphs not part of the primary dataset (e.g., history graphs, provenance graphs).
Override to include additional system-level graphs specific to your repository type.
@spec directories(schema()) :: [DCATR.Dataset.t()]
Default implementation of DCATR.Directory.Type.directories/1 for repositories.
Returns the dataset as the sole sub-directory (when present).
@spec graphs(schema()) :: [DCATR.Graph.t()]
Default implementation of DCATR.Directory.Type.graphs/1 for repositories.
Returns direct graph members: data_graph (when present), manifest, and system graphs.
In multi-graph mode (with dataset), data_graph is nil and the data graphs are reached
via dataset traversal.
@spec primary_graph(schema()) :: DCATR.DataGraph.t() | nil
Default implementation of primary_graph/1.
Returns the primary_graph field.
@spec resolve_graph_selector(schema(), DCATR.GraphResolver.selector()) :: DCATR.Graph.t() | nil | :undefined
Default implementation of DCATR.GraphResolver.resolve_graph_selector/2.
Resolves repository-specific selectors, then delegates to the dataset for unknown selectors.
Supported selectors:
:primary - Primary graph (when present):repository_manifest, :repo_manifest - Repository manifest graph@spec system_graphs(schema()) :: [DCATR.SystemGraph.t()]
Default implementation of system_graphs/1.
Returns the system_graphs field.