|
@@ -50,9 +50,20 @@ |
|
|
|
(conj accumulator [(first (last accumulator)) item next-sym] |
|
|
|
[next-sym component-id-attr component-id-attr-val]))) |
|
|
|
|
|
|
|
(defn namespace-attrs |
|
|
|
[attr-paths-lookup id-attr] |
|
|
|
(for [[k v] attr-paths-lookup :when (and (= (namespace k) (namespace id-attr)) |
|
|
|
(not= k id-attr))] k)) |
|
|
|
|
|
|
|
(defn generate-attr-tx-data |
|
|
|
[dt-value-type-lookup attr] |
|
|
|
(when-let [value-type (get dt-value-type-lookup attr)] |
|
|
|
(cond |
|
|
|
(= value-type :db.type/uuid) [:db/add -1 attr (dt/squuid)]))) |
|
|
|
|
|
|
|
;; query for the id of the parent entity |
|
|
|
(defn cache-row |
|
|
|
[ds-conn attr-paths-lookup component-attr-id-attr-map row] |
|
|
|
[ds-conn dt-value-type-lookup attr-paths-lookup component-attr-id-attr-map row] |
|
|
|
(let [;;_ (info "attr-paths-lookup: " attr-paths-lookup) |
|
|
|
insertion-order (sort-by namespace (filter #(contains? attr-paths-lookup %) (keys row))) |
|
|
|
;;_ (info "insertion-order: " insertion-order) |
|
@@ -65,7 +76,10 @@ |
|
|
|
first) |
|
|
|
;;_ (info "root-result: " root-result) |
|
|
|
_ (when (nil? root-result) |
|
|
|
(ds/transact ds-conn [[:db/add -1 (first insertion-order) (get row (first insertion-order))]]))] |
|
|
|
(let [other-root-attrs (namespace-attrs attr-paths-lookup (first insertion-order)) |
|
|
|
generated-tx-data (vec (remove nil? (map (partial generate-attr-tx-data dt-value-type-lookup) (remove #(contains? row %) other-root-attrs))))] |
|
|
|
(ds/transact ds-conn (concat [[:db/add -1 (first insertion-order) (get row (first insertion-order))]] |
|
|
|
generated-tx-data))))] |
|
|
|
(doseq [field (rest insertion-order)] |
|
|
|
;;(dorun (map (partial cache-field conn attr-paths-lookup component-attr-id-attr-map row) insertion-order)) |
|
|
|
(let [field-attr-paths (get attr-paths-lookup field) |
|
@@ -95,8 +109,9 @@ |
|
|
|
[:db/add -1 component-id-attr component-id-attr-val] |
|
|
|
[:db/add -1 field (get row field)]])) |
|
|
|
;;_ (info "tx-data: " tx-data) |
|
|
|
] |
|
|
|
(ds/transact ds-conn tx-data)) |
|
|
|
other-attrs (namespace-attrs attr-paths-lookup component-id-attr) |
|
|
|
generated-tx-data (vec (remove nil? (map (partial generate-attr-tx-data dt-value-type-lookup) (remove #(contains? row %) other-attrs))))] |
|
|
|
(ds/transact ds-conn (concat tx-data generated-tx-data))) |
|
|
|
(not= (get result field) (get row field)) |
|
|
|
(ds/transact ds-conn [[:db/add (:db/id result) field (get row field)]]))))) |
|
|
|
)) |
|
|
0 comments on commit
ee652be