zazuko / cube-creator

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

Only some of the Entries can be changed through the Edit Button #729

Closed l00mi closed 3 years ago

l00mi commented 3 years ago

In https://pipelines-integ.lindas.admin.ch/app/shared-dimensions/dimension!!el01 only Cu, Cd and Hg loaded if the ✎ is clicked.

tpluscode commented 3 years ago

While I think the problem stems from ongoing issues with the database cluster, I cleaned it up at least for now so that functionality is restored.

Step 1. Remove broken shapes

Resources in the graph are saved with a shape which describes the saved structure in basic terms. Somehow, some shapes lack sh:property which is why those cannot be retrieved later. It also turned out that some resources had multiple such broken shapes.

I used the query below to prune them

PREFIX sh: <http://www.w3.org/ns/shacl#>

with <https://lindas.admin.ch/cube/dimension>
delete {
  ?rootShape ?p ?o
}
WHERE {
  {
    select ?rootShape {
      ?term schema:inDefinedTermSet <https://ld.admin.ch/cube/dimension/el01> .
      ?rootShape sh:targetNode ?term .

      optional { ?rootShape sh:property ?property. }
    }
    GROUP BY ?term ?rootShape
    having (count(?property) = 0)
  }

  ?rootShape ?p ?o
}

Step 2 Recreate missing shapes

This inserts shapes describing the broken resources

PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX schema: <http://schema.org/>

with <https://lindas.admin.ch/cube/dimension>
insert { 
    ?shape sh:targetNode ?term ;
           sh:property [
             sh:path ?p
           ] .
}
WHERE {
    {
        select DISTINCT ?term ?p {
            ?term schema:inDefinedTermSet <https://ld.admin.ch/cube/dimension/el01> .
            ?term ?p ?o .

            minus {
                [] sh:targetNode ?term
            }
        }
    }

  bind (BNODE(str(?term)) as ?shape)
}

Closing now. May reopen if this happens again, despite improvements to infrastructure