feat(ontology): add Cohort Discovery rule deletion, fix stale URIs and SWRL raw-editor sync - #148
Conversation
…d SWRL raw-editor sync query-cohorts.js now tracks the loaded ontology's base_uri and reconstructs any class/property URI from its local name against it, instead of trusting the uri/iri/id field on the object (which can be stale after the domain is re-based — see the companion reasoning/generation PRs for the same root cause elsewhere). Previously nothing reconstructed these URIs on this screen, so a re-based domain could make an apparently well-configured Cohort Discovery rule show 0 members/edges. Adds a "Delete rule" button to the Cohort Discovery designer (JS wiring in query-cohorts.js, markup in _ontology_cohorts.html). The backend delete endpoint already existed; there was simply no way to trigger it from the design screen. ontology-axioms.js now prefers an element's simple name over its stored URI when populating the class/property dropdowns of the Expressions & Axioms editor (previously the reverse). The backend (OntologyGenerator._resolve_uri) always rebuilds the correct URI from a simple name against the current Base URI, so this avoids axioms carrying forward a stale stored URI. ontology-swrl.js: the entity filter for the SWRL rule graph now also includes direct subclasses of entities that participate in a business relationship, even when the subclass itself has none — previously such a subclass could not be referenced or typed against in a rule. The raw-text editor's auto-sync from the visual graph selection is now suppressed while the editor is in raw mode, so typing an atom that has no corresponding graph node (e.g. a derived class in a THEN clause) is no longer silently overwritten. Also switches the D3.js CDN from d3js.org to jsdelivr (see the companion frontend PR for the full rationale).
|
|
Review — not ready to mergeLooked at the four-file diff against Blockers1. const base = (this.baseUri || '').replace(/[#/]+$/, '');
if (base && name) return `${base}#${name}`;
This helper would emit Please join the same way as Also remap already-saved 2. Previously: ontology-level data properties, filtered by Now: nested Two problems:
Keep the reconstructed URI, but keep the previous source + fallback, or merge nested + ontology-level lists. 3. Spanish comment — // Raw editor sync — solo si NO estamos en modo raw; ...Rewrite that comment in English. Product UI copy can stay localised; comments cannot. 4. No tests for new behaviour ( This is user-visible JS with a real behavioural fork (
5. Changelog ( No Should-fix before merge
Process / non-blocking
What looks good
Suggested retest (after the URI join fix)
Happy to re-review once |
What
Three unrelated fixes in the Ontology Designer's Cohort Discovery, Expressions & Axioms, and SWRL screens, grouped together because they're small and touch neighboring code.
Cohort Discovery had no way to delete a rule from the UI. The backend delete endpoint already existed;
query-cohorts.jsgets_syncDeleteBtn/deleteActiveRuleand_ontology_cohorts.htmlgets the "Delete rule" button (next to "Save rule", disabled until a rule is loaded) to actually call it.Cohort Discovery also had the same stale-URI problem described in the reasoning/generation PRs, but more visibly: nothing on this screen reconstructed a class/property URI from its current Base URI, so a re-based domain could make an apparently correctly-configured rule show 0 members/0 edges with no obvious cause. Adds base-URI tracking and a
_currentUri()helper, used everywhere the screen previously readuri/iri/iddirectly (class selection, lookup-by-URI, available data properties, compatible relationship properties between two entities, each hop's dropdown).Expressions & Axioms editor now prefers an element's simple name over its stored URI when populating class/property dropdowns (previously the reverse). The backend (
OntologyGenerator._resolve_uri, see the companion generation PR) already rebuilds the correct URI from a simple name against the current Base URI — sending the name instead of a potentially-stale URI avoids axioms carrying a stale URI forward in the first place.SWRL rule editor: the entity filter for the rule graph now also includes direct subclasses of entities that participate in a business relationship, even when the subclass itself has none — previously such a subclass couldn't be referenced or typed against in a rule, despite being a reasonable thing to do. The raw-text editor's auto-sync from the visual graph selection is now suppressed while the editor is in raw mode, so typing an atom with no corresponding graph node (e.g. a derived class in a
THENclause) is no longer silently overwritten. Also switches the D3.js CDN to jsdelivr (same change as the companion frontend PR — this file needed other edits too, so it's included here rather than split further).Why
The delete-rule gap and the stale-URI issue both make Cohort Discovery awkward to actually use day to day. The axioms/SWRL fixes are UX papercuts that were easy to fix alongside the above while in the same area of the codebase.
How to test