feat: parse + emit the top-level ontology block - #5
Merged
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1.
Ontology block DTOs
Four new classes under
bi.saiku.ossie.model.ontology:OntologyEntry— one entry in the top-levelontology:list.Pairs a concept with its relationships.
OntologyConcept—{name, type, identify_by}.typeis astring 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 tomultiplicity.OntologyRole— the target concept (primitive type or anothernamed concept in the same ontology).
OssieDocument.ontologyfield added with@JsonProperty("ontology"),included in
@JsonPropertyOrderbeforesemantic_modelso the wireshape 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_byexpression stringontologyRoundTripsWithoutLoss— two consecutive reader/writerpasses produce structurally identical DTO trees
documentsWithoutOntologyBlockRoundTripCleanly— pre-ontologydocuments (only
semantic_model:) still parse + emit clean; theempty ontology field doesn't leak into output
24 tests total across the module.
README
New section showing
doc.getOntology()traversal — the entity-levelview is the whole point of this PR.