zazuko / cube-creator

A tool to create RDF cubes from CSV files
GNU Affero General Public License v3.0
11 stars 2 forks source link

fix: clean up dimension mapping graphs #1417

Closed tpluscode closed 1 year ago

tpluscode commented 1 year ago

Dimension mappings are stored as instances of prov:KeyEntityPair similar to

[
  rdf:type prov:KeyEntityPair ;
  prov:pairKey "164" ;
  prov:pairEntity <https://ld.admin.ch/dimension/term> ;
] .

<https://ld.admin.ch/dimension/term> a prov:Entity .

When such a pair was removed, the a prov:Entity triple was left over. It does not have any side effects but is clutter nonetheless. This PR ensures that they will be removed when a dimension mapping is saved.

Additioanally the query below can be used to clean up any dangling triples from mapping graphs.

PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX csvw: <http://www.w3.org/ns/csvw#>
PREFIX cube: <https://cube.link/>

DELETE {
    graph ?mapping {
        ?entity a prov:Entity .
    }
}
where {
    graph ?mapping {
        ?mapping a prov:Dictionary .
        ?entity a prov:Entity .

        filter not exists {
            ?pair prov:pairEntity ?entity .
        }
    }
}
changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: 197a9f70dd90e3ca9d10b44c043dc5d743501f40

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ---------------------- | ----- | | @cube-creator/core-api | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

codecov-commenter commented 1 year ago

Codecov Report

Merging #1417 (197a9f7) into master (55c3333) will decrease coverage by 3.27%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1417      +/-   ##
==========================================
- Coverage   80.58%   77.31%   -3.27%     
==========================================
  Files         196      196              
  Lines       13486    13491       +5     
  Branches      814      784      -30     
==========================================
- Hits        10868    10431     -437     
- Misses       2610     3052     +442     
  Partials        8        8              
Impacted Files Coverage Δ
...e/lib/domain/dimension-mapping/DimensionMapping.ts 96.66% <100.00%> (+0.14%) :arrow_up:

... and 13 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.