src/p4l/settings.py
changeset 62 8433e12362e0
parent 61 305f9fcd409b
child 70 2ee11f57e318
--- a/src/p4l/settings.py	Tue Sep 10 16:54:29 2013 +0200
+++ b/src/p4l/settings.py	Tue Sep 10 17:51:25 2013 +0200
@@ -454,6 +454,41 @@
 }
 """
 }
+SPARQL_TYPE_QUERIES = {
+'filter' : """
+PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
+PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX owl:<http://www.w3.org/2002/07/owl#>
+PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
+SELECT DISTINCT ?uri ?label
+WHERE {
+    ?uri a skos:Concept.
+    ?uri skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/DocumentType> .
+    ?uri skos:prefLabel ?label.
+    FILTER (lang(?label) = %s).
+    ?uri skos:prefLabel ?lab.
+    FILTER regex (str(?lab), ?reg, 'i').
+    FILTER (lang (?lab) = %s).
+    BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place).
+    BIND (STRLEN(STR(?lab)) AS ?len)
+}
+ORDER BY ?place ?len ?lab
+""",
+'root' : """
+PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
+PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+PREFIX owl:<http://www.w3.org/2002/07/owl#>
+PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
+SELECT DISTINCT ?uri ?label
+WHERE {
+    ?uri a skos:Concept ;
+    skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/DocumentType> ;    
+    skos:prefLabel ?label .
+    FILTER (lang(?label) = %s). 
+    FILTER NOT EXISTS { [skos:narrower ?uri] }
+}
+"""
+}
 
 
 REST_FRAMEWORK = {