Difference between revisions of "Template:SPARQLhierarchy"

From Wikibase Personal data
Jump to navigation Jump to search
m (Podehaye moved page SPARQLhierarchy to Template:SPARQLhierarchy)
 
Line 1: Line 1:
 
PREFIX pdio: <http://wiki.personaldata.io/entity/>
 
PREFIX pdiot: <http://wiki.personaldata.io/prop/direct/>
 
PREFIX pdiop: <http://wiki.personaldata.io/prop/>
 
PREFIX pdiops: <http://wiki.personaldata.io/prop/statement/>
 
PREFIX pdiopq: <http://wiki.personaldata.io/prop/qualifier/>
 
 
 
 
#defaultView:Graph
 
#defaultView:Graph
 
SELECT ?item1 ?item1Label ?rgb ?item2 ?item2Label ?link
 
SELECT ?item1 ?item1Label ?rgb ?item2 ?item2Label ?link

Latest revision as of 03:22, 21 May 2019

  1. defaultView:Graph

SELECT ?item1 ?item1Label ?rgb ?item2 ?item2Label ?link WITH {SELECT ?nodeType ?nodeRGB WHERE {

   pdio:{{{visualization}}} pdiop:P26 ?nodeTypeStatement.
   ?nodeTypeStatement pdiops:P26 ?nodeType.
   OPTIONAL {
     ?nodeTypeStatement pdiopq:P115 ?nodeRGB
   }
 }

} AS %nodeTypes WITH {SELECT ?edgeTypeDomain ?edgeTypeRange ?edgeType ?rgb WHERE {

   pdio:Q803 pdiop:P117 ?edgeTypeStatement.
   ?edgeTypeStatement pdiops:P117 ?edgeType.
   ?edgeTypeStatement pdiopq:P24 ?edgeTypeDomain.
   ?edgeTypeStatement pdiopq:P23 ?edgeTypeRange.
   OPTIONAL {
     ?edgeTypeStatement pdiopq:P115 ?rgb     
   }
 }

} AS %edgeTypes WITH {SELECT ?node ?nodeType ?nodeRGB WHERE {

   ?node pdiot:{{{predicate}}} pdio:{{{value}}}.
   ?node pdiot:P3 ?nodeType.
   INCLUDE %nodeTypes.
 }

} AS %nodes WITH {SELECT ?domain ?range ?rgb WHERE {

   INCLUDE %edgeTypes.
   ?domain pdiot:P3 ?edgeTypeDomain.
   ?range pdiot:P3 ?edgeTypeRange.
   ?edgeType pdiot:P105 ?Pid.
   BIND(URI(CONCAT("http://wiki.personaldata.io/prop/direct/", ?Pid)) AS ?link).
   ?domain ?link ?range.
   ?domain pdiot:{{{predicate}}} pdio:{{{value}}}.       # This is filtering for each edge twice, potentially a huge waste: |E|*|V| instead of |V|
   ?range pdiot:{{{predicate}}} pdio:{{{value}}}.
 }

} AS %edges WHERE {

 {  
    INCLUDE %nodeTypes.
    BIND(?nodeType AS ?item1).
    BIND(?nodeRGB AS ?rgb).
 }
 UNION
 {  
    INCLUDE %edgeTypes.
    BIND(?edgeTypeDomain AS ?item1).
    BIND(?edgeTypeRange AS ?item2).
 }
 UNION
 {  
    INCLUDE %nodes.
    BIND(?node AS ?item1).
    BIND(?nodeRGB AS ?rgb).
 }
 UNION
 {  
    INCLUDE %edges.
    BIND(?domain AS ?item1).
    BIND(?range AS ?item2).
 }
 SERVICE wikibase:label {
   bd:serviceParam wikibase:language "en" . 
 }

} LIMIT 10000