diff --git a/commands/cat/my_reports.py b/commands/cat/my_reports.py index e1df0ce4..e075c633 100644 --- a/commands/cat/my_reports.py +++ b/commands/cat/my_reports.py @@ -28,6 +28,25 @@ from textual.widgets import Static, Button, DataTable, Header, Footer, Input, Tree, Label + +#: How many list items a TUI cell shows before "+N more" (R4). +TUI_CELL_ITEMS = 10 + + +def tui_cell(value): + """One TUI table cell for a list or a dict (R4): a list joins its items' names with ", " (+N more + past TUI_CELL_ITEMS); a dict is JSON. Neither becomes extra columns.""" + import json as _json + from pyegeria.view.output_formatter import value_names + if isinstance(value, dict): + return _json.dumps(value, ensure_ascii=False, default=str) + if isinstance(value, (list, tuple)): + names = value_names(list(value)) if any(isinstance(v, dict) for v in value) else [str(v) for v in value] + shown = names[:TUI_CELL_ITEMS] + rest = len(names) - len(shown) + return ", ".join(shown) + (f" (+{rest} more)" if rest else "") + return value + class RunSpec(App): CSS_PATH = "my_reports.tcss" @@ -310,14 +329,9 @@ async def display_response(self, response): self.log(f"list_item: {list_item}") for key, value in response_dict.items(): self.log(f"key: {key}, value: {value}") - if isinstance(value, dict): - for vkey, vvalue in value.items(): - self.log(f"vkey: {vkey}, vvalue: {vvalue}") - self.rotated_table.setdefault(str(vkey), []).append(vvalue) - elif isinstance(value, list): - for v in value: - self.log(f"v: {v}") - self.rotated_table.setdefault(str(v), []).append(" ") + if isinstance(value, (dict, list)): + # R4: one cell, never extra columns (a native DICT holds lists and objects) + self.rotated_table.setdefault(str(key), []).append(tui_cell(value)) elif key == "kind" and value == "empty": key_str: str = "NoData" message: str = "For That Asset Type in this repository" @@ -332,12 +346,8 @@ async def display_response(self, response): self.log(f"key: {key}, value: {value}") if key == "kind": continue - elif isinstance(value, dict): - for vkey, vvalue in value.items(): - self.rotated_table.setdefault(str(vkey), []).append(vvalue) - elif isinstance(value, list): - for v in value: - self.rotated_table.setdefault(str(v), []).append(" ") + elif isinstance(value, (dict, list)): + self.rotated_table.setdefault(str(key), []).append(tui_cell(value)) # R4: one cell elif key == "kind" and value == "empty": key_str = "NoData" message = "For That Asset Type in this repository" diff --git a/commands/cat/run_report.py b/commands/cat/run_report.py index 7ff2765f..1fd9fb04 100644 --- a/commands/cat/run_report.py +++ b/commands/cat/run_report.py @@ -21,7 +21,7 @@ import os import sys import time -from typing import Any, Dict, List, Mapping, Sequence +from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple import click from rich import box @@ -61,6 +61,7 @@ def list_generic( render_table: bool = False, table_caption: str | None = None, use_pager: bool = True, + table_shape: str = "rows", ) -> Dict[str, Any]: """ Execute a report spec and return results, usable both as a library function and CLI. @@ -90,6 +91,12 @@ def list_generic( params = dict(params or {}) ofmt = (output_format or "TABLE").upper() + if ofmt == "DOCUMENT": + # SD-1: a document spec's exporter takes its own parameters; exec_report_spec refuses a + # spec that is not a document spec, and the caller writes the file (write_document). + return exec_report_spec(report_spec, output_format="DOCUMENT", params=params, view_server=view_server, + view_url=view_url, user=user, user_pass=user_pass) + # Load format spec to introspect required/optional params # First, validate existence of the report regardless of type fmt_any = select_report_spec(report_spec, "ANY") @@ -144,6 +151,22 @@ def list_generic( else: raise ValueError(f"Missing required parameter(s): {', '.join(missing)}") + if ofmt == "TABLE" and table_shape == "structured": + # R3: the structured table, drawn natively (run_report's own CLI asks for it; the library default + # stays "rows", which the Textual TUI and hey_egeria commands read). + result = exec_report_spec(report_spec, output_format="TABLE", table_shape="structured", params=params, + view_server=view_server, view_url=view_url, user=user, user_pass=user_pass) + heading = get_report_spec_heading(report_spec) or f"Report: {report_spec}" + rendered = False + if render_table and result.get("kind") == "table": + console = Console(width=width, force_terminal=not jupyter) + render_structured_table(console, result, heading, + table_caption or f"View Server '{view_server}' @ Platform - {view_url}", + use_pager=use_pager) + rendered = True + return {"kind": result.get("kind"), "heading": heading, "structured": result, + "notes": list(result.get("notes") or []), "rendered": rendered} + # Map only TABLE to DICT for data retrieval; pass through other formats mapped_format = "DICT" if ofmt == "TABLE" else ofmt try: @@ -196,12 +219,13 @@ def list_generic( force_terminal=not jupyter, ) caption = table_caption or f"View Server '{view_server}' @ Platform - {view_url}" - _render_table(console, heading, caption, data, use_pager=use_pager) + _render_table(console, heading, caption, data, use_pager=use_pager, notes=result.get("notes")) rendered = True return { "kind": "table", "heading": heading, "data": data, + "notes": list(result.get("notes") or []), "required": required_params, "optional": optional_params, "rendered": rendered, @@ -251,60 +275,70 @@ def list_generic( } +#: How many scalar list items a CLI cell shows before "+N more" (fix-now F4), and the width a joined +#: cell may reach before items are cut at an item boundary. +CELL_ITEMS = 3 +CELL_CHARS = 120 + + +def _object_name(x: Mapping[str, Any]) -> str: + name = x.get("name") or x.get("displayName") or x.get("qualifiedName") or x.get("guid") + if name: + return str(name) + str_vals = [v for v in x.values() if isinstance(v, str) and v.strip()] + return str_vals[0] if str_vals else f"(unnamed {x.get('type') or 'item'})" + + +def _join_capped(items: List[str], *, max_items: Optional[int] = None, max_chars: int = CELL_CHARS) -> str: + """Items joined with ", ", cut at an item boundary when there are more than `max_items` or the + cell would pass `max_chars`, always with "+N more" (fix-now F4: never only a count).""" + shown: List[str] = [] + for item in items: + if max_items is not None and len(shown) >= max_items: + break + if shown and len(", ".join(shown + [item])) > max_chars: + break + shown.append(item) + if not shown and items: + shown = [items[0]] + rest = len(items) - len(shown) + return ", ".join(shown) + (f" (+{rest} more)" if rest else "") + + +def _cell(value: Any) -> str: + """One CLI table cell for a nested value (fix-now F4).""" + if isinstance(value, Mapping): # a map is one "k: v; ..." cell, never exploded into columns + return "; ".join(f"{k}: {_cell(v)}" for k, v in value.items()) + if isinstance(value, (list, tuple)): + if not value: + return "" + if all(isinstance(x, Mapping) for x in value): + return _join_capped([_object_name(x) for x in value]) + items = [str(x) for x in value] + if len(", ".join(items)) <= CELL_CHARS // 2: # the whole list fits: show all of it + return ", ".join(items) + return _join_capped(items, max_items=CELL_ITEMS) + return "" if value is None else str(value) + + def _flatten(item: Any, parent_key: str = "", sep: str = ".") -> Dict[str, Any]: - """Flatten nested dict-like objects into a single level using dot-notation keys. - For nested collections of entities (master-detail), try to summarize by name. - """ - flat: Dict[str, Any] = {} + """One table row from a result row: each top-level key is a column; a nested map is one + "k: v; ..." cell and a list is a joined cell with "+N more" (fix-now F4), so nested values never + explode into dotted columns that push the author's columns out.""" if isinstance(item, Mapping): - for k, v in item.items(): - new_key = f"{parent_key}{sep}{k}" if parent_key else str(k) - flat.update(_flatten(v, new_key, sep)) - elif isinstance(item, (list, tuple)): - if not item: - flat[parent_key or "list"] = "" - elif all(isinstance(x, Mapping) for x in item): - # Master-detail or nested entities: try to summarize by name - names = [] - for x in item: - # Prefer friendlier names often added by materializers - name = ( - x.get("name") - or x.get("displayName") - or x.get("qualifiedName") - or x.get("guid") - ) - if name: - names.append(str(name)) - else: - # Fallback: find first string value in the dict - str_vals = [v for v in x.values() if isinstance(v, str)] - names.append(str_vals[0] if str_vals else str(x)) - - summary = ", ".join(names) - # If still very long, truncate for table display - if len(summary) > 120: - summary = summary[:117] + "..." - flat[parent_key or "list"] = summary - elif len(item) <= 3: - flat[parent_key or "list"] = ", ".join([str(x) for x in item]) - else: - flat[parent_key or "list"] = f"{len(item)} items" - else: - flat[parent_key or "value"] = item - return flat + return {(f"{parent_key}{sep}{k}" if parent_key else str(k)): _cell(v) for k, v in item.items()} + return {parent_key or "value": _cell(item)} -def _collect_columns(rows: Sequence[Mapping[str, Any]], max_cols: int = 12) -> List[str]: - """Collect a union of keys across rows, up to max_cols, keeping a stable ordering.""" +def _collect_columns(rows: Sequence[Mapping[str, Any]], max_cols: int = 12) -> Tuple[List[str], List[str]]: + """The columns to show, in the author's order (first appearance across rows), and the ones dropped + from the end past `max_cols` (fix-now F5: the caller names them in a footer, never a silent cut).""" seen: List[str] = [] for row in rows: for k in row.keys(): if k not in seen: seen.append(k) - if len(seen) >= max_cols: - return seen - return seen + return seen[:max_cols], seen[max_cols:] def _ensure_rows(data: Any) -> List[Mapping[str, Any]]: @@ -317,7 +351,7 @@ def _ensure_rows(data: Any) -> List[Mapping[str, Any]]: if isinstance(item, Mapping): rows.append(_flatten(item)) else: - rows.append({"value": item}) + rows.append({"value": _cell(item)}) return rows if isinstance(data, Mapping): # If a single object contains a list-like 'elements' or similar, prefer that @@ -329,13 +363,19 @@ def _ensure_rows(data: Any) -> List[Mapping[str, Any]]: return [{"value": data}] -def _render_table(console: Console, title: str, caption: str, data: Any, use_pager: bool = True) -> None: +def hidden_columns_footer(dropped: Sequence[str]) -> str: + """The footer naming columns the table could not show (fix-now F5, the Portal #832 pattern).""" + return f"+{len(dropped)} more column{'s' if len(dropped) != 1 else ''}: {', '.join(dropped)}" if dropped else "" + + +def _render_table(console: Console, title: str, caption: str, data: Any, use_pager: bool = True, + notes: Optional[Sequence[str]] = None, max_cols: int = 12) -> None: rows = _ensure_rows(data) if not rows: console.print("No results found.") return - columns = _collect_columns(rows) + columns, dropped = _collect_columns(rows, max_cols=max_cols) table = Table( title=title, @@ -354,12 +394,156 @@ def _render_table(console: Console, title: str, caption: str, data: Any, use_pag for row in rows: table.add_row(*[str(row.get(col, "")) for col in columns]) + footer = [hidden_columns_footer(dropped)] if dropped else [] + footer += list(notes or []) # fix-now F8: e.g. "the first 100 ...; more may exist" + + def _print(): + console.print(table) + for line in footer: + console.print(line) + # Page the table if it's large if use_pager: with console.pager(): - console.print(table) + _print() else: + _print() + + +# ── R3: the structured TABLE (kind "table") drawn natively with Rich ── + +#: Narrowest a main-table column may get before columns are dropped from the end (author's order). +MIN_COLUMN_WIDTH = 14 + + +def _row_name(row: Mapping[str, Any], columns: Sequence[Mapping[str, Any]]) -> str: + for key in ("display_name", "displayName", "title", "qualified_name", "name"): + if row.get(key): + return str(row[key]) + first = next((row.get(c["key"]) for c in columns if isinstance(row.get(c["key"]), (str, int, float))), None) + return str(first) if first not in (None, "") else "row" + + +def _names(value: Any, label: Optional[str]) -> List[str]: + from pyegeria.view.output_formatter import _legacy_name + items = value if isinstance(value, list) else [value] + out = [] + for item in items: + if isinstance(item, Mapping): + out.append(_legacy_name(dict(item), label) or _object_name(item)) + elif item not in (None, ""): + out.append(str(item)) + return out + + +def _clamp(text: str, max_lines: int, width: int) -> str: + """Long text cut at max_lines lines of the column's width, with "…" (R3).""" + lines: List[str] = [] + for para in str(text).splitlines() or [""]: + while len(para) > width and len(lines) < max_lines: + lines.append(para[:width]) + para = para[width:] + if len(lines) >= max_lines: + break + lines.append(para) + cut = "\n".join(lines[:max_lines]) + return cut + "…" if len(cut.replace("\n", "")) < len(str(text).replace("\n", "")) else cut + + +def _rich_cell(value: Any, column: Mapping[str, Any], width: int) -> Any: + from rich.table import Table as _Table + from pyegeria.view.structured_table import DEFAULT_MAX_ITEMS, DEFAULT_MAX_LINES + if value in (None, "", [], {}): + return "" + render = column.get("render") or "text" + limit = column.get("max_items") or DEFAULT_MAX_ITEMS + if render == "subtable": + n = len(value) if isinstance(value, list) else 1 + return f"{n} item{'s' if n != 1 else ''} · see below" + if render == "count": + return str(len(value)) if isinstance(value, (list, dict)) else str(value) + if render == "kv" and isinstance(value, Mapping): + grid = _Table.grid(padding=(0, 1)) + grid.add_column(style="bold") + grid.add_column() + for k, v in value.items(): + grid.add_row(str(k), _cell(v)) + return grid + if isinstance(value, (list, Mapping)): + names = _names(value, column.get("label")) + shown, rest = names[:limit], len(names) - min(len(names), limit) + if render == "bullets": + return "\n".join(f"• {n}" for n in shown) + (f"\n+{rest} more" if rest else "") + return ", ".join(shown) + (f" (+{rest} more)" if rest else "") + if column.get("type") == "text": # long text only: a short value is never cut + return _clamp(str(value), column.get("max_lines") or DEFAULT_MAX_LINES, max(width, 8)) + return str(value) + + +def render_structured_table(console: Console, result: Mapping[str, Any], title: str, caption: str = "", + use_pager: bool = False) -> None: + """Draw a structured TABLE (kind "table", R1) with Rich (R3): bullets one per line, kv as a nested + table, long text cut at max_lines with "…", each subtable as a separate table after the main one + titled " · " (owner §7.3), and columns that do not fit the terminal dropped from + the end of the author's order with a footer naming them. Notes (caps, reductions) follow.""" + columns = list(result.get("columns") or []) + rows = list(result.get("rows") or []) + if not rows: + console.print("No results found.") + for note in result.get("notes") or []: + console.print(note) + return + fit = max(1, (console.width or 80) // MIN_COLUMN_WIDTH) + shown_cols, dropped = columns[:fit], columns[fit:] + width = max(MIN_COLUMN_WIDTH, (console.width or 80) // max(1, len(shown_cols)) - 3) + + table = Table(title=title, caption=caption or None, show_lines=True, box=box.ROUNDED, expand=True) + for col in shown_cols: + table.add_column(str(col.get("name") or col.get("key")), overflow="fold") + subtables = [] + for row in rows: + table.add_row(*[_rich_cell(row.get(c["key"]), c, width) for c in shown_cols]) + for c in shown_cols: + if c.get("render") == "subtable" and isinstance(row.get(c["key"]), list) and row.get(c["key"]): + subtables.append((f"{_row_name(row, columns)} · {c.get('name')}", row[c["key"]])) + + footer = [] + if dropped: + footer.append(hidden_columns_footer([str(c.get("name") or c.get("key")) for c in dropped])) + if result.get("total") is None and result.get("shown"): + footer.append(f"{result['shown']} rows shown; the total was not counted.") + footer += list(result.get("notes") or []) + + def _print(): console.print(table) + for sub_title, sub_rows in subtables: + sub = Table(title=sub_title, show_lines=True, box=box.SIMPLE_HEAD, expand=True) + keys: List[str] = [] + for r in sub_rows: + for k in (r.keys() if isinstance(r, Mapping) else ["value"]): + if k not in keys: + keys.append(k) + for k in keys: + sub.add_column(str(k), overflow="fold") + for r in sub_rows: + r = r if isinstance(r, Mapping) else {"value": r} + sub.add_row(*[_sub_cell(r.get(k)) for k in keys]) + console.print(sub) + for line in footer: + console.print(line) + + if use_pager: + with console.pager(): + _print() + else: + _print() + + +def _sub_cell(value: Any) -> str: + """A subtable cell: two levels only, so a reduced third level shows as "N: names".""" + if isinstance(value, Mapping) and "count" in value and "names" in value: + return f"{value['count']}: {', '.join(value['names'])}" + return _cell(value) def write_output_file(content: str, report_spec: str, suffix: str) -> str: @@ -384,12 +568,54 @@ def write_output_file(content: str, report_spec: str, suffix: str) -> str: return full_file_path -def main(): +def validation_line(result: Mapping[str, Any]) -> str: + """One line saying whether a DOCUMENT result was validated, by what, and what was found.""" + v = result.get("validation") or {} + state = v.get("state", "not_validated") + if state == "not_validated": + return f"Validation: not validated ({v.get('reason') or 'no reason given'})" + findings = v.get("findings") or [] + tail = f", {len(findings)} finding{'s' if len(findings) != 1 else ''}" if findings else "" + return f"Validation: {state} ({v.get('validator')}{tail})" + + +def write_document(result: Mapping[str, Any], output_dir: str, *, force: bool = False) -> str: + """Write a DOCUMENT result's text to `output_dir/` and return the path. + + The file name is the result's own (already checked by the executor) and is checked again + here: it must name a file directly inside `output_dir`. An existing file is not overwritten + unless `force` is set (FileExistsError, with the path).""" + from pyegeria.view._output_format_models import check_document_file_name + + if result.get("kind") != "document": + raise ValueError(f"not a DOCUMENT result (kind {result.get('kind')!r})") + file_name = str(result.get("file_name") or "") + reason = check_document_file_name(file_name) + if reason: + raise ValueError(f"DOCUMENT file_name refused: {reason}") + out_dir = os.path.abspath(os.path.expanduser(output_dir)) + os.makedirs(out_dir, exist_ok=True) + path = os.path.join(out_dir, file_name) + if os.path.dirname(os.path.abspath(path)) != out_dir: + raise ValueError(f"DOCUMENT file_name refused: '{file_name}' does not name a file in {out_dir}") + if os.path.exists(path) and not force: + raise FileExistsError(f"{path} already exists; pass --force to overwrite it") + with open(path, "w", encoding="utf-8") as f: + f.write(str(result.get("text", ""))) + return path + + +def main(argv: Sequence[str] | None = None): parser = argparse.ArgumentParser(description="Generic list command using exec_report_spec") parser.add_argument("--report", dest="report_spec", help="Report spec name to execute (see report specs)") parser.add_argument("--output-format", dest="output_format", default="TABLE", - choices=["TABLE", "MD", "REPORT", "REPORT-GRAPH", "FORM", "HTML", "MERMAID", "LIST", "JSON", "DICT"], - help="Output rendering format") + choices=["TABLE", "MD", "REPORT", "REPORT-GRAPH", "FORM", "HTML", "MERMAID", "LIST", "JSON", "DICT", + "DOCUMENT"], + help="Output rendering format (DOCUMENT: a standard document from a document spec)") + parser.add_argument("--output", dest="output_dir", + help="DOCUMENT only: directory to write the document to, as its file name") + parser.add_argument("--force", action="store_true", + help="DOCUMENT only: overwrite the file if it already exists") parser.add_argument("--server", dest="server", help="Egeria view server name", default=app_config.egeria_view_server) parser.add_argument("--url", dest="url", help="Egeria platform URL", default=app_config.egeria_view_server_url) parser.add_argument("--userid", dest="user", help="User Id", default=EGERIA_USER) @@ -398,7 +624,7 @@ def main(): parser.add_argument("--params-json", dest="params_json", help="JSON string of parameters for the report spec") parser.add_argument("--param", dest="params_kv", action="append", default=[], help="Repeated key=value parameters") - args = parser.parse_args() + args = parser.parse_args(argv) # Prompt for report spec if not provided report_spec = args.report_spec or Prompt.ask("Enter the report spec to execute").strip() @@ -424,12 +650,36 @@ def main(): force_terminal=not app_config.egeria_jupyter, ) + if output_format == "DOCUMENT": + if not args.output_dir: + console.print("[bold red]DOCUMENT output needs --output to write the document to[/]") + return 2 + try: + result = list_generic(report_spec, output_format="DOCUMENT", params=params, view_server=args.server, + view_url=args.url, user=args.user, user_pass=args.password) + path = write_document(result, args.output_dir, force=args.force) + except FileExistsError as e: + console.print(f"[bold red]{e}[/]") + return 1 + except ValueError as e: + console.print(f"[bold red]{e}[/]") + return 1 + except PyegeriaException as e: + print_exception_response(e) + return 1 + print(f"==> {result.get('standard')} document written to {path}") + print(validation_line(result)) + for note in result.get("notes") or []: + print(f" note: {note}") + return 0 + try: # Use shared function with prompting enabled for missing required params write_file = output_format in TEXT_FILE_FORMATS result = list_generic(report_spec, output_format=output_format, params=params, view_server=args.server, view_url=args.url, user=args.user, user_pass=args.password, jupyter=app_config.egeria_jupyter, - width=settings.Environment.egeria_width, prompt_missing=True, write_file=write_file) + width=settings.Environment.egeria_width, prompt_missing=True, write_file=write_file, + table_shape="structured" if output_format == "TABLE" else "rows") # R3 if result.get("kind") == "empty": console.print("No results found.") @@ -438,7 +688,10 @@ def main(): if output_format in {"TABLE", "DICT"}: heading = result.get("heading") or (get_report_spec_heading(report_spec) or f"Report: {report_spec}") caption = f"View Server '{args.server}' @ Platform - {args.url}" - _render_table(console, heading, caption, result.get("data")) + if result.get("structured") is not None: + render_structured_table(console, result["structured"], heading, caption) + else: + _render_table(console, heading, caption, result.get("data"), notes=result.get("notes")) return # For narrative formats, either a file was written or content is returned diff --git a/docs/output-formats-and-report-specs.md b/docs/output-formats-and-report-specs.md index c2fd7253..327c1521 100644 --- a/docs/output-formats-and-report-specs.md +++ b/docs/output-formats-and-report-specs.md @@ -376,6 +376,174 @@ Notes --- +### Structured tables and native rows + +Report specs render complex values (lists, maps, related elements) from **native values**. Two caller +flags expose them; neither is a spec field, and the defaults return today's shapes unchanged. + +- `exec_report_spec(name, output_format="TABLE", table_shape="structured")` returns: + + ``` + {"kind": "table", + "columns": [{"key", "name", "type", "render", "detail_spec", "valid_values", "max_items", "max_lines"}], + "rows": [{key: native value}], + "total": int | None, "shown": int, "notes": [str]} + ``` + + `type` is inferred from the column's values: `scalar` (a short value), `text` (long or multi-line), + `list` (of scalars), `map`, `elements` (related elements) or `table` (sub-rows, e.g. a `detail_spec` + column). A column that mixes kinds takes the widest and the notes say so. `render` is the column's own, + else the default for its type (`text`, `bullets`, `kv`, `join`, `subtable`). Related elements are + `{guid, qualifiedName, displayName, type}`. A table shows two levels: an object inside a sub-row is + reduced to `{count, names, guid?}` with a note. `total` is the row count when the query did not fill + its page; when it did, `total` is `None` and the notes say "more may exist" (Egeria's paging contract). + `total_basis` says what `total` rests on: `"one page"` (the one page the query returned; a short page + is not promised to be the last). + An empty relationship cell says what it means: when the request asked for that relationship (graph + depth 1 or more, not filtered out) it is an explicit empty list and the notes say "none"; when it did + not, the cell is `null` and the notes say "not read". Egeria omits a relationship an element does not + have, so this is the only way to tell the two apart. The flat DICT and text outputs stay blank. +- `exec_report_spec(name, output_format="DICT", dict_shape="native")` (and `generate_output(..., + dict_shape="native")`) returns DICT rows with native values: lists stay lists, related elements are + objects with both names, classifications and zones are lists, and `format=True` columns are not + stringified. The default `"flat"` is unchanged. `dict_shape` does not change TABLE (its structured form + is `table_shape`). +- A column can say how it renders (R2), all optional: + - `render`: `text`, `join`, `bullets`, `kv`, `subtable`, `count` or `link`. Unset, it follows the + value's type (above); a column of related elements with more than `max_items` in a cell defaults to + `count`. `subtable` without a `detail_spec` uses the objects' own scalar keys. + - `max_items` (default 10): list items shown before "+N more". + - `max_lines` (default 3): lines of long text shown in web-oriented outputs. Markdown documents + (REPORT, LIST) do not clamp. + - `label`: `qualified_name` (the default) or `display_name`, the name a related element shows in text + outputs. Set it per column (Digital-Products sets `display_name` on Product Manager and License); + there is no global switch, because consumers split qualifiedNames. + These fields travel in Egeria-held specs (microflow column items; `label` travels as `related_label`, + since an item's own `label` is the column's title). +- Renderers draw from native values (R3): + - **LIST (markdown table cells):** a list of scalars is bullets, one item per line (`a
b`), with + "+N more" past `max_items`; related elements are joined, "a, b (+N more: c, d)", in the column's + `label`; a map is `k: v
...`; a `count` column shows the number. `|` is escaped and newlines + become `
`. A `format=True` or `detail_spec` column keeps its own rendering. REPORT and LIST are + documents, not tiles, so long text is not clamped. + - **REPORT:** lists are markdown lists, and `detail_spec` columns are sub-reports after the row. + - **CLI (`run_report --output-format TABLE`):** asks for the structured table and draws it with Rich: + bullets one per line, a map as a nested table, long text cut at `max_lines` with "…", a sub-table as + a separate table after the main one titled " · ", and columns that do not fit the + terminal dropped from the end of the author's order with a footer naming them. The library function + `list_generic` keeps the flat rows unless asked (`table_shape="structured"`); the Textual report TUI + stays on flat rows. +- Both apply to find-method specs; DOCUMENT, chart and analytic results ignore them. Any other value is + refused with a sentence. `_async_run_report` takes the same flags. + +### Document outputs + +A **DOCUMENT** spec produces one document in a published standard (for example DCAT-AP 3 as +JSON-LD), not a rendering of columns. The document is built by an **exporter**: a function +registered as an analytic function (`register_analytic_functions`) and named as the spec's +`action.analytic_function`. A DOCUMENT spec has exactly one format, of type `DOCUMENT`, and it +carries a `document` block: + +```python +FormatSet( + heading="Toy Catalog", description="A toy document", + action=ActionParameter(analytic_function="toy_export"), + formats=[Format(types=["DOCUMENT"], document={ + "standard": "toy-1", + "media_type": "application/json", + "file_name": "{scope}-toy.json", # filled from the run's parameters + "validator": "json-schema", # optional, a registered validator name + "validator_options": {"schema": "package:my_exporters/schemas/toy.schema.json"}, + })]) +``` + +Load rules (each refusal is a sentence): + +- `DOCUMENT` needs `action.analytic_function`. A DOCUMENT spec with a `function` (a find) and no + analytic function is refused: a find returns elements, not a document. +- `DOCUMENT` stands alone in its format row, needs its `document` block, and the spec has no + other formats. Only a DOCUMENT format carries a `document` block. +- `file_name` is a single file name: no path separators, no `..`, not hidden. Parameter values + filled into it are made file-name safe (`Folder::Sales/EU` becomes `Folder_Sales_EU`) and the + result is checked again. A parameter the run did not supply is refused. + +Run it with `exec_report_spec(name, output_format="DOCUMENT", params={...})`. Any other output +format asked of a DOCUMENT spec is refused with a sentence naming DOCUMENT, and DOCUMENT asked of +any other spec is refused. The exporter returns `{"text": str, "notes": [str, ...]}` (or a plain +string). The result is: + +``` +{"kind": "document", + "standard": "toy-1", "media_type": "application/json", "file_name": "Sales-toy.json", + "text": "...", + "validation": {"state": "valid" | "invalid" | "not_validated", + "validator": "json-schema" | None, + "findings": ["/age: -1 is less than the minimum of 0", ...], + "reason": None | "why it was not validated"}, + "notes": ["what the exporter left out, and why", ...]} +``` + +`validation` is **always present**; an unvalidated document says so and why, and is never +presented as conforming: + +- no validator declared: `not_validated`, "no validator is declared for this standard"; +- a validator name not registered: `not_validated`, "the validator is not registered"; +- a validator that raises: `not_validated`, "the validator failed: [ at line L, + column C]". A crash says nothing about the document, so it is never a finding and never + `invalid`. The parser's own text is never put in `reason`: it can quote the input. +- a spec's `schema`/`shapes` option that is not a `package:` reference: `not_validated`, "was not + run" (and refused when the spec loads as a model). + +`notes` is always present too: every field the exporter omitted or left empty is named there +with the reason. + +**Validators** are registered by name with +`pyegeria.view.document_validators.register_document_validators({name: fn})`, where +`fn(text, media_type, **validator_options) -> (valid: bool, findings: list[str])`; a name already +registered raises `DocumentValidatorCollision`. Two are built in: + +- `json-schema` (jsonschema): option `schema`, for JSON or YAML text; +- `shacl` (pySHACL over rdflib): option `shapes` (Turtle), for JSON-LD, Turtle, RDF/XML, + N-Triples… by media type. Findings read " : ". + +A validator **never fetches over the network**. In a report spec, `schema`/`shapes` must be +package data (`package:/`): specs can be held in Egeria and written +by any user, so a spec may not make pyegeria read a local file or a URL. Code may pass a local path +or `file://` URL to the validator functions directly, and `make_shacl_validator(shapes)` binds the +`shacl` built-in to one shapes graph, for registering a validator per standard. An `http(s)` +reference is refused; a JSON Schema `$ref` that is not in the schema is `Unresolvable`, never +fetched; JSON-LD whose `@context` names another document is refused (inline the context). rdflib, pySHACL and jsonschema are plain pyegeria dependencies, so +`not_validated` never means "an extra is missing". + +**CLI.** `run_report --report --output-format DOCUMENT --output --param scope=...` +writes the document to `/` and prints the validation line and any notes. It +refuses to overwrite an existing file unless `--force` is given. + +#### DCAT Catalog (DCAT-AP 3) + +The built-in specs **DCAT Catalog** (JSON-LD) and **DCAT Catalog (Turtle)** export the Assets in +a collection or folder as a DCAT-AP 3 catalog. The exporter is the analytic function +`export_dcat` (`pyegeria/view/export_dcat.py`); the validator is `dcat-ap-3-shacl`, pySHACL over +the DCAT-AP 3.0.1 shapes vendored in `pyegeria/view/data/dcat-ap-3/` (CC BY 4.0; source, commit +and hashes in the README there). + +```bash +run_report --report "DCAT Catalog" --output-format DOCUMENT --output ./out --param scope=DashboardFolder::Consumer::Portal +``` + +- `scope` is a collection qualifiedName or GUID; `export_dcat` also takes `search_string` (assets + in the asset domain), `format` (`jsonld` or `turtle`) and `page_size`. +- A `dcat:Dataset` is an **Asset**. DigitalProducts and Agreements are Bitol's: each is named in + the notes (": a DigitalProduct, not a DCAT dataset (Bitol)"), never exported. +- It reads as the caller. A zoned Asset the caller can read is `dct:accessRights NON_PUBLIC`. A + member Egeria refuses with a 403 is noted as "not visible to ", never as absent. +- Identity is the qualifiedName (`dct:identifier`); the GUID is `adms:identifier`. Nodes are + `urn:egeria:guid:` IRIs and the output is sorted, so the same metadata gives the same bytes. +- Every property left out says why in the notes, grouped by reason with the datasets it applies + to (no Ownership, no License, no access path, no keywords...). + +--- + ### Vega-Lite Graphs and Automated Extraction PyEgeria supports dynamic Vega-Lite visualization for categorical data. Instead of manually extracting charting attributes for each API payload, the `materialize_egeria_summary` engine automatically scans Egeria API responses for numeric dictionaries (e.g. `typeMembership: {"Asset": 5, "GlossaryTerm": 10}`). When found, it automatically generates two attributes at the root level of the materialized object: diff --git a/docs/release-notes/6.2.37.md b/docs/release-notes/6.2.37.md new file mode 100644 index 00000000..d1594069 --- /dev/null +++ b/docs/release-notes/6.2.37.md @@ -0,0 +1,107 @@ +# pyegeria 6.2.37 + +pyegeria 6.2.37 adds standard-document output to report specs (a DCAT-AP 3 catalog of Assets first), and corrects +and extends how report specs render complex values: +- **New output, new shapes, all opt-in:** a DOCUMENT output type with validators; a structured TABLE + (`table_shape="structured"`) and native DICT rows (`dict_shape="native"`); per-column render intents. +- **Existing applications work unchanged:** the same calls return the same result shapes. Structured and native + results come back only when a caller asks for them, and DICT stays flat by default. +- **Behaviour change:** rendered **text** changes on upgrade (see below). Anything that parses pyegeria's rendered + text (REPORT, LIST, MD, FORM, HTML or the CLI table), rather than DICT or JSON, should be re-checked. + +## New + +- **DOCUMENT output type (SD-1).** A report spec can produce one standard document instead of rendered columns: + `exec_report_spec(name, output_format="DOCUMENT", params=...)` returns + `{kind: "document", standard, media_type, file_name, text, validation, notes}`. + - `validation` is always present: `valid`, `invalid`, or `not_validated` with the reason. A validator that fails + is `not_validated` with its error type and line/column, never its parser's text. + - `notes` says what the document leaves out and why. + - Validators are registered by name (`register_document_validators`); `json-schema`, `shacl` and + `dcat-ap-3-shacl` are built in. A validator never fetches over the network, and a report spec may name only + `package:` files (a spec can be held in Egeria and written by any user). + - `run_report --output-format DOCUMENT --output [--force]` writes the file and prints the validation line. + - See "Document outputs" in `docs/output-formats-and-report-specs.md`. +- **DCAT Catalog (SD-2).** The built-in specs "DCAT Catalog" (JSON-LD) and "DCAT Catalog (Turtle)" export the + Assets in a collection (`scope`, a qualifiedName or GUID) as a DCAT-AP 3 catalog, read as the caller and + validated against the DCAT-AP 3.0.1 SHACL shapes shipped with pyegeria (CC BY 4.0; source and hashes in + `pyegeria/view/data/dcat-ap-3/README.md`). + - DigitalProducts and Agreements are Bitol's: each is named in the notes, never exported. + - A zoned Asset the caller can read is `dct:accessRights NON_PUBLIC`; a member Egeria refuses with a 403 is noted + as "not visible", never as absent. + - Every property left out says why in the notes. +- **Structured TABLE (R1).** `exec_report_spec(..., output_format="TABLE", table_shape="structured")` (and the + async `_async_run_report`) returns `kind: "table"`: + - `columns`, each with an inferred `type` (scalar, text, list, map, elements, table) and a `render`; + - `rows` of native values keyed by column key, related elements as `{guid, qualifiedName, displayName, type}`; + - `total`, `shown`, `total_basis` ("one page") and `notes` for every cap or reduction; + - an empty relationship cell is "none" when the relationship was read, and "not read" when it was not + requested; + - a table shows two levels: a third is reduced to a count and names, with a note. +- **Native DICT (R1).** `dict_shape="native"` on `exec_report_spec`, `generate_output` and the async twin returns + DICT rows with native values: lists stay lists, related elements carry both names, classifications and zones are + lists, and `format=True` columns are not stringified. The default `"flat"` is unchanged; TABLE stays flat under + `dict_shape`. Any other `table_shape` or `dict_shape` value is refused in words. +- **Column render intents (R2).** A report-spec column can set `render` (text, join, bullets, kv, subtable, count, + link), `max_items` (default 10), `max_lines` (default 3) and `label` (`qualified_name`, the default, or + `display_name` for related elements in text outputs). All four are carried in Egeria-held specs (`label` as + `related_label` in a microflow column item). +- **The CLI draws the structured table (R3).** `run_report --output-format TABLE` renders with Rich: lists one + item per line, maps as nested tables, long text cut at `max_lines` with "…", each sub-table as a separate table + after the main one, and dropped columns named in a footer. `list_generic` keeps flat rows unless asked. +- **My Egeria and the report TUI read native DICT (R4).** + - Shop for Data's catalog, root-collection and domain details ask for `dict_shape="native"` and read related + elements as lists (`value_names`). The Domains tree no longer shows one leaf per character of a joined string, + and a link-wrapped "Containing Members" value is unwrapped. + - The report TUI (`my_reports`) shows a list as one joined cell (+N more past 10) and a dict as JSON in one + cell, instead of turning list items or dict keys into extra columns. + - The Data Products demo no longer splits a value that can be a list. + +## Fixed + +- **Digital-Products `Members` was empty on every row** (F7). Egeria returns a collection's members as + `collectionMembers`; the spec's `members` column now reads it when the element has no `members` field. +- **A capped result said nothing** (F8). Digital-Products returned exactly 100 of 445 products with no word. A + result that fills its page now says so, as `notes` beside `data` and as a line in text output: + "Showing the first 100: the query stopped at its page size of 100; more may exist." The record of what each + list request sent is kept per call, so concurrent runs on one shared client never mix their notes. +- **`page_size` / `start_from` given as text** are converted to whole numbers; anything else is refused in words + instead of reaching Egeria. + +## Behaviour change: rendered text changes on upgrade + +These corrections change rendered **text** (REPORT, LIST, MD, FORM, HTML and the CLI table). **DICT and JSON row +shapes are unchanged**; a DICT/TABLE result that filled its page also carries a top-level `notes` list beside +`data`. + +- **F1:** header classifications are joined with `", "` (no stray newline before the comma). +- **F2:** REPORT/MD/FORM show a `False` or `0` value instead of dropping it. +- **F3:** FORM/MD say "Diagram omitted in this format; see REPORT or MERMAID." where a diagram was silently dropped + (the camelCase `solutionBlueprintMermaidGraph` now matches too); `links`, `implemented by` and `sub_components` + render as values. +- **F4:** the CLI table shows list items with "(+N more)" instead of "N items", and a map as one `k: v; ...` cell + instead of dotted columns. +- **F5:** the CLI table keeps the author's column order and names the columns it cannot show + ("+N more columns: ...") instead of dropping them silently. +- **F6:** LIST no longer drops an unnamed object in a list value: it shows its first text value or + "(unnamed )". +- **F7:** the Digital-Products `Members` column is filled. Relationship columns still show qualifiedNames by + default. +- **F8:** capped results say so (above). +- **F9:** markdown table cells escape `|` and turn newlines into `
`; markdown emphasis is kept. +- **F10:** `format="bulleted-list"` works in REPORT/MD (a markdown list), not only in LIST. +- **R2, Digital-Products:** its Product Manager and License columns show the related element's display name (for + example "Data for Internal Use" instead of "LicenseType::Jacquard::LICENSE-TYPE-IOU::Data for Internal Use") in + every output of that spec (DICT, TABLE, LIST, REPORT, FORM). This is the spec's own `label: display_name`; no + other spec or column changes. +- **R3, LIST cells:** a list of scalars renders as bullets (`a
b`) instead of "a, b"; a related-element list + past `max_items` (10) shows "(+N more: ...)", and a map shows `k: v
...`. Columns with `format=True` or a + `detail_spec` render as before. + +## Dependencies and size + +- rdflib, pyshacl and jsonschema are now plain dependencies (about 2.25 MB of wheels: pyshacl 1.31 MB, rdflib + 0.62 MB, pyparsing 0.13 MB, html5rdf 0.11 MB, owlrl 0.06 MB, prettytable 0.04 MB; jsonschema was already + installed). +- The pyegeria wheel is 3,366,371 bytes, 76,742 bytes (about 75 KB) more than 6.2.36's 3,289,629. The DCAT-AP 3.0.1 + shapes account for most of it. diff --git a/my_egeria/my_egeria/DemoCode/Data_Products_Demo/data_products.py b/my_egeria/my_egeria/DemoCode/Data_Products_Demo/data_products.py index 190c070a..af3d2358 100644 --- a/my_egeria/my_egeria/DemoCode/Data_Products_Demo/data_products.py +++ b/my_egeria/my_egeria/DemoCode/Data_Products_Demo/data_products.py @@ -16,6 +16,7 @@ sys.path.append(str(root_path)) from textual.css.query import NoMatches +from pyegeria.view.output_formatter import value_names from textual.screen import ModalScreen from textual import on from textual.app import App, ComposeResult @@ -448,7 +449,7 @@ def handle_catalog_table_row_selected(self, message: DataTable.RowSelected): if entry.get("Containing Members") is not None: member = entry.get("Containing Members") self.log(f"member variable: {member}, type: {type(member)}") - split_members = member.split(",") + split_members = value_names(member) # R4: a list (native DICT) or a string self.log(f"split_members: {split_members}, type: {type(split_members)}") self.member_list.extend(split_members) self.log(f"member_list: {self.member_list}, type: {type(self.member_list)}") @@ -464,7 +465,7 @@ def handle_catalog_table_row_selected(self, message: DataTable.RowSelected): if isinstance(member.get("Containing Members"), list): member_ext = member.get("Containing Members") self.log(f"member variable: {member_ext}, type: {type(member_ext)}") - split_members = member_ext.split(",") + split_members = value_names(member_ext) # R4 self.log(f"split_members: {split_members}, type: {type(split_members)}") self.member_list.extend(split_members) self.log(f"member_list: {self.member_list}, type: {type(self.member_list)}") @@ -473,7 +474,7 @@ def handle_catalog_table_row_selected(self, message: DataTable.RowSelected): if isinstance(member.get("Containing Members"), str): item_string = member.get("Containing Members") self.log(f"member variable: {item_string}, type: {type(item_string)}") - split_members = item_string.split(",") + split_members = value_names(item_string) # R4 self.log(f"split_members: {split_members}, type: {type(split_members)}") self.member_list.extend(split_members) self.log(f"member_list: {self.member_list}, type: {type(self.member_list)}") diff --git a/my_egeria/my_egeria/shop_for_data_handler.py b/my_egeria/my_egeria/shop_for_data_handler.py index 2583b926..3b79cd39 100644 --- a/my_egeria/my_egeria/shop_for_data_handler.py +++ b/my_egeria/my_egeria/shop_for_data_handler.py @@ -35,6 +35,7 @@ settings, ) from textual.widgets import DataTable, Tree +from pyegeria.view.output_formatter import value_names from ShopForDataScreen import ShopForDataScreen from SearchForTermScreen import SearchForTermScreen from SelectionOverviewScreen import SelectionOverviewScreen @@ -142,6 +143,7 @@ def _fetch_one(self, report_spec: str, qualified_name: str, graph_query_depth: i result = exec_report_spec( format_set_name=report_spec, output_format="DICT", + dict_shape="native", # R4: related elements as lists, read with value_names() params={"search_string": qualified_name, "graph_query_depth": graph_query_depth}, view_server=self.view_server, view_url=self.platform_url, @@ -598,6 +600,7 @@ def build_domain_details(self, target_qualified_name: str, target_type__name: st self.domain_details = exec_report_spec( format_set_name="BusinessCapabilities", output_format="DICT", + dict_shape="native", # R4 params={"search_string": self.domain_qualified_name, "filter_string": self.domain_qualified_name, "graph_query_depth": 1 @@ -639,8 +642,9 @@ def build_domain_details(self, target_qualified_name: str, target_type__name: st term_qualified_name = term.get("Qualified Name") or "" term_type = term.get("Type Name") or "" term_GUID = term.get("GUID") or "" - term_members = term.get("Containing Members") - term_memberof = term.get("Member Of") + # R4: lists (native) or strings (flat); never iterated character by character + term_members = value_names(term.get("Containing Members")) or None + term_memberof = value_names(term.get("Member Of")) or None build_structure[term_qualified_name] = { "term_type": term_type, "term_GUID": term_GUID, @@ -678,6 +682,7 @@ def build_catalog_details(self, target_qualified_name: str, target_display_name: self.catalog_details = exec_report_spec( format_set_name="Digital-Product-Catalog", output_format="DICT", + dict_shape="native", # R4 params={"search_string": self.catalog_qualified_name, "filter_string": self.catalog_qualified_name, "graph_query_depth": 1}, @@ -743,7 +748,7 @@ def build_catalog_details(self, target_qualified_name: str, target_display_name: for product in self.catalog_details_data: collection_memberships = product.get("Member Of") if collection_memberships: - collection_membership_list = collection_memberships.split(",") + collection_membership_list = value_names(collection_memberships) # R4 self.app.log(f"Membership List for product {product.get('Display Name')}: {collection_membership_list}") for membership_qname in collection_membership_list: self.app.log(f"Processing collection membership: {membership_qname}") @@ -808,7 +813,7 @@ def build_glossary_details(self, target_qualified_name: str, target_display_name glossary_tree.root.expand() glossary_tree.auto_expand = True - folder_entries = [f.strip() for f in self.glossary_folders.split(",")] + folder_entries = value_names(self.glossary_folders) # R4: a list or the ", " string nodes = {(): glossary_tree.root} prefixes = ["GlossaryCategory", "GlossaryTerm", "CollectionFolder"] @@ -873,10 +878,10 @@ def build_root_collection_details(self, target_qualified_name: str, target_displ collection = self._fetch_one("BasicCollections", target_qualified_name) or {} self.app.log(f"collection: {collection}") if target_qualified_name == collection.get("Qualified Name"): - root_collection_contains: str = collection.get("Containing Members") or "" + root_collection_contains = collection.get("Containing Members") or "" self.app.log(f"root_collection_contains: {root_collection_contains}") if root_collection_contains: - folders = str.split(root_collection_contains, ", ") + folders = value_names(root_collection_contains) # R4: a list, or a (link-wrapped) string for folder in folders: collection_branch.add_leaf(folder) diff --git a/pyegeria/core/_server_client.py b/pyegeria/core/_server_client.py index 6a8ca59a..a8db273a 100644 --- a/pyegeria/core/_server_client.py +++ b/pyegeria/core/_server_client.py @@ -8,6 +8,9 @@ """ import asyncio +import json +from contextlib import contextmanager +from contextvars import ContextVar import os import re import time @@ -133,6 +136,28 @@ def _with_paging(body: dict, start_from: int, page_size: int) -> dict: out["pageSize"] = page_size return out + +#: The record of the list requests made in the current call, when a caller asked for one +#: (`recording_list_requests`): a per-call dict, so concurrent runs never share it (read-back C1). +LIST_REQUEST_RECORD: "ContextVar[Optional[dict]]" = ContextVar("pyegeria_list_request_record", default=None) + + +@contextmanager +def recording_list_requests(): + """Record, for the calls made inside this block, what the last list request sent and got back: + yields the caller's own dict (keys `cap`, `graph_query_depth`, `include_only_relationships`, + `skip_relationships`). A coroutine run inside the block (sync wrappers run it in a task that copies + this context) writes into the same dict, which the caller reads after the call. + + The record keeps the LAST list request of the call: a find method that made a second list request + internally would report that request's depth and cap. Today's report-spec finds make one.""" + record: dict = {} + token = LIST_REQUEST_RECORD.set(record) + try: + yield record + finally: + LIST_REQUEST_RECORD.reset(token) + class ServerClient(BaseServerClient): """ An abstract class used to establish connectivity for an Egeria Client @@ -670,7 +695,7 @@ async def _async_get_elements_by_property_value( "POST", url, validated_body.model_dump_json(exclude_none=True), timeout=timeout ) - elements = response.json().get("elements", NO_ELEMENTS_FOUND) + elements = self._elements_noting_page_cap(response, NO_ELEMENTS_FOUND) if type(elements) is list: if len(elements) == 0: elements = NO_ELEMENTS_FOUND @@ -973,7 +998,7 @@ async def _async_get_related_elements_with_property_value( response: Response = await self._async_make_request( "POST", url, body_slimmer(body), timeout=timeout ) - elements = response.json().get("elements", NO_ELEMENTS_FOUND) + elements = self._elements_noting_page_cap(response, NO_ELEMENTS_FOUND) if type(elements) is list: if len(elements) == 0: return NO_ELEMENTS_FOUND @@ -6494,6 +6519,32 @@ def validate_update_relationship_request(self, body: dict | UpdateRelationshipRe validated_body = None return validated_body + def _elements_noting_page_cap(self, response, default): + """The `elements` of a list answer. When a caller is recording (`recording_list_requests`), the + answer's facts go into the caller's own record, read back from the request that was sent, so + every list helper is covered: `cap` = (shown, page_size, start_from) when the answer filled the + page size, plus the graph depth and relationship filters sent. Nothing is kept on the client: a + client shared by concurrent runs (dashboard tiles) never mixes one run's cap with another's + (fix-now F8, read-back C1).""" + elements = response.json().get("elements", default) + record = LIST_REQUEST_RECORD.get() + if record is None: + return elements + try: + sent = json.loads(response.request.content or b"{}") + except Exception: # noqa: BLE001 -- no request body (a GET) or not JSON: nothing to record + return elements + if not isinstance(sent, dict): + return elements + page_size = sent.get("pageSize") + record["cap"] = ((len(elements), page_size, sent.get("startFrom") or 0) + if isinstance(elements, list) and isinstance(page_size, int) and page_size > 0 + and len(elements) >= page_size else None) + record["graph_query_depth"] = sent.get("graphQueryDepth") + record["include_only_relationships"] = sent.get("includeOnlyRelationships") + record["skip_relationships"] = sent.get("skipRelationships") + return elements + @dynamic_catch async def _async_find_request(self, url: str, _type: str, _gen_output: Callable[..., Any], search_string: str = "*", starts_with: bool = True, ends_with: bool = False, ignore_case: bool = True, @@ -6599,7 +6650,7 @@ async def _async_find_request(self, url: str, _type: str, _gen_output: Callable[ json_body = validated_body.model_dump_json(indent=2, exclude_none=True, by_alias=True) response = await self._async_make_request("POST", url, json_body, timeout = 90) - elements = response.json().get("elements", NO_ELEMENTS_FOUND) + elements = self._elements_noting_page_cap(response, NO_ELEMENTS_FOUND) if type(elements) is str: logger.info(NO_ELEMENTS_FOUND) return NO_ELEMENTS_FOUND @@ -6660,7 +6711,7 @@ async def _async_get_name_request(self, url: str, _type: str, _gen_output: Calla json_body = validated_body.model_dump_json(indent=2, exclude_none=True) response = await self._async_make_request("POST", url, json_body) - elements = response.json().get("elements", NO_ELEMENTS_FOUND) + elements = self._elements_noting_page_cap(response, NO_ELEMENTS_FOUND) if type(elements) is str or len(elements) == 0: logger.info(NO_ELEMENTS_FOUND) return NO_ELEMENTS_FOUND @@ -6778,7 +6829,7 @@ async def _async_get_request_body_request(self, url: str, _type: str, _gen_outpu json_body = validated_body.model_dump_json(indent=2, exclude_none=True) response = await self._async_make_request("POST", url, json_body) - elements = response.json().get("elements", None) + elements = self._elements_noting_page_cap(response, None) if elements is None: elements = response.json().get("element", NO_ELEMENTS_FOUND) @@ -6865,7 +6916,7 @@ async def _async_activity_status_search_request( json_body = validated_body.model_dump_json(indent=2, exclude_none=True) response = await self._async_make_request("POST", url, json_body, timeout=90) - elements = response.json().get("elements", NO_ELEMENTS_FOUND) + elements = self._elements_noting_page_cap(response, NO_ELEMENTS_FOUND) if type(elements) is str: logger.info(NO_ELEMENTS_FOUND) return NO_ELEMENTS_FOUND @@ -6909,7 +6960,7 @@ async def _async_activity_status_filter_request( json_body = validated_body.model_dump_json(indent=2, exclude_none=True) response = await self._async_make_request("POST", url, json_body) - elements = response.json().get("elements", NO_ELEMENTS_FOUND) + elements = self._elements_noting_page_cap(response, NO_ELEMENTS_FOUND) if type(elements) is str or len(elements) == 0: logger.info(NO_ELEMENTS_FOUND) return NO_ELEMENTS_FOUND @@ -6956,7 +7007,7 @@ async def _async_activity_status_request( json_body = validated_body.model_dump_json(indent=2, exclude_none=True) response = await self._async_make_request("POST", url, json_body) - elements = response.json().get("elements", NO_ELEMENTS_FOUND) + elements = self._elements_noting_page_cap(response, NO_ELEMENTS_FOUND) if type(elements) is str: logger.info(NO_ELEMENTS_FOUND) return NO_ELEMENTS_FOUND @@ -7040,7 +7091,7 @@ async def _async_content_status_search_request( json_body = validated_body.model_dump_json(indent=2, exclude_none=True) response = await self._async_make_request("POST", url, json_body, timeout=90) - elements = response.json().get("elements", NO_ELEMENTS_FOUND) + elements = self._elements_noting_page_cap(response, NO_ELEMENTS_FOUND) if type(elements) is str: logger.info(NO_ELEMENTS_FOUND) return NO_ELEMENTS_FOUND @@ -7084,7 +7135,7 @@ async def _async_content_status_filter_request( json_body = validated_body.model_dump_json(indent=2, exclude_none=True) response = await self._async_make_request("POST", url, json_body) - elements = response.json().get("elements", NO_ELEMENTS_FOUND) + elements = self._elements_noting_page_cap(response, NO_ELEMENTS_FOUND) if type(elements) is str or len(elements) == 0: logger.info(NO_ELEMENTS_FOUND) return NO_ELEMENTS_FOUND @@ -7168,7 +7219,7 @@ async def _async_deployment_status_search_request( json_body = validated_body.model_dump_json(indent=2, exclude_none=True) response = await self._async_make_request("POST", url, json_body, timeout=90) - elements = response.json().get("elements", NO_ELEMENTS_FOUND) + elements = self._elements_noting_page_cap(response, NO_ELEMENTS_FOUND) if type(elements) is str: logger.info(NO_ELEMENTS_FOUND) return NO_ELEMENTS_FOUND @@ -7212,7 +7263,7 @@ async def _async_deployment_status_filter_request( json_body = validated_body.model_dump_json(indent=2, exclude_none=True) response = await self._async_make_request("POST", url, json_body) - elements = response.json().get("elements", NO_ELEMENTS_FOUND) + elements = self._elements_noting_page_cap(response, NO_ELEMENTS_FOUND) if type(elements) is str or len(elements) == 0: logger.info(NO_ELEMENTS_FOUND) return NO_ELEMENTS_FOUND @@ -7263,7 +7314,7 @@ async def _async_get_results_body_request(self, url: str, _type: str, _gen_outpu json_body = validated_body.model_dump_json(indent=2, exclude_none=True) response = await self._async_make_request("POST", url, json_body) - elements = response.json().get("elements", None) + elements = self._elements_noting_page_cap(response, None) if elements is None: elements = response.json().get("element", NO_ELEMENTS_FOUND) @@ -7293,7 +7344,7 @@ async def _async_get_level_identifier_query_body_request(self, url: str, _gen_ou json_body = validated_body.model_dump_json(indent=2, exclude_none=True) response = await self._async_make_request("POST", url, json_body) - elements = response.json().get("elements", None) + elements = self._elements_noting_page_cap(response, None) if elements is None: elements = response.json().get("element", NO_ELEMENTS_FOUND) diff --git a/pyegeria/view/README.md b/pyegeria/view/README.md index 60ea2a23..e0ae6042 100644 --- a/pyegeria/view/README.md +++ b/pyegeria/view/README.md @@ -13,7 +13,9 @@ into MD/LIST/DICT/REPORT/MERMAID/chart output. | `microflow.py` | `microflow/1`: the stored micro-flow model, its JSON Schema (`schemas/microflow-1.json`), the conversions to and from `FormatSet`, and the allowlists (`FIND_METHOD_ALLOWLIST`, `ADDITIONAL_PROPS_HOOKS`). | | `_output_format_models.py` | Pydantic models `Column`/`Format`/`FormatSet`/`ActionParameter` — define new report specs with these, not raw dicts. | | `output_formatter.py` | `generate_output()` — materializes elements into MD/LIST/DICT/REPORT formats. | -| `format_set_executor.py` | `exec_report_spec()` — runs a `FormatSet`'s query/render path; dispatches `SERIES`/`BAR`/`PIE` output formats to Vega-Lite chart rendering before normal Format-row lookup. | +| `format_set_executor.py` | `exec_report_spec()` — runs a `FormatSet`'s query/render path; dispatches `SERIES`/`BAR`/`PIE` output formats to Vega-Lite chart rendering before normal Format-row lookup; runs a DOCUMENT spec's exporter and validator (SD-1). | +| `document_validators.py` | DOCUMENT validators by name: built-ins `json-schema`, `shacl`, `dcat-ap-3-shacl`; never fetch over the network; a spec may name only `package:` files. | +| `export_dcat.py` | `export_dcat` analytic function: a DCAT-AP 3 catalog (JSON-LD/Turtle) of the Assets in a collection or search, read as the caller (SD-2). Shapes vendored in `data/dcat-ap-3/`. | | `analytic_registry.py` / `analytic_demo_specs.py` | `analytic_registry.py` is the registry of analytic routines (aggregated-result functions, as opposed to per-element query+format). Each entry is a routine declaration (`RoutineDeclaration`; `AnalyticFunctionSpec` is its compatibility view): `inputs` by role, `params` with a `category`, `bindings` (the python binding is `function`, and a module allow-list applies to it only; a report spec names routines by registered name, never by path, ISSUE-173), `declaration` (results, `out`), `tile_safe`, `admission`. `analytic_demo_specs.py` holds one real, executable demo `FormatSet` per registered function. | | `role_supply.py` | `RoleSupply` protocol and `PlainSupply`: how the executor obtains a routine's declared inputs (`egeria_client:`, `reader:`, `viewer`, `subject`). Plain pyegeria supplies the caller's `EgeriaTech` only. `RoleRefused`, `NoSuchReader`, `CallerTokenExpired`. | | `spec_resolver.py` | Load-time resolution of report specs: `resolve`, `unrunnable_specs`, checks 1-7, `declared_inputs` (check 5, shared with the executor). Backs `list_report_specs(with_status=True)`. | diff --git a/pyegeria/view/_output_format_models.py b/pyegeria/view/_output_format_models.py index 0793b8ad..6102b6f7 100644 --- a/pyegeria/view/_output_format_models.py +++ b/pyegeria/view/_output_format_models.py @@ -68,7 +68,7 @@ import os import warnings from pathlib import Path -from typing import Dict, List, Optional, Union, Any +from typing import Dict, List, Literal, Optional, Union, Any from pydantic import BaseModel, Field, PrivateAttr, field_validator, model_validator from loguru import logger __all__ = [ @@ -130,6 +130,10 @@ def load_format_sets_from_json(file_path: str) -> Dict[str, 'FormatSet']: logger.error(f"Error loading format sets from {file_path}: {e}") raise +COLUMN_RENDERS = ("text", "join", "bullets", "kv", "subtable", "count", "link") +COLUMN_LABELS = ("qualified_name", "display_name") + + class Column(BaseModel): """ Represents an attribute (formerly called a column) in an output format. @@ -140,6 +144,14 @@ class Column(BaseModel): format: Whether the attribute's value should be formatted detail_spec: Optional report spec to use for detailed rendering of this column valid_values: Optional list or dict of valid values for Enum mapping + render: How a renderer draws the value (R2): text, join, bullets, kv, subtable, count or link. + Unset, it follows the value's type (scalar/text -> text, list -> bullets, map -> kv, + related elements -> join, sub-rows -> subtable). `subtable` without detail_spec uses the + objects' own scalar keys. + max_items: Items a list cell shows before "+N more" (effective default 10). + max_lines: Lines a long text cell shows in web-oriented outputs (effective default 3). + label: Which name a related element shows in text outputs: "qualified_name" (the default, + today's text) or "display_name". Set per column, never globally (the F7 read-back). """ name: str key: str @@ -147,20 +159,107 @@ class Column(BaseModel): format: Union[bool, str] = False detail_spec: Optional[str] = None valid_values: Optional[Union[List[str], Dict[str, str]]] = None + render: Optional[Literal["text", "join", "bullets", "kv", "subtable", "count", "link"]] = None + max_items: Optional[int] = Field(default=None, ge=1) + max_lines: Optional[int] = Field(default=None, ge=1) + label: Optional[Literal["qualified_name", "display_name"]] = None # New preferred alias for Column Attribute = Column +DOCUMENT_OUTPUT_TYPE = "DOCUMENT" + + +def check_document_file_name(file_name: str) -> Optional[str]: + """Why a document file name (or its template) is refused, or None when it is safe: a file + name is one name in the output directory, never a path. No separators, no `..`, not empty, + not hidden.""" + if not isinstance(file_name, str) or not file_name.strip(): + return "the file name is empty" + if "/" in file_name or "\\" in file_name: + return f"the file name '{file_name}' contains a path separator; it must be a single file name" + if ".." in file_name: + return f"the file name '{file_name}' contains '..'; it must be a single file name" + if file_name.startswith(".") or file_name.startswith("~"): + return f"the file name '{file_name}' starts with '{file_name[0]}'; it must be a plain file name" + if "\x00" in file_name: + return "the file name contains a NUL character" + return None + + +class DocumentSpec(BaseModel): + """What a DOCUMENT format produces (SD-1): one document in a published standard. + + Fields: + standard: the standard the document conforms to, e.g. "dcat-ap-3". + media_type: its media type, e.g. "application/ld+json". + file_name: a template filled from the run's parameters, e.g. "{scope}-dcat.jsonld". + A single file name: path separators and ".." are refused here and again after the + parameters are filled in. + validator: an optional registered document-validator name + (`pyegeria.view.document_validators`). With none, every result says + `not_validated` and why. + validator_options: options passed to the validator, e.g. {"shapes": "package:/"} + for the built-in `shacl`, {"schema": "package:/"} for `json-schema`. A + file reference here must be a `package:` reference: a spec may be held in Egeria and + written by any user, so it may not name a local file or URL. + """ + standard: str + media_type: str + file_name: str + validator: Optional[str] = None + validator_options: Dict[str, Any] = Field(default_factory=dict) + + @field_validator("validator_options") + @classmethod + def _package_references_only(cls, v): + """A spec may be held in Egeria and written by any user, so it may not make the Portal or + EA read a local file: `schema`/`shapes` must be `package:` references (SD-1 read-back C2).""" + from pyegeria.view.document_validators import spec_option_refusal + reason = spec_option_refusal(v) + if reason: + raise ValueError(f"DOCUMENT {reason}") + return v + + @field_validator("file_name") + @classmethod + def _safe_file_name(cls, v): + reason = check_document_file_name(v) + if reason: + raise ValueError(f"DOCUMENT file_name refused: {reason}") + return v + + class Format(BaseModel): """ Represents a format configuration with types and attributes. Fields: - types: The output types this format supports (e.g., "DICT", "TABLE", "ALL") - attributes: The attributes (formerly columns) to include in the output + types: The output types this format supports (e.g., "DICT", "TABLE", "ALL", "DOCUMENT") + attributes: The attributes (formerly columns) to include in the output. A DOCUMENT + format has none: its exporter builds the whole document. + document: For a DOCUMENT format only (and required there): the standard, media type, + file name template and optional validator. See `DocumentSpec`. """ types: List[str] - attributes: List[Union[Column, Dict[str, Any]]] + attributes: List[Union[Column, Dict[str, Any]]] = Field(default_factory=list) + document: Optional[DocumentSpec] = None + + @model_validator(mode="after") + def _document_block_matches_type(self): + """A DOCUMENT format stands alone in its row and carries a `document` block; no other + format carries one.""" + types = [str(t).upper() for t in self.types] + if DOCUMENT_OUTPUT_TYPE in types: + if len(types) > 1: + raise ValueError( + f"A DOCUMENT format cannot share its row with other output types ({', '.join(self.types)}): " + f"a document is not a rendering of attributes") + if self.document is None: + raise ValueError("A DOCUMENT format needs a 'document' block (standard, media_type, file_name)") + elif self.document is not None: + raise ValueError(f"Only a DOCUMENT format carries a 'document' block, not {', '.join(self.types)}") + return self @model_validator(mode="before") @classmethod @@ -399,6 +498,48 @@ def validate_formats(cls, v): result.append(item) return result + @model_validator(mode="after") + def _document_spec_rules(self): + """A report spec with a DOCUMENT format (SD-1) is a document spec: + + - its document is built by an exporter, so its action needs an `analytic_function`; + - a `function` (find) with no analytic function is refused, since a find returns + elements to render column by column, not a document; + - it has no other formats, since every other output type is refused for it at run time. + """ + doc_formats = [f for f in self.formats if isinstance(f, Format) and f.document is not None] + if not doc_formats: + return self + others = [t for f in self.formats if isinstance(f, Format) and f.document is None for t in f.types] + if len(doc_formats) > 1: + raise ValueError(f"Report spec '{self.heading}' has {len(doc_formats)} DOCUMENT formats; " + f"a document spec produces exactly one document") + if others: + raise ValueError(f"Report spec '{self.heading}' is a DOCUMENT spec and cannot also offer " + f"{', '.join(others)}: a DOCUMENT spec produces only its document") + action = self.action + if action is None or isinstance(action, dict): + fn = (action or {}).get("function") if isinstance(action, dict) else None + analytic = (action or {}).get("analytic_function") if isinstance(action, dict) else None + else: + fn, analytic = action.function, action.analytic_function + if not analytic: + if fn: + raise ValueError( + f"Report spec '{self.heading}' has a DOCUMENT format and a find function ({fn}) but no " + f"analytic_function: a find returns elements, not a document. Name an exporter as the " + f"action's analytic_function") + raise ValueError(f"Report spec '{self.heading}' has a DOCUMENT format but no action.analytic_function; " + f"a document is built by an exporter registered as an analytic function") + return self + + def document_format(self) -> Optional["Format"]: + """This spec's DOCUMENT format, or None when it is not a document spec.""" + for f in self.formats: + if isinstance(f, Format) and f.document is not None: + return f + return None + @field_validator('question_spec', mode='before') @classmethod def validate_question_spec(cls, v): diff --git a/pyegeria/view/analytic_registry.py b/pyegeria/view/analytic_registry.py index ae35b743..0ff20f66 100644 --- a/pyegeria/view/analytic_registry.py +++ b/pyegeria/view/analytic_registry.py @@ -2054,6 +2054,41 @@ def _always_applies(what: str) -> str: ("OTHER", "Other"))], ), ), + "export_dcat": AnalyticFunctionSpec( + name="export_dcat", + function="pyegeria.view.export_dcat.export_dcat", + inputs=["egeria_client:EgeriaTech"], + description="A DCAT-AP 3 catalog (JSON-LD or Turtle) of the Assets in a collection, or of the assets " + "matching a search, read as the caller (SD-2). DigitalProducts and Agreements are Bitol's " + "and are named in the notes, never exported; zoned Assets the caller can read are marked " + "NON_PUBLIC; every property left out is named in the notes. Returns a document " + "({text, notes}) for a DOCUMENT report spec such as 'DCAT Catalog'. Cost: one member " + "listing (paged to an empty page) plus one element read per Asset.", + returns="document (dict: text, notes)", + generic=True, + family="Standard Documents", + params=[ + AnalyticParam(name="scope", type="str", + description="The catalog: a collection or folder qualifiedName, or its GUID."), + AnalyticParam(name="search_string", type="str", + description="Instead of scope: assets in the asset domain matching this string."), + AnalyticParam(name="format", type="str", default="jsonld", + description="jsonld (default) or turtle."), + AnalyticParam(name="page_size", type="int", default=50, + description="Members (or search results) read per page; reading stops at an empty page."), + ], + declaration=AnalyticDeclaration( + result_kind="finding", + absence=_absence( + not_measured="The catalog was not exported: reading the scope from Egeria failed.", + not_permitted="You are not permitted to read this collection.", + not_applicable="A DCAT catalog does not apply: the scope names no collection you can read.", + nothing_found="Exported: no Asset in scope is visible to you, so the catalog lists no " + "dataset; the notes say what was left out and why.", + ), + out=[_field("text", "Document", "string"), _field("notes", "Notes", "list")], + ), + ), } _RUNTIME_ANALYTIC_FUNCTIONS = AnalyticFunctionDict() diff --git a/pyegeria/view/base_report_formats.py b/pyegeria/view/base_report_formats.py index ddb1f9f0..1103e059 100644 --- a/pyegeria/view/base_report_formats.py +++ b/pyegeria/view/base_report_formats.py @@ -2676,8 +2676,8 @@ def _user_report_specs_dir() -> str: Column(name='Members', key='members', format=True), Column(name='Uses Products', key='uses_digital_products'), Column(name='Used by Products', key='used_by_digital_products'), - Column(name='Product Manager', key='assigned_actors'), - Column(name='License', key='governed_by'), + Column(name='Product Manager', key='assigned_actors', label='display_name'), + Column(name='License', key='governed_by', label='display_name'), Column(name='Solution Blueprint', key='solution_designs'), ]), Format( @@ -2693,8 +2693,8 @@ def _user_report_specs_dir() -> str: Column(name='Members', key='members', format=True), Column(name='Uses Products', key='uses_digital_products'), Column(name='Used by Products', key='used_by_digital_products'), - Column(name='Product Manager', key='assigned_actors'), - Column(name='License', key='governed_by'), + Column(name='Product Manager', key='assigned_actors', label='display_name'), + Column(name='License', key='governed_by', label='display_name'), Column(name='Solution Blueprint', key='solution_designs'), Column(name="Mermaid", key="mermaid") ], @@ -4714,6 +4714,32 @@ def list_report_specs(*, with_status: bool = False) -> list: spec_params={"_type": "FolderCollection"}, ), ), + # SD-2: standard documents. A DOCUMENT spec produces one document (SD-1); its exporter is the + # analytic function export_dcat. Run with output_format "DOCUMENT" and a `scope` parameter. + "DCAT Catalog": FormatSet( + heading="DCAT Catalog", + description="A DCAT-AP 3 catalog (JSON-LD) of the Assets in a collection or folder, read as you. Give " + "`scope`: the collection's qualifiedName or GUID. DigitalProducts and Agreements are Bitol's " + "and are named in the notes, not exported; validated against the vendored DCAT-AP 3.0.1 " + "SHACL shapes. Run with output_format DOCUMENT.", + family="Standard Documents", + target_type="Collection", + formats=[Format(types=["DOCUMENT"], document={ + "standard": "dcat-ap-3", "media_type": "application/ld+json", + "file_name": "{scope}-dcat.jsonld", "validator": "dcat-ap-3-shacl"})], + action=ActionParameter(analytic_function="export_dcat", analytic_spec_params={"format": "jsonld"}), + ), + "DCAT Catalog (Turtle)": FormatSet( + heading="DCAT Catalog (Turtle)", + description="The DCAT Catalog document as Turtle: a DCAT-AP 3 catalog of the Assets in a collection or " + "folder, read as you. Give `scope`. Run with output_format DOCUMENT.", + family="Standard Documents", + target_type="Collection", + formats=[Format(types=["DOCUMENT"], document={ + "standard": "dcat-ap-3", "media_type": "text/turtle", + "file_name": "{scope}-dcat.ttl", "validator": "dcat-ap-3-shacl"})], + action=ActionParameter(analytic_function="export_dcat", analytic_spec_params={"format": "turtle"}), + ), }) # The question specs ship in the report-spec seed (builtin tier) since RS-EGERIA-TIER stage 2 (owner diff --git a/pyegeria/view/data/dcat-ap-3/LICENSE b/pyegeria/view/data/dcat-ap-3/LICENSE new file mode 100644 index 00000000..4ea99c21 --- /dev/null +++ b/pyegeria/view/data/dcat-ap-3/LICENSE @@ -0,0 +1,395 @@ +Attribution 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution 4.0 International Public License ("Public License"). To the +extent this Public License may be interpreted as a contract, You are +granted the Licensed Rights in consideration of Your acceptance of +these terms and conditions, and the Licensor grants You such rights in +consideration of benefits the Licensor receives from making the +Licensed Material available under these terms and conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + d. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + g. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + i. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + j. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + k. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/pyegeria/view/data/dcat-ap-3/README.md b/pyegeria/view/data/dcat-ap-3/README.md new file mode 100644 index 00000000..c9819564 --- /dev/null +++ b/pyegeria/view/data/dcat-ap-3/README.md @@ -0,0 +1,25 @@ +# DCAT-AP 3 SHACL shapes (vendored) + +These files are the published SHACL shapes of **DCAT-AP 3.0.1**, copied unchanged so that +pyegeria's `dcat-ap-3-shacl` document validator never fetches anything over the network. + +| File | What it is | +|---|---| +| `dcat-ap-SHACL.ttl` | The DCAT-AP 3.0.1 constraints (cardinalities, datatypes). Used by `dcat-ap-3-shacl`. | +| `ranges.ttl` | The DCAT-AP 3.0.1 range (class) constraints. Vendored for completeness; not used by `dcat-ap-3-shacl`, which validates documents that link to external vocabularies by IRI without typing them. | +| `LICENSE` | The licence the shapes are published under (CC BY 4.0), copied from the source repository. | + +- **Source:** https://github.com/SEMICeu/DCAT-AP, `releases/3.0.1/shacl/`, at commit + `4470b8ea907b7eb9ec55ab22befd1ecd2210ff32` (master, fetched 2026-11-11). The shapes are + byte-identical to the 3.0.1 release commit `729eddfc176d0afee5850ade6528f96f72579412`. +- **Publisher:** SEMIC, Interoperable Europe (European Commission). +- **Licence:** Creative Commons Attribution 4.0 International (CC BY 4.0), which permits + redistribution with attribution. Attribution: "DCAT-AP 3.0.1 SHACL shapes, © SEMIC / + European Commission, CC BY 4.0, https://github.com/SEMICeu/DCAT-AP". +- **SHA-256:** + - `dcat-ap-SHACL.ttl` 990d3e42721de6a4be8cc338a7171559f195e62dea89c0b56531356b78cc026f + - `ranges.ttl` a6eed0fae8d0f5ca977fe2098ca12081ac60b0efe1ddce802d5c08e49505ebcc + - `LICENSE` 9e5f1b3c610b9c2da5c313bf81d577a7d1acec686bdb0384edefa6df0f90cd94 + +To update: download the new release's `shacl/` files from the same repository, replace these +files, update the commit, hashes and version above, and rerun `tests/micro-tests/test_sd2_export_dcat.py`. diff --git a/pyegeria/view/data/dcat-ap-3/dcat-ap-SHACL.ttl b/pyegeria/view/data/dcat-ap-3/dcat-ap-SHACL.ttl new file mode 100644 index 00000000..a6022f1e --- /dev/null +++ b/pyegeria/view/data/dcat-ap-3/dcat-ap-SHACL.ttl @@ -0,0 +1,2217 @@ +@prefix dc: . +@prefix dcat: . +@prefix foaf: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix shacl: . +@prefix skos: . +@prefix vcard: . +@prefix xsd: . + + rdfs:member , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + ; + shacl:targetClass . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Identifier.notation"; + shacl:description "A string that is an identifier in the context of the identifier scheme referenced by its datatype."@en; + shacl:name "notation"@en; + shacl:nodeKind shacl:Literal; + shacl:path skos:notation . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Identifier.notation"; + shacl:description "A string that is an identifier in the context of the identifier scheme referenced by its datatype."@en; + shacl:minCount 1; + shacl:name "notation"@en; + shacl:path skos:notation . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Identifier.notation"; + shacl:description "A string that is an identifier in the context of the identifier scheme referenced by its datatype."@en; + shacl:maxCount 1; + shacl:name "notation"@en; + shacl:path skos:notation . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:CatalogRecord . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.modificationdate"; + shacl:description "The most recent date on which the Catalogue entry was changed or modified."@en; + shacl:minCount 1; + shacl:name "modification date"@en; + shacl:path dc:modified . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.changetype"; + shacl:description "The status of the catalogue record in the context of editorial flow of the dataset and data service descriptions."@en; + shacl:maxCount 1; + shacl:name "change type"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.language"; + shacl:class dc:LinguisticSystem; + shacl:description "A language used in the textual metadata describing titles, descriptions, etc. of the Catalogued Resource."@en; + shacl:name "language"@en; + shacl:path dc:language . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.applicationprofile"; + shacl:class dc:Standard; + shacl:description "An Application Profile that the Catalogued Resource's metadata conforms to."@en; + shacl:name "application profile"@en; + shacl:path dc:conformsTo . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.primarytopic"; + shacl:description "A link to the Dataset, Data service or Catalog described in the record."@en; + shacl:name "primary topic"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path foaf:primaryTopic . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.sourcemetadata"; + shacl:description "The original metadata that was used in creating metadata for the Dataset, Data Service or Dataset Series."@en; + shacl:maxCount 1; + shacl:name "source metadata"@en; + shacl:path dc:source . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.changetype"; + shacl:class skos:Concept; + shacl:description "The status of the catalogue record in the context of editorial flow of the dataset and data service descriptions."@en; + shacl:name "change type"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.listingdate"; + shacl:description "The date on which the description of the Resource was included in the Catalogue."@en; + shacl:maxCount 1; + shacl:name "listing date"@en; + shacl:path dc:issued . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.primarytopic"; + shacl:description "A link to the Dataset, Data service or Catalog described in the record."@en; + shacl:minCount 1; + shacl:name "primary topic"@en; + shacl:path foaf:primaryTopic . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.modificationdate"; + shacl:description "The most recent date on which the Catalogue entry was changed or modified."@en; + shacl:name "modification date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:modified . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.description"; + shacl:description "A free-text account of the record. This property can be repeated for parallel language versions of the description."@en; + shacl:name "description"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:description . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.changetype"; + shacl:description "The status of the catalogue record in the context of editorial flow of the dataset and data service descriptions."@en; + shacl:name "change type"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.sourcemetadata"; + shacl:class dcat:CatalogRecord; + shacl:description "The original metadata that was used in creating metadata for the Dataset, Data Service or Dataset Series."@en; + shacl:name "source metadata"@en; + shacl:path dc:source . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.applicationprofile"; + shacl:description "An Application Profile that the Catalogued Resource's metadata conforms to."@en; + shacl:name "application profile"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:conformsTo . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.modificationdate"; + shacl:description "The most recent date on which the Catalogue entry was changed or modified."@en; + shacl:maxCount 1; + shacl:name "modification date"@en; + shacl:path dc:modified . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.primarytopic"; + shacl:class dcat:Resource; + shacl:description "A link to the Dataset, Data service or Catalog described in the record."@en; + shacl:name "primary topic"@en; + shacl:path foaf:primaryTopic . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.sourcemetadata"; + shacl:description "The original metadata that was used in creating metadata for the Dataset, Data Service or Dataset Series."@en; + shacl:name "source metadata"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:source . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.listingdate"; + shacl:description "The date on which the description of the Resource was included in the Catalogue."@en; + shacl:name "listing date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:issued . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.title"; + shacl:description "A name given to the Catalogue Record."@en; + shacl:name "title"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:title . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.language"; + shacl:description "A language used in the textual metadata describing titles, descriptions, etc. of the Catalogued Resource."@en; + shacl:name "language"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:language . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.primarytopic"; + shacl:description "A link to the Dataset, Data service or Catalog described in the record."@en; + shacl:maxCount 1; + shacl:name "primary topic"@en; + shacl:path foaf:primaryTopic . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:Catalog . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.geographicalcoverage"; + shacl:class dc:Location; + shacl:description "A geographical area covered by the Catalogue."@en; + shacl:name "geographical coverage"@en; + shacl:path dc:spatial . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.haspart"; + shacl:description "A related Catalogue that is part of the described Catalogue."@en; + shacl:name "has part"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:hasPart . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.dataset"; + shacl:description "A Dataset that is part of the Catalogue."@en; + shacl:name "dataset"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:dataset . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.themes"; + shacl:description "A knowledge organization system used to classify the Resources that are in the Catalogue."@en; + shacl:name "themes"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:themeTaxonomy . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.applicablelegislation"; + shacl:description "The legislation that mandates the creation or management of the Catalogue."@en; + shacl:name "applicable legislation"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.language"; + shacl:class dc:LinguisticSystem; + shacl:description "A language used in the textual metadata describing titles, descriptions, etc. of the Datasets in the Catalogue."@en; + shacl:name "language"@en; + shacl:path dc:language . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.record"; + shacl:class dcat:CatalogRecord; + shacl:description "A Catalogue Record that is part of the Catalogue."@en; + shacl:name "record"@en; + shacl:path dcat:record . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.record"; + shacl:description "A Catalogue Record that is part of the Catalogue."@en; + shacl:name "record"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:record . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.catalogue"; + shacl:class dcat:Catalog; + shacl:description "A catalogue whose contents are of interest in the context of this catalogue."@en; + shacl:name "catalogue"@en; + shacl:path dcat:catalog . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.releasedate"; + shacl:description "The date of formal issuance (e.g., publication) of the Catalogue."@en; + shacl:name "release date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:issued . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.themes"; + shacl:class skos:ConceptScheme; + shacl:description "A knowledge organization system used to classify the Resources that are in the Catalogue."@en; + shacl:name "themes"@en; + shacl:path dcat:themeTaxonomy . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.publisher"; + shacl:description "An entity (organisation) responsible for making the Catalogue available."@en; + shacl:maxCount 1; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.modificationdate"; + shacl:description "The most recent date on which the Catalogue was modified."@en; + shacl:name "modification date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:modified . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.description"; + shacl:description "A free-text account of the Catalogue."@en; + shacl:name "description"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:description . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.applicablelegislation"; + shacl:class ; + shacl:description "The legislation that mandates the creation or management of the Catalogue."@en; + shacl:name "applicable legislation"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.dataset"; + shacl:class dcat:Dataset; + shacl:description "A Dataset that is part of the Catalogue."@en; + shacl:name "dataset"@en; + shacl:path dcat:dataset . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.creator"; + shacl:description "An entity responsible for the creation of the catalogue."@en; + shacl:name "creator"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:creator . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.temporalcoverage"; + shacl:description "A temporal period that the Catalogue covers."@en; + shacl:name "temporal coverage"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:temporal . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.creator"; + shacl:description "An entity responsible for the creation of the catalogue."@en; + shacl:maxCount 1; + shacl:name "creator"@en; + shacl:path dc:creator . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.homepage"; + shacl:description "A web page that acts as the main page for the Catalogue."@en; + shacl:name "homepage"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path foaf:homepage . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.temporalcoverage"; + shacl:class dc:PeriodOfTime; + shacl:description "A temporal period that the Catalogue covers."@en; + shacl:name "temporal coverage"@en; + shacl:path dc:temporal . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.description"; + shacl:description "A free-text account of the Catalogue."@en; + shacl:minCount 1; + shacl:name "description"@en; + shacl:path dc:description . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.publisher"; + shacl:description "An entity (organisation) responsible for making the Catalogue available."@en; + shacl:name "publisher"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.geographicalcoverage"; + shacl:description "A geographical area covered by the Catalogue."@en; + shacl:name "geographical coverage"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:spatial . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.rights"; + shacl:class dc:RightsStatement; + shacl:description "A statement that specifies rights associated with the Catalogue."@en; + shacl:name "rights"@en; + shacl:path dc:rights . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.modificationdate"; + shacl:description "The most recent date on which the Catalogue was modified."@en; + shacl:maxCount 1; + shacl:name "modification date"@en; + shacl:path dc:modified . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.licence"; + shacl:description "A licence under which the Catalogue can be used or reused."@en; + shacl:maxCount 1; + shacl:name "licence"@en; + shacl:path dc:license . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.publisher"; + shacl:description "An entity (organisation) responsible for making the Catalogue available."@en; + shacl:minCount 1; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.releasedate"; + shacl:description "The date of formal issuance (e.g., publication) of the Catalogue."@en; + shacl:maxCount 1; + shacl:name "release date"@en; + shacl:path dc:issued . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.publisher"; + shacl:class foaf:Agent; + shacl:description "An entity (organisation) responsible for making the Catalogue available."@en; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.rights"; + shacl:description "A statement that specifies rights associated with the Catalogue."@en; + shacl:name "rights"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:rights . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.catalogue"; + shacl:description "A catalogue whose contents are of interest in the context of this catalogue."@en; + shacl:name "catalogue"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:catalog . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.creator"; + shacl:class foaf:Agent; + shacl:description "An entity responsible for the creation of the catalogue."@en; + shacl:name "creator"@en; + shacl:path dc:creator . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.service"; + shacl:class dcat:DataService; + shacl:description "A site or end-point (Data Service) that is listed in the Catalogue."@en; + shacl:name "service"@en; + shacl:path dcat:service . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.haspart"; + shacl:class dcat:Catalog; + shacl:description "A related Catalogue that is part of the described Catalogue."@en; + shacl:name "has part"@en; + shacl:path dc:hasPart . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.title"; + shacl:description "A name given to the Catalogue."@en; + shacl:name "title"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:title . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.homepage"; + shacl:description "A web page that acts as the main page for the Catalogue."@en; + shacl:maxCount 1; + shacl:name "homepage"@en; + shacl:path foaf:homepage . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.language"; + shacl:description "A language used in the textual metadata describing titles, descriptions, etc. of the Datasets in the Catalogue."@en; + shacl:name "language"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:language . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.licence"; + shacl:class dc:LicenseDocument; + shacl:description "A licence under which the Catalogue can be used or reused."@en; + shacl:name "licence"@en; + shacl:path dc:license . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.service"; + shacl:description "A site or end-point (Data Service) that is listed in the Catalogue."@en; + shacl:name "service"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:service . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.licence"; + shacl:description "A licence under which the Catalogue can be used or reused."@en; + shacl:name "licence"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:license . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.title"; + shacl:description "A name given to the Catalogue."@en; + shacl:minCount 1; + shacl:name "title"@en; + shacl:path dc:title . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.homepage"; + shacl:class foaf:Document; + shacl:description "A web page that acts as the main page for the Catalogue."@en; + shacl:name "homepage"@en; + shacl:path foaf:homepage . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:DataService . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.conformsto"; + shacl:description "An established (technical) standard to which the Data Service conforms."@en; + shacl:name "conforms to"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:conformsTo . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.applicablelegislation"; + shacl:description "The legislation that mandates the creation or management of the Data Service."@en; + shacl:name "applicable legislation"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.accessrights"; + shacl:description "Information regarding access or restrictions based on privacy, security, or other policies."@en; + shacl:name "access rights"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:accessRights . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.servesdataset"; + shacl:class dcat:Dataset; + shacl:description "This property refers to a collection of data that this data service can distribute."@en; + shacl:name "serves dataset"@en; + shacl:path dcat:servesDataset . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.landingpage"; + shacl:description "A web page that provides access to the Data Service and/or additional information."@en; + shacl:name "landing page"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:landingPage . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.endpointURL"; + shacl:description "The root location or primary endpoint of the service (an IRI)."@en; + shacl:name "endpoint URL"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:endpointURL . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.keyword"; + shacl:description "A keyword or tag describing the Data Service."@en; + shacl:name "keyword"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:keyword . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.endpointdescription"; + shacl:description "A description of the services available via the end-points, including their operations, parameters etc."@en; + shacl:name "endpoint description"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:endpointDescription . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.publisher"; + shacl:description "An entity (organisation) responsible for making the Data Service available."@en; + shacl:maxCount 1; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.documentation"; + shacl:class foaf:Document; + shacl:description "A page or document about this Data Service"@en; + shacl:name "documentation"@en; + shacl:path foaf:page . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.description"; + shacl:description "A free-text account of the Data Service."@en; + shacl:name "description"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:description . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.applicablelegislation"; + shacl:class ; + shacl:description "The legislation that mandates the creation or management of the Data Service."@en; + shacl:name "applicable legislation"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.format"; + shacl:class dc:MediaTypeOrExtent; + shacl:description "The structure that can be returned by querying the endpointURL."@en; + shacl:name "format"@en; + shacl:path dc:format . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.accessrights"; + shacl:description "Information regarding access or restrictions based on privacy, security, or other policies."@en; + shacl:maxCount 1; + shacl:name "access rights"@en; + shacl:path dc:accessRights . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.contactpoint"; + shacl:class vcard:Kind; + shacl:description "Contact information that can be used for sending comments about the Data Service."@en; + shacl:name "contact point"@en; + shacl:path dcat:contactPoint . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.endpointURL"; + shacl:description "The root location or primary endpoint of the service (an IRI)."@en; + shacl:minCount 1; + shacl:name "endpoint URL"@en; + shacl:path dcat:endpointURL . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.publisher"; + shacl:description "An entity (organisation) responsible for making the Data Service available."@en; + shacl:name "publisher"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.theme"; + shacl:description "A category of the Data Service."@en; + shacl:name "theme"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:theme . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.documentation"; + shacl:description "A page or document about this Data Service"@en; + shacl:name "documentation"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path foaf:page . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.contactpoint"; + shacl:description "Contact information that can be used for sending comments about the Data Service."@en; + shacl:name "contact point"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:contactPoint . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.licence"; + shacl:description "A licence under which the Data service is made available."@en; + shacl:maxCount 1; + shacl:name "licence"@en; + shacl:path dc:license . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.publisher"; + shacl:class foaf:Agent; + shacl:description "An entity (organisation) responsible for making the Data Service available."@en; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.format"; + shacl:description "The structure that can be returned by querying the endpointURL."@en; + shacl:name "format"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:format . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.conformsto"; + shacl:class dc:Standard; + shacl:description "An established (technical) standard to which the Data Service conforms."@en; + shacl:name "conforms to"@en; + shacl:path dc:conformsTo . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.servesdataset"; + shacl:description "This property refers to a collection of data that this data service can distribute."@en; + shacl:name "serves dataset"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:servesDataset . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.title"; + shacl:description "A name given to the Data Service."@en; + shacl:name "title"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:title . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.licence"; + shacl:class dc:LicenseDocument; + shacl:description "A licence under which the Data service is made available."@en; + shacl:name "licence"@en; + shacl:path dc:license . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.theme"; + shacl:class skos:Concept; + shacl:description "A category of the Data Service."@en; + shacl:name "theme"@en; + shacl:path dcat:theme . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.accessrights"; + shacl:class dc:RightsStatement; + shacl:description "Information regarding access or restrictions based on privacy, security, or other policies."@en; + shacl:name "access rights"@en; + shacl:path dc:accessRights . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.licence"; + shacl:description "A licence under which the Data service is made available."@en; + shacl:name "licence"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:license . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.title"; + shacl:description "A name given to the Data Service."@en; + shacl:minCount 1; + shacl:name "title"@en; + shacl:path dc:title . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.landingpage"; + shacl:class foaf:Document; + shacl:description "A web page that provides access to the Data Service and/or additional information."@en; + shacl:name "landing page"@en; + shacl:path dcat:landingPage . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:DatasetSeries . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.geographicalcoverage"; + shacl:class dc:Location; + shacl:description "A geographic region that is covered by the Dataset Series."@en; + shacl:name "geographical coverage"@en; + shacl:path dc:spatial . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.frequency"; + shacl:class dc:Frequency; + shacl:description "The frequency at which the Dataset Series is updated."@en; + shacl:name "frequency"@en; + shacl:path dc:accrualPeriodicity . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.applicablelegislation"; + shacl:description "The legislation that mandates the creation or management of the Dataset Series."@en; + shacl:name "applicable legislation"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.releasedate"; + shacl:description "The date of formal issuance (e.g., publication) of the Dataset Series."@en; + shacl:name "release date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:issued . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.frequency"; + shacl:description "The frequency at which the Dataset Series is updated."@en; + shacl:name "frequency"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:accrualPeriodicity . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.publisher"; + shacl:description "An entity (organisation) responsible for ensuring the coherency of the Dataset Series "@en; + shacl:maxCount 1; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.modificationdate"; + shacl:description "The most recent date on which the Dataset Series was changed or modified."@en; + shacl:name "modification date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:modified . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.description"; + shacl:description "A free-text account of the Dataset Series."@en; + shacl:name "description"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:description . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.applicablelegislation"; + shacl:class ; + shacl:description "The legislation that mandates the creation or management of the Dataset Series."@en; + shacl:name "applicable legislation"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.contactpoint"; + shacl:class vcard:Kind; + shacl:description "Contact information that can be used for sending comments about the Dataset Series."@en; + shacl:name "contact point"@en; + shacl:path dcat:contactPoint . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.temporalcoverage"; + shacl:description "A temporal period that the Dataset Series covers."@en; + shacl:name "temporal coverage"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:temporal . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.frequency"; + shacl:description "The frequency at which the Dataset Series is updated."@en; + shacl:maxCount 1; + shacl:name "frequency"@en; + shacl:path dc:accrualPeriodicity . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.temporalcoverage"; + shacl:class dc:PeriodOfTime; + shacl:description "A temporal period that the Dataset Series covers."@en; + shacl:name "temporal coverage"@en; + shacl:path dc:temporal . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.description"; + shacl:description "A free-text account of the Dataset Series."@en; + shacl:minCount 1; + shacl:name "description"@en; + shacl:path dc:description . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.publisher"; + shacl:description "An entity (organisation) responsible for ensuring the coherency of the Dataset Series "@en; + shacl:name "publisher"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.geographicalcoverage"; + shacl:description "A geographic region that is covered by the Dataset Series."@en; + shacl:name "geographical coverage"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:spatial . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.contactpoint"; + shacl:description "Contact information that can be used for sending comments about the Dataset Series."@en; + shacl:name "contact point"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:contactPoint . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.modificationdate"; + shacl:description "The most recent date on which the Dataset Series was changed or modified."@en; + shacl:maxCount 1; + shacl:name "modification date"@en; + shacl:path dc:modified . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.releasedate"; + shacl:description "The date of formal issuance (e.g., publication) of the Dataset Series."@en; + shacl:maxCount 1; + shacl:name "release date"@en; + shacl:path dc:issued . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.publisher"; + shacl:class foaf:Agent; + shacl:description "An entity (organisation) responsible for ensuring the coherency of the Dataset Series "@en; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.title"; + shacl:description "A name given to the Dataset Series."@en; + shacl:name "title"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:title . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.title"; + shacl:description "A name given to the Dataset Series."@en; + shacl:minCount 1; + shacl:name "title"@en; + shacl:path dc:title . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:Dataset . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.geographicalcoverage"; + shacl:class dc:Location; + shacl:description "A geographic region that is covered by the Dataset."@en; + shacl:name "geographical coverage"@en; + shacl:path dc:spatial . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.otheridentifier"; + shacl:description "A secondary identifier of the Dataset"@en; + shacl:name "other identifier"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.frequency"; + shacl:class dc:Frequency; + shacl:description "The frequency at which the Dataset is updated."@en; + shacl:name "frequency"@en; + shacl:path dc:accrualPeriodicity . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.conformsto"; + shacl:description "An implementing rule or other specification."@en; + shacl:name "conforms to"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:conformsTo . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.applicablelegislation"; + shacl:description "The legislation that mandates the creation or management of the Dataset."@en; + shacl:name "applicable legislation"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.relatedresource"; + shacl:description "A related resource."@en; + shacl:name "related resource"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:relation . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.provenance"; + shacl:class dc:ProvenanceStatement; + shacl:description "A statement about the lineage of a Dataset."@en; + shacl:name "provenance"@en; + shacl:path dc:provenance . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.accessrights"; + shacl:description "Information that indicates whether the Dataset is publicly accessible, has access restrictions or is not public."@en; + shacl:name "access rights"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:accessRights . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.temporalresolution"; + shacl:description "The minimum time period resolvable in the dataset."@en; + shacl:maxCount 1; + shacl:name "temporal resolution"@en; + shacl:path dcat:temporalResolution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.version"; + shacl:description "The version indicator (name or identifier) of a resource."@en; + shacl:maxCount 1; + shacl:name "version"@en; + shacl:path dcat:version . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.wasgeneratedby"; + shacl:description "An activity that generated, or provides the business context for, the creation of the dataset."@en; + shacl:name "was generated by"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path prov:wasGeneratedBy . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.temporalresolution"; + shacl:description "The minimum time period resolvable in the dataset."@en; + shacl:name "temporal resolution"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:temporalResolution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.language"; + shacl:class dc:LinguisticSystem; + shacl:description "A language of the Dataset."@en; + shacl:name "language"@en; + shacl:path dc:language . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.datasetdistribution"; + shacl:class dcat:Distribution; + shacl:description "An available Distribution for the Dataset."@en; + shacl:name "dataset distribution"@en; + shacl:path dcat:distribution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.source"; + shacl:class dcat:Dataset; + shacl:description "A related Dataset from which the described Dataset is derived."@en; + shacl:name "source"@en; + shacl:path dc:source . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.landingpage"; + shacl:description "A web page that provides access to the Dataset, its Distributions and/or additional information."@en; + shacl:name "landing page"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:landingPage . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.type"; + shacl:class skos:Concept; + shacl:description "A type of the Dataset."@en; + shacl:name "type"@en; + shacl:path dc:type . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.sample"; + shacl:description "A sample distribution of the dataset."@en; + shacl:name "sample"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.wasgeneratedby"; + shacl:class prov:Activity; + shacl:description "An activity that generated, or provides the business context for, the creation of the dataset."@en; + shacl:name "was generated by"@en; + shacl:path prov:wasGeneratedBy . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.isreferencedby"; + shacl:description "A related resource, such as a publication, that references, cites, or otherwise points to the dataset."@en; + shacl:name "is referenced by"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:isReferencedBy . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.qualifiedrelation"; + shacl:description "A description of a relationship with another resource."@en; + shacl:name "qualified relation"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:qualifiedRelation . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.spatialresolution"; + shacl:datatype xsd:decimal; + shacl:description "The minimum spatial separation resolvable in a dataset, measured in meters."@en; + shacl:name "spatial resolution"@en; + shacl:path dcat:spatialResolutionInMeters . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.spatialresolution"; + shacl:description "The minimum spatial separation resolvable in a dataset, measured in meters."@en; + shacl:name "spatial resolution"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:spatialResolutionInMeters . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.hasversion"; + shacl:class dcat:Dataset; + shacl:description "A related Dataset that is a version, edition, or adaptation of the described Dataset."@en; + shacl:name "has version"@en; + shacl:path dcat:hasVersion . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.releasedate"; + shacl:description "The date of formal issuance (e.g., publication) of the Dataset."@en; + shacl:name "release date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:issued . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.type"; + shacl:description "A type of the Dataset."@en; + shacl:name "type"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:type . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.versionnotes"; + shacl:description "A description of the differences between this version and a previous version of the Dataset."@en; + shacl:name "version notes"@en; + shacl:nodeKind shacl:Literal; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.keyword"; + shacl:description "A keyword or tag describing the Dataset."@en; + shacl:name "keyword"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:keyword . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.provenance"; + shacl:description "A statement about the lineage of a Dataset."@en; + shacl:name "provenance"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:provenance . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.sample"; + shacl:class dcat:Distribution; + shacl:description "A sample distribution of the dataset."@en; + shacl:name "sample"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.inseries"; + shacl:class dcat:DatasetSeries; + shacl:description "A dataset series of which the dataset is part."@en; + shacl:name "in series"@en; + shacl:path dcat:inSeries . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.frequency"; + shacl:description "The frequency at which the Dataset is updated."@en; + shacl:name "frequency"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:accrualPeriodicity . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.publisher"; + shacl:description "An entity (organisation) responsible for making the Dataset available."@en; + shacl:maxCount 1; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.documentation"; + shacl:class foaf:Document; + shacl:description "A page or document about this Dataset."@en; + shacl:name "documentation"@en; + shacl:path foaf:page . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.modificationdate"; + shacl:description "The most recent date on which the Dataset was changed or modified."@en; + shacl:name "modification date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:modified . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.description"; + shacl:description "A free-text account of the Dataset."@en; + shacl:name "description"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:description . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.applicablelegislation"; + shacl:class ; + shacl:description "The legislation that mandates the creation or management of the Dataset."@en; + shacl:name "applicable legislation"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.accessrights"; + shacl:description "Information that indicates whether the Dataset is publicly accessible, has access restrictions or is not public."@en; + shacl:maxCount 1; + shacl:name "access rights"@en; + shacl:path dc:accessRights . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.contactpoint"; + shacl:class vcard:Kind; + shacl:description "Contact information that can be used for sending comments about the Dataset."@en; + shacl:name "contact point"@en; + shacl:path dcat:contactPoint . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.creator"; + shacl:description "An entity responsible for producing the dataset."@en; + shacl:name "creator"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:creator . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.source"; + shacl:description "A related Dataset from which the described Dataset is derived."@en; + shacl:name "source"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:source . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.temporalcoverage"; + shacl:description "A temporal period that the Dataset covers."@en; + shacl:name "temporal coverage"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:temporal . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.inseries"; + shacl:description "A dataset series of which the dataset is part."@en; + shacl:name "in series"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:inSeries . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.qualifiedattribution"; + shacl:class prov:Attribution; + shacl:description "An Agent having some form of responsibility for the resource."@en; + shacl:name "qualified attribution"@en; + shacl:path prov:qualifiedAttribution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.frequency"; + shacl:description "The frequency at which the Dataset is updated."@en; + shacl:maxCount 1; + shacl:name "frequency"@en; + shacl:path dc:accrualPeriodicity . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.temporalcoverage"; + shacl:class dc:PeriodOfTime; + shacl:description "A temporal period that the Dataset covers."@en; + shacl:name "temporal coverage"@en; + shacl:path dc:temporal . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.description"; + shacl:description "A free-text account of the Dataset."@en; + shacl:minCount 1; + shacl:name "description"@en; + shacl:path dc:description . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.publisher"; + shacl:description "An entity (organisation) responsible for making the Dataset available."@en; + shacl:name "publisher"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.geographicalcoverage"; + shacl:description "A geographic region that is covered by the Dataset."@en; + shacl:name "geographical coverage"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:spatial . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.theme"; + shacl:description "A category of the Dataset."@en; + shacl:name "theme"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:theme . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.documentation"; + shacl:description "A page or document about this Dataset."@en; + shacl:name "documentation"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path foaf:page . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.contactpoint"; + shacl:description "Contact information that can be used for sending comments about the Dataset."@en; + shacl:name "contact point"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:contactPoint . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.modificationdate"; + shacl:description "The most recent date on which the Dataset was changed or modified."@en; + shacl:maxCount 1; + shacl:name "modification date"@en; + shacl:path dc:modified . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.otheridentifier"; + shacl:class ; + shacl:description "A secondary identifier of the Dataset"@en; + shacl:name "other identifier"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.identifier"; + shacl:description "The main identifier for the Dataset, e.g. the URI or other unique identifier in the context of the Catalogue."@en; + shacl:name "identifier"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:identifier . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.releasedate"; + shacl:description "The date of formal issuance (e.g., publication) of the Dataset."@en; + shacl:maxCount 1; + shacl:name "release date"@en; + shacl:path dc:issued . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.publisher"; + shacl:class foaf:Agent; + shacl:description "An entity (organisation) responsible for making the Dataset available."@en; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.qualifiedattribution"; + shacl:description "An Agent having some form of responsibility for the resource."@en; + shacl:name "qualified attribution"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path prov:qualifiedAttribution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.version"; + shacl:description "The version indicator (name or identifier) of a resource."@en; + shacl:name "version"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:version . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.creator"; + shacl:class foaf:Agent; + shacl:description "An entity responsible for producing the dataset."@en; + shacl:name "creator"@en; + shacl:path dc:creator . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.conformsto"; + shacl:class dc:Standard; + shacl:description "An implementing rule or other specification."@en; + shacl:name "conforms to"@en; + shacl:path dc:conformsTo . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.hasversion"; + shacl:description "A related Dataset that is a version, edition, or adaptation of the described Dataset."@en; + shacl:name "has version"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:hasVersion . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.title"; + shacl:description "A name given to the Dataset."@en; + shacl:name "title"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:title . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.language"; + shacl:description "A language of the Dataset."@en; + shacl:name "language"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:language . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.theme"; + shacl:class skos:Concept; + shacl:description "A category of the Dataset."@en; + shacl:name "theme"@en; + shacl:path dcat:theme . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.temporalresolution"; + shacl:datatype xsd:duration; + shacl:description "The minimum time period resolvable in the dataset."@en; + shacl:name "temporal resolution"@en; + shacl:path dcat:temporalResolution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.accessrights"; + shacl:class dc:RightsStatement; + shacl:description "Information that indicates whether the Dataset is publicly accessible, has access restrictions or is not public."@en; + shacl:name "access rights"@en; + shacl:path dc:accessRights . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.datasetdistribution"; + shacl:description "An available Distribution for the Dataset."@en; + shacl:name "dataset distribution"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:distribution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.title"; + shacl:description "A name given to the Dataset."@en; + shacl:minCount 1; + shacl:name "title"@en; + shacl:path dc:title . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.qualifiedrelation"; + shacl:class dcat:Relationship; + shacl:description "A description of a relationship with another resource."@en; + shacl:name "qualified relation"@en; + shacl:path dcat:qualifiedRelation . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.landingpage"; + shacl:class foaf:Document; + shacl:description "A web page that provides access to the Dataset, its Distributions and/or additional information."@en; + shacl:name "landing page"@en; + shacl:path dcat:landingPage . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:Distribution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.mediatype"; + shacl:class dc:MediaType; + shacl:description "The media type of the Distribution as defined in the official register of media types managed by IANA."@en; + shacl:name "media type"@en; + shacl:path dcat:mediaType . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.availability"; + shacl:description "An indication how long it is planned to keep the Distribution of the Dataset available."@en; + shacl:name "availability"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.applicablelegislation"; + shacl:description "The legislation that mandates the creation or management of the Distribution."@en; + shacl:name "applicable legislation"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.status"; + shacl:class skos:Concept; + shacl:description "The status of the distribution in the context of maturity lifecycle."@en; + shacl:name "status"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.temporalresolution"; + shacl:description "The minimum time period resolvable in the dataset distribution."@en; + shacl:maxCount 1; + shacl:name "temporal resolution"@en; + shacl:path dcat:temporalResolution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.compressionformat"; + shacl:description "The format of the file in which the data is contained in a compressed form, e.g. to reduce the size of the downloadable file."@en; + shacl:maxCount 1; + shacl:name "compression format"@en; + shacl:path dcat:compressFormat . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.linkedschemas"; + shacl:class dc:Standard; + shacl:description "An established schema to which the described Distribution conforms."@en; + shacl:name "linked schemas"@en; + shacl:path dc:conformsTo . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.accessservice"; + shacl:description "A data service that gives access to the distribution of the dataset."@en; + shacl:name "access service"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:accessService . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.linkedschemas"; + shacl:description "An established schema to which the described Distribution conforms."@en; + shacl:name "linked schemas"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:conformsTo . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.downloadURL"; + shacl:description "A URL that is a direct link to a downloadable file in a given format."@en; + shacl:name "download URL"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:downloadURL . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.temporalresolution"; + shacl:description "The minimum time period resolvable in the dataset distribution."@en; + shacl:name "temporal resolution"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:temporalResolution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.language"; + shacl:class dc:LinguisticSystem; + shacl:description "A language used in the Distribution."@en; + shacl:name "language"@en; + shacl:path dc:language . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.status"; + shacl:description "The status of the distribution in the context of maturity lifecycle."@en; + shacl:maxCount 1; + shacl:name "status"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.haspolicy"; + shacl:description "The policy expressing the rights associated with the distribution if using the [[ODRL]] vocabulary."@en; + shacl:maxCount 1; + shacl:name "has policy"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.packagingformat"; + shacl:class dc:MediaType; + shacl:description "The format of the file in which one or more data files are grouped together, e.g. to enable a set of related files to be downloaded together."@en; + shacl:name "packaging format"@en; + shacl:path dcat:packageFormat . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.status"; + shacl:description "The status of the distribution in the context of maturity lifecycle."@en; + shacl:name "status"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.spatialresolution"; + shacl:datatype xsd:decimal; + shacl:description "The minimum spatial separation resolvable in a dataset distribution, measured in meters."@en; + shacl:name "spatial resolution"@en; + shacl:path dcat:spatialResolutionInMeters . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.mediatype"; + shacl:description "The media type of the Distribution as defined in the official register of media types managed by IANA."@en; + shacl:name "media type"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:mediaType . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.spatialresolution"; + shacl:description "The minimum spatial separation resolvable in a dataset distribution, measured in meters."@en; + shacl:name "spatial resolution"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:spatialResolutionInMeters . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.releasedate"; + shacl:description "The date of formal issuance (e.g., publication) of the Distribution."@en; + shacl:name "release date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:issued . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.bytesize"; + shacl:description "The size of a Distribution in bytes."@en; + shacl:name "byte size"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:byteSize . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.checksum"; + shacl:class ; + shacl:description "A mechanism that can be used to verify that the contents of a distribution have not changed."@en; + shacl:name "checksum"@en; + shacl:path . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.documentation"; + shacl:class foaf:Document; + shacl:description "A page or document about this Distribution."@en; + shacl:name "documentation"@en; + shacl:path foaf:page . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.mediatype"; + shacl:description "The media type of the Distribution as defined in the official register of media types managed by IANA."@en; + shacl:maxCount 1; + shacl:name "media type"@en; + shacl:path dcat:mediaType . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.modificationdate"; + shacl:description "The most recent date on which the Distribution was changed or modified."@en; + shacl:name "modification date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:modified . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.description"; + shacl:description "A free-text account of the Distribution."@en; + shacl:name "description"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:description . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.applicablelegislation"; + shacl:class ; + shacl:description "The legislation that mandates the creation or management of the Distribution."@en; + shacl:name "applicable legislation"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.checksum"; + shacl:description "A mechanism that can be used to verify that the contents of a distribution have not changed."@en; + shacl:maxCount 1; + shacl:name "checksum"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.format"; + shacl:class dc:MediaTypeOrExtent; + shacl:description "The file format of the Distribution."@en; + shacl:name "format"@en; + shacl:path dc:format . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.accessservice"; + shacl:class dcat:DataService; + shacl:description "A data service that gives access to the distribution of the dataset."@en; + shacl:name "access service"@en; + shacl:path dcat:accessService . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.compressionformat"; + shacl:description "The format of the file in which the data is contained in a compressed form, e.g. to reduce the size of the downloadable file."@en; + shacl:name "compression format"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:compressFormat . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.haspolicy"; + shacl:class ; + shacl:description "The policy expressing the rights associated with the distribution if using the [[ODRL]] vocabulary."@en; + shacl:name "has policy"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.format"; + shacl:description "The file format of the Distribution."@en; + shacl:maxCount 1; + shacl:name "format"@en; + shacl:path dc:format . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.rights"; + shacl:class dc:RightsStatement; + shacl:description "A statement that specifies rights associated with the Distribution."@en; + shacl:name "rights"@en; + shacl:path dc:rights . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.documentation"; + shacl:description "A page or document about this Distribution."@en; + shacl:name "documentation"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path foaf:page . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.availability"; + shacl:class skos:Concept; + shacl:description "An indication how long it is planned to keep the Distribution of the Dataset available."@en; + shacl:name "availability"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.modificationdate"; + shacl:description "The most recent date on which the Distribution was changed or modified."@en; + shacl:maxCount 1; + shacl:name "modification date"@en; + shacl:path dc:modified . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.licence"; + shacl:description "A licence under which the Distribution is made available."@en; + shacl:maxCount 1; + shacl:name "licence"@en; + shacl:path dc:license . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.accessURL"; + shacl:description "A URL that gives access to a Distribution of the Dataset."@en; + shacl:name "access URL"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:accessURL . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.availability"; + shacl:description "An indication how long it is planned to keep the Distribution of the Dataset available."@en; + shacl:maxCount 1; + shacl:name "availability"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.releasedate"; + shacl:description "The date of formal issuance (e.g., publication) of the Distribution."@en; + shacl:maxCount 1; + shacl:name "release date"@en; + shacl:path dc:issued . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.rights"; + shacl:description "A statement that specifies rights associated with the Distribution."@en; + shacl:name "rights"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:rights . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.packagingformat"; + shacl:description "The format of the file in which one or more data files are grouped together, e.g. to enable a set of related files to be downloaded together."@en; + shacl:maxCount 1; + shacl:name "packaging format"@en; + shacl:path dcat:packageFormat . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.format"; + shacl:description "The file format of the Distribution."@en; + shacl:name "format"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:format . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.packagingformat"; + shacl:description "The format of the file in which one or more data files are grouped together, e.g. to enable a set of related files to be downloaded together."@en; + shacl:name "packaging format"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:packageFormat . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.title"; + shacl:description "A name given to the Distribution."@en; + shacl:name "title"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:title . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.language"; + shacl:description "A language used in the Distribution."@en; + shacl:name "language"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:language . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.licence"; + shacl:class dc:LicenseDocument; + shacl:description "A licence under which the Distribution is made available."@en; + shacl:name "licence"@en; + shacl:path dc:license . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.checksum"; + shacl:description "A mechanism that can be used to verify that the contents of a distribution have not changed."@en; + shacl:name "checksum"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.accessURL"; + shacl:description "A URL that gives access to a Distribution of the Dataset."@en; + shacl:minCount 1; + shacl:name "access URL"@en; + shacl:path dcat:accessURL . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.compressionformat"; + shacl:class dc:MediaType; + shacl:description "The format of the file in which the data is contained in a compressed form, e.g. to reduce the size of the downloadable file."@en; + shacl:name "compression format"@en; + shacl:path dcat:compressFormat . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.temporalresolution"; + shacl:datatype xsd:duration; + shacl:description "The minimum time period resolvable in the dataset distribution."@en; + shacl:name "temporal resolution"@en; + shacl:path dcat:temporalResolution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.bytesize"; + shacl:datatype xsd:nonNegativeInteger; + shacl:description "The size of a Distribution in bytes."@en; + shacl:name "byte size"@en; + shacl:path dcat:byteSize . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.licence"; + shacl:description "A licence under which the Distribution is made available."@en; + shacl:name "licence"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:license . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.bytesize"; + shacl:description "The size of a Distribution in bytes."@en; + shacl:maxCount 1; + shacl:name "byte size"@en; + shacl:path dcat:byteSize . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.haspolicy"; + shacl:description "The policy expressing the rights associated with the distribution if using the [[ODRL]] vocabulary."@en; + shacl:name "has policy"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.spatialresolution"; + shacl:description "The minimum spatial separation resolvable in a dataset distribution, measured in meters."@en; + shacl:maxCount 1; + shacl:name "spatial resolution"@en; + shacl:path dcat:spatialResolutionInMeters . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + ; + shacl:targetClass dcat:Relationship . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Relationship.relation"; + shacl:description "A resource related to the source resource."@en; + shacl:name "relation"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:relation . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Relationship.hadrole"; + shacl:description "A function of an entity or agent with respect to another entity or resource."@en; + shacl:name "had role"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dcat:hadRole . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Relationship.relation"; + shacl:description "A resource related to the source resource."@en; + shacl:minCount 1; + shacl:name "relation"@en; + shacl:path dc:relation . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Relationship.hadrole"; + shacl:class dcat:Role; + shacl:description "A function of an entity or agent with respect to another entity or resource."@en; + shacl:name "had role"@en; + shacl:path dcat:hadRole . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Relationship.hadrole"; + shacl:description "A function of an entity or agent with respect to another entity or resource."@en; + shacl:minCount 1; + shacl:name "had role"@en; + shacl:path dcat:hadRole . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dcat:Resource . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dcat:Role . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:Frequency . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + ; + shacl:targetClass dc:LicenseDocument . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#LicenceDocument.type"; + shacl:class skos:Concept; + shacl:description "A type of licence, e.g. indicating 'public domain' or 'royalties required'."@en; + shacl:name "type"@en; + shacl:path dc:type . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#LicenceDocument.type"; + shacl:description "A type of licence, e.g. indicating 'public domain' or 'royalties required'."@en; + shacl:name "type"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:type . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:LinguisticSystem . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + ; + shacl:targetClass dc:Location . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Location.bbox"; + shacl:description "The geographic bounding box of a resource."@en; + shacl:name "bbox"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:bbox . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Location.geometry"; + shacl:class ; + shacl:description "The corresponding geometry for a resource."@en; + shacl:name "geometry"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Location.centroid"; + shacl:description "The geographic center (centroid) of a resource."@en; + shacl:name "centroid"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:centroid . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Location.centroid"; + shacl:description "The geographic center (centroid) of a resource."@en; + shacl:maxCount 1; + shacl:name "centroid"@en; + shacl:path dcat:centroid . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Location.geometry"; + shacl:description "The corresponding geometry for a resource."@en; + shacl:name "geometry"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Location.bbox"; + shacl:description "The geographic bounding box of a resource."@en; + shacl:maxCount 1; + shacl:name "bbox"@en; + shacl:path dcat:bbox . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Location.geometry"; + shacl:description "The corresponding geometry for a resource."@en; + shacl:maxCount 1; + shacl:name "geometry"@en; + shacl:path . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:MediaTypeOrExtent . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:MediaType . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dc:PeriodOfTime . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.beginning"; + shacl:description "The beginning of a period or interval."@en; + shacl:maxCount 1; + shacl:name "beginning"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.beginning"; + shacl:description "The beginning of a period or interval."@en; + shacl:name "beginning"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.end"; + shacl:description "The end of a period or interval."@en; + shacl:maxCount 1; + shacl:name "end"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.startdate"; + shacl:description "The start of the period."@en; + shacl:name "start date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:startDate . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.enddate"; + shacl:description "The end of the period."@en; + shacl:maxCount 1; + shacl:name "end date"@en; + shacl:path dcat:endDate . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.end"; + shacl:class ; + shacl:description "The end of a period or interval."@en; + shacl:name "end"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.end"; + shacl:description "The end of a period or interval."@en; + shacl:name "end"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.enddate"; + shacl:description "The end of the period."@en; + shacl:name "end date"@en; + shacl:nodeKind shacl:Literal; + shacl:path dcat:endDate . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.beginning"; + shacl:class ; + shacl:description "The beginning of a period or interval."@en; + shacl:name "beginning"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.startdate"; + shacl:description "The start of the period."@en; + shacl:maxCount 1; + shacl:name "start date"@en; + shacl:path dcat:startDate . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:ProvenanceStatement . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:RightsStatement . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:Standard . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + ; + shacl:targetClass foaf:Agent . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Agent.type"; + shacl:description "The nature of the agent."@en; + shacl:maxCount 1; + shacl:name "type"@en; + shacl:path dc:type . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Agent.type"; + shacl:class skos:Concept; + shacl:description "The nature of the agent."@en; + shacl:name "type"@en; + shacl:path dc:type . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Agent.type"; + shacl:description "The nature of the agent."@en; + shacl:name "type"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path dc:type . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Agent.name"; + shacl:description "A name of the agent."@en; + shacl:minCount 1; + shacl:name "name"@en; + shacl:path foaf:name . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Agent.name"; + shacl:description "A name of the agent."@en; + shacl:name "name"@en; + shacl:nodeKind shacl:Literal; + shacl:path foaf:name . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass foaf:Document . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass prov:Activity . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass prov:Attribution . + + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + ; + shacl:targetClass skos:ConceptScheme . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#ConceptScheme.title"; + shacl:description "A name of the concept scheme."@en; + shacl:name "title"@en; + shacl:nodeKind shacl:Literal; + shacl:path dc:title . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#ConceptScheme.title"; + shacl:description "A name of the concept scheme."@en; + shacl:minCount 1; + shacl:name "title"@en; + shacl:path dc:title . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + ; + shacl:targetClass skos:Concept . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Concept.preferredlabel"; + shacl:description "A preferred label of the concept."@en; + shacl:name "preferred label"@en; + shacl:nodeKind shacl:Literal; + shacl:path skos:prefLabel . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Concept.preferredlabel"; + shacl:description "A preferred label of the concept."@en; + shacl:minCount 1; + shacl:name "preferred label"@en; + shacl:path skos:prefLabel . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + ; + shacl:targetClass . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Checksum.checksumvalue"; + shacl:description "A lower case hexadecimal encoded digest value produced using a specific algorithm."@en; + shacl:name "checksum value"@en; + shacl:nodeKind shacl:Literal; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Checksum.checksumvalue"; + shacl:datatype xsd:hexBinary; + shacl:description "A lower case hexadecimal encoded digest value produced using a specific algorithm."@en; + shacl:name "checksum value"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Checksum.checksumvalue"; + shacl:description "A lower case hexadecimal encoded digest value produced using a specific algorithm."@en; + shacl:maxCount 1; + shacl:name "checksum value"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Checksum.algorithm"; + shacl:description "The algorithm used to produce the subject Checksum."@en; + shacl:name "algorithm"@en; + shacl:nodeKind shacl:BlankNodeOrIRI; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Checksum.algorithm"; + shacl:description "The algorithm used to produce the subject Checksum."@en; + shacl:maxCount 1; + shacl:name "algorithm"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Checksum.algorithm"; + shacl:description "The algorithm used to produce the subject Checksum."@en; + shacl:minCount 1; + shacl:name "algorithm"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Checksum.checksumvalue"; + shacl:description "A lower case hexadecimal encoded digest value produced using a specific algorithm."@en; + shacl:minCount 1; + shacl:name "checksum value"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Checksum.algorithm"; + shacl:class ; + shacl:description "The algorithm used to produce the subject Checksum."@en; + shacl:name "algorithm"@en; + shacl:path . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass vcard:Kind . + diff --git a/pyegeria/view/data/dcat-ap-3/ranges.ttl b/pyegeria/view/data/dcat-ap-3/ranges.ttl new file mode 100644 index 00000000..93fb195b --- /dev/null +++ b/pyegeria/view/data/dcat-ap-3/ranges.ttl @@ -0,0 +1,1232 @@ +@prefix dc: . +@prefix dcat: . +@prefix foaf: . +@prefix prov: . +@prefix rdf: . +@prefix rdfs: . +@prefix shacl: . +@prefix skos: . +@prefix vcard: . +@prefix xsd: . + + rdfs:member , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass rdfs:Literal . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + ; + shacl:targetClass . + + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:CatalogRecord . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.language"; + shacl:class dc:LinguisticSystem; + shacl:description "A language used in the textual metadata describing titles, descriptions, etc. of the Catalogued Resource."@en; + shacl:name "language"@en; + shacl:path dc:language . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.applicationprofile"; + shacl:class dc:Standard; + shacl:description "An Application Profile that the Catalogued Resource's metadata conforms to."@en; + shacl:name "application profile"@en; + shacl:path dc:conformsTo . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.changetype"; + shacl:class skos:Concept; + shacl:description "The status of the catalogue record in the context of editorial flow of the dataset and data service descriptions."@en; + shacl:name "change type"@en; + shacl:path . + + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.sourcemetadata"; + shacl:class dcat:CatalogRecord; + shacl:description "The original metadata that was used in creating metadata for the Dataset, Data Service or Dataset Series."@en; + shacl:name "source metadata"@en; + shacl:path dc:source . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#CatalogueRecord.primarytopic"; + shacl:class dcat:Resource; + shacl:description "A link to the Dataset, Data service or Catalog described in the record."@en; + shacl:name "primary topic"@en; + shacl:path foaf:primaryTopic . + + + + + + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:Catalog . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.geographicalcoverage"; + shacl:class dc:Location; + shacl:description "A geographical area covered by the Catalogue."@en; + shacl:name "geographical coverage"@en; + shacl:path dc:spatial . + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.language"; + shacl:class dc:LinguisticSystem; + shacl:description "A language used in the textual metadata describing titles, descriptions, etc. of the Datasets in the Catalogue."@en; + shacl:name "language"@en; + shacl:path dc:language . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.record"; + shacl:class dcat:CatalogRecord; + shacl:description "A Catalogue Record that is part of the Catalogue."@en; + shacl:name "record"@en; + shacl:path dcat:record . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.catalogue"; + shacl:class dcat:Catalog; + shacl:description "A catalogue whose contents are of interest in the context of this catalogue."@en; + shacl:name "catalogue"@en; + shacl:path dcat:catalog . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.themes"; + shacl:class skos:ConceptScheme; + shacl:description "A knowledge organization system used to classify the Resources that are in the Catalogue."@en; + shacl:name "themes"@en; + shacl:path dcat:themeTaxonomy . + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.applicablelegislation"; + shacl:class ; + shacl:description "The legislation that mandates the creation or management of the Catalogue."@en; + shacl:name "applicable legislation"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.dataset"; + shacl:class dcat:Dataset; + shacl:description "A Dataset that is part of the Catalogue."@en; + shacl:name "dataset"@en; + shacl:path dcat:dataset . + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.temporalcoverage"; + shacl:class dc:PeriodOfTime; + shacl:description "A temporal period that the Catalogue covers."@en; + shacl:name "temporal coverage"@en; + shacl:path dc:temporal . + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.rights"; + shacl:class dc:RightsStatement; + shacl:description "A statement that specifies rights associated with the Catalogue."@en; + shacl:name "rights"@en; + shacl:path dc:rights . + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.publisher"; + shacl:class foaf:Agent; + shacl:description "An entity (organisation) responsible for making the Catalogue available."@en; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.creator"; + shacl:class foaf:Agent; + shacl:description "An entity responsible for the creation of the catalogue."@en; + shacl:name "creator"@en; + shacl:path dc:creator . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.service"; + shacl:class dcat:DataService; + shacl:description "A site or end-point (Data Service) that is listed in the Catalogue."@en; + shacl:name "service"@en; + shacl:path dcat:service . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.haspart"; + shacl:class dcat:Catalog; + shacl:description "A related Catalogue that is part of the described Catalogue."@en; + shacl:name "has part"@en; + shacl:path dc:hasPart . + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.licence"; + shacl:class dc:LicenseDocument; + shacl:description "A licence under which the Catalogue can be used or reused."@en; + shacl:name "licence"@en; + shacl:path dc:license . + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Catalogue.homepage"; + shacl:class foaf:Document; + shacl:description "A web page that acts as the main page for the Catalogue."@en; + shacl:name "homepage"@en; + shacl:path foaf:homepage . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:DataService . + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.servesdataset"; + shacl:class dcat:Dataset; + shacl:description "This property refers to a collection of data that this data service can distribute."@en; + shacl:name "serves dataset"@en; + shacl:path dcat:servesDataset . + + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.documentation"; + shacl:class foaf:Document; + shacl:description "A page or document about this Data Service"@en; + shacl:name "documentation"@en; + shacl:path foaf:page . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.applicablelegislation"; + shacl:class ; + shacl:description "The legislation that mandates the creation or management of the Data Service."@en; + shacl:name "applicable legislation"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.format"; + shacl:class dc:MediaTypeOrExtent; + shacl:description "The structure that can be returned by querying the endpointURL."@en; + shacl:name "format"@en; + shacl:path dc:format . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.contactpoint"; + shacl:class vcard:Kind; + shacl:description "Contact information that can be used for sending comments about the Data Service."@en; + shacl:name "contact point"@en; + shacl:path dcat:contactPoint . + + + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.publisher"; + shacl:class foaf:Agent; + shacl:description "An entity (organisation) responsible for making the Data Service available."@en; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.conformsto"; + shacl:class dc:Standard; + shacl:description "An established (technical) standard to which the Data Service conforms."@en; + shacl:name "conforms to"@en; + shacl:path dc:conformsTo . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.licence"; + shacl:class dc:LicenseDocument; + shacl:description "A licence under which the Data service is made available."@en; + shacl:name "licence"@en; + shacl:path dc:license . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.endpointdescription"; + shacl:class rdfs:Resource; + shacl:description "A description of the services available via the end-points, including their operations, parameters etc."@en; + shacl:name "endpoint description"@en; + shacl:path dcat:endpointDescription . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.theme"; + shacl:class skos:Concept; + shacl:description "A category of the Data Service."@en; + shacl:name "theme"@en; + shacl:path dcat:theme . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.endpointURL"; + shacl:class rdfs:Resource; + shacl:description "The root location or primary endpoint of the service (an IRI)."@en; + shacl:name "endpoint URL"@en; + shacl:path dcat:endpointURL . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.accessrights"; + shacl:class dc:RightsStatement; + shacl:description "Information regarding access or restrictions based on privacy, security, or other policies."@en; + shacl:name "access rights"@en; + shacl:path dc:accessRights . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DataService.landingpage"; + shacl:class foaf:Document; + shacl:description "A web page that provides access to the Data Service and/or additional information."@en; + shacl:name "landing page"@en; + shacl:path dcat:landingPage . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:DatasetSeries . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.geographicalcoverage"; + shacl:class dc:Location; + shacl:description "A geographic region that is covered by the Dataset Series."@en; + shacl:name "geographical coverage"@en; + shacl:path dc:spatial . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.frequency"; + shacl:class dc:Frequency; + shacl:description "The frequency at which the Dataset Series is updated."@en; + shacl:name "frequency"@en; + shacl:path dc:accrualPeriodicity . + + + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.applicablelegislation"; + shacl:class ; + shacl:description "The legislation that mandates the creation or management of the Dataset Series."@en; + shacl:name "applicable legislation"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.contactpoint"; + shacl:class vcard:Kind; + shacl:description "Contact information that can be used for sending comments about the Dataset Series."@en; + shacl:name "contact point"@en; + shacl:path dcat:contactPoint . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.temporalcoverage"; + shacl:class dc:PeriodOfTime; + shacl:description "A temporal period that the Dataset Series covers."@en; + shacl:name "temporal coverage"@en; + shacl:path dc:temporal . + + + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#DatasetSeries.publisher"; + shacl:class foaf:Agent; + shacl:description "An entity (organisation) responsible for ensuring the coherency of the Dataset Series "@en; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:Dataset . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.geographicalcoverage"; + shacl:class dc:Location; + shacl:description "A geographic region that is covered by the Dataset."@en; + shacl:name "geographical coverage"@en; + shacl:path dc:spatial . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.frequency"; + shacl:class dc:Frequency; + shacl:description "The frequency at which the Dataset is updated."@en; + shacl:name "frequency"@en; + shacl:path dc:accrualPeriodicity . + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.provenance"; + shacl:class dc:ProvenanceStatement; + shacl:description "A statement about the lineage of a Dataset."@en; + shacl:name "provenance"@en; + shacl:path dc:provenance . + + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.language"; + shacl:class dc:LinguisticSystem; + shacl:description "A language of the Dataset."@en; + shacl:name "language"@en; + shacl:path dc:language . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.datasetdistribution"; + shacl:class dcat:Distribution; + shacl:description "An available Distribution for the Dataset."@en; + shacl:name "dataset distribution"@en; + shacl:path dcat:distribution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.source"; + shacl:class dcat:Dataset; + shacl:description "A related Dataset from which the described Dataset is derived."@en; + shacl:name "source"@en; + shacl:path dc:source . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.type"; + shacl:class skos:Concept; + shacl:description "A type of the Dataset."@en; + shacl:name "type"@en; + shacl:path dc:type . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.wasgeneratedby"; + shacl:class prov:Activity; + shacl:description "An activity that generated, or provides the business context for, the creation of the dataset."@en; + shacl:name "was generated by"@en; + shacl:path prov:wasGeneratedBy . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.spatialresolution"; + shacl:datatype xsd:decimal; + shacl:description "The minimum spatial separation resolvable in a dataset, measured in meters."@en; + shacl:name "spatial resolution"@en; + shacl:path dcat:spatialResolutionInMeters . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.hasversion"; + shacl:class dcat:Dataset; + shacl:description "A related Dataset that is a version, edition, or adaptation of the described Dataset."@en; + shacl:name "has version"@en; + shacl:path dcat:hasVersion . + + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.sample"; + shacl:class dcat:Distribution; + shacl:description "A sample distribution of the dataset."@en; + shacl:name "sample"@en; + shacl:path . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.inseries"; + shacl:class dcat:DatasetSeries; + shacl:description "A dataset series of which the dataset is part."@en; + shacl:name "in series"@en; + shacl:path dcat:inSeries . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.documentation"; + shacl:class foaf:Document; + shacl:description "A page or document about this Dataset."@en; + shacl:name "documentation"@en; + shacl:path foaf:page . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.applicablelegislation"; + shacl:class ; + shacl:description "The legislation that mandates the creation or management of the Dataset."@en; + shacl:name "applicable legislation"@en; + shacl:path . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.contactpoint"; + shacl:class vcard:Kind; + shacl:description "Contact information that can be used for sending comments about the Dataset."@en; + shacl:name "contact point"@en; + shacl:path dcat:contactPoint . + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.qualifiedattribution"; + shacl:class prov:Attribution; + shacl:description "An Agent having some form of responsibility for the resource."@en; + shacl:name "qualified attribution"@en; + shacl:path prov:qualifiedAttribution . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.temporalcoverage"; + shacl:class dc:PeriodOfTime; + shacl:description "A temporal period that the Dataset covers."@en; + shacl:name "temporal coverage"@en; + shacl:path dc:temporal . + + + + + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.otheridentifier"; + shacl:class ; + shacl:description "A secondary identifier of the Dataset"@en; + shacl:name "other identifier"@en; + shacl:path . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.publisher"; + shacl:class foaf:Agent; + shacl:description "An entity (organisation) responsible for making the Dataset available."@en; + shacl:name "publisher"@en; + shacl:path dc:publisher . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.creator"; + shacl:class foaf:Agent; + shacl:description "An entity responsible for producing the dataset."@en; + shacl:name "creator"@en; + shacl:path dc:creator . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.conformsto"; + shacl:class dc:Standard; + shacl:description "An implementing rule or other specification."@en; + shacl:name "conforms to"@en; + shacl:path dc:conformsTo . + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.theme"; + shacl:class skos:Concept; + shacl:description "A category of the Dataset."@en; + shacl:name "theme"@en; + shacl:path dcat:theme . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.temporalresolution"; + shacl:datatype xsd:duration; + shacl:description "The minimum time period resolvable in the dataset."@en; + shacl:name "temporal resolution"@en; + shacl:path dcat:temporalResolution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.accessrights"; + shacl:class dc:RightsStatement; + shacl:description "Information that indicates whether the Dataset is publicly accessible, has access restrictions or is not public."@en; + shacl:name "access rights"@en; + shacl:path dc:accessRights . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.qualifiedrelation"; + shacl:class dcat:Relationship; + shacl:description "A description of a relationship with another resource."@en; + shacl:name "qualified relation"@en; + shacl:path dcat:qualifiedRelation . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Dataset.landingpage"; + shacl:class foaf:Document; + shacl:description "A web page that provides access to the Dataset, its Distributions and/or additional information."@en; + shacl:name "landing page"@en; + shacl:path dcat:landingPage . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dcat:Distribution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.mediatype"; + shacl:class dc:MediaType; + shacl:description "The media type of the Distribution as defined in the official register of media types managed by IANA."@en; + shacl:name "media type"@en; + shacl:path dcat:mediaType . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.status"; + shacl:class skos:Concept; + shacl:description "The status of the distribution in the context of maturity lifecycle."@en; + shacl:name "status"@en; + shacl:path . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.linkedschemas"; + shacl:class dc:Standard; + shacl:description "An established schema to which the described Distribution conforms."@en; + shacl:name "linked schemas"@en; + shacl:path dc:conformsTo . + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.language"; + shacl:class dc:LinguisticSystem; + shacl:description "A language used in the Distribution."@en; + shacl:name "language"@en; + shacl:path dc:language . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.packagingformat"; + shacl:class dc:MediaType; + shacl:description "The format of the file in which one or more data files are grouped together, e.g. to enable a set of related files to be downloaded together."@en; + shacl:name "packaging format"@en; + shacl:path dcat:packageFormat . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.spatialresolution"; + shacl:datatype xsd:decimal; + shacl:description "The minimum spatial separation resolvable in a dataset distribution, measured in meters."@en; + shacl:name "spatial resolution"@en; + shacl:path dcat:spatialResolutionInMeters . + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.checksum"; + shacl:class ; + shacl:description "A mechanism that can be used to verify that the contents of a distribution have not changed."@en; + shacl:name "checksum"@en; + shacl:path . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.documentation"; + shacl:class foaf:Document; + shacl:description "A page or document about this Distribution."@en; + shacl:name "documentation"@en; + shacl:path foaf:page . + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.applicablelegislation"; + shacl:class ; + shacl:description "The legislation that mandates the creation or management of the Distribution."@en; + shacl:name "applicable legislation"@en; + shacl:path . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.format"; + shacl:class dc:MediaTypeOrExtent; + shacl:description "The file format of the Distribution."@en; + shacl:name "format"@en; + shacl:path dc:format . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.accessservice"; + shacl:class dcat:DataService; + shacl:description "A data service that gives access to the distribution of the dataset."@en; + shacl:name "access service"@en; + shacl:path dcat:accessService . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.haspolicy"; + shacl:class ; + shacl:description "The policy expressing the rights associated with the distribution if using the [[ODRL]] vocabulary."@en; + shacl:name "has policy"@en; + shacl:path . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.rights"; + shacl:class dc:RightsStatement; + shacl:description "A statement that specifies rights associated with the Distribution."@en; + shacl:name "rights"@en; + shacl:path dc:rights . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.availability"; + shacl:class skos:Concept; + shacl:description "An indication how long it is planned to keep the Distribution of the Dataset available."@en; + shacl:name "availability"@en; + shacl:path . + + + + + + + + + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.licence"; + shacl:class dc:LicenseDocument; + shacl:description "A licence under which the Distribution is made available."@en; + shacl:name "licence"@en; + shacl:path dc:license . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.compressionformat"; + shacl:class dc:MediaType; + shacl:description "The format of the file in which the data is contained in a compressed form, e.g. to reduce the size of the downloadable file."@en; + shacl:name "compression format"@en; + shacl:path dcat:compressFormat . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.temporalresolution"; + shacl:datatype xsd:duration; + shacl:description "The minimum time period resolvable in the dataset distribution."@en; + shacl:name "temporal resolution"@en; + shacl:path dcat:temporalResolution . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Distribution.bytesize"; + shacl:datatype xsd:nonNegativeInteger; + shacl:description "The size of a Distribution in bytes."@en; + shacl:name "byte size"@en; + shacl:path dcat:byteSize . + + + + + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + ; + shacl:targetClass dcat:Relationship . + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Relationship.hadrole"; + shacl:class dcat:Role; + shacl:description "A function of an entity or agent with respect to another entity or resource."@en; + shacl:name "had role"@en; + shacl:path dcat:hadRole . + + + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dcat:Resource . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dcat:Role . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:Frequency . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + ; + shacl:targetClass dc:LicenseDocument . + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#LicenceDocument.type"; + shacl:class skos:Concept; + shacl:description "A type of licence, e.g. indicating 'public domain' or 'royalties required'."@en; + shacl:name "type"@en; + shacl:path dc:type . + + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:LinguisticSystem . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + ; + shacl:targetClass dc:Location . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Location.geometry"; + shacl:class ; + shacl:description "The corresponding geometry for a resource."@en; + shacl:name "geometry"@en; + shacl:path . + + + + + + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:MediaTypeOrExtent . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:MediaType . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + , + , + ; + shacl:targetClass dc:PeriodOfTime . + + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.end"; + shacl:class ; + shacl:description "The end of a period or interval."@en; + shacl:name "end"@en; + shacl:path . + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#PeriodofTime.beginning"; + shacl:class ; + shacl:description "The beginning of a period or interval."@en; + shacl:name "beginning"@en; + shacl:path . + + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:ProvenanceStatement . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:RightsStatement . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass dc:Standard . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + ; + shacl:targetClass foaf:Agent . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Agent.type"; + shacl:class skos:Concept; + shacl:description "The nature of the agent."@en; + shacl:name "type"@en; + shacl:path dc:type . + + + + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass foaf:Document . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass prov:Activity . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass prov:Attribution . + + a shacl:NodeShape; + shacl:closed false; + shacl:targetClass rdfs:Literal . + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + ; + shacl:targetClass skos:ConceptScheme . + + + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + ; + shacl:targetClass skos:Concept . + + + + a shacl:NodeShape; + shacl:closed false; + shacl:property , + , + , + , + , + , + , + ; + shacl:targetClass . + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Checksum.checksumvalue"; + shacl:datatype xsd:hexBinary; + shacl:description "A lower case hexadecimal encoded digest value produced using a specific algorithm."@en; + shacl:name "checksum value"@en; + shacl:path . + + + + + + + rdfs:seeAlso "https://semiceu.github.io/DCAT-AP/releases/3.0.1#Checksum.algorithm"; + shacl:class ; + shacl:description "The algorithm used to produce the subject Checksum."@en; + shacl:name "algorithm"@en; + shacl:path . + diff --git a/pyegeria/view/document_validators.py b/pyegeria/view/document_validators.py new file mode 100644 index 00000000..c5a49af9 --- /dev/null +++ b/pyegeria/view/document_validators.py @@ -0,0 +1,373 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright Contributors to the ODPi Egeria project. +"""Validators for DOCUMENT report-spec outputs (SD-1). + +A document validator is a callable ``(text, media_type, **options) -> (valid, findings)``: + +- ``valid`` is a bool; +- ``findings`` is a list of sentences, one per problem (empty when there is none). + +Validators are registered by name, mirroring ``register_analytic_functions``: a name that is +already registered raises ``DocumentValidatorCollision``. A DOCUMENT format names its validator +in ``document.validator`` and passes any options in ``document.validator_options``. + +Two built-ins ship with pyegeria: + +- ``json-schema``: option ``schema``, a JSON Schema (path, ``file://`` URL or ``package:`` + resource) to check JSON or YAML text against; +- ``shacl``: option ``shapes``, a SHACL shapes graph (same kinds of reference) to check RDF + text against with pySHACL. + +**A validator never fetches over the network.** A schema or shapes reference is package data +(``package:/``); programmatic callers may also give a local path or a +``file://`` URL, but a report spec may not (``spec_option_refusal``), since specs can be held in +Egeria and written by any user. A failed validator's ``reason`` never quotes parser text. An ``http(s)`` +reference raises ``DocumentValidatorRefused``, and so does RDF text whose JSON-LD ``@context`` +names a remote document (rdflib would fetch it). The executor reports a raised validator as +``not_validated`` with the error, never as a finding. +""" +from __future__ import annotations + +import json +from importlib import resources +from pathlib import Path +from typing import Any, Callable, Dict, List, Tuple +from urllib.parse import unquote, urlparse + +DocumentValidator = Callable[..., Tuple[bool, List[str]]] + + +class DocumentValidatorCollision(ValueError): + """A document validator name is already registered.""" + + +class DocumentValidatorRefused(ValueError): + """A validator was asked to do something it never does (such as fetch over the network).""" + + +# ── Reading local references only ── + +def read_local_reference(ref: str, *, what: str) -> str: + """Read the text a schema/shapes reference names: a filesystem path, a ``file://`` URL or a + ``package:/`` resource. Anything that would need the network + is refused with a sentence.""" + if not isinstance(ref, str) or not ref.strip(): + raise DocumentValidatorRefused(f"no {what} was given to the validator") + ref = ref.strip() + scheme = urlparse(ref).scheme.lower() + if scheme in {"http", "https", "ftp"}: + raise DocumentValidatorRefused( + f"the {what} '{ref}' is a network address; a validator never fetches over the network. " + f"Give a local path, a file:// URL or a package: resource") + if ref.startswith("package:"): + package, _, resource = ref[len("package:"):].partition("/") + if not package or not resource: + raise DocumentValidatorRefused( + f"the {what} '{ref}' is not of the form package:/") + target = resources.files(package) + for part in resource.split("/"): + target = target / part + return target.read_text(encoding="utf-8") + if scheme == "file": + return Path(unquote(urlparse(ref).path)).read_text(encoding="utf-8") + return Path(ref).expanduser().read_text(encoding="utf-8") + + +# ── The json-schema built-in ── + +def _parse_structured_text(text: str, media_type: str) -> Any: + mt = (media_type or "").lower() + if "yaml" in mt: + import yaml + return yaml.safe_load(text) + return json.loads(text) + + +def json_schema_validator(text: str, media_type: str, *, schema: str) -> Tuple[bool, List[str]]: + """Check JSON (or YAML, by media type) ``text`` against the JSON Schema ``schema`` names. + + A ``$ref`` the schema cannot resolve locally is an error, not a fetch: the validator is given + an empty ``referencing.Registry`` with no ``retrieve``, so an unknown (remote) ``$ref`` raises + ``Unresolvable`` instead of going to the network.""" + import jsonschema + + schema_doc = json.loads(read_local_reference(schema, what="JSON Schema")) + instance = _parse_structured_text(text, media_type) + from referencing import Registry + + validator_cls = jsonschema.validators.validator_for(schema_doc) + validator_cls.check_schema(schema_doc) + # An empty registry with no `retrieve`: a $ref the schema cannot resolve locally raises + # Unresolvable. Without `registry=`, jsonschema falls back to a registry that urlopens remote + # $refs (SD-1 read-back C1). + validator = validator_cls(schema_doc, registry=Registry()) + errors = sorted(validator.iter_errors(instance), + key=lambda e: (list(map(str, e.absolute_path)), e.message)) + findings = [f"{'/' + '/'.join(map(str, e.absolute_path)) if e.absolute_path else '(document)'}: {e.message}" + for e in errors] + return (not findings, findings) + + +# ── The shacl built-in ── + +_RDF_FORMATS = { + "application/ld+json": "json-ld", + "application/json": "json-ld", + "text/turtle": "turtle", + "application/x-turtle": "turtle", + "application/rdf+xml": "xml", + "application/n-triples": "nt", + "application/n-quads": "nquads", + "application/trig": "trig", + "text/n3": "n3", +} + + +def rdf_format_for(media_type: str) -> str: + """The rdflib parser name for an RDF media type; refuses one it does not know.""" + fmt = _RDF_FORMATS.get((media_type or "").split(";")[0].strip().lower()) + if fmt is None: + raise DocumentValidatorRefused(f"the media type '{media_type}' is not an RDF serialisation the " + f"shacl validator reads ({', '.join(sorted(_RDF_FORMATS))})") + return fmt + + +def _remote_contexts(node: Any) -> List[str]: + """Every ``@context``/``@import`` value in a JSON-LD document that names another document.""" + found: List[str] = [] + if isinstance(node, dict): + for key, value in node.items(): + if key in ("@context", "@import"): + for item in value if isinstance(value, list) else [value]: + if isinstance(item, str): + found.append(item) + else: + found.extend(_remote_contexts(item)) + else: + found.extend(_remote_contexts(value)) + elif isinstance(node, list): + for item in node: + found.extend(_remote_contexts(item)) + return found + + +def parse_rdf_offline(text: str, media_type: str, *, what: str = "document"): + """Parse RDF text into an rdflib Graph without any network access. A JSON-LD document whose + ``@context`` names another document is refused (rdflib would fetch it).""" + from rdflib import Graph + + fmt = rdf_format_for(media_type) + if fmt == "json-ld": + remote = _remote_contexts(json.loads(text)) + if remote: + raise DocumentValidatorRefused( + f"the {what}'s JSON-LD @context names another document ({len(set(remote))} reference(s)); " + f"reading it would fetch over the network, which a validator never does. Inline the context") + graph = Graph() + graph.parse(data=text, format=fmt) + return graph + + +def _short(graph, node) -> str: + if node is None: + return "(no path)" + try: + return graph.namespace_manager.normalizeUri(node) + except Exception: # noqa: BLE001 -- a blank node or an odd IRI: show it as is + return str(node) + + +def _focus_label(data_graph, node) -> str: + """How a finding names its focus node: its class's local name and its dct:identifier when it has + them ("Dataset Sales::Orders"), else the node as written ("").""" + from rdflib import URIRef + from rdflib.namespace import DCTERMS, RDF + + types = sorted(str(t) for t in data_graph.objects(node, RDF.type)) + kind = types[0].rsplit("#", 1)[-1].rsplit("/", 1)[-1] if types else "" + ident = data_graph.value(node, DCTERMS.identifier) + name = str(ident) if ident is not None else (f"<{node}>" if isinstance(node, URIRef) else str(node)) + return f"{kind} {name}" if kind else name + + +def shacl_findings(data_graph, shapes_graph) -> Tuple[bool, List[str]]: + """Run pySHACL and return ``(conforms, findings)``; one finding per validation result, per focus + node and path, sorted so the list is stable: + + - a missing mandatory property (sh:minCount) reads " : missing "; + - anything else reads " : : ". + + Results of severity Warning or Info are prefixed with it; they do not make the document invalid.""" + import pyshacl + from rdflib import Namespace + from rdflib.namespace import RDF + + SH = Namespace("http://www.w3.org/ns/shacl#") + conforms, results_graph, _ = pyshacl.validate( + data_graph, shacl_graph=shapes_graph, inference="none", allow_warnings=True, + do_owl_imports=False, advanced=True) + findings: List[str] = [] + for result in results_graph.subjects(RDF.type, SH.ValidationResult): + severity = results_graph.value(result, SH.resultSeverity) + focus = results_graph.value(result, SH.focusNode) + path = results_graph.value(result, SH.resultPath) + message = results_graph.value(result, SH.resultMessage) + component = results_graph.value(result, SH.sourceConstraintComponent) + prefix = "" if severity in (None, SH.Violation) else f"{str(severity).rsplit('#', 1)[-1]}: " + where = _focus_label(data_graph, focus) + if component == SH.MinCountConstraintComponent and path is not None: + findings.append(f"{prefix}{where}: missing {_short(data_graph, path)}") + else: + findings.append(f"{prefix}{where}: {_short(data_graph, path)}: " + f"{message if message is not None else 'does not conform'}") + return bool(conforms), sorted(set(findings)) + + +def shacl_validator(text: str, media_type: str, *, shapes: str, + shapes_media_type: str = "text/turtle") -> Tuple[bool, List[str]]: + """Check RDF ``text`` (JSON-LD, Turtle, … by media type) against the SHACL ``shapes`` graph.""" + shapes_graph = parse_rdf_offline(read_local_reference(shapes, what="SHACL shapes"), + shapes_media_type, what="shapes graph") + data_graph = parse_rdf_offline(text, media_type) + return shacl_findings(data_graph, shapes_graph) + + +def make_shacl_validator(shapes: str, shapes_media_type: str = "text/turtle") -> DocumentValidator: + """A ``(text, media_type)`` validator bound to one shapes graph, parsed once on first use. + Used to register a named validator for one standard (e.g. ``dcat-ap-3-shacl``).""" + cache: Dict[str, Any] = {} + + def _validate(text: str, media_type: str, **_ignored: Any) -> Tuple[bool, List[str]]: + if "shapes" not in cache: + cache["shapes"] = parse_rdf_offline(read_local_reference(shapes, what="SHACL shapes"), + shapes_media_type, what="shapes graph") + return shacl_findings(parse_rdf_offline(text, media_type), cache["shapes"]) + + return _validate + + +# ── The registry ── + +#: DCAT-AP 3.0.1's SHACL shapes, vendored (see pyegeria/view/data/dcat-ap-3/README.md). +DCAT_AP_3_SHAPES = "package:pyegeria.view/data/dcat-ap-3/dcat-ap-SHACL.ttl" + +_BUILTIN_VALIDATORS: Dict[str, DocumentValidator] = { + "json-schema": json_schema_validator, + "shacl": shacl_validator, + "dcat-ap-3-shacl": make_shacl_validator(DCAT_AP_3_SHAPES), +} +_RUNTIME_VALIDATORS: Dict[str, DocumentValidator] = {} + + +def get_document_validators() -> Dict[str, DocumentValidator]: + """Every registered document validator, built-ins first.""" + return {**_BUILTIN_VALIDATORS, **_RUNTIME_VALIDATORS} + + +def get_document_validator(name: str): + """The validator registered under ``name``, or None.""" + return get_document_validators().get(name) + + +def register_document_validators(new_validators: Dict[str, DocumentValidator], *, + source: str = "runtime") -> None: + """Add document validators by name. A name already registered raises + ``DocumentValidatorCollision`` and nothing from this call is added.""" + existing = get_document_validators() + for name, fn in new_validators.items(): + if not isinstance(name, str) or not name.strip(): + raise ValueError(f"a document validator needs a non-empty name (from {source})") + if not callable(fn): + raise ValueError(f"document validator '{name}' from {source} is not callable") + if name in existing: + raise DocumentValidatorCollision( + f"Document validator '{name}' already exists; cannot register from {source}") + _RUNTIME_VALIDATORS.update(new_validators) + + +def unregister_document_validator(name: str) -> bool: + """Remove a runtime-registered validator; built-ins cannot be removed.""" + return _RUNTIME_VALIDATORS.pop(name, None) is not None + + +def clear_runtime_document_validators() -> None: + _RUNTIME_VALIDATORS.clear() + + +# ── Running a document's validator (the executor's half of the contract) ── + +#: Validator options that name a file to read. From a spec definition (which may be held in Egeria +#: and written by any user) each must be a ``package:`` reference: pyegeria's own package data or an +#: installed exporter package's. Local paths and file:// URLs stay available to programmatic +#: callers only (``make_shacl_validator(path)``, ``json_schema_validator(..., schema=path)``). +REFERENCE_OPTIONS = ("schema", "shapes") + + +def spec_option_refusal(options: Dict[str, Any] | None) -> str | None: + """Why a spec's validator_options are refused, or None. Only ``package:`` references may name a + file from a spec definition (SD-1 read-back C2).""" + for key in REFERENCE_OPTIONS: + value = (options or {}).get(key) + if value is None: + continue + if not isinstance(value, str) or not value.strip().startswith("package:"): + return (f"validator option '{key}' must be a package: reference (package:/) " + f"when it comes from a report spec; a spec may not name a local file or URL") + return None + + +def _error_words(exc: BaseException) -> str: + """What a failed validator says in ``reason``: never the parser's text, which can quote the input + (the document, or a schema/shapes file). The error type, plus line and column when known, and our + own refusal sentences, which carry no file content.""" + if isinstance(exc, DocumentValidatorRefused): + return f"{type(exc).__name__}: {exc}" + try: # jsonschema wraps referencing's errors; name the real one + exc = object.__getattribute__(exc, "_wrapped") + except AttributeError: + pass + ref = getattr(exc, "ref", None) + if isinstance(ref, str): # a $ref the schema could not resolve: name it (it is the schema's, not input) + return f"{type(exc).__name__}: the $ref {ref} is not resolvable without a network fetch" + line = getattr(exc, "lineno", None) or getattr(exc, "lines", None) + col = getattr(exc, "colno", None) + mark = getattr(exc, "problem_mark", None) + if mark is not None: + line, col = getattr(mark, "line", -1) + 1, getattr(mark, "column", -1) + 1 + where = "" + if isinstance(line, int): + where = f" at line {line}" + (f", column {col}" if isinstance(col, int) else "") + return f"{type(exc).__name__}{where}" + +def run_document_validator(text: str, media_type: str, validator: str | None, + options: Dict[str, Any] | None = None) -> Dict[str, Any]: + """The ``validation`` block of a DOCUMENT result. Always returned, never omitted: + + - ``state``: ``valid`` | ``invalid`` | ``not_validated``; + - ``validator``: the declared name, or None; + - ``findings``: the validator's sentences (empty when it found nothing or did not run); + - ``reason``: why the document was not validated, or None when it was. + + A validator that raises is ``not_validated`` with its error type (and line/column) as the + reason, never the parser's text: a crash says nothing about the document, so it is never + reported as a finding or as ``invalid``. ``options`` come from a spec definition, so a + ``schema``/``shapes`` option that is not a ``package:`` reference is refused (not run).""" + if not validator: + return {"state": "not_validated", "validator": None, "findings": [], + "reason": "no validator is declared for this standard"} + fn = get_document_validator(validator) + if fn is None: + return {"state": "not_validated", "validator": validator, "findings": [], + "reason": f"the validator {validator} is not registered"} + refusal = spec_option_refusal(options) + if refusal: + return {"state": "not_validated", "validator": validator, "findings": [], + "reason": f"the validator {validator} was not run: {refusal}"} + try: + valid, findings = fn(text, media_type, **(options or {})) + except Exception as exc: # noqa: BLE001 -- any crash is reported, never raised or counted as a finding + return {"state": "not_validated", "validator": validator, "findings": [], + "reason": f"the validator {validator} failed: {_error_words(exc)}"} + findings = [str(f) for f in (findings or [])] + return {"state": "valid" if valid else "invalid", "validator": validator, "findings": findings, + "reason": None} diff --git a/pyegeria/view/egeria_relationship_fields.py b/pyegeria/view/egeria_relationship_fields.py new file mode 100644 index 00000000..27bfd0d3 --- /dev/null +++ b/pyegeria/view/egeria_relationship_fields.py @@ -0,0 +1,303 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright Contributors to the ODPi Egeria project. +"""The relationship lists an Egeria 6 element can carry, and the relationship type(s) each one reads. + +Generated from Egeria's `AttributedMetadataElement.java` and `OpenMetadataRootElement.java` +(open-metadata-framework, metadataelements; egeria commit ebafb08fdc, 2026-10-04): every +`RelatedMetadataElementSummary` field, with the relationship type names its comment gives. An empty tuple +means the comment names none. + +Used by the structured TABLE and native DICT (R1) to tell a relationship that was read and is absent +("none") from one that was not requested ("not read"): Egeria omits an empty relationship list. + +Do not edit by hand. Regenerate with `scripts/gen_egeria_relationship_fields.py ` +when Egeria adds relationships. +""" + +RELATIONSHIP_FIELDS = { + "acceptedAnswers": ('AcceptedAnswer',), + "actionCause": ('Actions',), + "actionSource": ('ActionRequester',), + "actionTargets": ('ActionTarget',), + "actionsForTarget": ('ActionTarget',), + "agreementActors": ('AgreementActor',), + "agreementContents": ('AgreementItem',), + "agreementItems": ('AgreementItem',), + "agreementsForContract": ('ContractLink',), + "alignsToPort": ('SolutionPortDelegation',), + "alsoKnownAs": ('ExternalIdLink',), + "annotationExtensions": ('AnnotationExtension',), + "annotationMatches": ('DiscoveredSchemaType',), + "annotationSubjects": ('AssociatedAnnotation',), + "answeredQuestions": ('AcceptedAnswer',), + "apiEndpoints": ('APIEndpoint',), + "apiHeader": ('APIOperations',), + "apiRequest": ('APIOperations',), + "apiResponse": ('APIOperations',), + "archiveContents": ('ArchiveContents',), + "assetsUsingProfile": ('ITInfrastructureProfile',), + "assignedActors": ('AssignmentScope',), + "assignedDataValueSpecifications": ('DataValueAssignment',), + "assignedItems": ('ReferenceValueAssignment',), + "assignedToDataValueSpecifications": ('DataValueAssignment',), + "assignmentScope": ('AssignmentScope',), + "associatedAnnotations": ('AssociatedAnnotation',), + "associatedGovernanceActions": ('TargetForGovernanceAction',), + "associatedLogSubjects": ('AssociatedLog',), + "associatedLogs": ('AssociatedLog',), + "associatedSecurityLists": ('AssociatedSecurityGroup',), + "associatedValues": ('ValidValueAssociation',), + "broaderSubjectArea": ('SubjectAreaHierarchy',), + "calledFromGovernanceEngines": ('SupportedGovernanceService',), + "canonicalValidValues": ('ValidValuesImplementation',), + "capabilities": ('SupportedSoftwareCapability',), + "capabilityConsumedAssets": ('CapabilityAssetUse',), + "catalogTargets": ('CatalogTarget',), + "certifications": ('Certification',), + "certifiedElements": ('Certification',), + "childProcesses": ('ProcessHierarchy',), + "cohortMembership": ('MetadataCohortPeer',), + "collectionMembers": ('CollectionMembership',), + "commentedOnElement": ('AttachedComment',), + "comments": ('AttachedComment',), + "configuredInSecurityCollections": ('UserAccount',), + "connectedResources": ('ResourceConnection',), + "connections": ('ConnectToEndpoint', 'ConnectorConnectionType', 'ResourceConnection'), + "connectorType": ('ConnectorConnectionType',), + "consistentValues": ('ConsistentValidValues',), + "consolidatedDuplicateOrigin": ('ConsolidatedDuplicateLink',), + "consolidatedDuplicateResult": ('ConsolidatedDuplicateLink',), + "consumedByCapabilities": ('CapabilityAssetUse',), + "consumedDesignPatterns": ('NestedDesignPattern',), + "consumingBusinessCapabilities": ('DigitalSupport',), + "consumingDesignPatterns": ('NestedDesignPattern',), + "contactDetails": ('ContactThrough',), + "contacts": ('ContactThrough',), + "containsDBSchemas": ('RelationalDBSchema',), + "containsDataFields": ('MemberDataField',), + "containsOperations": ('APIOperations',), + "contextRelevantTerms": ('UsedInContext',), + "contracts": ('ContractLink',), + "contributionRecord": ('ContributionRecord',), + "contributorProfile": ('ContributionRecord',), + "controlsZones": ('ZoneHierarchy',), + "crowdSourcedContributions": ('CrowdSourcingContribution',), + "crowdSourcingContributors": ('CrowdSourcingContribution',), + "dataDescription": ('DataDescription',), + "dataSetContent": ('DataSetContent',), + "dataStructureDefinition": ('DataStructureDefinition',), + "dataValueSpecifications": ('DataValueDefinition',), + "databaseSchemaType": ('RelationalDBSchema',), + "definedInSecretsCollection": ('ResourcePermissions',), + "delegationPorts": ('SolutionPortDelegation',), + "dependedOnProcessSteps": ('NextGovernanceActionProcessStep',), + "dependentProjects": ('ProjectDependency',), + "dependsOnBusinessCapabilities": ('BusinessCapabilityDependency',), + "dependsOnProjects": ('ProjectDependency',), + "dependsOnSoftwarePackages": ('SoftwarePackageDependency',), + "deployedTo": ('DeployedOn',), + "derivedFrom": ('ImplementedBy',), + "derivedFromDataField": ('SchemaAttributeDefinition',), + "derivedFromDataStructure": ('SchemaTypeDefinition',), + "describedByDataValueSpecifications": ('DataValueDefinition',), + "describes": ('MoreInformation',), + "describesDataFor": ('DataDescription',), + "describesDesignOf": ('SolutionDesign',), + "describesStructure": ('Schema',), + "digitalSubscribers": ('DigitalSubscriber',), + "digitalSubscriptions": ('DigitalSubscriber',), + "edges": ('GraphEdgeLink',), + "embeddedConnections": ('EmbeddedConnection',), + "endpoint": ('ConnectToEndpoint',), + "equivalentElements": ('ExternalIdLink',), + "equivalentSchemaAttribute": ('SchemaAttributeDefinition',), + "equivalentSchemaType": ('SchemaTypeDefinition',), + "exceptions": ('Exception',), + "excludedFromRequirements": ('Exception',), + "externalReferences": ('ExternalReferenceLink',), + "externalSchemaType": ('LinkedExternalSchemaType',), + "facetedElements": ('ReferenceableFacet',), + "firstStep": ('GovernanceActionProcessFlow',), + "followOnProcessSteps": ('NextGovernanceActionProcessStep',), + "followOnReports": ('ReportDependency',), + "foreignKeys": ('ForeignKey',), + "fromSurveyReports": ('ReportedAnnotation',), + "generalizedDesignPattern": ('SpecializedDesignPattern',), + "generatedReports": ('ReportOrigin',), + "governanceActionExecutor": ('GovernanceActionExecutor',), + "governedBy": ('GovernedBy',), + "governedElements": ('GovernedBy',), + "groupingLocations": ('NestedLocation',), + "homeFolder": ('NestedFile',), + "hostCluster": ('HostClusterMember',), + "hostedByDeployedITInfrastructure": ('SupportedSoftwareCapability',), + "hostedITAssets": ('DeployedOn',), + "identifiedByRequestForActions": ('RequestForActionTarget',), + "impactedResources": ('ImpactedResource',), + "implementationResources": ('ImplementationResource',), + "implementedBy": ('ImplementedBy',), + "incidentReports": ('ImpactedResource',), + "includedInIntegrationGroups": ('RegisteredIntegrationConnector',), + "includesSoftwarePackages": ('OperatingPlatformManifest',), + "informalTags": ('AttachedTag',), + "inheritsFromZone": ('ZoneHierarchy',), + "installedOn": ('OperatingPlatformUse',), + "interactingWithActors": ('SolutionComponentActor',), + "interactingWithSolutionComponents": ('SolutionComponentActor',), + "interestingNotificationTypes": ('NotificationSubscriber',), + "involvedInAgreements": ('AgreementActor',), + "keywordElements": ('SearchKeywordLink',), + "knownLocations": ('KnownLocation',), + "licensedElements": ('License',), + "licenses": ('License',), + "likedElement": ('AttachedLike',), + "likes": ('AttachedLike',), + "lineageLinkage": ('Many',), + "linkedFiles": ('LinkedFile',), + "linkedFolders": ('LinkedFile',), + "linkedFromDataFields": ('LinkedDataField',), + "linkedMediaFiles": ('LinkedMedia',), + "linkedToDataFields": ('LinkedDataField',), + "linkedToPrimaryKey": ('ForeignKey',), + "listedInSecretsCollection": ('SecretsCollectionSecurityList',), + "localResources": ('KnownLocation',), + "madeOfDataClasses": ('DataClassComposition',), + "managedHosts": ('HostClusterMember',), + "managedProjects": ('ProjectHierarchy',), + "managesStorageFor": ('StoredOn',), + "managingProjects": ('ProjectHierarchy',), + "mapFromElement": ('MapFromElementType',), + "mapToElement": ('MapToElementType',), + "matchedByAnnotations": ('DiscoveredSchemaType',), + "matchingValues": ('ValidValueMapping',), + "meaningForDataElements": ('SemanticAssignment',), + "meanings": ('SemanticAssignment',), + "measurements": ('GovernanceResults',), + "memberOfCollections": ('CollectionMembership',), + "memberOfValidValueSets": ('ValidValueMember',), + "metrics": ('GovernanceResults',), + "monitoredResources": ('MonitoredResource',), + "monitoredThrough": ('MonitoredResource',), + "myFollowers": ('Peer',), + "myPeers": ('Peer',), + "nestedDataFields": ('NestedDataField',), + "nestedFiles": ('NestedFile',), + "nestedFolders": ('FolderHierarchy',), + "nestedLocations": ('NestedLocation',), + "nestedSolutionComponents": ('SolutionComposition',), + "nestedSubjectAreas": ('SubjectAreaHierarchy',), + "noteLogEntries": ('AttachedNoteLogEntry',), + "noteLogSubjects": ('AttachedNoteLog',), + "noteLogs": ('AttachedNoteLog',), + "operatingPlatforms": ('OperatingPlatformUse',), + "packagedInArchiveFiles": ('ArchiveContents',), + "packagedInOperatingPlatforms": ('OperatingPlatformManifest',), + "parentConnections": ('EmbeddedConnection',), + "parentDataFields": ('NestedDataField',), + "parentFolder": ('FolderHierarchy',), + "parentProcesses": ('ProcessHierarchy',), + "parentSchemaElements": ('APIHeader', 'APIOperations', 'APIRequest', 'APIResponse', 'AttributeForSchema', 'NestedSchemaAttribute', 'SchemaTypeOption'), + "partOfDataClasses": ('DataClassComposition',), + "partOfDataStructures": ('MemberDataField',), + "peerDuplicateOrigin": ('PeerDuplicateLink',), + "peerDuplicatePartner": ('PeerDuplicateLink',), + "peerLocations": ('AdjacentLocation',), + "performsRoles": ('ITProfileRoleAppointment', 'PersonRoleAppointment', 'TeamRoleAppointment'), + "populatedUsingQuery": ('SmartQuery',), + "portDelegatingFrom": ('PortDelegation',), + "portDelegatingTo": ('PortDelegation',), + "portOwningProcesses": ('ProcessPort',), + "ports": ('ProcessPort',), + "predefinedTargetForAction": ('TargetForGovernanceAction',), + "presentInNoteLogs": ('AttachedNoteLogEntry',), + "previousAnnotations": ('AnnotationExtension',), + "priorReports": ('ReportDependency',), + "profilesForAsset": ('ITInfrastructureProfile',), + "propertyFacets": ('ReferenceableFacet',), + "providesMoreInformation": ('MoreInformation',), + "providesStorageFor": ('AttachedStorage',), + "queries": ('DerivedSchemaTypeQueryTarget',), + "referenceValues": ('ReferenceValueAssignment',), + "referencingElements": ('ExternalReferenceLink',), + "refreshedByConnectors": ('CatalogTarget',), + "registeredWithCohorts": ('MetadataCohortPeer',), + "relatedActions": ('Actions',), + "relatedDesignPatterns": ('RelatedDesignPattern',), + "relatedTerms": (), + "relevantToScopes": ('ScopedBy',), + "reportOriginator": ('ReportOrigin',), + "reportSubjects": ('ReportSubject',), + "reportedAnnotations": ('ReportedAnnotation',), + "reports": ('ReportSubject',), + "requestForActionTargets": ('RequestForActionTarget',), + "requestedActions": ('ActionRequester',), + "resourceList": ('ResourceList',), + "resourceListUsers": ('ResourceList',), + "resourceProfileAnnotations": ('ResourceProfileData',), + "resourceProfileData": ('ResourceProfileData',), + "resultsStoredIn": ('SmartQuery',), + "reviewedElement": ('AttachedRating',), + "reviews": ('AttachedRating',), + "rolePerformers": ('ITProfileRoleAppointment', 'PersonRoleAppointment', 'TeamRoleAppointment'), + "runningWithAsset": ('SoftwarePackageDependency',), + "sampleData": ('SampleData',), + "schemaAttributes": ('AttributeForSchema', 'NestedSchemaAttribute'), + "schemaOptions": ('SchemaTypeOption',), + "schemaType": ('Schema',), + "scopedElements": ('ScopedBy',), + "searchKeywords": ('SearchKeywordLink',), + "securityAccessControls": ('ResourcePermissions',), + "securityLists": ('SecretsCollectionSecurityList',), + "semanticDefinitions": ('SemanticDefinition',), + "semanticallyAssociatedDefinitions": ('SemanticDefinition',), + "serverEndpoints": ('ServerEndpoint',), + "serverForEndpoint": ('ServerEndpoint',), + "solutionComponent": ('SolutionComponentPort',), + "solutionDesigns": ('SolutionDesign',), + "solutionPorts": ('SolutionComponentPort',), + "sourcedFromTemplate": ('SourcedFrom',), + "sourcesOfSampleData": ('SampleData',), + "specializedDesignPattern": ('SpecializedDesignPattern',), + "specificationProperties": ('SpecificationPropertyAssignment',), + "specificationPropertyUsers": ('SpecificationPropertyAssignment',), + "storageVolumes": ('AttachedStorage',), + "storedOn": ('StoredOn',), + "subDataValueSpecifications": ('DataValueHierarchy',), + "subTeams": ('TeamStructure',), + "subscribers": ('NotificationSubscriber',), + "superDataValueSpecification": ('DataValueHierarchy',), + "superTeam": ('TeamStructure',), + "supplementsElement": (), + "supplyFrom": ('InformationSupplyChainLink',), + "supplyTo": ('InformationSupplyChainLink',), + "supportedAPIs": ('APIEndpoint',), + "supportedDataSets": ('DataSetContent',), + "supportedGovernanceServices": ('SupportedGovernanceService',), + "supportedIntegrationConnectors": ('RegisteredIntegrationConnector',), + "supportsBusinessCapabilities": ('BusinessCapabilityDependency',), + "supportsGovernanceActions": ('GovernanceActionExecutor',), + "taggedElements": ('AttachedTag',), + "templateCreatedElements": ('SourcedFrom',), + "templateUses": ('CatalogTemplate',), + "templatesForCataloguing": ('CatalogTemplate',), + "triggeredFrom": ('GovernanceActionProcessFlow',), + "usedByDigitalProducts": ('DigitalProductDependency',), + "usedInAccessControls": ('AssociatedSecurityGroup',), + "usedInCertifications": ('DataStructureDefinition',), + "usedInContexts": ('UsedInContext',), + "usedInImplementationOf": ('ImplementationResource',), + "usedInSolutionComponents": ('SolutionComposition',), + "userAccounts": ('UserAccount',), + "userIdentities": ('ProfileIdentity',), + "userProfile": ('ProfileIdentity',), + "usesDigitalProducts": ('DigitalProductDependency',), + "usesDigitalServices": ('DigitalSupport',), + "validValueConsumers": ('ValidValueAssignment',), + "validValueImplementations": ('ValidValuesImplementation',), + "validValueMembers": ('ValidValueMember',), + "validValues": ('ValidValueAssignment',), + "vertices": ('GraphEdgeLink',), + "visibleEndpoints": ('VisibleEndpoint',), + "visibleInNetworks": ('VisibleEndpoint',), + "wiredTo": ('SolutionLinkingWire',), +} diff --git a/pyegeria/view/egeria_spec_cache.py b/pyegeria/view/egeria_spec_cache.py index 92902a4b..4e865a93 100644 --- a/pyegeria/view/egeria_spec_cache.py +++ b/pyegeria/view/egeria_spec_cache.py @@ -447,6 +447,10 @@ def _build(el: Dict[str, Any], *, folders: List[str], identity: str, registry_na raise _Skip(label, str(exc)) except MicroflowError as exc: raise _Skip(label, str(exc)) + except ValueError as exc: # pydantic's ValidationError: e.g. a DOCUMENT block that refuses to load (SD-2 N2) + errors = getattr(exc, "errors", None) + words = "; ".join(e.get("msg", "") for e in errors()) if callable(errors) else str(exc) + raise _Skip(label, f"the spec does not load: {words}") result = resolve(fs, label, registry_names=registry_names if registry_names is not None else _known_names()) if isinstance(result, Unrunnable): raise _Skip(label, f"refused by load-time resolution: {result.unrunnable_reason}") diff --git a/pyegeria/view/export_dcat.py b/pyegeria/view/export_dcat.py new file mode 100644 index 00000000..08f8da35 --- /dev/null +++ b/pyegeria/view/export_dcat.py @@ -0,0 +1,534 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright Contributors to the ODPi Egeria project. +"""export_dcat: a DCAT-AP 3 catalog of Egeria Assets (SD-2), as JSON-LD or Turtle. + +Registered as the analytic function ``export_dcat`` and run by the built-in DOCUMENT spec +"DCAT Catalog" (SD-1's document output type). The mapping is the design's §7 table +(DESIGN-REPORT-SPECS-STANDARD-DOCUMENTS-DCAT-BITOL-2026-11-11, owner decision D2): + +========================= ==================================================================== +DCAT Egeria +========================= ==================================================================== +dcat:Catalog the scope collection (title, description, publisher from Ownership), + or a search over the asset domain +dcat:Dataset each Asset in scope. DigitalProducts and Agreements (Bitol's) and any + other non-Asset member are named in notes, never exported +dcat:Distribution the Asset's Connection -> Endpoint (accessURL) and, for a DataFile, + its pathName (downloadURL); mediaType / format from the file type +dcat:DataService a DeployedAPI Asset's endpoint (endpointURL, servesDataset) +dct:publisher the Ownership classification's owner +dct:license the License relationship (LicenseType) +dct:accessRights ZoneMembership: none -> PUBLIC, zoned -> NON_PUBLIC +dcat:keyword SearchKeywords +dcat:theme glossary terms by SemanticAssignment (meanings) +dct:issued / dct:modified element header createTime / updateTime +dct:identifier qualifiedName; the GUID is adms:identifier +dcat:landingPage the Asset's url, else an ExternalReference's url +========================= ==================================================================== + +**Absence-as-answer.** Every property left out for some dataset is named in ``notes``, with the +datasets and the reason. A member Egeria refuses with a 403 (zone security, ISSUE-182) is noted as +"not visible to "; it is never reported as absent from the collection. Egeria also leaves +out of a member listing what the viewer cannot see, which the notes always say. + +**The viewer.** Everything is read with the client the routine is given (the caller's own, +``egeria_client:EgeriaTech``): no service account, no shared cache. + +**Paging.** Members (and search results) are read page by page, startFrom advancing by the page +size, until a page comes back empty; a short page is not the last page (Egeria's paging contract). +Pages may overlap; an element is read once. Reading stops early, with a note saying which, +only on a page identical to the one before it or after two pages in a row with nothing new. + +**Determinism.** Node IRIs are built from GUIDs (``urn:egeria:guid:``), never blank nodes, +and the output is sorted by node and property, so the same metadata gives the same bytes. +""" +from __future__ import annotations + +import json +import re +from typing import Any, Dict, Iterable, List, Optional, Tuple +from urllib.parse import quote + +from rdflib import Graph, Literal, Namespace, URIRef +from rdflib.namespace import DCAT, DCTERMS, FOAF, RDF, SKOS, XSD + +ADMS = Namespace("http://www.w3.org/ns/adms#") +VCARD = Namespace("http://www.w3.org/2006/vcard/ns#") +ACCESS_RIGHT = Namespace("http://publications.europa.eu/resource/authority/access-right/") +FILE_TYPE = Namespace("http://publications.europa.eu/resource/authority/file-type/") +IANA = "http://www.iana.org/assignments/media-types/" + +PREFIXES = {"dcat": DCAT, "dct": DCTERMS, "adms": ADMS, "foaf": FOAF, "vcard": VCARD, "skos": SKOS, + "xsd": XSD, "rdf": RDF} + +#: The JSON-LD @context: inline (a validator never fetches one), prefixes only. +JSONLD_CONTEXT = {p: str(ns) for p, ns in sorted(PREFIXES.items())} + +#: Types that are Bitol's, not DCAT's (owner decision D2). Matched on the type or a supertype. +BITOL_TYPES = ("DigitalProduct", "Agreement") + +#: File extension -> (IANA media type, EU file-type code). +_FILE_TYPES = { + "csv": ("text/csv", "CSV"), "json": ("application/json", "JSON"), "parquet": ("application/vnd.apache.parquet", "PARQUET"), + "xml": ("application/xml", "XML"), "txt": ("text/plain", "TXT"), "xlsx": ( + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "XLSX"), + "avro": ("application/avro", "AVRO"), "pdf": ("application/pdf", "PDF"), "html": ("text/html", "HTML"), + "yaml": ("application/yaml", "YAML"), "yml": ("application/yaml", "YAML"), +} + +_GUID = re.compile(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", re.I) +_MAX_PAGES = 1000 # a bound, never a silent truncation: reaching it is noted + +#: The relationships one Asset read asks Egeria for: only what the mapping uses, so a heavily +#: surveyed Asset is not read with all its annotations and lineage. +ASSET_RELATIONSHIPS = ["ResourceConnection", "ConnectToEndpoint", "License", "SearchKeywordLink", + "SemanticAssignment", "ExternalReferenceLink", "APIEndpoint", "ServerEndpoint"] + + +def _iri(guid: str, *suffix: str) -> URIRef: + return URIRef("urn:egeria:guid:" + guid + "".join(f":{s}" for s in suffix)) + + +def _is_list(result: Any) -> bool: + return isinstance(result, list) + + +def _type_names(element: Dict[str, Any]) -> Tuple[str, List[str]]: + t = (element.get("elementHeader") or {}).get("type") or {} + return t.get("typeName") or "", list(t.get("superTypeNames") or []) + + +def _qn(element: Dict[str, Any]) -> str: + props = element.get("properties") or {} + return props.get("qualifiedName") or (element.get("elementHeader") or {}).get("guid") or "?" + + +def _guid(element: Dict[str, Any]) -> str: + return (element.get("elementHeader") or {}).get("guid") or "" + + +def _related(element: Dict[str, Any], key: str) -> List[Dict[str, Any]]: + """The related elements under one of an element's relationship lists (Egeria 6 shape: + a list of {relationshipHeader, relatedElement, ...}).""" + value = element.get(key) + items = value if isinstance(value, list) else [value] if isinstance(value, dict) else [] + return [i.get("relatedElement") for i in items if isinstance(i, dict) and isinstance(i.get("relatedElement"), dict)] + + +def _date(value: Optional[str]) -> Optional[Literal]: + if not value: + return None + return Literal(value.replace("+00:00", "Z"), datatype=XSD.dateTime) + + +def _as_iri(address: str) -> Optional[URIRef]: + """An endpoint address or path as an IRI: a URL as it is, an absolute path as file://.""" + if not address: + return None + if re.match(r"^[A-Za-z][A-Za-z0-9+.-]*://", address): + return URIRef(quote(address, safe=":/?#[]@!$&'()*+,;=%~")) + if address.startswith("/"): + return URIRef("file://" + quote(address, safe="/:~")) + return None + + +class _Notes: + """Notes grouped by what was left out, so the same gap across many datasets is one sentence.""" + + def __init__(self) -> None: + self.general: List[str] = [] + self.by_reason: Dict[str, List[str]] = {} + + def add(self, sentence: str) -> None: + if sentence not in self.general: + self.general.append(sentence) + + def omitted(self, reason: str, qn: str) -> None: + self.by_reason.setdefault(reason, []).append(qn) + + def render(self) -> List[str]: + out = list(self.general) + for reason in sorted(self.by_reason): + names = sorted(set(self.by_reason[reason])) + out.append(f"{reason} for {len(names)} dataset{'s' if len(names) != 1 else ''}: {'; '.join(names)}") + return out + + +# ── Reads (as the client's user) ── + +def _paged(read, page_size: int, notes: _Notes, what: str) -> List[Dict[str, Any]]: + """Read pages until one comes back empty, advancing startFrom by the full page size each time + (Egeria's paging contract: a short page is not the last page, and only an empty one is). Egeria + answers "no elements" with a string, which counts as an empty page. + + Pages may overlap (laz's asset-domain search returns short pages that share elements), so an + element already read is skipped, never counted twice (ISSUE-185), and a page with nothing new + does not by itself end the reading. Reading stops early only when a page is identical to the + one before it (the server ignored startFrom) or after two pages in a row bring nothing new; the + note says which, since later pages, if any, were not read.""" + items: List[Dict[str, Any]] = [] + seen: set = set() + start = 0 + previous: Optional[List[str]] = None + no_new_in_a_row = 0 + for _ in range(_MAX_PAGES): + page = read(start, page_size) + if not _is_list(page) or not page: + return items + guids = [_guid(e) for e in page] + if guids == previous: + notes.add(f"Stopped reading {what} at startFrom {start}: Egeria answered with exactly the page before " + f"it (it ignored startFrom), so later pages, if any, were not read.") + return items + new = [e for e in page if _guid(e) not in seen] + seen.update(_guid(e) for e in new) + items.extend(new) + no_new_in_a_row = 0 if new else no_new_in_a_row + 1 + if no_new_in_a_row == 2: + notes.add(f"Stopped reading {what} at startFrom {start}: two pages in a row held only elements already " + f"read, so later pages, if any, were not read.") + return items + previous = guids + start += page_size + notes.add(f"Stopped reading {what} after {_MAX_PAGES} pages of {page_size}: the catalog may be incomplete.") + return items + + +def _not_visible(exc: BaseException) -> bool: + from pyegeria.view.dashboard_resolver import is_not_visible_error + return is_not_visible_error(exc) + + +def _not_found(exc: BaseException) -> bool: + from pyegeria.core._exceptions import PyegeriaNotFoundException + return isinstance(exc, PyegeriaNotFoundException) or "-404-" in str(exc) + + +def _read_scope(client: Any, scope: str) -> Dict[str, Any]: + """The scope collection, by GUID or qualifiedName (exact match).""" + if _GUID.match(scope): + found = client.get_collection_by_guid(scope, output_format="JSON", graph_query_depth=0) + if isinstance(found, dict): + return found + raise ValueError(f"export_dcat: no collection with GUID {scope} is visible to {client.user_id}") + found = client.get_collections_by_name(scope, output_format="JSON", graph_query_depth=0) + exact = [c for c in found if _qn(c) == scope] if _is_list(found) else [] + if not exact: + raise ValueError(f"export_dcat: no collection with qualifiedName '{scope}' is visible to {client.user_id}") + return exact[0] + + +# ── The mapping ── + +class _Builder: + def __init__(self, viewer: str) -> None: + self.g = Graph() + for prefix, ns in PREFIXES.items(): + self.g.bind(prefix, ns) + self.viewer = viewer + self.notes = _Notes() + + def _agent(self, owner: str, owner_type: str = "") -> URIRef: + node = URIRef("urn:egeria:owner:" + quote(owner, safe="")) + self.g.add((node, RDF.type, FOAF.Agent)) + self.g.add((node, FOAF.name, Literal(owner))) + return node + + @staticmethod + def _owner(element: Dict[str, Any]) -> Tuple[str, str]: + ownership = (element.get("elementHeader") or {}).get("ownership") or {} + props = ownership.get("classificationProperties") or {} + return str(props.get("owner") or ""), str(props.get("ownerTypeName") or "") + + def _identity(self, node: URIRef, element: Dict[str, Any]) -> None: + guid = _guid(element) + self.g.add((node, DCTERMS.identifier, Literal(_qn(element)))) + ident = _iri(guid, "identifier") + self.g.add((node, ADMS.identifier, ident)) + self.g.add((ident, RDF.type, ADMS.Identifier)) + self.g.add((ident, SKOS.notation, Literal(guid))) + versions = (element.get("elementHeader") or {}).get("versions") or {} + for prop, key in ((DCTERMS.issued, "createTime"), (DCTERMS.modified, "updateTime")): + value = _date(versions.get(key)) + if value is not None: + self.g.add((node, prop, value)) + + def catalog(self, element: Optional[Dict[str, Any]], *, search_string: Optional[str] = None) -> URIRef: + if element is not None: + node = _iri(_guid(element)) + props = element.get("properties") or {} + self.g.add((node, RDF.type, DCAT.Catalog)) + self.g.add((node, DCTERMS.title, Literal(props.get("displayName") or _qn(element)))) + if not props.get("displayName"): + self.notes.add(f"Catalog title is the collection's qualifiedName: it has no displayName.") + if props.get("description"): + self.g.add((node, DCTERMS.description, Literal(props["description"]))) + else: + self.notes.add("Catalog dct:description omitted: the collection has no description.") + owner, owner_type = self._owner(element) + if owner: + self.g.add((node, DCTERMS.publisher, self._agent(owner, owner_type))) + else: + self.notes.add("Catalog dct:publisher omitted: the collection has no Ownership classification " + "(DCAT-AP requires a publisher for a Catalog).") + self._identity(node, element) + return node + node = URIRef("urn:egeria:search:" + quote(search_string or "", safe="")) + self.g.add((node, RDF.type, DCAT.Catalog)) + self.g.add((node, DCTERMS.title, Literal(f"Egeria assets matching '{search_string}'"))) + self.g.add((node, DCTERMS.description, Literal( + f"Assets in Egeria's asset domain whose properties match the search string '{search_string}', " + f"as visible to {self.viewer}."))) + self.g.add((node, DCTERMS.identifier, Literal(f"search:{search_string}"))) + self.notes.add("Catalog dct:publisher omitted: a search has no owner (DCAT-AP requires a publisher " + "for a Catalog).") + return node + + def dataset(self, catalog: URIRef, element: Dict[str, Any]) -> None: + guid, qn = _guid(element), _qn(element) + props = element.get("properties") or {} + header = element.get("elementHeader") or {} + type_name, supers = _type_names(element) + node = _iri(guid) + self.g.add((catalog, DCAT.dataset, node)) + self.g.add((node, RDF.type, DCAT.Dataset)) + self.g.add((node, DCTERMS.title, Literal(props.get("displayName") or qn))) + if not props.get("displayName"): + self.notes.omitted("dct:title is the qualifiedName (no displayName)", qn) + if props.get("description"): + self.g.add((node, DCTERMS.description, Literal(props["description"]))) + else: + self.notes.omitted("dct:description omitted: the Asset has no description", qn) + self._identity(node, element) + + # Access rights: the viewer rule. A zoned Asset is only here because the viewer can read it. + zones = ((header.get("zoneMembership") or {}).get("classificationProperties") or {}).get("zoneMembership") + rights = ACCESS_RIGHT.NON_PUBLIC if zones else ACCESS_RIGHT.PUBLIC + self.g.add((node, DCTERMS.accessRights, rights)) + self.g.add((rights, RDF.type, DCTERMS.RightsStatement)) + + owner, owner_type = self._owner(element) + if owner: + self.g.add((node, DCTERMS.publisher, self._agent(owner, owner_type))) + else: + self.notes.omitted("dct:publisher omitted: no Ownership classification", qn) + + licences = _related(element, "licenses") + for lic in licences: + lp = lic.get("properties") or {} + lnode = URIRef(lp["url"]) if lp.get("url") and _as_iri(lp["url"]) else _iri(_guid(lic)) + self.g.add((node, DCTERMS.license, lnode)) + self.g.add((lnode, RDF.type, DCTERMS.LicenseDocument)) + self.g.add((lnode, DCTERMS.title, Literal(lp.get("displayName") or _qn(lic)))) + self.g.add((lnode, DCTERMS.identifier, Literal(_qn(lic)))) + if not licences: + self.notes.omitted("dct:license omitted: no License relationship", qn) + + keywords = [k.get("properties", {}).get("keyword") or k.get("properties", {}).get("displayName") + for k in _related(element, "searchKeywords")] + for kw in sorted(k for k in keywords if k): + self.g.add((node, DCAT.keyword, Literal(kw))) + if not any(keywords): + self.notes.omitted("dcat:keyword omitted: no SearchKeywords", qn) + + terms = _related(element, "meanings") + for term in terms: + tp = term.get("properties") or {} + tnode = _iri(_guid(term)) + self.g.add((node, DCAT.theme, tnode)) + self.g.add((tnode, RDF.type, SKOS.Concept)) + self.g.add((tnode, SKOS.prefLabel, Literal(tp.get("displayName") or _qn(term)))) + if not terms: + self.notes.omitted("dcat:theme omitted: no glossary term by SemanticAssignment", qn) + + landing = props.get("url") or next((r.get("properties", {}).get("url") for r in _related(element, "externalReferences") + if (r.get("properties") or {}).get("url")), None) + if landing and _as_iri(landing): + self.g.add((node, DCAT.landingPage, _as_iri(landing))) + else: + self.notes.omitted("dcat:landingPage omitted: no url and no ExternalReference with a url", qn) + + self._distributions(node, element, type_name, supers) + + def _endpoints(self, element: Dict[str, Any]) -> List[Dict[str, Any]]: + """Endpoints reachable from the Asset: Connection -> (side link) Endpoint, or a direct endpoint.""" + found: List[Dict[str, Any]] = [] + for item in element.get("connections") or []: + if not isinstance(item, dict): + continue + for side in item.get("sideLinks") or []: + rel = (side or {}).get("relatedElement") or {} + if _type_names(rel)[0] == "Endpoint" or "Endpoint" in _type_names(rel)[1]: + found.append(rel) + for key in ("endpoint", "apiEndpoints", "serverEndpoints"): + found.extend(r for r in _related(element, key)) + unique = {(_guid(e)): e for e in found if _guid(e)} + return [unique[k] for k in sorted(unique)] + + def _distributions(self, node: URIRef, element: Dict[str, Any], type_name: str, supers: List[str]) -> None: + qn, guid = _qn(element), _guid(element) + props = element.get("properties") or {} + is_file = "DataFile" in supers or type_name == "DataFile" + is_api = "DeployedAPI" in supers or type_name == "DeployedAPI" + path = props.get("pathName") if is_file else None + endpoints = self._endpoints(element) + addresses = sorted({(e.get("properties") or {}).get("networkAddress") for e in endpoints} - {None, ""}) + usable = [a for a in addresses if _as_iri(a) is not None] + if not usable and not (path and _as_iri(path) is not None): + if addresses: + self.notes.omitted("dcat:distribution omitted: the endpoint address is not a URL or an absolute " + "path, and DCAT-AP requires a distribution's accessURL", qn) + else: + self.notes.omitted("dcat:distribution omitted: no access path (no Connection with an Endpoint" + + (", no pathName" if is_file else "") + ")", qn) + return + addresses = usable + ext = (props.get("fileExtension") or (path.rsplit(".", 1)[-1] if path and "." in path else "")).lower() + media = _FILE_TYPES.get(ext) + for i, address in enumerate(addresses or [path]): + dist = _iri(guid, "distribution", str(i)) + self.g.add((node, DCAT.distribution, dist)) + self.g.add((dist, RDF.type, DCAT.Distribution)) + access = _as_iri(address) + self.g.add((dist, DCAT.accessURL, access)) + if path and _as_iri(path) is not None: + self.g.add((dist, DCAT.downloadURL, _as_iri(path))) + if media: + media_node, format_node = URIRef(IANA + media[0]), FILE_TYPE[media[1]] + self.g.add((dist, DCAT.mediaType, media_node)) + self.g.add((media_node, RDF.type, DCTERMS.MediaType)) + self.g.add((dist, DCTERMS["format"], format_node)) + self.g.add((format_node, RDF.type, DCTERMS.MediaTypeOrExtent)) + elif props.get("deployedImplementationType") or props.get("fileType"): + self.notes.omitted("dcat:mediaType omitted: the file type is not one this exporter maps", qn) + if is_api: + svc = _iri(guid, "service") + self.g.add((svc, RDF.type, DCAT.DataService)) + self.g.add((svc, DCTERMS.title, Literal(props.get("displayName") or qn))) + self.g.add((svc, DCAT.endpointURL, access)) + self.g.add((svc, DCAT.servesDataset, node)) + self.g.add((dist, DCAT.accessService, svc)) + + +# ── Serialisation ── + +def _sort_jsonld(value: Any) -> Any: + if isinstance(value, dict): + return {k: _sort_jsonld(value[k]) for k in sorted(value)} + if isinstance(value, list): + items = [_sort_jsonld(v) for v in value] + return sorted(items, key=lambda v: json.dumps(v, sort_keys=True)) + return value + + +def serialise(graph: Graph, fmt: str) -> str: + """The graph as Turtle or JSON-LD (compacted with the inline prefix @context), sorted so the + same graph always gives the same text.""" + if fmt == "turtle": + return graph.serialize(format="turtle") + raw = json.loads(graph.serialize(format="json-ld", context=JSONLD_CONTEXT, auto_compact=True)) + nodes = raw.get("@graph", [raw] if "@id" in raw else []) + nodes = [{k: v for k, v in n.items() if k != "@context"} for n in nodes] + doc = {"@context": JSONLD_CONTEXT, + "@graph": sorted((_sort_jsonld(n) for n in nodes), key=lambda n: n.get("@id", ""))} + return json.dumps(doc, indent=2, ensure_ascii=False) + "\n" + + +# ── The routine ── + +def _nothing_exported(outcome: Dict[str, int], viewer: str, *, searched: bool) -> str: + """Why the catalog has no dataset, from what happened to each element in scope. An empty scope, + a scope of only Bitol types or non-Assets, and Assets the viewer could not read are different + answers and are never reported as one another.""" + if not any(outcome.values()): + where = "the search matched nothing" if searched else "the scope has no members" + return f"No dataset exported: {where} that {viewer} can see." + words = {"bitol": "a DigitalProduct or Agreement (Bitol's, not DCAT's)", + "not_asset": "not an Asset", + "not_visible": f"not visible to {viewer}", + "not_found": "no longer found when read", + "unreadable": "could not be read"} + parts = [f"{n} {words[k]}" for k, n in outcome.items() if n] + return f"No dataset exported: of the {sum(outcome.values())} element(s) in scope, " + "; ".join(parts) + "." + + +def export_dcat(client: Any, scope: Optional[str] = None, search_string: Optional[str] = None, + format: str = "jsonld", page_size: int = 50, **_ignored: Any) -> Dict[str, Any]: + """Export the Assets in ``scope`` (a collection qualifiedName or GUID) or matching + ``search_string`` as a DCAT-AP 3 catalog. Returns ``{"text", "notes"}`` (SD-1's exporter shape). + + ``format`` is ``jsonld`` (default) or ``turtle``. Read as the client's user.""" + fmt = (format or "jsonld").lower().replace("-", "") + if fmt in ("ttl",): + fmt = "turtle" + if fmt not in ("jsonld", "turtle"): + raise ValueError(f"export_dcat: format '{format}' is not jsonld or turtle") + if not scope and not search_string: + raise ValueError("export_dcat needs a scope (a collection qualifiedName or GUID) or a search_string") + page_size = int(page_size or 50) + viewer = getattr(client, "user_id", None) or "the caller" + b = _Builder(viewer) + + if scope: + collection = _read_scope(client, scope) + catalog = b.catalog(collection) + guid = _guid(collection) + members = _paged(lambda s, n: client.get_collection_members( + collection_guid=guid, start_from=s, page_size=n, output_format="JSON", graph_query_depth=0), page_size, b.notes, + f"the members of {_qn(collection)}") + b.notes.add(f"Read as {viewer}: Egeria leaves members in zones {viewer} cannot see out of the member " + f"listing, so this catalog lists only what {viewer} can see.") + else: + catalog = b.catalog(None, search_string=search_string) + members = _paged(lambda s, n: client.find_in_asset_domain( + search_string=search_string, start_from=s, page_size=n, output_format="JSON", graph_query_depth=0), page_size, b.notes, + f"the assets matching '{search_string}'") + b.notes.add(f"Read as {viewer}: Egeria leaves assets in zones {viewer} cannot see out of a search, so this " + f"catalog lists only what {viewer} can see.") + + seen = set() + exported = 0 + outcome = {"bitol": 0, "not_asset": 0, "not_visible": 0, "not_found": 0, "unreadable": 0} + for member in sorted(members, key=_guid): + guid = _guid(member) + if not guid or guid in seen: + continue + seen.add(guid) + type_name, supers = _type_names(member) + kinds = [t for t in BITOL_TYPES if t == type_name or t in supers] + if kinds: + b.notes.add(f"{_qn(member)}: a {kinds[0]}, not a DCAT dataset (Bitol)") + outcome["bitol"] += 1 + continue + if not (type_name == "Asset" or "Asset" in supers): + b.notes.add(f"{_qn(member)}: a {type_name or 'element of unknown type'}, not an Asset, so not a DCAT dataset") + outcome["not_asset"] += 1 + continue + try: + element = client.get_element_by_guid(guid, output_format="JSON", + include_only_relationships=ASSET_RELATIONSHIPS) + except Exception as exc: # noqa: BLE001 -- classified below, never silently dropped + if _not_visible(exc): + b.notes.add(f"{_qn(member)}: not visible to {viewer} (Egeria refused the read: zone security); " + f"it is in scope but not exported") + outcome["not_visible"] += 1 + elif _not_found(exc): + b.notes.add(f"{_qn(member)}: listed in scope but no longer found when read; not exported") + outcome["not_found"] += 1 + else: + b.notes.add(f"{_qn(member)}: could not be read ({type(exc).__name__}); not exported") + outcome["unreadable"] += 1 + continue + if not isinstance(element, dict): + b.notes.add(f"{_qn(member)}: listed in scope but no longer found when read; not exported") + outcome["not_found"] += 1 + continue + b.dataset(catalog, element) + exported += 1 + + if exported == 0: + b.notes.add(_nothing_exported(outcome, viewer, searched=not scope)) + if not any(True for _ in b.g.subjects(RDF.type, DCAT.DataService)): + b.notes.add("dcat:DataService omitted: no DeployedAPI with an endpoint in scope.") + b.notes.add("dcat:contactPoint omitted: this exporter does not read owners' contact details.") + return {"text": serialise(b.g, fmt), "notes": b.notes.render()} diff --git a/pyegeria/view/format_set_executor.py b/pyegeria/view/format_set_executor.py index 6c8f2a10..a1d30958 100644 --- a/pyegeria/view/format_set_executor.py +++ b/pyegeria/view/format_set_executor.py @@ -17,6 +17,8 @@ import inspect import json import os +import re +import string import sys from typing import Any, Dict, Iterable, List, Optional, Tuple, Union @@ -39,6 +41,11 @@ from pyegeria.egeria_tech_client import EgeriaTech from pyegeria.view.role_supply import PlainSupply, RoleRefused, RoleSupply, supply_inputs from pyegeria.view.overview_metrics import recording_unmeasured +from pyegeria.view._output_format_models import DOCUMENT_OUTPUT_TYPE, check_document_file_name +from pyegeria.view.document_validators import run_document_validator +from pyegeria.core._server_client import recording_list_requests +from pyegeria.view.output_formatter import check_dict_shape, dict_shape_for_call +from pyegeria.view.structured_table import build_structured_table, check_table_shape, mark_relationship_absence _CLIENT_CLASS_MAP = { "CollectionManager": "pyegeria.omvs.collection_manager.CollectionManager", @@ -762,6 +769,9 @@ async def _async_run_report( output_format: str = "DICT", params: Optional[Dict[str, Any]] = None, refresh_spec: bool = False, + *, + table_shape: Optional[str] = None, + dict_shape: Optional[str] = None, ) -> Dict[str, Any]: """Run a report spec with an async EgeriaTech client (see `_async_run_report_impl`). @@ -771,7 +781,8 @@ async def _async_run_report( if refresh_spec: from pyegeria.view.egeria_spec_cache import async_fetch_spec_for_call report_name = await async_fetch_spec_for_call(egeria_client, report_name) - result = await _async_run_report_impl(report_name, egeria_client, output_format=output_format, params=params) + result = await _async_run_report_impl(report_name, egeria_client, output_format=output_format, params=params, + table_shape=table_shape, dict_shape=dict_shape) return _with_spec_source(result, report_name, output_format) @@ -780,6 +791,9 @@ async def _async_run_report_impl( egeria_client: EgeriaTech, output_format: str = "DICT", params: Optional[Dict[str, Any]] = None, + *, + table_shape: Optional[str] = None, + dict_shape: Optional[str] = None, ) -> Dict[str, Any]: """ Execute the action for a given format set and return a normalized result structure. @@ -790,10 +804,18 @@ async def _async_run_report_impl( - {"kind":"text","mime": "text/markdown"|"text/html","content": str} - {"kind":"unknown","raw": any} """ - params = dict(params or {}) + params = coerce_paging_params(dict(params or {})) + row_shape = _row_shape(str(output_format or "DICT").upper(), table_shape, dict_shape) user_name = egeria_client.user_id user_pwd = egeria_client.user_pwd + # SD-1: DOCUMENT specs run through exec_report_spec (the analytic/role-supply path), which + # this find-only async path does not have. Refuse in words rather than fail inside it. + if str(output_format).upper() == DOCUMENT_OUTPUT_TYPE or _document_spec_struct(report_name) is not None: + raise ValueError( + f"Report spec '{report_name}' ({output_format}): DOCUMENT output runs through exec_report_spec " + f"(output_format='DOCUMENT'), not the async find path") + # Resolve the format set and action effective_format = "REPORT" if output_format in ["HTML", "MARKDOWN"] else output_format if effective_format == "JSON": @@ -923,14 +945,23 @@ async def _async_run_report_impl( except Exception as auth_err: # Do not fail the entire call if token refresh fails; downstream call may still work logger.debug(f"Token creation/lookup issue: {auth_err}") - result = await func(**call_params) + with recording_list_requests() as list_record, dict_shape_for_call(row_shape): + result = await func(**call_params) if not result or result == NO_ELEMENTS_FOUND: return {"kind": "empty"} - + cap_notes = page_cap_notes(func, call_params, result, list_record) + + if output_format == "TABLE" and table_shape == "structured": + return build_structured_table(result, (fmt.get("formats") or {}).get("attributes") or [], + notes=cap_notes, capped=bool(cap_notes), record=list_record) + if output_format == "DICT" and row_shape == "native" and isinstance(result, list): + cap_notes = cap_notes + mark_relationship_absence( # "none" / "not read" (R1 follow-up) + result, [c if isinstance(c, dict) else c.model_dump() + for c in (fmt.get("formats") or {}).get("attributes") or []], list_record, keyed_by="name") if output_format in {"DICT", "JSON", "ALL", "TABLE"}: # Return raw data (list/dict/any) — do not stringify here; include TABLE to enable Rich rendering upstream - return {"kind": "json", "data": result} + return {"kind": "json", "data": result, **({"notes": cap_notes} if cap_notes else {})} # For narrative formats, try to use generate_output if the result is structured if output_format in {"REPORT", "REPORT-GRAPH", "MD", "FORM", "LIST", "HTML", "MERMAID", "GRAPH"}: @@ -956,7 +987,11 @@ async def _async_run_report_impl( content = preamble + content mime = "text/html" if output_format in ["HTML", "GRAPH"] else "text/markdown" - return {"kind": "text", "mime": mime, "content": content} + if cap_notes: # fix-now F8: a capped result says so in the text too + content = content.rstrip("\n") + "\n\n" + "\n".join( + (f"

{n}

" if mime == "text/html" else f"_{n}_") for n in cap_notes) + "\n" + return {"kind": "text", "mime": mime, "content": content, + **({"notes": cap_notes} if cap_notes else {})} return {"kind": "unknown", "raw": result} @@ -1161,6 +1196,185 @@ def _as_category_value_dict(result: Any) -> Optional[Dict[str, Union[int, float] return None +def _effective_page_size(func: Any, call_params: Dict[str, Any]) -> Optional[int]: + """The page size a find call ran with: the one sent, else the find function's own default + (e.g. find_digital_products' page_size=100). None when neither is a positive whole number (the + server then chose, and pyegeria cannot know its cap).""" + sent = call_params.get("page_size") + if isinstance(sent, int) and sent > 0: + return sent + try: + default = inspect.signature(func).parameters["page_size"].default + except (KeyError, TypeError, ValueError): + return None + return default if isinstance(default, int) and default > 0 else None + + +def _cap_words(shown: int, size: int, start: int) -> str: + first = f"rows {start + 1}-{start + shown}" if start else f"the first {shown}" + return f"Showing {first}: the query stopped at its page size of {size}; more may exist." + + +def page_cap_notes(func: Any, call_params: Dict[str, Any], result: Any, + record: Optional[Dict[str, Any]] = None) -> List[str]: + """Fix-now F8: a find result that filled its page says so, never a bare N. Egeria's paging + contract means a full page may or may not be the last, so the words are "more may exist". + + `record` is this call's own list-request record (`recording_list_requests`), which covers a find + method that renders text itself; a plain list result is checked against the page size sent (or the + find function's own default) as well. No state is read from the client (read-back C1).""" + cap = (record or {}).get("cap") + if cap: + shown, size, start = cap + return [_cap_words(shown, size, start)] + size = _effective_page_size(func, call_params) + if isinstance(result, list) and size and len(result) >= size: + return [_cap_words(len(result), size, call_params.get("start_from") or 0)] + return [] + + +_PAGING_PARAMS = ("page_size", "start_from") + + +def coerce_paging_params(params: Dict[str, Any]) -> Dict[str, Any]: + """page_size/start_from as whole numbers (fix-now F8): a numeric string is converted, anything else + is refused in words rather than sent to Egeria (where it failed as an HTTP 500).""" + for name in _PAGING_PARAMS: + value = params.get(name) + if value in (None, ""): + continue + if isinstance(value, bool): + raise ValueError(f"{name} must be a whole number of 0 or more, not {value!r}") + try: + number = int(str(value).strip()) if not isinstance(value, int) else value + except ValueError: + raise ValueError(f"{name} must be a whole number of 0 or more, not {value!r}") from None + if number < 0: + raise ValueError(f"{name} must be a whole number of 0 or more, not {value!r}") + params[name] = number + return params + + +def _row_shape(output_format: str, table_shape: Optional[str], dict_shape: Optional[str]) -> str: + """The DICT row shape a find call runs with (R1): "native" for DICT + dict_shape="native" and for + TABLE + table_shape="structured", else "flat" (TABLE stays flat under dict_shape: its structured + form is table_shape). Unknown values are refused with a sentence.""" + table_shape = check_table_shape(table_shape) + dict_shape = check_dict_shape(dict_shape) + if output_format == "DICT" and dict_shape == "native": + return "native" + if output_format == "TABLE" and table_shape == "structured": + return "native" + return "flat" + + +def _spec_display_name(format_set_name: Any) -> str: + if isinstance(format_set_name, dict): + return str(format_set_name.get("_report_spec_name") or format_set_name.get("heading") or "?") + return str(format_set_name) + + +def _document_spec_struct(format_set_name: Any) -> Optional[Dict[str, Any]]: + """The selected-spec struct (as `select_report_spec` returns it) when this spec is a DOCUMENT + spec, else None. A spec passed as a dict is read as given (a FormatSet dict or a selected + struct); by name it is looked up across tiers and aliases.""" + if isinstance(format_set_name, dict): + formats = format_set_name.get("formats") + rows = formats if isinstance(formats, list) else [formats] if formats else [] + for row in rows: + row = row.dict() if hasattr(row, "dict") and not isinstance(row, dict) else row + if isinstance(row, dict) and row.get("document"): + struct = dict(format_set_name) + struct["formats"] = row + action = struct.get("action") + if action is not None and not isinstance(action, dict): + struct["action"] = action.model_dump() + return struct + return None + try: + struct = select_report_spec(format_set_name, DOCUMENT_OUTPUT_TYPE) + except Exception: # noqa: BLE001 -- an unknown name is reported by the normal path below + return None + if struct and isinstance(struct.get("formats"), dict) and struct["formats"].get("document"): + return struct + return None + + +_FILE_NAME_UNSAFE = re.compile(r"[^A-Za-z0-9._+-]+") + + +def fill_document_file_name(template: str, params: Dict[str, Any]) -> str: + """Fill a DOCUMENT file-name template from the run's parameters. + + Only plain `{name}` fields are allowed (no attribute or index access). Each value is made + file-name safe (anything but letters, digits and `._+-` becomes `_`, and `..` is broken up), + so a qualifiedName such as `Folder::Sales/EU` cannot become a path. The result is checked + again; a template that still names a path, or a parameter the run did not supply, is refused + with a sentence.""" + values: Dict[str, str] = {} + for _literal, field, spec, conversion in string.Formatter().parse(template): + if field is None: + continue + if not field.isidentifier(): + raise ValueError(f"DOCUMENT file_name template '{template}' has field '{{{field}}}'; only plain " + f"parameter names are allowed") + if spec or conversion: + raise ValueError(f"DOCUMENT file_name template '{template}' formats field '{field}'; only plain " + f"parameter names are allowed") + raw = params.get(field) + if raw in (None, ""): + raise ValueError(f"DOCUMENT file_name template '{template}' needs parameter '{field}', which this " + f"run did not supply") + safe = _FILE_NAME_UNSAFE.sub("_", str(raw)).replace("..", "_").strip("._") or "_" + values[field] = safe + file_name = template.format(**values) + reason = check_document_file_name(file_name) + if reason: + raise ValueError(f"DOCUMENT file_name refused: {reason}") + return file_name + + +def _exec_document( + name: str, struct: Dict[str, Any], *, params: Dict[str, Any], + view_server: str, view_url: str, user: str, user_pass: str, + token: Optional[str] = None, supply: Optional[RoleSupply] = None, +) -> Dict[str, Any]: + """Run a DOCUMENT spec (SD-1): call its exporter, validate what it returns, and return + + {"kind": "document", "standard", "media_type", "file_name", "text", + "validation": {"state", "validator", "findings", "reason"}, "notes": [...]} + + The exporter is the action's analytic function; it returns `{"text": str, "notes"?: [str]}` + (or a plain string, read as text with no notes). `validation` and `notes` are always present: + an empty `notes` means the exporter had nothing to say about the document's content. A + validator that raises leaves the document `not_validated` with its error, never `invalid`. + """ + action = struct.get("action") or {} + if not action.get("analytic_function"): + raise ValueError(f"Report spec '{name}' has a DOCUMENT format but no analytic_function (exporter)") + doc = struct["formats"]["document"] + fill_from = {**(action.get("analytic_spec_params") or {}), + **{k: v for k, v in params.items() if v not in (None, "")}} + file_name = fill_document_file_name(doc["file_name"], fill_from) + + result = _run_analytic_function(action, params=params, view_server=view_server, view_url=view_url, + user=user, user_pass=user_pass, token=token, supply=supply) + if isinstance(result, str): + text, notes = result, [] + elif isinstance(result, dict) and isinstance(result.get("text"), str): + text = result["text"] + raw_notes = result.get("notes") or [] + notes = [str(n) for n in (raw_notes if isinstance(raw_notes, list) else [raw_notes])] + else: + raise ValueError( + f"Report spec '{name}': exporter '{action['analytic_function']}' returned " + f"{type(result).__name__}, not a document ({{'text': str, 'notes'?: [str]}})") + validation = run_document_validator(text, doc["media_type"], doc.get("validator"), + doc.get("validator_options") or {}) + return {"kind": "document", "standard": doc["standard"], "media_type": doc["media_type"], + "file_name": file_name, "text": text, "validation": validation, "notes": notes} + + def exec_report_spec( format_set_name: str | dict, *, @@ -1173,11 +1387,19 @@ def exec_report_spec( token: Optional[str] = None, supply: Optional[RoleSupply] = None, refresh_spec: bool = False, + table_shape: Optional[str] = None, + dict_shape: Optional[str] = None, ) -> Dict[str, Any]: """ Execute the action for a given report spec (see `_exec_report_spec_impl` for the result shapes). + R1: `table_shape="structured"` with output_format TABLE returns the structured table + (`pyegeria.view.structured_table`, `kind: "table"`); `dict_shape="native"` with DICT returns rows + with native values. Both are caller flags; the defaults ("rows", "flat") return today's shapes, and + any other value is refused with a sentence. They apply to a find-method spec only: DOCUMENT, chart + and analytic results ignore them. + RS-EGERIA-TIER: the name may be tier-addressed (`egeria: