Skip to content

Manually removing published cube

Michael Luggen edited this page Nov 16, 2022 · 6 revisions

The query below can be used to remove a cube, its metadata and observations.

  1. Replace the WITH line with the organization's proper graph name
  2. Replace the URI in the BIND line with the correct cube identifier to remove
PREFIX cube: <https://cube.link/>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

WITH <https://lindas.admin.ch/foen/cube>
delete {
  ?cube a cube:Cube ;
        cube:observationConstraint ?shape ;
        cube:observationSet ?set ;
        ?p1 ?metaLevel1 .

  ?metaLevel1 ?p2 ?metaLevel2 .
  
  ?shape ?shapeP ?shapeO .
  ?propertyS ?propertyP ?propertyO .
  
  ?set cube:observation ?observationS .
  ?observationS ?observationP ?observationO .
}
WHERE  
{ 
    BIND(<https://environment.ld.admin.ch/foen/ubd000501/10> AS ?cube)
    ?cube  rdf:type  cube:Cube

      { # Cube's direct metadata
        ?cube  ?p1  ?metaLevel1
        OPTIONAL
          { # Second level of metadata in blank nodes
            ?metaLevel1  ?p2  ?metaLevel2
            FILTER isBlank(?metaLevel1)
          }
      }
    UNION
      { # Constraint Shape properties
        ?cube   cube:observationConstraint  ?shape .
        ?shape  ?shapeP               ?shapeO
      }
    UNION
      { # Property Shape properties need to be queried deep to get RDF Lists
        ?cube cube:observationConstraint/sh:property ?property .
        ?property (<>|!<>)* ?propertyS .
        ?propertyS  ?propertyP  ?propertyO
      }
    UNION
      { # Actual observation data
        ?cube     cube:observationSet  ?set .
        ?set      cube:observation     ?observationS .
        ?observationS
                  ?observationP        ?observationO
      }
}
Clone this wiki locally