Skip to content

feat: parse + emit the top-level ontology block - #5

Merged
buggtb merged 1 commit into
mainfrom
feature/ontology-block
Jul 9, 2026
Merged

feat: parse + emit the top-level ontology block#5
buggtb merged 1 commit into
mainfrom
feature/ontology-block

Conversation

@buggtb

@buggtb buggtb commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Closes #1.

Ontology block DTOs

Four new classes under bi.saiku.ossie.model.ontology:

  • OntologyEntry — one entry in the top-level ontology: list.
    Pairs a concept with its relationships.
  • OntologyConcept{name, type, identify_by}. type is a
    string not an enum so future spec kinds (AttributeType, etc.)
    round-trip without needing a library bump.
  • OntologyRelationship{name, roles, verbalizes, multiplicity, derived_by}. Same string-not-enum reasoning applies to
    multiplicity.
  • OntologyRole — the target concept (primitive type or another
    named concept in the same ontology).

OssieDocument.ontology field added with @JsonProperty("ontology"),
included in @JsonPropertyOrder before semantic_model so the wire
shape matches the apache/ossie flights example.

Tests

Anchor test fixture is the Runway + Airport shape from the
apache/ossie flights example — the same YAML the discussion in the
issue referenced.

  • readsOntologyBlockFromYaml — deep read: concept names, type,
    identify_by, every relationship's roles + verbalizes +
    multiplicity + derived_by
  • writesOntologyBlockToYaml — every wire field survives emission,
    including the tricky derived_by expression string
  • ontologyRoundTripsWithoutLoss — two consecutive reader/writer
    passes produce structurally identical DTO trees
  • documentsWithoutOntologyBlockRoundTripCleanly — pre-ontology
    documents (only semantic_model:) still parse + emit clean; the
    empty ontology field doesn't leak into output

24 tests total across the module.

README

New section showing doc.getOntology() traversal — the entity-level
view is the whole point of this PR.

Closes #1.

Adds four DTOs under bi.saiku.ossie.model.ontology mirroring the
apache/ossie wire shape:

- OntologyEntry { concept, relationships }
- OntologyConcept { name, type, identify_by }
- OntologyRelationship { name, roles, verbalizes, multiplicity,
  derived_by }
- OntologyRole { concept }

OssieDocument gains an ontology field with @JsonProperty("ontology")
and @JsonPropertyOrder places it before semantic_model to match the
flights.yaml shape.

String not enum for type/multiplicity so unknown spec values
round-trip without dragging library bumps into every consumer.

Four tests (24 total across the module):
- readsOntologyBlockFromYaml — deep read of concepts + relationships
- writesOntologyBlockToYaml — wire fields survive emission including
  derived_by expressions
- ontologyRoundTripsWithoutLoss — two passes produce structurally
  identical DTO trees
- documentsWithoutOntologyBlockRoundTripCleanly — pre-ontology
  documents still work

README gains a section showing doc.getOntology() traversal.
@buggtb
buggtb merged commit 18d008c into main Jul 9, 2026
2 checks passed
pull Bot pushed a commit to AKJUS/saiku that referenced this pull request Jul 9, 2026
…piculedata#1410)

Exposes the OSI ontology block through the AI Query API + the MCP
surface. Consumes the OntologyEntry / OntologyConcept /
OntologyRelationship / OntologyRole DTOs published from
bi.saiku.ossie:ossie-core:0.1.0-SNAPSHOT (spiculedata/ossie#5).

## What's new

### REST endpoint

    GET /rest/saiku/api/ai/ossie/ontology/{connection}/{model}

Returns:
- {"connection": "...", "model": "...", "ontology": [OntologyEntry]}
- Empty list when the underlying document has no ontology block
- Same validation shape as /schema — unknown connection returns
  VALIDATION_ERROR with candidate list

### MCP tool

- describe_ossie_ontology, same operand schema as describe_ossie_model
  (connection + model). Wraps the REST endpoint via
  AiOssieResource.getOntology.
- Only advertised in tools/list when AiOssieResource is wired
  (matches existing Ossie-tool gating pattern).

### OssieDiscoverService

- New public getOntology(connectionName) returning List<OntologyEntry>
- Refactored: extracted a package-private readDocument helper so
  getModel + getOntology share connection-validation + YAML-read code
  paths. Zero behavioural change on getModel.

## Tests

- McpResourceTest: +2 cases (ontology tool advertised on tools/list
  when Ossie is wired, describe_ossie_ontology dispatches to
  getOntology on the resource). 14/14 total.
- Full saiku-service + saiku-web reactor: green.

## Docs

docs/AI-OSSIE-API.md gains a new "Step 4b — inspect the ontology
block" section between validation and preview. Table of MCP tools
updated to 6.

Closes saiku#1410. Ontology-block DTOs are pure passthrough; consumers
that want to reason over the graph (subsumption, transitive closure,
concept-based navigation) build on top.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spec: parse + emit the top-level ontology block (concepts, relationships, verbalize)

1 participant