change links from simple relationships to nodes

integration-tests
Josha von Gizycki 6 years ago
parent 06b049f0ff
commit 962ff1310a

@ -124,15 +124,17 @@
(neo4j/exec-query! delete {:uuid uuid}))
(neo4j/defquery create-link
"MATCH (i:instance {uuid:{instance_uuid}}),
(i2)
WHERE i2.uuid IN {instance_uuids}
CREATE (i)-[:link {name:{name},
created_at:{created_at}}]->(i2)")
(defn create-link! [instance-uuid name instance-uuids]
"MATCH (i:instance {uuid:{from}}),
(u:user {uuid:{by}}),
(t:instance)
WHERE t.uuid IN {to}
CREATE (l:link {uuid:{uuid}})-[:created_by]->(u)
SET l.created_at = {created_at},
l.name = {name}
CREATE (i)<-[:link_from]-(l)-[:link_to]->(t)")
(defn create-link! [link]
(neo4j/exec-query! create-link
{:instance_uuid instance-uuid
:name name
:created_at (neo4j/now-str)
:instance_uuids instance-uuids}))
(assoc link
:uuid (neo4j/uuid)
:created_at (neo4j/now-str))))

@ -88,9 +88,10 @@
(let [form (link-form! schema-uuid)]
(if (form/valid? form req)
(let [form-data (form/form-data form req)]
(domain/create-link! uuid
(:name form-data)
(:instances form-data))
(domain/create-link! {:from uuid
:name (:name form-data)
:to (:instances form-data)
:by (get-in req [:session :uuid])})
(resp/redirect (path :instance-show {:uuid uuid})))
(link-selection! uuid schema-uuid req))))

Loading…
Cancel
Save