sparna-git / Sparnatural

Sparnatural : visual SPARQL query builder for knowledge graphs in the browser, configurable with SHACL
http://sparnatural.eu
GNU Lesser General Public License v3.0
219 stars 41 forks source link

Incorrect query generation when unselecting EndClassGroup #465

Closed tfrancart closed 1 year ago

tfrancart commented 1 year ago
  1. Generate a simple query X --property--> Y = all
  2. Change the EndClassGroup to Z, select "all", and click on the eye of "Z" to select it : X --property--> Z (selected) = all

The generated SPARQL query is wrong as an extra variable is generated for X:

image

image

here the variable "?Lot_partenaire_4" should not be here

tfrancart commented 1 year ago

this comes from the ActionStore.variables array

tfrancart commented 1 year ago

This can come from the fact that in RemoveEndClass.ts we are recreating the complete CriteriaGroup, which triggers a new variable generation

image

SteinerPascal commented 1 year ago

Should I have a look at it?

tfrancart commented 1 year ago

Hello @SteinerPascal if you have some time, yes I would gladly welcome help because I have been scratching my head on this for a couple of hours and cannot get to anything. I feel there is 2 problems:

  1. There is an extra variable in the SPARQL
  2. The variable counter is not reset when triggering RemoveEndClass, and the CriteriaGroup is recreated just like it was new, so all variables are renumbered.

It would be better if the variable names are consistent, and what was once xxxx_1 remains xxxx_1.

tfrancart commented 1 year ago
  1. RemoveEndClass empties CriteriaGroup and recreate a completely new one, then reselect the first class based on previous selection
  2. The recreation of the StartClassGroup uses a new sequence counter from the actionStore.sparqlVarID
  3. RemoveEndClass ask to "updateVarList" that should reset actionStore.variables based on the actually selected variables in the UI
  4. When clicking on the eye, onSelectViewVar event is triggered, which calls selectViewVar, then readVariablesFromUI, and this is where the bug is : this returns the extra, unwanted "xxxx_1" variable.
tfrancart commented 1 year ago

I think in the updateDraggables function, we just remove the HTML but we don't actually remove the draggable from the list of draggables. image