Gno.Service (Gno v0.1.0)

Copy Markdown View Source

A DCATR.Service for SPARQL triple stores.

A service combines the structural model from DCATR.Service with Gno-specific operational concerns:

  • store - a Gno.Store backend providing the SPARQL triple store connection
  • commit_operation - a Gno.CommitOperation defining the middleware pipeline and commit workflow

Services are typically loaded from RDF manifest files via Gno.Manifest and then used with the functions in the top-level Gno module. Repository initialization is handled by Gno.Service.Setup.

Graph Selectors

Many operations accept a graph selector (via the :graph option or graph_name/2) that is resolved to a concrete graph IRI. Built-in selectors include:

  • :default — the default graph of the RDF dataset
  • :primary — the primary data graph designated in the repository manifest
  • :repo_manifest — the repository manifest graph
  • :service — all service graphs (for bulk operations like drop/2)

Custom selectors can be added by overriding DCATR.GraphResolver.resolve_graph_selector/2.

Summary

Functions

Builds a service with the given ID and attributes.

Checks if the service's repository exists in its store.

Returns the default graph if one is designated.

Returns a graph by ID, local name, or symbolic selector.

Returns a graph by its ID.

Returns a graph by its local name.

Returns the graph name for a given graph, selector, or ID.

Returns the complete local name to graph ID mapping.

Returns all graphs aggregated from repository and local_data catalogs.

Checks if a graph exists in the container.

Loads a service from a dataset.

Loads graph name mappings from a service manifest graph.

Creates a new service with an auto-generated blank node ID.

Returns the primary graph from the repository if one is designated.

Returns the repository type module for this service type.

Resolves a symbolic selector to a graph.

Returns the service data type module for this service type.

Returns the effective value of use_primary_as_default for this service.

Validates basic setup integrity.

Types

t()

@type t() :: %Gno.Service{
  __additional_statements__: term(),
  __id__: term(),
  commit_operation: term(),
  graph_names: term(),
  graph_names_by_id: term(),
  local_data: term(),
  repository: term(),
  store: term(),
  use_primary_as_default: term()
}

Functions

build(id)

build(id, initial)

Builds a service with the given ID and attributes.

build!(id)

build!(id, initial)

build_id(attributes)

check_setup(service)

@spec check_setup(t()) :: :ok | {:error, term()}

Checks if the service's repository exists in its store.

default_graph(service)

Returns the default graph if one is designated.

This implementation of DCATR.Service.Type.default_graph/1 delegates to DCATR.Service.Type.default_graph/1.

from(value)

@spec from(Grax.Schema.t()) :: {:ok, t()} | {:error, any()}

from!(value)

@spec from!(Grax.Schema.t()) :: t()

graph(container, id_or_selector)

Returns a graph by ID, local name, or symbolic selector.

This overrides DCATR.GraphResolver's generated graph/2 to add local name lookup.

Delegates to DCATR.Service.Type.graph/2.

graph_by_id(service, id)

Returns a graph by its ID.

Delegates to DCATR.Service.Type.graph_by_id/2.

graph_by_name(service, name)

Returns a graph by its local name.

This implementation of DCATR.Service.Type.graph_by_name/2 delegates to DCATR.Service.Type.graph_by_name/2.

graph_name(service, selector_or_graph_or_id, opts \\ [])

Returns the graph name for a given graph, selector, or ID.

This implementation of DCATR.Service.Type.graph_name/3 delegates to DCATR.Service.Type.graph_name/3.

graph_name_mapping(service)

Returns the complete local name to graph ID mapping.

Delegates to DCATR.Service.Type.graph_name_mapping/1.

graphs(service)

Returns all graphs aggregated from repository and local_data catalogs.

Delegates to DCATR.Service.Type.graphs/1.

handle_sparql(operation, service, opts \\ [])

Executes a Gno.Store.SPARQL.Operation through this service's store.

Resolves graph names via graph_name/2 before dispatching to Gno.Store.

has_graph?(container, id_or_selector)

Checks if a graph exists in the container.

Convenience function based on graph/2 - returns true if the graph exists, false otherwise.

load(graph, id, opts \\ [])

@spec load(
  RDF.Graph.t() | RDF.Description.t(),
  RDF.IRI.coercible() | RDF.BlankNode.t(),
  opts :: keyword()
) :: {:ok, t()} | {:error, any()}

load!(graph, id, opts \\ [])

@spec load!(
  RDF.Graph.t() | RDF.Description.t(),
  RDF.IRI.coercible() | RDF.BlankNode.t(),
  opts :: keyword()
) :: t()

load_from_dataset(dataset, service_id, opts \\ [])

Loads a service from a dataset.

This implementation of DCATR.Service.Type.load_from_dataset/3 delegates to DCATR.Service.Type.load_from_dataset/4.

load_graph_names(service, graph)

Loads graph name mappings from a service manifest graph.

This implementation of DCATR.Service.Type.load_graph_names/2 delegates to DCATR.Service.Type.load_graph_names/2.

new(attrs \\ [])

Creates a new service with an auto-generated blank node ID.

new!(attrs \\ [])

primary_graph(service)

Returns the primary graph from the repository if one is designated.

This implementation of DCATR.Service.Type.primary_graph/1 delegates to DCATR.Service.Type.primary_graph/1.

repository_type()

Returns the repository type module for this service type.

resolve_graph_selector(service, selector)

Resolves a symbolic selector to a graph.

This implementation of DCATR.GraphResolver.resolve_graph_selector/2 delegates to DCATR.Service.Type.resolve_graph_selector/2.

service_data_type()

Returns the service data type module for this service type.

use_primary_as_default(service)

Returns the effective value of use_primary_as_default for this service.

This implementation of DCATR.Service.Type.use_primary_as_default/1 delegates to DCATR.Service.Type.use_primary_as_default/1.

validate_setup(service)

@spec validate_setup(t()) :: :ok | {:error, term()}

Validates basic setup integrity.

The default implementation checks for repository existence (same as check_setup/1). Extensions can override this via Gno.Service.Setup.Extension.validate/2 for deeper structural validation.