130 uri_labels.update(get_labels_for_uris([s.uri for s in self.object.otherLanguages.all()], "http://www.iiep.unesco.org/plan4learning/scheme/Languages", lang, False)) |
132 uri_labels.update(get_labels_for_uris([s.uri for s in self.object.otherLanguages.all()], "http://www.iiep.unesco.org/plan4learning/scheme/Languages", lang, False)) |
131 uri_labels.update(get_labels_for_uris([s.uri for s in self.object.projectNames.all()], "http://www.iiep.unesco.org/plan4learning/scheme/Projects", None, True)) |
133 uri_labels.update(get_labels_for_uris([s.uri for s in self.object.projectNames.all()], "http://www.iiep.unesco.org/plan4learning/scheme/Projects", None, True)) |
132 uri_labels.update(get_labels_for_uris([s.uri for s in self.object.subjectCorporateBodies.all()], "http://www.iiep.unesco.org/plan4learning/scheme/Organizations", None, True)) |
134 uri_labels.update(get_labels_for_uris([s.uri for s in self.object.subjectCorporateBodies.all()], "http://www.iiep.unesco.org/plan4learning/scheme/Organizations", None, True)) |
133 uri_labels.update(get_labels_for_uris([s.uri for s in self.object.corporateAuthors.all()], "http://www.iiep.unesco.org/plan4learning/scheme/Organizations", None, True)) |
135 uri_labels.update(get_labels_for_uris([s.uri for s in self.object.corporateAuthors.all()], "http://www.iiep.unesco.org/plan4learning/scheme/Organizations", None, True)) |
134 uri_labels.update(get_labels_for_uris([self.object.recordType] if self.object.recordType else [], "http://www.iiep.unesco.org/plan4learning/scheme/DocumentType", lang, False)) |
136 uri_labels.update(get_labels_for_uris([self.object.recordType] if self.object.recordType else [], "http://www.iiep.unesco.org/plan4learning/scheme/DocumentType", lang, False)) |
135 |
|
136 context['uri_labels'] = json.dumps(uri_labels) |
137 context['uri_labels'] = json.dumps(uri_labels) |
137 |
138 |
|
139 context['subjects_query_dict'] = json.dumps({ |
|
140 'data-url': settings.SPARQL_QUERY_ENDPOINT, |
|
141 'data-query': |
|
142 """ |
|
143 PREFIX skos:<http://www.w3.org/2004/02/skos/core#> |
|
144 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> |
|
145 PREFIX owl:<http://www.w3.org/2002/07/owl#> |
|
146 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> |
|
147 SELECT DISTINCT ?uri ?label |
|
148 WHERE { |
|
149 ?uri a skos:Concept. |
|
150 ?uri skos:inScheme <http://skos.um.es/unescothes/CS000> . |
|
151 ?uri skos:prefLabel ?label. |
|
152 FILTER (lang(?label) = ?language). |
|
153 ?uri skos:prefLabel ?lab. |
|
154 FILTER regex (str(?lab), ?reg, 'i'). |
|
155 FILTER (lang (?lab) = ?language). |
|
156 BIND (STRLEN(STRBEFORE (str(?lab), ?reg)) AS ?place). |
|
157 BIND (STRLEN(STR(?lab)) AS ?len) |
|
158 } |
|
159 ORDER BY ?place ?len ?lab |
|
160 """, |
|
161 'data-root-query': |
|
162 """ |
|
163 PREFIX skos:<http://www.w3.org/2004/02/skos/core#> |
|
164 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> |
|
165 PREFIX owl:<http://www.w3.org/2002/07/owl#> |
|
166 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> |
|
167 SELECT DISTINCT ?uri ?label |
|
168 WHERE { |
|
169 ?uri a skos:Collection ; |
|
170 skos:inScheme <http://skos.um.es/unescothes/CS000> ; |
|
171 rdfs:label ?label . |
|
172 FILTER (lang(?label) = ?language). |
|
173 FILTER NOT EXISTS { [skos:member ?uri] } |
|
174 } |
|
175 """, |
|
176 'data-childs-query': |
|
177 """ |
|
178 PREFIX skos:<http://www.w3.org/2004/02/skos/core#> |
|
179 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> |
|
180 PREFIX owl:<http://www.w3.org/2002/07/owl#> |
|
181 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> |
|
182 SELECT DISTINCT ?uri ?label |
|
183 WHERE { |
|
184 ?uri skos:inScheme <http://skos.um.es/unescothes/CS000> . |
|
185 { ?uri a ?type |
|
186 FILTER (?type = skos:Collection || ?type = skos:Concept) }. |
|
187 ?root skos:narrower|skos:member ?uri. |
|
188 ?uri skos:prefLabel|rdfs:label ?label. |
|
189 FILTER (lang(?label) = ?language). |
|
190 } |
|
191 """, |
|
192 'data-child-count-query': |
|
193 """ |
|
194 PREFIX skos:<http://www.w3.org/2004/02/skos/core#> |
|
195 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> |
|
196 PREFIX owl:<http://www.w3.org/2002/07/owl#> |
|
197 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> |
|
198 SELECT (COUNT(?uri) as ?nb) |
|
199 WHERE { |
|
200 ?uri skos:inScheme <http://skos.um.es/unescothes/CS000> . |
|
201 ?root skos:narrower|skos:member ?uri. |
|
202 } |
|
203 """ |
|
204 }) |
|
205 |
138 return context |
206 return context |
139 |
207 |
140 |
208 |