|
|
@ -1,11 +1,15 @@
|
|
|
|
(ns wanijo.instance.domain
|
|
|
|
(ns wanijo.instance.domain
|
|
|
|
(:require [clojure.spec.alpha :as spec]
|
|
|
|
(:require [clojure.spec.alpha :as spec]
|
|
|
|
|
|
|
|
[clojure.spec.test.alpha :as spectest]
|
|
|
|
[wanijo.framework.neo4j :as neo4j]
|
|
|
|
[wanijo.framework.neo4j :as neo4j]
|
|
|
|
[clojure.pprint :as pprint]))
|
|
|
|
[clojure.pprint :as pprint]))
|
|
|
|
|
|
|
|
|
|
|
|
(spec/def ::created-at ::neo4j/date-str)
|
|
|
|
(spec/def ::created-at ::neo4j/date-str)
|
|
|
|
(spec/def ::updated-at ::neo4j/date-str)
|
|
|
|
(spec/def ::updated-at ::neo4j/date-str)
|
|
|
|
(spec/def ::name (spec/and (complement empty?) string?))
|
|
|
|
(spec/def ::name (spec/and (complement empty?) string?))
|
|
|
|
|
|
|
|
(spec/def ::value (some-fn string? boolean? nil? number?))
|
|
|
|
|
|
|
|
(spec/def ::instance_uuid ::neo4j/uuid)
|
|
|
|
|
|
|
|
(spec/def ::attribute_uuid ::neo4j/uuid)
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery findy-by-schema
|
|
|
|
(neo4j/defquery findy-by-schema
|
|
|
|
"MATCH (i:instance)-[:of]->(s:schema)
|
|
|
|
"MATCH (i:instance)-[:of]->(s:schema)
|
|
|
@ -115,6 +119,18 @@
|
|
|
|
:attribute_uuid (-> prop :attribute :uuid)}]))
|
|
|
|
:attribute_uuid (-> prop :attribute :uuid)}]))
|
|
|
|
(:properties instance)))
|
|
|
|
(:properties instance)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(spec/def ::prop-tuple-values
|
|
|
|
|
|
|
|
(spec/keys :req-un [::neo4j/uuid
|
|
|
|
|
|
|
|
::neo4j/date-str
|
|
|
|
|
|
|
|
::value
|
|
|
|
|
|
|
|
::instance_uuid
|
|
|
|
|
|
|
|
::attribute_uuid]))
|
|
|
|
|
|
|
|
(spec/def ::prop-tuple
|
|
|
|
|
|
|
|
(spec/tuple fn? ::prop-tuple-values))
|
|
|
|
|
|
|
|
(spec/fdef instance->prop-tuples
|
|
|
|
|
|
|
|
:ret (spec/coll-of ::prop-tuple))
|
|
|
|
|
|
|
|
(spectest/instrument `instance->prop-tuples)
|
|
|
|
|
|
|
|
|
|
|
|
(defn edit! [instance]
|
|
|
|
(defn edit! [instance]
|
|
|
|
(let [prop-tuples (instance->prop-tuples instance)]
|
|
|
|
(let [prop-tuples (instance->prop-tuples instance)]
|
|
|
|
(apply neo4j/exec-queries!
|
|
|
|
(apply neo4j/exec-queries!
|
|
|
|