Skip to content

feat(ontology): add Cohort Discovery rule deletion, fix stale URIs and SWRL raw-editor sync - #176

Open
benoitcayladbx wants to merge 1 commit into
0.9.0from
feat/designer-cohort-delete-and-stale-uri
Open

benoitcayladbx wants to merge 1 commit into
0.9.0from
feat/designer-cohort-delete-and-stale-uri

Conversation

@benoitcayladbx

Copy link
Copy Markdown
Collaborator

Reopened against 0.9.0 after develop was deleted. GitHub cannot reopen #148 (closed PR + missing base), so this is a successor of #148 with the same commits. Original author: @jeremiaspf. Please rebase onto current 0.9.0 before review — expect conflicts.


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.js gets _syncDeleteBtn/deleteActiveRule and _ontology_cohorts.html gets 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 read uri/iri/id directly (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 THEN clause) 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

  1. Create a Cohort Discovery rule, save it, then use the new "Delete rule" button — it should remove the rule and the button should be disabled again with no rule loaded.
  2. Rename a domain's Base URI after creating classes/relationships used in a Cohort rule — before this fix, the rule shows 0 members/edges; after, it resolves correctly.
  3. Save an axiom in Expressions & Axioms referencing a class, rename the domain's Base URI, reopen the editor — the dropdown should still resolve the class correctly.
  4. In the SWRL editor, reference a subclass with no relationships of its own in a rule — it should now appear in the graph. Switch to raw-text mode and type an atom with no matching graph node — it should no longer get overwritten by the visual sync.

…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).
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.

2 participants