fix(ontology): rebuild stale class URIs in OWL/R2RML/Digital Twin generation and persist Constraints tab - #175
Open
benoitcayladbx wants to merge 1 commit into
Conversation
…eration and persist Constraints tab OntologyGenerator._resolve_uri, R2RMLGenerator and DigitalTwin graph construction all reconstruct a class/property URI from its local name against the domain's current Base URI when the stored URI does not start with it, instead of using the stale URI as-is. This is the same re-basing problem fixed in the reasoning engines (see the companion PR), applied here to: axioms saved from the Expressions & Axioms editor (an axiom referencing a stale class URI no longer matched the class's own owl:Class declaration in the exported OWL, leaving it effectively orphaned); R2RML generation (mapped instances got an rdf:type disconnected from the real class, and their data-property lookup used the wrong URI too); and the Digital Twin graph (instances of a re-based class did not attach to it). R2RMLGenerator additionally reorders TriplesMap generation so the class comment and logical table are built after the class URI is resolved, and looks up data properties using the resolved URI. Adds two endpoints, POST /ontology/constraints/save and POST /ontology/constraints/delete, backing the Designer's Constraints tab (entity disjointWith/equivalentTo; relationship cardinality, functional/inverse-functional/symmetric/transitive). Previously the tab had no endpoint to persist to, so changes made there were never saved. ReasoningService adds _get_constraints(), reading domain.constraints — where the Constraints tab actually stores its data — so a relationship marked Transitive or Symmetric there is picked up by the graph-reasoning pass. Previously graph reasoning only looked at each property's internal characteristics field, which the Constraints tab never wrote to, so marking a relationship Transitive/Symmetric there had no real effect on reasoning even though the UI accepted the setting.
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.
Reopened against
0.9.0afterdevelopwas deleted. GitHub cannot reopen #147 (closed PR + missing base), so this is a successor of #147 with the same commits. Original author: @jeremiaspf. Please rebase onto current0.9.0before review — expect conflicts.Note for rebase:
POST /ontology/constraints/save|deleteis obsolete on 0.9.0 (legacy constraints migrated to SHACL; unit tests assert those endpoints no longer exist). Keep the stale-URI reconstruction in OWL/R2RML/Digital Twin; drop or rewrite the constraints persistence against the SHACL path.What
Continuation of the "stale class URI after Base URI change" problem fixed for the reasoning engines in the companion reasoning-engines PR (
fix/reasoning-lakebase-dialect-and-stale-uri), applied here to ontology/mapping generation — plus an unrelated persistence gap in the Designer's Constraints tab that a couple of these fixes depend on.Stale-URI reconstruction, three places:
OntologyGenerator._resolve_uri: when given a full URI (not a simple name) — as happens when the Expressions & Axioms editor sends a class/property's stored URI — it now checks whether that URI starts with the domain's current Base URI, and if not, extracts the local name and rebuilds it against the current Base URI. Before this, an axiom referencing a stale class URI no longer matched that class's ownowl:Classdeclaration in the exported OWL, leaving the axiom effectively orphaned.R2RMLGenerator: reconstructs a mapping's class URI the same way before generating itsTriplesMap, and looks up the class's data properties using the resolved URI rather than the original. Before this, mapped instances got anrdf:typepointing at the stale URI — disconnected from the real class — and their data properties weren't found either.DigitalTwingraph construction: same reconstruction when building the visual graph, so instances of a re-based class attach to it correctly instead of appearing disconnected.Constraints tab had no backend to save to. Adds
POST /ontology/constraints/saveandPOST /ontology/constraints/delete, which persist/remove an entry (by index) indomain.constraints— entitydisjointWith/equivalentToand relationship cardinality/functional/inverse-functional/symmetric/transitive. Before this, the Constraints tab UI accepted input but had nowhere to send it, so nothing was ever saved.ReasoningServicedidn't consume Constraints tab data at all. Adds_get_constraints(), readingdomain.constraints(where the tab's data actually lives, via the new endpoints above) in addition to the property's internalcharacteristicsfield (which in practice the UI never populates). Before this, marking a relationship Transitive or Symmetric in the Constraints tab had no effect on graph reasoning — the transitive closure / symmetric expansion pass only looked at a field nothing wrote to.Why
Same root cause across the first three files: modules that trust a stored
uri/irifield literally instead of treating it as derivable from(local name, current Base URI). The Constraints-tab gap is separate but directly blocks the SWRL/graph-reasoning fix from being meaningfully testable, since without persistence there's nothing for_get_constraints()to read.How to test
rdf:typeshould point at the current-Base-URI class); open the Digital Twin view (instances should attach to the class).