# `DCATR.ServiceData`
[🔗](https://github.com/dcat-r/dcatr-ex/blob/v0.1.0/lib/dcatr/model/service_data.ex#L1)

A local catalog of service-specific `DCATR.Graph`s not distributed with the `DCATR.Repository`.

Since `dcatr:Service` is a `dcat:DataService` (not a `dcat:Catalog`), it cannot directly
contain graphs. ServiceData fills this role as the local `dcat:Catalog` counterpart to
`DCATR.Repository` (the distributed catalog), organizing all graphs that are specific to
a service instance:

- a `DCATR.ServiceManifestGraph` - service configuration
- a set of `DCATR.WorkingGraph`s - temporary/experimental data
- a set of service-specific `DCATR.SystemGraph`s

Typically instantiated as a blank node to avoid managing an additional URI,
but can have an explicit URI if external referencing is required.

## Schema Mapping

This schema does not directly inherit from `DCAT.Catalog` in Grax to avoid
bloating the Elixir structs with all DCAT properties. Any DCAT metadata is
still preserved in the `__additional_statements__` field of the struct.
When needed, [Grax schema mapping](https://rdf-elixir.dev/grax/api.html#mapping-between-schemas)
allows accessing service data as a `dcat:Catalog` with all DCAT properties mapped
to struct fields via the `DCAT.Catalog` schema from DCAT.ex.

# `t`

```elixir
@type t() :: %DCATR.ServiceData{
  __additional_statements__: term(),
  __id__: term(),
  manifest_graph: term(),
  system_graphs: term(),
  working_graphs: term()
}
```

# `all_graphs`

```elixir
@spec all_graphs(DCATR.Directory.Type.schema()) :: [DCATR.Graph.t()]
```

Returns all graphs through the entire sub-directory tree.

# `all_members`

```elixir
@spec all_members(DCATR.Directory.Type.schema()) :: [DCATR.Element.t()]
```

Returns all elements through the entire sub-directory tree.

# `build`

# `build`

# `build!`

# `build!`

# `build_id`

# `directories`

Returns all direct directories in the service data.

This implementation of `c:DCATR.Directory.Type.directories/1` always returns an empty list,
as service data does not contain sub-directories.

# `find_graph`

```elixir
@spec find_graph(DCATR.Directory.Type.schema(), RDF.IRI.coercible()) ::
  DCATR.Graph.t() | nil
```

Finds a graph by ID recursively through the sub-directory tree.

# `from`

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

# `from!`

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

# `graph`

```elixir
@spec graph(DCATR.GraphResolver.container(), DCATR.GraphResolver.id_or_selector()) ::
  DCATR.Graph.t() | nil
```

Returns a graph by ID or symbolic selector.

Tries `resolve_graph_selector/2` first. On `:undefined`, falls back to
`find_graph/2` (from `DCATR.Directory.Type`) for ID-based lookup.

# `graphs`

Returns all direct graphs in the service data.

This implementation of `c:DCATR.Directory.Type.graphs/1` delegates to
`DCATR.ServiceData.Type.graphs/1`.

# `has_graph?`

```elixir
@spec has_graph?(
  DCATR.GraphResolver.container(),
  DCATR.GraphResolver.id_or_selector()
) :: boolean()
```

Checks if a graph exists in the container.

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

# `load`

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

# `load!`

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

# `members`

```elixir
@spec members(DCATR.Directory.Type.schema()) :: [DCATR.Element.t()]
```

Returns all direct element members.

# `new`

# `new!`

# `resolve_graph_selector`

Resolves a symbolic selector to a graph.

This implementation of `c:DCATR.GraphResolver.resolve_graph_selector/2` delegates to
`DCATR.ServiceData.Type.resolve_graph_selector/2`.

# `system_graphs`

Returns all service-local system graphs.

This implementation of `c:DCATR.ServiceData.Type.system_graphs/1` delegates to
`DCATR.ServiceData.Type.system_graphs/1`.

# `working_graphs`

Returns all working graphs in the service data.

This implementation of `c:DCATR.ServiceData.Type.working_graphs/1` delegates to
`DCATR.ServiceData.Type.working_graphs/1`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
