← Return to the example · Supporting files

2020 02 petri net tasks LR.cypher

CREATE CONSTRAINT ON (node:`UNIQUE IMPORT LABEL`) ASSERT (node.`UNIQUE IMPORT ID`) IS UNIQUE;
UNWIND [{_id:49, properties:{identity:"Prepare Waste extraction plan", transition_type:"Task"}}, {_id:103, properties:{identity:"Identify waste", transition_type:"Task"}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n += row.properties SET n:Transition;
UNWIND [{_id:46, properties:{identity:"Plan agreed", resource_type:"State", token:1}}, {_id:47, properties:{identity:"Operator", resource_type:"Role", token:5}}, {_id:102, properties:{identity:"Engineer", resource_type:"Role", token:10}}, {_id:116, properties:{identity:"Waste understood", resource_type:"State", token:1}}] AS row
CREATE (n:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row._id}) SET n += row.properties SET n:Place;
UNWIND [{start: {_id:47}, end: {_id:103}, properties:{Consumed_tokens:5}}, {start: {_id:102}, end: {_id:49}, properties:{Consumed_tokens:10}}, {start: {_id:116}, end: {_id:49}, properties:{Consumed_tokens:0}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row.start._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row.end._id})
CREATE (start)-[r:ARC]->(end) SET r += row.properties;
UNWIND [{start: {_id:103}, end: {_id:116}, properties:{Produced_tokens:1}}, {start: {_id:49}, end: {_id:46}, properties:{Produced_tokens:1}}] AS row
MATCH (start:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row.start._id})
MATCH (end:`UNIQUE IMPORT LABEL`{`UNIQUE IMPORT ID`: row.end._id})
CREATE (start)-[r:ARC]->(end) SET r += row.properties;
MATCH (n:`UNIQUE IMPORT LABEL`)  WITH n LIMIT 20000 REMOVE n:`UNIQUE IMPORT LABEL` REMOVE n.`UNIQUE IMPORT ID`;
DROP CONSTRAINT ON (node:`UNIQUE IMPORT LABEL`) ASSERT (node.`UNIQUE IMPORT ID`) IS UNIQUE;