Line data Source code
1 4 : (ns matchscore.domain.resource.entity
2 : (:require
3 : [schemas.domain.resource :as resource-schemas]))
4 :
5 :
6 24 : (def updatable-fields [:name :resource-type :is-active :attributes])
7 :
8 :
9 4 : (defn make-resource
10 : "Creates a validated Resource map."
11 : [data & [from-qualified]]
12 2 : (if from-qualified
13 0 : (resource-schemas/make-resource-record-from-qualified data)
14 3 : (resource-schemas/make-resource-record data)))
15 :
16 :
17 4 : (defn has-changes?
18 : "Returns true if any updatable field present in updates differs from existing."
19 : [existing updates]
20 2 : (not=
21 4 : (select-keys existing updatable-fields)
22 7 : (select-keys (merge existing updates) updatable-fields)))
23 :
24 :
25 4 : (defn merge-updates
26 : "Merges updatable fields from updates into existing resource."
27 : [existing updates]
28 7 : (merge existing (select-keys updates updatable-fields)))
|