Skip to content

Manually removing published cube

Tomasz Pluskiewicz edited this page Nov 22, 2021 · 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/cube/identifier/version/> as ?cube )

  ?cube a cube:Cube .
  
  optional {
    ?cube ?p1 ?metaLevel1 .
  }
  
  optional {
    ?metaLevel1 ?p2 ?metaLevel2 .
    filter (isBlank(?metaLevel1))
  }

  optional {
    # Constraint Shape properties
    ?cube cube:observationConstraint ?shape .

    ?shape ?shapeP ?shapeO .
  }
  
  optional
  {
    # Property Shape properties need to be queried deep to get RDF Lists
    ?cube cube:observationConstraint/sh:property ?property .

    ?property (<>|!<>)* ?propertyS .
    ?propertyS ?propertyP ?propertyO .
  }
  
  optional
  {
    # Actual observation data
    ?cube cube:observationSet ?set .

    ?set cube:observation ?observationS .
    ?observationS ?observationP ?observationO .
  }
}
Clone this wiki locally