Showing
1 changed file
with
396 additions
and
0 deletions
www.reportinghub.no/swp/swon.ui.ttl
0 → 100644
| 1 | +# baseURI: http://uispin.org/swon | ||
| 2 | +# imports: http://uispin.org/ui | ||
| 3 | + | ||
| 4 | +@prefix arg: <http://spinrdf.org/arg#> . | ||
| 5 | +@prefix let: <http://uispin.org/let#> . | ||
| 6 | +@prefix letrs: <http://uispin.org/letrs#> . | ||
| 7 | +@prefix owl: <http://www.w3.org/2002/07/owl#> . | ||
| 8 | +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
| 9 | +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
| 10 | +@prefix sp: <http://spinrdf.org/sp#> . | ||
| 11 | +@prefix spif: <http://spinrdf.org/spif#> . | ||
| 12 | +@prefix spin: <http://spinrdf.org/spin#> . | ||
| 13 | +@prefix spl: <http://spinrdf.org/spl#> . | ||
| 14 | +@prefix spr: <http://spinrdf.org/spr#> . | ||
| 15 | +@prefix swon: <http://uispin.org/swon#> . | ||
| 16 | +@prefix ui: <http://uispin.org/ui#> . | ||
| 17 | +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
| 18 | + | ||
| 19 | +arg:labelFunction | ||
| 20 | + rdf:type rdf:Property ; | ||
| 21 | + rdfs:label "label function"^^xsd:string ; | ||
| 22 | + rdfs:subPropertyOf sp:arg . | ||
| 23 | + | ||
| 24 | +arg:name | ||
| 25 | + rdf:type rdf:Property ; | ||
| 26 | + rdfs:label "name"^^xsd:string ; | ||
| 27 | + rdfs:subPropertyOf sp:arg . | ||
| 28 | + | ||
| 29 | +arg:resultSet | ||
| 30 | + rdf:type rdf:Property ; | ||
| 31 | + rdfs:label "result set"^^xsd:string ; | ||
| 32 | + rdfs:subPropertyOf ui:resultSet . | ||
| 33 | + | ||
| 34 | +arg:rowIndex | ||
| 35 | + rdf:type rdf:Property ; | ||
| 36 | + rdfs:label "row index"^^xsd:string ; | ||
| 37 | + rdfs:subPropertyOf sp:arg . | ||
| 38 | + | ||
| 39 | +arg:value | ||
| 40 | + rdf:type rdf:Property ; | ||
| 41 | + rdfs:label "value"^^xsd:string ; | ||
| 42 | + rdfs:subPropertyOf sp:arg . | ||
| 43 | + | ||
| 44 | +<http://uispin.org/swon> | ||
| 45 | + rdf:type owl:Ontology ; | ||
| 46 | + rdfs:comment "A library of SWP elements for creating JSON text output."^^xsd:string ; | ||
| 47 | + owl:imports <http://uispin.org/ui> ; | ||
| 48 | + owl:versionInfo "0.1.0"^^xsd:string . | ||
| 49 | + | ||
| 50 | +swon:Elements | ||
| 51 | + rdf:type ui:NodeClass ; | ||
| 52 | + rdfs:comment "Abstract superclass of the JSON elements."^^xsd:string ; | ||
| 53 | + rdfs:label "JSON Elements"^^xsd:string ; | ||
| 54 | + rdfs:subClassOf ui:Element ; | ||
| 55 | + spin:constraint | ||
| 56 | + [ rdf:type spl:Argument ; | ||
| 57 | + rdfs:comment "An option function that can be used to transform the values before they are inserted into the name-value pairs. A typical use case is to use ui:label."^^xsd:string ; | ||
| 58 | + spl:optional "true"^^xsd:boolean ; | ||
| 59 | + spl:predicate arg:labelFunction ; | ||
| 60 | + spl:valueType spin:Function | ||
| 61 | + ] ; | ||
| 62 | + ui:abstract "true"^^xsd:boolean . | ||
| 63 | + | ||
| 64 | +swon:ForEachResultSetColumnIndex | ||
| 65 | + rdf:type spin:SelectTemplate ; | ||
| 66 | + rdfs:label "For each result set column index"^^xsd:string ; | ||
| 67 | + rdfs:subClassOf spin:SelectTemplates ; | ||
| 68 | + spin:body | ||
| 69 | + [ rdf:type sp:Select ; | ||
| 70 | + sp:resultVariables ([ sp:varName "colIndex"^^xsd:string | ||
| 71 | + ]) ; | ||
| 72 | + sp:where ([ sp:object | ||
| 73 | + [ sp:varName "colIndex"^^xsd:string | ||
| 74 | + ] ; | ||
| 75 | + sp:predicate spr:colIndices ; | ||
| 76 | + sp:subject | ||
| 77 | + [ sp:varName "resultSet"^^xsd:string | ||
| 78 | + ] | ||
| 79 | + ]) | ||
| 80 | + ] ; | ||
| 81 | + spin:constraint | ||
| 82 | + [ rdf:type spl:Argument ; | ||
| 83 | + rdfs:comment "The result set to get all column indices of."^^xsd:string ; | ||
| 84 | + spl:predicate arg:resultSet ; | ||
| 85 | + spl:valueType sp:Select | ||
| 86 | + ] . | ||
| 87 | + | ||
| 88 | +swon:ForEachResultSetRowIndex | ||
| 89 | + rdf:type spin:SelectTemplate ; | ||
| 90 | + rdfs:label "For each result set row index"^^xsd:string ; | ||
| 91 | + rdfs:subClassOf spin:SelectTemplates ; | ||
| 92 | + spin:body | ||
| 93 | + [ rdf:type sp:Select ; | ||
| 94 | + sp:resultVariables ([ sp:varName "rowIndex"^^xsd:string | ||
| 95 | + ]) ; | ||
| 96 | + sp:where ([ sp:object | ||
| 97 | + [ sp:varName "rowIndex"^^xsd:string | ||
| 98 | + ] ; | ||
| 99 | + sp:predicate spr:rowIndices ; | ||
| 100 | + sp:subject | ||
| 101 | + [ sp:varName "resultSet"^^xsd:string | ||
| 102 | + ] | ||
| 103 | + ]) | ||
| 104 | + ] ; | ||
| 105 | + spin:constraint | ||
| 106 | + [ rdf:type spl:Argument ; | ||
| 107 | + rdfs:comment "The result set to get all column indices of."^^xsd:string ; | ||
| 108 | + spl:predicate arg:resultSet ; | ||
| 109 | + spl:valueType sp:Select | ||
| 110 | + ] . | ||
| 111 | + | ||
| 112 | +swon:NameValuePair | ||
| 113 | + rdf:type ui:NodeClass ; | ||
| 114 | + rdfs:label "Name value pair"^^xsd:string ; | ||
| 115 | + rdfs:subClassOf swon:Elements ; | ||
| 116 | + spin:constraint | ||
| 117 | + [ rdf:type spl:Argument ; | ||
| 118 | + rdfs:comment "The name of the variable."^^xsd:string ; | ||
| 119 | + spl:predicate arg:name ; | ||
| 120 | + spl:valueType xsd:string | ||
| 121 | + ] ; | ||
| 122 | + spin:constraint | ||
| 123 | + [ rdf:type spl:Argument ; | ||
| 124 | + rdfs:comment "The value (will be rendered as null if unbound)."^^xsd:string ; | ||
| 125 | + spl:optional "true"^^xsd:boolean ; | ||
| 126 | + spl:predicate arg:value | ||
| 127 | + ] ; | ||
| 128 | + ui:prototype | ||
| 129 | + [ rdf:type ui:group ; | ||
| 130 | + ui:child | ||
| 131 | + [ rdf:type ui:TextNode ; | ||
| 132 | + ui:childIndex 0 ; | ||
| 133 | + ui:text "\""^^xsd:string | ||
| 134 | + ] ; | ||
| 135 | + ui:child | ||
| 136 | + [ rdf:type ui:TextNode ; | ||
| 137 | + ui:childIndex 1 ; | ||
| 138 | + ui:text [ sp:varName "name"^^xsd:string | ||
| 139 | + ] | ||
| 140 | + ] ; | ||
| 141 | + ui:child | ||
| 142 | + [ rdf:type ui:TextNode ; | ||
| 143 | + ui:childIndex 2 ; | ||
| 144 | + ui:text "\":"^^xsd:string | ||
| 145 | + ] ; | ||
| 146 | + ui:child | ||
| 147 | + [ rdf:type ui:if ; | ||
| 148 | + ui:child | ||
| 149 | + [ rdf:type ui:TextNode ; | ||
| 150 | + ui:childIndex 0 ; | ||
| 151 | + ui:text "\""^^xsd:string | ||
| 152 | + ] ; | ||
| 153 | + ui:child | ||
| 154 | + [ rdf:type ui:TextNode ; | ||
| 155 | + ui:childIndex 1 ; | ||
| 156 | + ui:text [ rdf:type ui:escapeJSON ; | ||
| 157 | + sp:arg1 [ rdf:type sp:if ; | ||
| 158 | + sp:arg1 [ rdf:type sp:bound ; | ||
| 159 | + sp:arg1 [ sp:varName "labelFunction"^^xsd:string | ||
| 160 | + ] | ||
| 161 | + ] ; | ||
| 162 | + sp:arg2 [ rdf:type spif:invoke ; | ||
| 163 | + sp:arg1 [ sp:varName "labelFunction"^^xsd:string | ||
| 164 | + ] ; | ||
| 165 | + sp:arg2 [ sp:varName "value"^^xsd:string | ||
| 166 | + ] | ||
| 167 | + ] ; | ||
| 168 | + sp:arg3 [ rdf:type xsd:string ; | ||
| 169 | + sp:arg1 [ sp:varName "value"^^xsd:string | ||
| 170 | + ] | ||
| 171 | + ] | ||
| 172 | + ] | ||
| 173 | + ] | ||
| 174 | + ] ; | ||
| 175 | + ui:child | ||
| 176 | + [ rdf:type ui:TextNode ; | ||
| 177 | + ui:childIndex 2 ; | ||
| 178 | + ui:text "\""^^xsd:string | ||
| 179 | + ] ; | ||
| 180 | + ui:childIndex 3 ; | ||
| 181 | + ui:condition | ||
| 182 | + [ rdf:type sp:bound ; | ||
| 183 | + sp:arg1 [ sp:varName "value"^^xsd:string | ||
| 184 | + ] | ||
| 185 | + ] | ||
| 186 | + ] ; | ||
| 187 | + ui:child | ||
| 188 | + [ rdf:type ui:else ; | ||
| 189 | + ui:child | ||
| 190 | + [ rdf:type ui:TextNode ; | ||
| 191 | + ui:childIndex 0 ; | ||
| 192 | + ui:text "null"^^xsd:string | ||
| 193 | + ] ; | ||
| 194 | + ui:childIndex 4 | ||
| 195 | + ] | ||
| 196 | + ] . | ||
| 197 | + | ||
| 198 | +swon:RSArray | ||
| 199 | + rdf:type ui:NodeClass ; | ||
| 200 | + rdfs:comment "Creates a simple JSON array with all values from the first column of a given result set, e.g. ['A','B','C']."^^xsd:string ; | ||
| 201 | + rdfs:label "RS Array"^^xsd:string ; | ||
| 202 | + rdfs:subClassOf swon:Elements ; | ||
| 203 | + spin:constraint | ||
| 204 | + [ rdf:type spl:Argument ; | ||
| 205 | + rdfs:comment "The result set to walk through."^^xsd:string ; | ||
| 206 | + spl:predicate arg:resultSet ; | ||
| 207 | + spl:valueType sp:Select | ||
| 208 | + ] ; | ||
| 209 | + ui:prototype | ||
| 210 | + [ rdf:type ui:call ; | ||
| 211 | + arg:resultSet | ||
| 212 | + [ sp:varName "resultSet"^^xsd:string | ||
| 213 | + ] ; | ||
| 214 | + ui:child | ||
| 215 | + [ rdf:type ui:TextNode ; | ||
| 216 | + ui:childIndex 0 ; | ||
| 217 | + ui:text "["^^xsd:string | ||
| 218 | + ] ; | ||
| 219 | + ui:child | ||
| 220 | + [ rdf:type ui:forEach ; | ||
| 221 | + ui:child | ||
| 222 | + [ rdf:type ui:group ; | ||
| 223 | + let:value | ||
| 224 | + [ rdf:type spr:cell ; | ||
| 225 | + sp:arg1 [ sp:varName "resultSet"^^xsd:string | ||
| 226 | + ] ; | ||
| 227 | + sp:arg2 [ sp:varName "rowIndex"^^xsd:string | ||
| 228 | + ] ; | ||
| 229 | + sp:arg3 0 | ||
| 230 | + ] ; | ||
| 231 | + ui:child | ||
| 232 | + [ rdf:type ui:TextNode ; | ||
| 233 | + ui:childIndex 0 ; | ||
| 234 | + ui:text "\""^^xsd:string | ||
| 235 | + ] ; | ||
| 236 | + ui:child | ||
| 237 | + [ rdf:type ui:TextNode ; | ||
| 238 | + ui:childIndex 1 ; | ||
| 239 | + ui:text [ rdf:type ui:escapeJSON ; | ||
| 240 | + sp:arg1 [ rdf:type sp:if ; | ||
| 241 | + sp:arg1 [ rdf:type sp:bound ; | ||
| 242 | + sp:arg1 [ sp:varName "labelFunction"^^xsd:string | ||
| 243 | + ] | ||
| 244 | + ] ; | ||
| 245 | + sp:arg2 [ rdf:type spif:invoke ; | ||
| 246 | + sp:arg1 [ sp:varName "labelFunction"^^xsd:string | ||
| 247 | + ] ; | ||
| 248 | + sp:arg2 [ sp:varName "value"^^xsd:string | ||
| 249 | + ] | ||
| 250 | + ] ; | ||
| 251 | + sp:arg3 [ rdf:type xsd:string ; | ||
| 252 | + sp:arg1 [ sp:varName "value"^^xsd:string | ||
| 253 | + ] | ||
| 254 | + ] | ||
| 255 | + ] | ||
| 256 | + ] | ||
| 257 | + ] ; | ||
| 258 | + ui:child | ||
| 259 | + [ rdf:type ui:TextNode ; | ||
| 260 | + ui:childIndex 2 ; | ||
| 261 | + ui:text "\""^^xsd:string | ||
| 262 | + ] ; | ||
| 263 | + ui:childIndex 0 | ||
| 264 | + ] ; | ||
| 265 | + ui:childIndex 1 ; | ||
| 266 | + ui:resultSet | ||
| 267 | + [ sp:varName "rs"^^xsd:string | ||
| 268 | + ] ; | ||
| 269 | + ui:separator ","^^xsd:string | ||
| 270 | + ] ; | ||
| 271 | + ui:child | ||
| 272 | + [ rdf:type ui:TextNode ; | ||
| 273 | + ui:childIndex 2 ; | ||
| 274 | + ui:text "]"^^xsd:string | ||
| 275 | + ] ; | ||
| 276 | + ui:template swon:ForEachResultSetRowIndex | ||
| 277 | + ] . | ||
| 278 | + | ||
| 279 | +swon:RSObject | ||
| 280 | + rdf:type ui:NodeClass ; | ||
| 281 | + rdfs:label "RS object"^^xsd:string ; | ||
| 282 | + rdfs:subClassOf swon:Elements ; | ||
| 283 | + spin:constraint | ||
| 284 | + [ rdf:type spl:Argument ; | ||
| 285 | + rdfs:comment "The result set containing the name-value pairs - the names are the result variables. If the optional row index isn't present, the system will use the first row."^^xsd:string ; | ||
| 286 | + spl:predicate arg:resultSet ; | ||
| 287 | + spl:valueType sp:Select | ||
| 288 | + ] ; | ||
| 289 | + spin:constraint | ||
| 290 | + [ rdf:type spl:Argument ; | ||
| 291 | + rdfs:comment "The (optional) row index to select the object."^^xsd:string ; | ||
| 292 | + spl:optional "true"^^xsd:boolean ; | ||
| 293 | + spl:predicate arg:rowIndex ; | ||
| 294 | + spl:valueType xsd:integer | ||
| 295 | + ] ; | ||
| 296 | + ui:prototype | ||
| 297 | + [ rdf:type ui:call ; | ||
| 298 | + arg:resultSet | ||
| 299 | + [ sp:varName "resultSet"^^xsd:string | ||
| 300 | + ] ; | ||
| 301 | + ui:child | ||
| 302 | + [ rdf:type ui:TextNode ; | ||
| 303 | + ui:childIndex 0 ; | ||
| 304 | + ui:text "{"^^xsd:string | ||
| 305 | + ] ; | ||
| 306 | + ui:child | ||
| 307 | + [ rdf:type ui:forEach ; | ||
| 308 | + ui:child | ||
| 309 | + [ rdf:type swon:NameValuePair ; | ||
| 310 | + arg:labelFunction | ||
| 311 | + [ sp:varName "labelFunction"^^xsd:string | ||
| 312 | + ] ; | ||
| 313 | + arg:name | ||
| 314 | + [ rdf:type spr:colName ; | ||
| 315 | + sp:arg1 [ sp:varName "resultSet"^^xsd:string | ||
| 316 | + ] ; | ||
| 317 | + sp:arg2 [ sp:varName "colIndex"^^xsd:string | ||
| 318 | + ] | ||
| 319 | + ] ; | ||
| 320 | + arg:value | ||
| 321 | + [ rdf:type spr:cell ; | ||
| 322 | + sp:arg1 [ sp:varName "resultSet"^^xsd:string | ||
| 323 | + ] ; | ||
| 324 | + sp:arg2 [ rdf:type sp:coalesce ; | ||
| 325 | + sp:arg1 [ sp:varName "rowIndex"^^xsd:string | ||
| 326 | + ] ; | ||
| 327 | + sp:arg2 0 | ||
| 328 | + ] ; | ||
| 329 | + sp:arg3 [ sp:varName "colIndex"^^xsd:string | ||
| 330 | + ] | ||
| 331 | + ] ; | ||
| 332 | + ui:childIndex 0 | ||
| 333 | + ] ; | ||
| 334 | + ui:childIndex 1 ; | ||
| 335 | + ui:resultSet | ||
| 336 | + [ sp:varName "rs"^^xsd:string | ||
| 337 | + ] ; | ||
| 338 | + ui:separator ","^^xsd:string | ||
| 339 | + ] ; | ||
| 340 | + ui:child | ||
| 341 | + [ rdf:type ui:TextNode ; | ||
| 342 | + ui:childIndex 2 ; | ||
| 343 | + ui:text "}"^^xsd:string | ||
| 344 | + ] ; | ||
| 345 | + ui:template swon:ForEachResultSetColumnIndex | ||
| 346 | + ] . | ||
| 347 | + | ||
| 348 | +swon:RSObjectArray | ||
| 349 | + rdf:type ui:NodeClass ; | ||
| 350 | + rdfs:comment "Creates a JSON array from a result set where each item is a swon:RSObject, with fields for each variable."^^xsd:string ; | ||
| 351 | + rdfs:label "RS object array"^^xsd:string ; | ||
| 352 | + rdfs:subClassOf swon:Elements ; | ||
| 353 | + spin:constraint | ||
| 354 | + [ rdf:type spl:Argument ; | ||
| 355 | + rdfs:comment "The result set delivering the rows."^^xsd:string ; | ||
| 356 | + spl:predicate arg:resultSet ; | ||
| 357 | + spl:valueType sp:Select | ||
| 358 | + ] ; | ||
| 359 | + ui:prototype | ||
| 360 | + [ rdf:type ui:call ; | ||
| 361 | + arg:resultSet | ||
| 362 | + [ sp:varName "resultSet"^^xsd:string | ||
| 363 | + ] ; | ||
| 364 | + ui:child | ||
| 365 | + [ rdf:type ui:TextNode ; | ||
| 366 | + ui:childIndex 0 ; | ||
| 367 | + ui:text "["^^xsd:string | ||
| 368 | + ] ; | ||
| 369 | + ui:child | ||
| 370 | + [ rdf:type ui:forEach ; | ||
| 371 | + ui:child | ||
| 372 | + [ rdf:type swon:RSObject ; | ||
| 373 | + arg:labelFunction | ||
| 374 | + [ sp:varName "labelFunction"^^xsd:string | ||
| 375 | + ] ; | ||
| 376 | + arg:resultSet | ||
| 377 | + [ sp:varName "resultSet"^^xsd:string | ||
| 378 | + ] ; | ||
| 379 | + arg:rowIndex | ||
| 380 | + [ sp:varName "rowIndex"^^xsd:string | ||
| 381 | + ] ; | ||
| 382 | + ui:childIndex 0 | ||
| 383 | + ] ; | ||
| 384 | + ui:childIndex 1 ; | ||
| 385 | + ui:resultSet | ||
| 386 | + [ sp:varName "rs"^^xsd:string | ||
| 387 | + ] ; | ||
| 388 | + ui:separator ","^^xsd:string | ||
| 389 | + ] ; | ||
| 390 | + ui:child | ||
| 391 | + [ rdf:type ui:TextNode ; | ||
| 392 | + ui:childIndex 2 ; | ||
| 393 | + ui:text "]"^^xsd:string | ||
| 394 | + ] ; | ||
| 395 | + ui:template swon:ForEachResultSetRowIndex | ||
| 396 | + ] . |
-
Please register or login to post a comment