Line 2: |
Line 2: |
| -- Module:SMW | | -- Module:SMW |
| local p = {} | | local p = {} |
− | | + | local linkedwiki = require 'linkedwiki' |
| function p.GetProcessesGraph() | | function p.GetProcessesGraph() |
| local process_types = {"LabProcess:OSL9a645a64b15442398ad3c057e1b64d87", "LabProcess:OSL4c1f7444e389471a8250f53407191735", "LabProcess:OSLd0c734a239844a0d8820856add12aeca"} | | local process_types = {"LabProcess:OSL9a645a64b15442398ad3c057e1b64d87", "LabProcess:OSL4c1f7444e389471a8250f53407191735", "LabProcess:OSLd0c734a239844a0d8820856add12aeca"} |
Line 191: |
Line 191: |
| end | | end |
| | | |
| + | function p.GetProcessObjectsSPARQL(process_types) |
| + | --local process_types = {"LabProcess:OSL9a645a64b15442398ad3c057e1b64d87", "LabProcess:OSL4c1f7444e389471a8250f53407191735", "LabProcess:OSLd0c734a239844a0d8820856add12aeca"} |
| + | local object = linkedwiki.new() |
| + | object:setConfig("https://kiprobatt.de") |
| + | mw.log(object:getConfig()) |
| + | |
| + | local query = [[ |
| + | PREFIX dc: <http://purl.org/dc/elements/1.1/> |
| + | PREFIX property: <https://kiprobatt.de/id/Property-3A> |
| + | PREFIX file: <https://kiprobatt.de/id/File-3A> |
| + | PREFIX category: <https://kiprobatt.de/id/Category-3A> |
| + | PREFIX material: <https://kiprobatt.de/id/Material-3A> |
| + | PREFIX process: <https://kiprobatt.de/id/LabProcess-3A> |
| + | PREFIX wiki: <https://kiprobatt.de/id/> |
| + | PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> |
| + | PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> |
| + | PREFIX owl: <http://www.w3.org/2002/07/owl#> |
| + | PREFIX swivt: <http://semantic-mediawiki.org/swivt/1.0#> |
| + | PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> |
| + | |
| + | SELECT ?id ?local_id ?label ?successor_object_semistatic ?successor_object ?process_output ?successor_object_static ?category ?type |
| + | WHERE { |
| + | ?id ^property:HasObject/property:IsInstanceOf process:OSLd0c734a239844a0d8820856add12aeca |
| + | optional { ?id property:HasId ?local_id } |
| + | optional { ?id property:Display_title_of ?label } |
| + | optional { ?id ^property:HasPredecessor/property:IsProcessParameterOf/property:HasOutput ?successor_object_semistatic } |
| + | optional { ?id ^property:HasPredecessor/property:IsObjectParameterOf ?successor_object } |
| + | optional { ?id ^property:HasObject/^property:IsOutputOf ?process_output } |
| + | optional { ?id ^property:HasInput/property:HasOutput ?successor_object_static } |
| + | optional { ?id rdf:type ?category } |
| + | optional { ?id property:IsInstanceOf ?type } |
| + | } |
| + | LIMIT 10000 |
| + | ]] |
| + | |
| + | local rtbl = object:query( query ) |
| + | mw.logObject(rtbl) |
| + | while( row ~= nil ) |
| + | do |
| + | if row['subject_label'] then --set subject label |
| + | text = text .. '"' .. row['subject'] .. '"' .. '[label="'.. row['subject_label'] .. '" href="' .. row['subject'] .. '"]' .. newline |
| + | end |
| + | i = i + 1 |
| + | row = rtbl['result']['rows'][i] |
| + | end |
| + | return result |
| + | end |
| -- expands single values for properties to tables with len 1 | | -- expands single values for properties to tables with len 1 |
| function p.toTable(v) | | function p.toTable(v) |