| Line 15: |
Line 15: |
| | rankdir=LR | | rankdir=LR |
| | ]] | | ]] |
| | + | local edges = "" |
| | for id,process in pairs(result) do | | for id,process in pairs(result) do |
| | --mw.logObject(process) | | --mw.logObject(process) |
| | local nodes = "" | | local nodes = "" |
| − | local edges = "" | + | local nodes2 = "" |
| | + | |
| | for obj_id, obj in pairs(process['objects']) do | | for obj_id, obj in pairs(process['objects']) do |
| | | | |
| | if p.IsGlobalObject(obj) then | | if p.IsGlobalObject(obj) then |
| − | nodes = nodes .. '"' .. obj_id .. '" [label="' .. obj['local_id'] .. '" href="/wiki/' .. obj_id .. '"];'
| |
| − | end
| |
| | local successors = nil | | local successors = nil |
| − | successors = p.concatTables(obj['successor_object'], obj['successor_object_semistatic']) | + | successors = p.concatTables(obj['successor_object'], obj['successor_object_static']) |
| − | successors = p.concatTables(successors, obj['successor_object_static']) | + | --if (successors == nil) then successors = p.toTable(obj['successor_object_semistatic']) end |
| | + | if (successors == nil and p.tableContains(p.toTable(obj['process_output']),obj_id) == false) then successors = p.toTable(obj['process_output']) end |
| | successors = p.removeDuplicates(successors) | | successors = p.removeDuplicates(successors) |
| | obj['successors'] = successors | | obj['successors'] = successors |
| Line 37: |
Line 38: |
| | -- if (p.tablelength(_successors) == 1) then successors = _successors end | | -- if (p.tablelength(_successors) == 1) then successors = _successors end |
| | --end | | --end |
| | + | local color = "black" |
| | if (successors ~= nil) then | | if (successors ~= nil) then |
| | + | color = "green" |
| | for succ_id, succ in pairs(successors) do | | for succ_id, succ in pairs(successors) do |
| | edges = edges .. '"' .. obj_id .. '" -> "' .. succ .. '";' | | edges = edges .. '"' .. obj_id .. '" -> "' .. succ .. '";' |
| | end | | end |
| | + | nodes2 = nodes2 .. '"' .. obj_id .. '" [color=' .. color .. ' label="' .. obj['label'] .. '" href="/wiki/' .. obj_id .. '"];' |
| | + | else |
| | + | nodes = nodes .. '"' .. obj_id .. '" [color=' .. color .. ' label="' .. obj['label'] .. '" href="/wiki/' .. obj_id .. '"];' |
| | + | end |
| | end | | end |
| − |
| |
| | end | | end |
| | g = g .. [[ | | g = g .. [[ |
| | subgraph cluster_]] .. id:gsub(":","_") .. [[ { | | subgraph cluster_]] .. id:gsub(":","_") .. [[ { |
| − | node [style=filled]; | + | node [shape=rect]; |
| | label = "]] .. process['label'] .. [["; | | label = "]] .. process['label'] .. [["; |
| | color=blue; | | color=blue; |
| | ]] .. nodes .. [[ | | ]] .. nodes .. [[ |
| | + | ]] .. nodes2 .. [[ |
| | | | |
| | } | | } |
| − | ]] .. edges .. [[
| |
| | | | |
| | ]] | | ]] |
| | end | | end |
| | g = g .. [[ | | g = g .. [[ |
| | + | |
| | + | ]] .. edges .. [[ |
| | + | |
| | }]] | | }]] |
| | d:wikitext(g) | | d:wikitext(g) |
| Line 108: |
Line 117: |
| | local isGlobal = p.IsGlobalObject(obj) | | local isGlobal = p.IsGlobalObject(obj) |
| | if isGlobal == false then | | if isGlobal == false then |
| − | mw.log("Follow " .. obj_id) | + | --mw.log("Follow " .. obj_id) |
| | p.concatTables(result,p.GetNextGlobalObject(dataset, obj)) | | p.concatTables(result,p.GetNextGlobalObject(dataset, obj)) |
| | elseif (succ ~= nil) then | | elseif (succ ~= nil) then |
| − | mw.log("Found " .. succ) | + | --mw.log("Found " .. succ) |
| | table.insert(result, succ) | | table.insert(result, succ) |
| | end | | end |
| Line 123: |
Line 132: |
| | function p.IsGlobalObject(obj) | | function p.IsGlobalObject(obj) |
| | local isGlobal = false | | local isGlobal = false |
| − | for type_id, type in pairs(obj['type']) do | + | local visible_types = {"Material:OSL344e5c0f20e04894abe53678e2f68351"} |
| − | if (type == "Category:LabProcessOutput") then isGlobal = true end | + | for category_id, category in pairs(p.toTable(obj['category'])) do |
| | + | if (category == "Category:LabProcessOutput") then isGlobal = true end |
| | + | end |
| | + | if (obj['type'] ~= nil) then |
| | + | for obj_type_id, obj_type in pairs(p.toTable(obj['type'])) do |
| | + | for vis_type_id, vis_type in pairs(p.toTable(visible_types)) do |
| | + | if (obj_type == vis_type) then isGlobal = true end |
| | + | end |
| | + | end |
| | end | | end |
| | return isGlobal | | return isGlobal |
| Line 137: |
Line 154: |
| | |?#-=id | | |?#-=id |
| | |?HasId#-=local_id | | |?HasId#-=local_id |
| | + | |?Display title of#-=label |
| | |?-HasPredecessor#-=successor_param | | |?-HasPredecessor#-=successor_param |
| | |?-HasPredecessor.IsProcessParameterOf#-=successor_subprocess | | |?-HasPredecessor.IsProcessParameterOf#-=successor_subprocess |
| Line 157: |
Line 175: |
| | |?#-=id | | |?#-=id |
| | |?HasId#-=local_id | | |?HasId#-=local_id |
| | + | |?Display title of#-=label |
| | |?-HasPredecessor.IsProcessParameterOf.HasOutput#-=successor_object_semistatic | | |?-HasPredecessor.IsProcessParameterOf.HasOutput#-=successor_object_semistatic |
| | |?-HasPredecessor.IsObjectParameterOf#-=successor_object | | |?-HasPredecessor.IsObjectParameterOf#-=successor_object |
| | + | |?-Has subobject.-IsOutputOf#-=process_output |
| | |?-HasInput.HasOutput#-=successor_object_static | | |?-HasInput.HasOutput#-=successor_object_static |
| − | |?Category#-=type | + | |?Category#-=category |
| | + | |?IsInstanceOf#-=type |
| | |format=plain | | |format=plain |
| | |limit=10000 | | |limit=10000 |
| Line 196: |
Line 217: |
| | end | | end |
| | return t1 | | return t1 |
| | + | end |
| | + | |
| | + | function p.tableContains(t,v) |
| | + | if (t == nil or v == nil) then return false end |
| | + | local contained = false |
| | + | for _,_v in ipairs(t) do |
| | + | if (_v == v) then contained = true end |
| | + | end |
| | + | return contained |
| | end | | end |
| | | | |