Skip to content

Commit

Permalink
Changed gene/*/update-other-names endpoints to use "other-names" key …
Browse files Browse the repository at this point in the history
…in data input structure (UI compatibility, #304)
  • Loading branch information
mluypaert committed Nov 6, 2020
1 parent 7777626 commit 23b6828
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/wormbase/names/entity.clj
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,19 @@
(fn handle-multi-card [request identifier]
(let [{conn :conn payload :body-params} request
ent-ns (namespace uiident)
data (some-> payload :data)
unqualified-attr (wnu/unqualify-keyword attr ent-ns)
update-elements (some-> payload
:data
unqualified-attr)
[lur entity] (identify-fn request identifier)]
(when (and entity data)
(when (and entity update-elements)
(let [build-tx (fn [id attr ^String val] (vec [dt-transact-fn id attr val]))
;;retriev db-id to add values to
db-id (:db/id entity)
;;retrieve provenance
prov (wnp/assoc-provenance request payload event)
;;build transaction statements to make
txes (map #(build-tx db-id attr %) data)
txes (map #(build-tx db-id attr %) update-elements)
;;transact data to datomic
tx-result @(d/transact-async conn (conj txes prov))]
(when-let [db-after (:db-after tx-result)]
Expand Down
8 changes: 8 additions & 0 deletions src/wormbase/names/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@
{}
mapping))

(defn unqualify-keyword
"Transform `keyword` such that it gets unqualified if it contains namespace `entity-type`."
[kw entity-type]
(if (and (qualified-keyword? kw)
(= (namespace kw) entity-type))
(-> kw name keyword)
kw))

(defn transform-ident-ref [k m kw-ns]
(update m k (fn [old]
(keyword kw-ns (if (keyword old)
Expand Down
2 changes: 1 addition & 1 deletion src/wormbase/specs/gene.clj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
(s/def ::updated (stc/spec {:spec (s/keys :req-un [:gene/id])
:description "The response data from updating a Gene."}))

(s/def ::update-other-names (stc/spec {:spec :gene/other-names
(s/def ::update-other-names (stc/spec {:spec (s/keys :req-un [:gene/other-names])
:description "A collection of other names."}))

(s/def ::merge (stc/spec {:spec (s/keys :req-un [:gene/biotype])
Expand Down

0 comments on commit 23b6828

Please sign in to comment.