vivo-project / VIVO

VIVO is an extensible semantic web application for research discovery and showcasing scholarly work
http://vivoweb.org
BSD 3-Clause "New" or "Revised" License
202 stars 127 forks source link

Some inferred TBox axioms are not removed when assertions are deleted #3884

Closed brianjlowe closed 1 year ago

brianjlowe commented 1 year ago

Describe the bug Some triples are not removed from the inferred-tbox graph by the TBox reasoner when the underlying assertions on which they are depend are deleted.

To Reproduce

  1. Go to Site Admin, Add/Remove RDF
  2. Select dataset.ttl file linked in description of issue https://github.com/vivo-project/VIVO/issues/3871
  3. Select Add mixed RDF.
  4. Select N3.
  5. Submit form.
    1. Go to localhost:8080/vivo/admin/gotoIndividual.jsp
  6. Enter URI http://vivo.mydomain.edu/individual/class_c (without <>).
  7. Triples will be displayed; some will be in the graph http://vitro.mannlib.cornell.edu/default/asserted-tbox and some in http://vitro.mannlib.cornell.edu/default/inferred-tbox.
  8. Return to Add/Remove form and repeat, except with "Remove mixed RDF" selected.
  9. Go to localhost:8080/vivo/admin/gotoIndividual.jsp
  10. Enter URI http://vivo.mydomain.edu/individual/class_c (without <>).
  11. Triples will be displayed; all will be in the graph http://vitro.mannlib.cornell.edu/default/inferred-tbox.

Expected behavior No triples should be displayed in any graph in step 12.

brianjlowe commented 1 year ago

Setting as blocker for now since it seems equally severe as #3871, which was also a blocker.

brianjlowe commented 1 year ago

This is likely a long-standing (but pretty serious) issue that happens on line 96 of JFactTBoxReasoner, where the listened-to triple removals are removed directly from the filteredAssertionsModel. The blank node IDs heard by the listener will not match the IDs in filteredAssertionsModel, so triples involving blank nodes will not be removed. This needs to use the logic used in the RDFServiceJena implementation, where blank nodes are treated as variables and the graph matching the appropriate blank node pattern is deleted.

It looks to be working when I duplicate removeUsingSparqlUpdate() from RDFServiceJena code. Will refactor this into JenaModelUtils so it can be used in both places.

brianjlowe commented 1 year ago

The workaround currently is to restart VIVO, because filteredAssertionsModel is completely refreshed from the underlying store.