Anonymous

Changes

From KIproBatt Wiki
fix dimension, query for final process outputs
Line 4: Line 4:     
function p.GetProcessesGraph()
 
function p.GetProcessesGraph()
local process_types = {"LabProcess:OSL9a645a64b15442398ad3c057e1b64d87", "LabProcess:OSL4c1f7444e389471a8250f53407191735"}
+
local process_types = {"LabProcess:OSL9a645a64b15442398ad3c057e1b64d87", "LabProcess:OSL4c1f7444e389471a8250f53407191735", "LabProcess:OSLd0c734a239844a0d8820856add12aeca"}
 
local result = p.GetProcesses(process_types)
 
local result = p.GetProcesses(process_types)
 
--mw.logObject(result)
 
--mw.logObject(result)
Line 19: Line 19:  
local edges = ""
 
local edges = ""
 
for obj_id, obj in pairs(process['objects']) do
 
for obj_id, obj in pairs(process['objects']) do
nodes = nodes .. '"' .. obj_id .. '" [label="' .. obj['local_id'] .. '"];'  
+
nodes = nodes .. '"' .. obj_id .. '" [label="' .. obj['local_id'] .. '" href="https://kiprobatt.de/wiki/' .. obj_id .. '"];'  
 +
local successors = nil
 
if (obj['successor_object'] ~= nil) then  
 
if (obj['successor_object'] ~= nil) then  
for succ_id, succ in pairs(obj['successor_object']) do
+
successors = p.NormalizePropertyValue(obj['successor_object']);
 +
end
 +
if (obj['successor_process_output'] ~= nil) then
 +
_successors = p.NormalizePropertyValue(obj['successor_process_output']);
 +
if (p.tablelength(_successors) == 1) then successors = _successors end
 +
end
 +
if (successors ~= nil) then
 +
for succ_id, succ in pairs(successors) do
 
edges = edges .. '"' .. obj_id .. '" -> "' .. succ .. '";'  
 
edges = edges .. '"' .. obj_id .. '" -> "' .. succ .. '";'  
 
end
 
end
Line 75: Line 83:  
end
 
end
 
     end
 
     end
 
+
    --mw.logObject(results)
 
return results
 
return results
 
end
 
end
Line 84: Line 92:  
-- note also: unlinking via parameter link is not supported at this point
 
-- note also: unlinking via parameter link is not supported at this point
 
--local process_type = "LabProcess:OSL9a645a64b15442398ad3c057e1b64d87"
 
--local process_type = "LabProcess:OSL9a645a64b15442398ad3c057e1b64d87"
local query = "[[Category:LabProcessOutput]] [[-HasObject.IsInstanceOf::" .. process_type .. "]] |?#-=id |?HasId#-=local_id |?-HasPredecessor#-=successor_param |?-HasPredecessor.IsProcessParameterOf#-=successor_subprocess |?-HasPredecessor.IsObjectParameterOf#-=successor_object |?-HasPredecessor.IsProcessParameterOf.IsSubprocessOf#-=successor_process |format=plain"
+
local query = "[[Category:LabProcessOutput]] [[-HasObject.IsInstanceOf::" .. process_type .. "]] " .. [[
 +
|?#-=id  
 +
|?HasId#-=local_id  
 +
|?-HasPredecessor#-=successor_param  
 +
|?-HasPredecessor.IsProcessParameterOf#-=successor_subprocess  
 +
|?-HasPredecessor.IsObjectParameterOf#-=successor_object  
 +
|?-HasPredecessor.IsProcessParameterOf.IsSubprocessOf#-=successor_process  
 +
|?-HasPredecessor.IsProcessParameterOf.IsSubprocessOf.-IsOutputOf#-=successor_process_output
 +
|format=plain
 +
|limit=10000
 +
]]
 
local result = mw.smw.ask( query )
 
local result = mw.smw.ask( query )
 +
mw.logObject(result)
 
return result
 
return result
 +
end
 +
 +
-- expands single values for properties to tables with len 1
 +
function p.NormalizePropertyValue(v)
 +
if (type(v) ~= "table") then
 +
v = {v}
 +
end
 +
return v
 +
end
 +
 +
function p.tablelength(T)
 +
  local count = 0
 +
  for _ in pairs(T) do count = count + 1 end
 +
  return count
 
end
 
end
    
return p
 
return p
Bots, bulkpusher, Bureaucrats, checkuser, filepusher, Interface administrators, oversight, pusher, rdfioadministrator, rdfiocurator, Administrators (Semantic MediaWiki), Curators (Semantic MediaWiki), Editors (Semantic MediaWiki), Administrators
5,444

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.