vl-data-insert.core

append-and-replace

(append-and-replace struct {t :Type, v :Value, u :Unit, n :N, s :SdValue})

Append :Value, :SdValue and :N if present. Relaces :Type and :Unit.

fit-in-struct

(fit-in-struct s m)

Fits m into the given structure s. Function looks up the :Type of m. If a structure with the same :Type exist append-and-replace is called.

store-result

(store-result doc m p)

Stores the result map m in the given document under path. If m contains :Type and :Value m is fit-in-struct and the structure s is assumed to be a vector. Other cases (e.g. merge in :AuxValues) are straight forward (see vl-data-insert/test/cmp/doc_test.clj for details).

store-results

(store-results doc v p)

Takes a vector of maps. Calls store-result on each map.

Example:

(def p "Calibration.Measurement.Values.Pressure")
(def m {:Type    "a"
      :Unit    "b"
      :Value   [0]
      :SdValue [0]
      :N       [1]})

(def d {:Calibration
       {:Measurement
        {:Values
         {:Pressure
         [{:Type    "a"
          :Unit    "b"
          :Value   [0]
          :SdValue [0]
          :N       [1]}]}}}})

(store-results d [m m m m] p)

;; =>
;;   {:Calibration
;;    {:Measurement
;;     {:Values
;;      {:Pressure
;;       [{:Type "a",
;;         :Unit "b",
;;         :Value [0 0 0 0 0],
;;         :SdValue [0 0 0 0 0],
;;         :N [1 1 1 1 1]}]}}}}

vector-vals

(vector-vals m)

Ensures that the values of :Value,:SdValue and :N are vectors.