Prepare user-friendly samples #15 - book

--- src/flatgui/samples/forms/orderticketwin.clj
+++ src/flatgui/samples/forms/orderticketwin.clj
@@ -28,12 +28,11 @@
             [flatgui.widgets.table.header :as th]
             [flatgui.widgets.table.contentpane :as tcpane]
             [flatgui.widgets.table.columnheader :as tcolh]
-            [flatgui.widgets.table.cell :as tcell]
-            )
+            [flatgui.widgets.table.cell :as tcell])
   (:import (java.text DecimalFormat)
            (flatgui.samples.bookpanel FGDataSimulator)))

-(def SIMULATOR (FGDataSimulator. 500))
+(def simulator (FGDataSimulator. 500))

 (def bid-columns [:bidsource :bidsize :bidpx])

@@ -156,211 +155,212 @@
       {:text symbol :caret-pos (awt/strlen (str symbol)) :selection-mark 0})
     (flatgui.widgets.textfield/text-model-evolver component)))

-(def orderticket-window (fg/defcomponent window/window :tiket { :clip-size (m/defpoint 7.25 7 0) :position-matrix (m/transtation-matrix 0 0) :text "Order Ticket"}
-
-                                         ;TODO remove this when borders are implemented
-                                         (fg/defcomponent panel/panel :ticket-panel { :clip-size (m/defpoint 7.25 6.625 0)
-                                                                                :position-matrix (m/transtation-matrix 0 0.375)
-                                                                                :look (fn [c r] [])}
-
-                                                          (fg/defcomponent toolbar/toolbar :general-toolbar {:position-matrix (m/transtation-matrix 0 0)
-                                                                                :clip-size (m/defpoint 4.5 0.375)}
-                                                                           (fg/defcomponent label/label :symbol-label
-                                                                                {:text "Symbol:"
-                                                                                :h-alignment :right
-                                                                                :clip-size (m/defpoint 0.75 0.375)
-                                                                                :position-matrix (m/transtation-matrix 0.125 0)})
-                                                                           (fg/defcomponent textfield/textfield :symbol-entry
-                                                                                {:clip-size (m/defpoint 0.75 0.3125)
-                                                                                :position-matrix (m/transtation-matrix 0.875 0.03125)
-                                                                                :evolvers {:model symbol-evolver}})
-                                                                           (fg/defcomponent checkbox/checkbox :follow-checkbox
-                                                                                {:clip-size (m/defpoint 1.5 0.25 0)
-                                                                                :text "Follow blotter"
-                                                                                :position-matrix (m/transtation-matrix 1.75 0.0625)})
-                                                                           (fg/defcomponent button/checkbutton :link-button
-                                                                                {:position-matrix (m/transtation-matrix 3.375 0.03125)
-                                                                                :clip-size (m/defpoint 0.75 0.3125)
-                                                                                :text "Link"}))
-
-
-                                                          (fg/defcomponent toolbar/toolbar :qty-toolbar {:position-matrix (m/transtation-matrix 4.5 0)
-                                                                                :clip-size (m/defpoint 2.75 0.375)}
-                                                                           (fg/defcomponent button/rolloverbutton :+1
-                                                                                {:position-matrix (m/transtation-matrix 0.125 0.03125)
-                                                                                :clip-size (m/defpoint 0.5625 0.3125)
-                                                                                :text "+1"})
-                                                                           (fg/defcomponent button/rolloverbutton :+10
-                                                                                {:position-matrix (m/transtation-matrix (+ 0.125 (* 1 0.5625)) 0.03125)
-                                                                                :clip-size (m/defpoint 0.5625 0.3125)
-                                                                                :text "+10"})
-                                                                           (fg/defcomponent button/rolloverbutton :+20
-                                                                                {:position-matrix (m/transtation-matrix (+ 0.125 (* 2 0.5625)) 0.03125)
-                                                                                :clip-size (m/defpoint 0.5625 0.3125)
-                                                                                :text "+20"})
-                                                                           (fg/defcomponent button/rolloverbutton :+100
-                                                                                {:position-matrix (m/transtation-matrix (+ 0.125 (* 3 0.5625)) 0.03125)
-                                                                                :clip-size (m/defpoint 0.5625 0.3125)
-                                                                                :text "+100"}))
-
-
-                                                          (fg/defcomponent table/table :bids { :clip-size (m/defpoint 3.5 2.5)
-                                                                                :position-matrix (m/transtation-matrix 0.125 0.375)
-                                                                                :header-ids bid-columns
-                                                                                :header-aliases {:bidsource "BidSrc" :bidsize "BidSize" :bidpx "BidPx"}
-                                                                                ;:value-provider (fn [model-row model-col] (str model-row model-col))
-                                                                                :value-provider (fn [model-row model-col]
-                                                                                (let [ col-id (name (nth bid-columns model-col))] (.getValue SIMULATOR model-row col-id)))
-                                                                                }
-                                                                           (th/deftablefit
-
-                                                                             ; TODO this does not work, it gets reset on initialization
-                                                                             ;(merge-properties (tcolh/defcolumn :bidpx [:sorting]) {:children {:sorting {:degree 0 :mode :desc}}})
-                                                                             (tcolh/defcolumn :bidpx [:sorting])
-
-                                                                             (tcolh/defcolumn :bidsource [:sorting])
-                                                                             (tcolh/defcolumn :bidsize [:sorting]))
-                                                                           (tcpane/deftablecontent 16 {:selection-mode :single
-                                                                                :row-height 0.25
-                                                                                :wheel-rotation-step-y 0.25
-                                                                                :default-cell-component (flatgui.base/merge-properties tcell/tablecell {:foreground (awt/color 0 0 0)
-                                                                                :evolvers {:background quote-background-evolver}})}))
-
-
-                                                          (fg/defcomponent table/table :asks {:clip-size (m/defpoint 3.5 2.5)
-                                                                                :position-matrix (m/transtation-matrix 3.625 0.375)
-                                                                                :header-ids ask-columns
-                                                                                :header-aliases {:asksource "AskSrc" :asksize "AskSize" :askpx "AskPx"}
-                                                                                ;:value-provider (fn [model-row model-col] (str model-row model-col))
-                                                                                :value-provider (fn [model-row model-col]
-                                                                                (let [ col-id (name (nth ask-columns model-col))] (.getValue SIMULATOR model-row col-id)))
-                                                                                }
-                                                                           (th/deftablefit
-                                                                             (tcolh/defcolumn :asksource [:sorting])
-                                                                             (tcolh/defcolumn :asksize [:sorting])
-                                                                             (tcolh/defcolumn :askpx [:sorting]))
-                                                                           (tcpane/deftablecontent 16 {:selection-mode :single
-                                                                                :row-height 0.25
-                                                                                :wheel-rotation-step-y 0.25
-                                                                                :default-cell-component (flatgui.base/merge-properties tcell/tablecell {:foreground (awt/color 0 0 0)
-                                                                                :evolvers {:background quote-background-evolver}})}))
-
-
-                                                          (fg/defcomponent label/label :qty-label { :text "Qty:"
-                                                                                :h-alignment :right
-                                                                                :clip-size (m/defpoint 0.5 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 0.125 3.0)})
-
-                                                          (fg/defcomponent textfield/textfield :qty-entry {:text-supplier textfield/textfield-num-only-text-suplier
-                                                                                :clip-size (m/defpoint 1.0 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 0.625 3.0)
-                                                                                :evolvers {:model qty-evolver}})
-
-                                                          (fg/defcomponent label/label :px-label { :text "Px:"
-                                                                                :h-alignment :right
-                                                                                :clip-size (m/defpoint 0.5 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 1.625 3.0)})
-
-                                                          (fg/defcomponent spinner/spinner :px-entry { :clip-size (m/defpoint 1.375 0.375 0)
-                                                                                :step 0.01
-                                                                                :position-matrix (m/transtation-matrix 2.125 3.0)
-                                                                                :children {:editor (fg/defcomponent spinner/spinnereditor :editor {:evolvers {:model px-evolver}})}
-                                                                                })
-
-                                                          (fg/defcomponent label/label :stgy-label {:text "Strategy:"
-                                                                                :h-alignment :right
-                                                                                :clip-size (m/defpoint 1.375 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 3.125 3.0)})
-
-                                                          (fg/defcomponent combobox/combobox :stgy-entry {:model ["WVAP" "TWAP" "With Volume" "Dynamic" "Custom"]
-                                                                                :clip-size (m/defpoint 1.375 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 4.5 3.0)})
-
-                                                          (fg/defcomponent textfield/textfield :exch-entry {:clip-size (m/defpoint 1.0 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 6.0 3.0)
-                                                                                :evolvers {:model exch-evolver}
-                                                                                })
-
-                                                          (fg/defcomponent label/label :aggr-label { :text "Aggressiveness:"
-                                                                                :clip-size (m/defpoint 1.5 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 0.125 3.5)})
-
-                                                          (fg/defcomponent slider/slider :aggr-slider { :clip-size (m/defpoint 3.0 0.5 0)
-                                                                                :position-matrix (m/transtation-matrix 1.75 3.5)})
-
-                                                          (fg/defcomponent label/label :type-label { :text "OrdType:"
-                                                                                :clip-size (m/defpoint 1.0 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 0.125 4.25)})
-
-                                                          (fg/defcomponent radiobutton/radiobutton :market { :text "Market:"
-                                                                                :clip-size (m/defpoint 1.25 0.25 0)
-                                                                                :position-matrix (m/transtation-matrix 1.125 4.25)
-                                                                                :evolvers {:pressed ordtype-group-evolver}})
-                                                          (fg/defcomponent radiobutton/radiobutton :limit { :text "Limit:"
-                                                                                :clip-size (m/defpoint 1.25 0.25 0)
-                                                                                :position-matrix (m/transtation-matrix 1.125 4.5625)
-                                                                                :evolvers {:pressed ordtype-group-evolver}})
-                                                          (fg/defcomponent radiobutton/radiobutton :stop { :text "Stop:"
-                                                                                :clip-size (m/defpoint 1.25 0.25 0)
-                                                                                :position-matrix (m/transtation-matrix 1.125 4.875)
-                                                                                :evolvers {:pressed ordtype-group-evolver}})
-                                                          (fg/defcomponent radiobutton/radiobutton :stoplmt { :text "Stop lmt:"
-                                                                                :clip-size (m/defpoint 1.25 0.25 0)
-                                                                                :position-matrix (m/transtation-matrix 1.125 5.1875)
-                                                                                :evolvers {:pressed ordtype-group-evolver}})
-
-                                                          (fg/defcomponent label/label :tif-label { :text "TimeInForce:"
-                                                                                :h-alignment :right
-                                                                                :clip-size (m/defpoint 1.375 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 2.375 4.25)})
-
-                                                          (fg/defcomponent combobox/combobox :tif-entry { :model ["Day", "GTC", "OPG", "IOC", "FOK", "GTX", "GTD"]
-                                                                                :clip-size (m/defpoint 1.375 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 3.75 4.25)})
-
-                                                          ;(fg/defcomponent w/label :text-label { :text "Text:"
-                                                          ;                                  :h-alignment :right
-                                                          ;                                  :clip-size (m/defpoint 1.375 0.375 0)
-                                                          ;                                  :position-matrix (m/transtation-matrix 2.375 4.75)})
-                                                          ;
-                                                          ;(fg/defcomponent w/textfield :text-entry { :clip-size (m/defpoint 1.375 0.375 0)
-                                                          ;                                     :position-matrix (m/transtation-matrix 3.75 4.75)})
-
-                                                          (fg/defcomponent label/label :text-label { :text "Text:"
-                                                                                :h-alignment :right
-                                                                                :clip-size (m/defpoint 0.75 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 5.125 4.25)})
-
-                                                          (fg/defcomponent textfield/textfield :text-entry {:clip-size (m/defpoint 1.0 0.375 0)
-                                                                                :position-matrix (m/transtation-matrix 5.875 4.25)})
-
-
-                                                          ;(fg/defcomponent w/label :exch-label { :text "Exch:"
-                                                          ;                                 :h-alignment :right
-                                                          ;                                 :clip-size (m/defpoint 0.75 0.375 0)
-                                                          ;                                 :position-matrix (m/transtation-matrix 5.125 4.25)})
-                                                          ;
-                                                          ;(fg/defcomponent w/textfield :exch-entry {:clip-size (m/defpoint 1.0 0.375 0)
-                                                          ;                                     :position-matrix (m/transtation-matrix 5.875 4.25)
-                                                          ;                                     :evolvers {:model exch-evolver}
-                                                          ;                                     })
-
-                                                          (fg/defcomponent button/button :buy { :position-matrix (m/transtation-matrix 0.125 6.125)
-                                                                                :clip-size (m/defpoint 1.0 0.375)
-                                                                                :text "Buy"})
-
-                                                          (fg/defcomponent button/button :sell { :position-matrix (m/transtation-matrix 6.125 6.125)
-                                                                                :clip-size (m/defpoint 1.0 0.375)
-                                                                                :text "Sell"})
-
-                                                          ;    (fg/defcomponent w/menu :ctx-menu { :value-provider (fn [model-row model-col] (str model-row "-" model-col))
-                                                          ;                                   :clip-size (m/defpoint 3 5 0)
-                                                          ;                                   :position-matrix (m/transtation-matrix 2.5 3.75)}
-                                                          ;      (fg/defcomponent w/menucontentpane :content-pane
-                                                          ;        {
-                                                          ;          :row-count 8
-                                                          ;          :row-order (vec (range 0 8))
-                                                          ;          }))
-
-
-                                                          )))
+(def general-toolbar
+  (fg/defcomponent toolbar/toolbar :general-toolbar
+    {:position-matrix (m/transtation 0 0)
+    :clip-size (m/defpoint 4.5 0.375)}
+    (fg/defcomponent label/label :symbol-label
+      {:text "Symbol:"
+       :h-alignment :right
+       :clip-size (m/defpoint 0.75 0.375)
+       :position-matrix (m/transtation 0.125 0)})
+    (fg/defcomponent textfield/textfield :symbol-entry
+      {:clip-size (m/defpoint 0.75 0.3125)
+       :position-matrix (m/transtation 0.875 0.03125)
+       :evolvers {:model symbol-evolver}})
+    (fg/defcomponent checkbox/checkbox :follow-checkbox
+      {:clip-size (m/defpoint 1.5 0.25 0)
+       :text "Follow blotter"
+       :position-matrix (m/transtation 1.75 0.0625)})
+    (fg/defcomponent button/checkbutton :link-button
+      {:position-matrix (m/transtation 3.375 0.03125)
+       :clip-size (m/defpoint 0.75 0.3125)
+       :text "Link"})))
+
+(def qty-toolbar
+  (fg/defcomponent toolbar/toolbar :qty-toolbar
+    {:position-matrix (m/transtation 4.5 0)
+     :clip-size (m/defpoint 2.75 0.375)}
+    (fg/defcomponent button/rolloverbutton :+1
+      {:position-matrix (m/transtation 0.125 0.03125)
+       :clip-size (m/defpoint 0.5625 0.3125)
+       :text "+1"})
+    (fg/defcomponent button/rolloverbutton :+10
+      {:position-matrix (m/transtation (+ 0.125 (* 1 0.5625)) 0.03125)
+       :clip-size (m/defpoint 0.5625 0.3125)
+       :text "+10"})
+    (fg/defcomponent button/rolloverbutton :+20
+      {:position-matrix (m/transtation (+ 0.125 (* 2 0.5625)) 0.03125)
+       :clip-size (m/defpoint 0.5625 0.3125)
+       :text "+20"})
+    (fg/defcomponent button/rolloverbutton :+100
+      {:position-matrix (m/transtation (+ 0.125 (* 3 0.5625)) 0.03125)
+       :clip-size (m/defpoint 0.5625 0.3125)
+       :text "+100"})))
+
+(def bids-table
+  (fg/defcomponent table/table :bids
+    {:clip-size (m/defpoint 3.5 2.5)
+     :position-matrix (m/transtation 0.125 0.375)
+     :header-ids bid-columns
+     :header-aliases {:bidsource "BidSrc" :bidsize "BidSize" :bidpx "BidPx"}
+     :value-provider (fn [model-row model-col] (let [ col-id (name (nth bid-columns model-col))] (.getValue simulator model-row col-id)))}
+    (th/deftablefit
+      (tcolh/defcolumn :bidpx [:sorting])
+      (tcolh/defcolumn :bidsource [:sorting])
+      (tcolh/defcolumn :bidsize [:sorting]))
+    (tcpane/deftablecontent 16
+      {:selection-mode :single
+       :row-height 0.25
+       :wheel-rotation-step-y 0.25
+       :default-cell-component (flatgui.base/merge-properties tcell/tablecell
+                                 {:foreground (awt/color 0 0 0)
+                                  :evolvers {:background quote-background-evolver}})})))
+
+(def asks-table
+  (fg/defcomponent table/table :asks
+    {:clip-size (m/defpoint 3.5 2.5)
+     :position-matrix (m/transtation 3.625 0.375)
+     :header-ids ask-columns
+     :header-aliases {:asksource "AskSrc" :asksize "AskSize" :askpx "AskPx"}
+     :value-provider (fn [model-row model-col] (let [ col-id (name (nth ask-columns model-col))] (.getValue simulator model-row col-id)))}
+    (th/deftablefit
+      (tcolh/defcolumn :asksource [:sorting])
+      (tcolh/defcolumn :asksize [:sorting])
+      (tcolh/defcolumn :askpx [:sorting]))
+    (tcpane/deftablecontent 16
+      {:selection-mode :single
+       :row-height 0.25
+       :wheel-rotation-step-y 0.25
+       :default-cell-component (flatgui.base/merge-properties tcell/tablecell
+                                 {:foreground (awt/color 0 0 0)
+                                  :evolvers {:background quote-background-evolver}})})))
+
+(def orderticket-window
+  (fg/defcomponent window/window :tiket
+    {:clip-size (m/defpoint 7.25 7 0)
+     :position-matrix (m/transtation 0 0)
+     :text "Order Ticket"}
+
+    (fg/defcomponent panel/panel :ticket-panel
+      {:clip-size (m/defpoint 7.25 6.625 0)
+       :position-matrix (m/transtation 0 0.375)
+       :look (fn [c r] [])}
+
+    general-toolbar
+
+    qty-toolbar
+
+    bids-table
+
+    asks-table
+
+    (fg/defcomponent label/label :qty-label
+      {:text "Qty:"
+       :h-alignment :right
+       :clip-size (m/defpoint 0.5 0.375 0)
+       :position-matrix (m/transtation 0.125 3.0)})
+
+    (fg/defcomponent textfield/textfield :qty-entry
+      {:text-supplier textfield/textfield-num-only-text-suplier
+       :clip-size (m/defpoint 1.0 0.375 0)
+       :position-matrix (m/transtation 0.625 3.0)
+       :evolvers {:model qty-evolver}})
+
+    (fg/defcomponent label/label :px-label
+      {:text "Px:"
+       :h-alignment :right
+       :clip-size (m/defpoint 0.5 0.375 0)
+       :position-matrix (m/transtation 1.625 3.0)})
+
+    (fg/defcomponent spinner/spinner :px-entry
+      {:clip-size (m/defpoint 1.375 0.375 0)
+       :step 0.01
+       :position-matrix (m/transtation 2.125 3.0)
+       ;; TODO without using :children keyword here?
+       :children {:editor (fg/defcomponent spinner/spinnereditor :editor {:evolvers {:model px-evolver}})}})
+
+    (fg/defcomponent label/label :stgy-label
+      {:text "Strategy:"
+       :h-alignment :right
+       :clip-size (m/defpoint 1.375 0.375 0)
+       :position-matrix (m/transtation 3.125 3.0)})
+
+    (fg/defcomponent combobox/combobox :stgy-entry
+      {:model ["WVAP" "TWAP" "With Volume" "Dynamic" "Custom"]
+       :clip-size (m/defpoint 1.375 0.375 0)
+       :position-matrix (m/transtation 4.5 3.0)})
+
+    (fg/defcomponent textfield/textfield :exch-entry
+      {:clip-size (m/defpoint 1.0 0.375 0)
+       :position-matrix (m/transtation 6.0 3.0)
+       :evolvers {:model exch-evolver}})
+
+    (fg/defcomponent label/label :aggr-label
+      {:text "Aggressiveness:"
+       :clip-size (m/defpoint 1.5 0.375 0)
+       :position-matrix (m/transtation 0.125 3.5)})
+
+    (fg/defcomponent slider/slider :aggr-slider
+      {:clip-size (m/defpoint 3.0 0.5 0)
+       :position-matrix (m/transtation 1.75 3.5)})
+
+    (fg/defcomponent label/label :type-label
+      {:text "OrdType:"
+       :clip-size (m/defpoint 1.0 0.375 0)
+       :position-matrix (m/transtation 0.125 4.25)})
+
+    (fg/defcomponent radiobutton/radiobutton :market
+      {:text "Market:"
+       :clip-size (m/defpoint 1.25 0.25 0)
+       :position-matrix (m/transtation 1.125 4.25)
+       :evolvers {:pressed ordtype-group-evolver}})
+
+    (fg/defcomponent radiobutton/radiobutton :limit
+      {:text "Limit:"
+       :clip-size (m/defpoint 1.25 0.25 0)
+       :position-matrix (m/transtation 1.125 4.5625)
+       :evolvers {:pressed ordtype-group-evolver}})
+
+    (fg/defcomponent radiobutton/radiobutton :stop
+      {:text "Stop:"
+       :clip-size (m/defpoint 1.25 0.25 0)
+       :position-matrix (m/transtation 1.125 4.875)
+       :evolvers {:pressed ordtype-group-evolver}})
+
+    (fg/defcomponent radiobutton/radiobutton :stoplmt
+      {:text "Stop lmt:"
+       :clip-size (m/defpoint 1.25 0.25 0)
+       :position-matrix (m/transtation 1.125 5.1875)
+       :evolvers {:pressed ordtype-group-evolver}})
+
+    (fg/defcomponent label/label :tif-label
+      {:text "TimeInForce:"
+       :h-alignment :right
+       :clip-size (m/defpoint 1.375 0.375 0)
+       :position-matrix (m/transtation 2.375 4.25)})
+
+    (fg/defcomponent combobox/combobox :tif-entry
+      {:model ["Day", "GTC", "OPG", "IOC", "FOK", "GTX", "GTD"]
+       :clip-size (m/defpoint 1.375 0.375 0)
+       :position-matrix (m/transtation 3.75 4.25)})
+
+    (fg/defcomponent label/label :text-label
+      {:text "Text:"
+       :h-alignment :right
+       :clip-size (m/defpoint 0.75 0.375 0)
+       :position-matrix (m/transtation 5.125 4.25)})
+
+    (fg/defcomponent textfield/textfield :text-entry
+      {:clip-size (m/defpoint 1.0 0.375 0)
+       :position-matrix (m/transtation 5.875 4.25)})
+
+    (fg/defcomponent button/button :buy
+      {:position-matrix (m/transtation 0.125 6.125)
+       :clip-size (m/defpoint 1.0 0.375)
+       :text "Buy"})
+
+    (fg/defcomponent button/button :sell
+      {:position-matrix (m/transtation 6.125 6.125)
+       :clip-size (m/defpoint 1.0 0.375)
+       :text "Sell"}))))


Improve Doc String

Improve Doc String

--- src/lens/api.clj
+++ src/lens/api.clj
@@ -137,7 +137,7 @@
 ;; ---- Study -----------------------------------------------------------------

 (defn create-study
-  "Creates the study with the id, name and more.
+  "Creates a study with the id, name and more.

   More can be a map of :description were :description should be a string.


Fix Error Hiding on Update

Fix Error Hiding on Update

--- src/lens/api.clj
+++ src/lens/api.clj
@@ -26,9 +26,9 @@
   "Returns a channel conveying the updated representation or any errors."
   [rep changes]
   (let [edited (merge rep {:data (dissoc changes :type)})]
-    (when (not= rep edited)
-      (hap/update (:self (:links rep)) edited))
-    (go rep)))
+    (if (not= rep edited)
+      (hap/update (:self (:links rep)) edited)
+      (go rep))))

 (defn upsert! [find-query create-form {:keys [id] :as data}]
   {:pre [find-query id]}


Add ability to automatically choose first device discovered

This works around inability to read input stream in nREPL / Cursive.
Need a better solution, but it at least lets the REPL start up.

--- Clojure/src/ambly/repl/jsc.clj
+++ Clojure/src/ambly/repl/jsc.clj
@@ -29,7 +29,7 @@
 (defn discover-and-pick-ambly-instance
   "Looks for Ambly WebDAV services advertised via Bonjour and presents
   a simple command-line UI letting user pick one."
-  []
+  [choose-first-discovered?]
   (let [reg-type "_http._tcp.local."
         discovered-services (atom (sorted-map))
         mdns-service (JmDNS/create)
@@ -59,10 +59,11 @@
       (loop [current-discovered-services @discovered-services]
         (println)
         (print-services current-discovered-services)
-        (println "\n[r] Refresh\n")
-        (print "Choice: ")
-        (flush)
-        (let [choice (read-line)]
+        (when-not choose-first-discovered?
+          (println "\n[r] Refresh\n")
+          (print "Choice: ")
+          (flush))
+        (let [choice (if choose-first-discovered? "1" (read-line))]
           (if (= "r" choice)
             (recur @discovered-services)
             (let [choices (service-map->choice-list current-discovered-services)
@@ -184,7 +185,7 @@
 (defn setup
   [repl-env opts]
   (let [_ (set-logging-level "javax.jmdns" java.util.logging.Level/SEVERE)
-        [webdav-endpoint-name webdav-endpoint] (discover-and-pick-ambly-instance)
+        [webdav-endpoint-name webdav-endpoint] (discover-and-pick-ambly-instance (:choose-first-discovered repl-env))
         _ (println "\nConnecting to" (service-name->display-name webdav-endpoint-name) "...\n")
         ; Assuming IPv4 for now
         endpoint-address (.getHostAddress (:address webdav-endpoint))
@@ -254,7 +255,7 @@
                  (aget (.. js/goog -dependencies_ -nameToPath) name)))))))
     {:merge-opts {:output-dir webdav-mount-point}}))

-(defrecord JscEnv [host port socket response-promise webdav-mount-point]
+(defrecord JscEnv [host port socket response-promise webdav-mount-point choose-first-discovered]
   repl/IParseStacktrace
   (-parse-stacktrace [this stacktrace error opts]
     (raw-stacktrace->canonical-stacktrace stacktrace opts))
@@ -276,12 +277,12 @@
     (shutdown-agents)))

 (defn repl-env* [options]
-  (let [{:keys [host port]}
+  (let [{:keys [host port choose-first-discovered]}
         (merge
           {:host "localhost"
            :port 50505}
           options)]
-    (JscEnv. host port (atom nil) (atom nil) (atom nil))))
+    (JscEnv. host port (atom nil) (atom nil) (atom nil) choose-first-discovered)))

 (defn repl-env
   [& {:as options}]


Removed 'FEED' from logged out nav

Removed 'FEED' from logged out nav

--- src-cljs/rmfu_ui/nav.cljs
+++ src-cljs/rmfu_ui/nav.cljs
@@ -47,4 +47,4 @@
                  [:a.nav-link.active {:href "/#/admin"} "Admin"]])]
              [:form.form-inline.navbar-form.pull-right
               [:button.btn.btn-success-outline {:type "button" :on-click #(logout)} "logout"]]]
-            [:a.navbar-brand.feed-title {:href "/"} "FEED"])])})))
+            )])})))


Adding to qb ontology

Adding to qb ontology

--- src/ontologies/grafter/rdf/ontologies/qb.clj
+++ src/ontologies/grafter/rdf/ontologies/qb.clj
@@ -11,6 +11,12 @@
 (def qb:component (qb "component"))
 (def qb:componentRequired (qb "componentRequired"))
 (def qb:componentAttachment (qb "componentAttachment"))
+(def qb:ComponentSpecification (qb "ComponentSpecification"))
+(def qb:ComponentProperty (qb "ComponentProperty"))
+
+(def qb:Attachable (qb "Attachable"))
+
+(def qb:order (qb "order"))

 (def qb:structure (qb "structure"))


Expect the full data structure rather than keys

It'll make it easier to read for others when they come to look at the
tests.

--- test/govuk/blinken_test.clj
+++ test/govuk/blinken_test.clj
@@ -22,15 +22,14 @@
       (let [group-govuk (groups "govuk")]
         (is (= (:name group-govuk) "GOV.UK"))
         (let [prod ((:environments group-govuk) "prod")]
-          (is (= (:name prod) "Production"))
+          (is (= {:name "Production"
+                  :worker {:type "icinga"
+                           :url "https://icinga.foo.production"
+                           :options {:foo "bar"}}}
+                 prod))
           (is (nil? (:type prod)))
           (is (nil? (:url prod)))
-          (is (nil? (:options prod)))
-          (is (:worker prod))
-          (is (= (-> prod :worker :type) "icinga"))
-          (is (= (-> prod :worker :url) "https://icinga.foo.production"))
-          (is (= (-> prod :worker :options)
-                 {:foo "bar"}))))))
+          (is (nil? (:options prod)))))))

   (testing "config file doesn't exist"
     (is (nil? (blinken/load-config (io/resource "fixtures/laeurglaerugh")


Three tests: test-get-port, test-get-port-special-cases, and test-get-port-negative

--- test/hurvinek/core_test.clj
+++ test/hurvinek/core_test.clj
@@ -50,3 +50,36 @@
     (testing "if the hurvinek.core/-main definition exists."
         (is (callable? 'hurvinek.core/-main))))

+;
+; Tests for function behaviours
+;
+
+(deftest test-get-port
+    "Check the function hurvinek.core/get-port."
+    (testing "the function hurvinek.core/get-port."
+        (is (= (get-port "1")     "1"))
+        (is (= (get-port "2")     "2"))
+        (is (= (get-port "3000")  "3000"))
+        (is (= (get-port "65534") "65534"))
+        (is (= (get-port "65535") "65535"))))
+
+(deftest test-get-port-special-cases
+    "Check the function hurvinek.core/get-port."
+    (testing "the function hurvinek.core/get-port."
+        (is (= (get-port nil)     "3000"))
+        (is (= (get-port "")      "3000"))
+        (is (= (get-port 0)       "3000"))
+        (is (= (get-port 1)       "3000"))
+        (is (= (get-port 65535)   "3000"))
+        (is (= (get-port 65536)   "3000"))))
+
+(deftest test-get-port-negative
+    "Check the function hurvinek.core/get-port."
+    (testing "the function hurvinek.core/get-port."
+        (is (thrown? AssertionError (get-port "0")))
+        (is (thrown? AssertionError (get-port "-1")))
+        (is (thrown? AssertionError (get-port "-2")))
+        (is (thrown? AssertionError (get-port "65536")))
+        (is (thrown? AssertionError (get-port "65537")))
+        (is (thrown? AssertionError (get-port "1000000")))))
+


Better documentation of current behavior.

--- test/midje/t_semi_sweet.clj
+++ test/midje/t_semi_sweet.clj
@@ -160,9 +160,9 @@
               (fake (other-function 12) => 1))
       @reported => (just pass)))

-  (fact "call that matches none of the expected arguments"
-    (after-silently
-      (expect (+ (mocked-function 12) (mocked-function 33)) => "result irrelevant because of earlier failure"
+  (fact "call that matches none of the expected arguments falls through to existing function"
+    (after-silently
+      (expect (+ (mocked-function 33)) => "result irrelevant because of failure"
               (fake (mocked-function 12) => "hi"))
      ;; At the moment, this does not produce a :mock-argument-match-failure. What it does
      ;; is call the "unfinished" function, which blows up, producing a `bad-result` (the exception


Add feedback about external changes to cue vars.

I think the cue object is pretty much exactly how I want it now, and all
that remains is to create the documentation and help patchers, w00t!

--- src/afterglow/max/Cue.clj
+++ src/afterglow/max/Cue.clj
@@ -87,6 +87,35 @@
   [this]
   (clojure.string/join (map #(if (= (:type %) :int) "i" "f") (cue-variables this))))

+(defn unwatch-cue-local-variables
+  "When a cue has ended, or this object is being deactivated, get rid
+  of any callback functions that were watching cue-local variable
+  value changes."
+  [this]
+  (doseq [[k f] (:local-var-fn @(.state this))]
+    (show/clear-variable-set-fn! k f))
+  (swap! (.state this) dissoc :local-var-fn))
+
+(defn watch-cue-local-variables
+  "After we start a cue, this function looks for any variable bindings
+  which are cue-local, and registers callback functions to send
+  updates if their values change. Also immediately sends out the
+  values of the variables that the cue started up with."
+  [this]
+  (unwatch-cue-local-variables this)  ; Should be unnecessary, but clean up just in case
+  (let [{:keys [x y]} @(.state this)
+        [_ active] (show/find-cue-grid-active-effect *show* x y)]
+    (when active
+      (doseq [[i v] (map vector (range) (cue-variables this))]
+      (when (string? (:key v))
+        (let [outlet (inc i)
+              cue-local-key (keyword (:key v))
+              cue-local-var (get-in active [:variables cue-local-key])
+              f (fn [_ new-value] (when (number? new-value) (.outlet this outlet (float new-value))))]
+          (swap! (.state this) assoc-in [:local-var-fn cue-local-var] f)
+          (f cue-local-var (show/get-variable cue-local-var))
+          (show/add-variable-set-fn! cue-local-var f)))))))
+
 (defn- -init
   [x y]
   (core/init)
@@ -111,10 +140,24 @@
     (.parentSetOutletAssist this (into-array String (concat ["Output changes in Cue state and associated id values"]
                                                             (cue-variable-outlet-assist this))))
     (.parentCreateInfoOutlet this false)
-    (swap! (.state this) assoc :f (fn [new-state _ id]
-                                    (.outlet this 0 (name new-state)
-                                             (into-array Atom [(Atom/newAtom id) (Atom/newAtom cue-name)])))))
-  (controllers/add-cue-fn! (:cue-grid *show*) x y (:f @(.state this))))
+
+    ;; Set up the callback function for changes to cue state
+    (let [f (fn [new-state _ id]
+              (.outlet this 0 (name new-state) (into-array Atom [(Atom/newAtom id) (Atom/newAtom cue-name)]))
+              (case new-state
+                :started (watch-cue-local-variables this)
+                :ended (unwatch-cue-local-variables this)
+                nil))]
+      (swap! (.state this) assoc :cue-fn f)
+      (controllers/add-cue-fn! (:cue-grid *show*) x y f))
+
+    ;; Set up the callback functions for changes to values of permanent show variables bound to the cue
+    (doseq [[i v] (map vector (range) (cue-variables this))]
+      (when (keyword? (:key v))
+        (let [outlet (inc i)
+              f (fn [_ new-value] (when (number? new-value) (.outlet this outlet (float new-value))))]
+          (swap! (.state this) assoc-in [:perm-var-fn (:key v)] f)
+          (show/add-variable-set-fn! (:key v) f))))))

 (defn apply-cue-local-variables
   "After we start a cue, this function looks for any local values we
@@ -227,7 +270,11 @@
 (defn- -notifyDeleted
   "The Max peer object has been deleted, so this instance is no longer
   going to be used. Unregister our cue state notification function,
-  and allow this object to be garbage collected."
-  [this]
-  (let [{:keys [x y f]} @(.state this)]
-    (controllers/clear-cue-fn! (:cue-grid *show*) x y f)))
+  and any variable change notification functions, and allow this
+  object to be garbage collected."
+  [this]
+  (let [{:keys [x y cue-fn perm-var-fn]} @(.state this)]
+    (controllers/clear-cue-fn! (:cue-grid *show*) x y cue-fn)
+    (doseq [[k f] perm-var-fn]
+      (show/clear-variable-set-fn! k f))
+    (unwatch-cue-local-variables this)))


cosmetics

cosmetics

--- src/nml/core.clj
+++ src/nml/core.clj
@@ -18,6 +18,14 @@
   (if msg (println (apply str msg)))
   (System/exit 1))

+(defn nml-add [tree parent child match proxy]
+  (let [missing?  (fn [children] (not-any? #(= (nml-name %) match) children))
+        vnew     #(parse proxy :start child)
+        f         (fn [& children] (if (missing? children)
+                                     (into [parent (vnew)] children)
+                                     (into [parent       ] children)))]
+    (if (nil? tree) [parent (vnew)] (insta/transform {parent f} tree))))
+
 (defn nml-get [tree nml key]
   (let [stmt     (last (filter #(= (nml-name %) nml) (rest tree)))
         nvsubseq (last (filter #(= (nml-name %) key) (rest (last stmt))))
@@ -32,15 +40,6 @@

 (defn nml-name [x]
   (nml-str (second x)))
-
-(defn nml-add [tree parent child match proxy]
-  (let [missing?  (fn [children] (not-any? #(= (nml-name %) match) children))
-        vnew     #(parse proxy :start child)
-        f         (fn [& children]
-            (if (missing? children)
-              (into [parent (vnew)] children)
-              (into [parent] children)))]
-    (if (nil? tree) [parent (vnew)] (insta/transform {parent f} tree))))

 (defn nml-set [tree nml key val & sub]
   (let [child  (if sub :nvsubseq :stmt)


Shelves fill up in the Y too

Shelves fill up in the Y too

--- test/packager/core_test.clj
+++ test/packager/core_test.clj
@@ -49,6 +49,7 @@
                                :dimensions [20.0 19.0]}]
                     :dimensions [20.0 20.0]}]
       (is (= expected (c/add c box)))))
+
   (testing "two boxes that fit on the same shelf end up on the same shelf"
     (let [c {:shelves []
              :dimensions [40.0 20.0]}
@@ -56,4 +57,15 @@
           expected {:shelves [{:boxes [box box]
                                :dimensions [40.0 19.0]}]
                     :dimensions [40.0 20.0]}]
+      (is (= expected (c/add (c/add c box) box)))))
+
+  (testing "two boxes that don't fit on the same shelf get a shelf each"
+    (let [c {:shelves []
+             :dimensions [20.0 40.0]}
+          box [19.0 19.0]
+          expected {:shelves [{:boxes [box]
+                               :dimensions [20.0 19.0]}
+                              {:boxes [box]
+                               :dimensions [20.0 19.0]}]
+                    :dimensions [20.0 40.0]}]
       (is (= expected (c/add (c/add c box) box))))))


Await completion first cut.

Await completion first cut.

--- src/onyx/api.clj
+++ src/onyx/api.clj
@@ -4,7 +4,9 @@
             [com.stuartsierra.component :as component]
             [clj-http.client :refer [post]]
             [taoensso.timbre :refer [info]]
-            [onyx.system :as system]))
+            [onyx.coordinator.impl :as impl]
+            [onyx.system :as system]
+            [onyx.extensions :as extensions]))

 (defprotocol ISubmit
   "Protocol for sending a job to the coordinator for execution."
@@ -15,11 +17,28 @@
    Registering allows the virtual peer to accept tasks."
   (register-peer [this peer-node]))

+(defprotocol IAwait
+  "Protocol for waiting for completion of Onyx internals"
+  (await-job-completion [this job-id]))
+
 (defprotocol IShutdown
   "Protocol for stopping a virtual peer's task and no longer allowing
    it to accept new tasks. Releases all resources that were previously
    acquired."
   (shutdown [this]))
+
+(defn- await-job-completion* [sync job-id]
+  (future
+    (loop []
+      (let [ch (chan 1)
+            task-path (extensions/resolve-node sync :task job-id)
+            task-nodes (extensions/bucket-at sync :task task-path)
+            task-nodes (filter #(not (impl/completed-task? %)) task-nodes)]
+        (extensions/on-change sync (fn [_] (>!! ch true)))
+        (if (every? impl/task-complete? task-nodes)
+          true
+          (do (<!! ch)
+              (recur)))))))

 ;; A coordinator that runs strictly in memory. Peers communicate with
 ;; the coordinator by directly accessing its channels.
@@ -30,6 +49,10 @@
       (>!! (:planning-ch-head (:coordinator onyx-coord)) [job ch])
       (<!! ch)))

+  IAwait
+  (await-job-completion [this job-id]
+    (await-job-completion* (:sync onyx-coord) job-id))
+
   IRegister
   (register-peer [this peer-node]
     (>!! (:born-peer-ch-head (:coordinator onyx-coord)) peer-node))
@@ -37,7 +60,7 @@
   IShutdown
   (shutdown [this] (component/stop onyx-coord)))

-;; A coordinator that can run remotely. Peers commuicate with the
+;; A coordinator runs remotely. Peers communicate with the
 ;; coordinator by submitting HTTP requests and parsing the responses.
 (deftype HttpCoordinator [uri]
   ISubmit
@@ -54,7 +77,7 @@
   (shutdown [this]))

 (defmulti connect
-  "A polymorphic function to connect with the coordinator."
+  "Establish a communication channel with the coordinator."
   (fn [uri opts] (keyword (first (split (second (split uri #":")) #"//")))))

 (defmethod connect :memory


Refactoring demo code.

Refactoring demo code.

--- umm-spec-lib/src/cmr/umm_spec/umm_json.clj
+++ umm-spec-lib/src/cmr/umm_spec/umm_json.clj
@@ -2,21 +2,7 @@
   "Contains functions for converting a UMM into JSON and back out of JSON."
   (:require [cheshire.core :as json]
             [cheshire.generate :as json-gen]
-            [cmr.umm-spec.json-schema :as js]
-
-            ;; Temporary require statements for demo
-
-            [cmr.umm-spec.xml-mappings.xml-generator :as xg]
-            [cmr.umm-spec.xml-mappings.iso19115-2 :as xm-iso2]
-            [cmr.umm-spec.xml-mappings.echo10 :as xm-echo10]
-            [cmr.umm-spec.umm-mappings.iso19115-2 :as um-iso2]
-            [cmr.umm-spec.umm-mappings.echo10 :as um-echo10]
-            [cmr.umm-spec.umm-mappings.parser :as xp]
-            [cmr.umm-spec.models.collection :as umm-c]
-            [cmr.umm-spec.models.common :as umm-cmn]
-            [cmr.umm-spec.json-schema :as js]
-
-            ))
+            [cmr.umm-spec.json-schema :as js]))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; UMM To JSON
@@ -71,30 +57,4 @@
   )

-;; Temporary Demo code

-(defn echo10->umm-json
-  [xml]
-  (umm->json (xp/parse-xml um-echo10/echo10-xml-to-umm-c xml)))
-
-(defn umm-json->echo10
-  [json-str]
-  (xg/generate-xml xm-echo10/umm-c-to-echo10-xml (json->umm json-str)))
-
-(defn iso19115->umm-json
-  [xml]
-  (umm->json (xp/parse-xml um-iso2/iso19115-2-xml-to-umm-c xml)))
-
-(defn umm-json->iso19115
-  [json-str]
-  (xg/generate-xml xm-iso2/umm-c-to-iso19115-2-xml (json->umm json-str)))
-
-
-(defn pretty-print-json
-  [json-str]
-  (println (json/generate-string (json/decode json-str) {:pretty true})))
-
-
-(defn pretty-print-xml
-  [xml]
-  (println (cmr.common.xml/pretty-print-xml xml)))


update to https://github.com/clojure/clojurescript/commit/4d200284bab9b92f65f7c1475acc92a94b98faf3

--- src/main/clojure/clojure/tools/analyzer/js.clj
+++ src/main/clojure/clojure/tools/analyzer/js.clj
@@ -14,7 +14,7 @@
              :refer [analyze analyze-in-env]
              :rename {analyze -analyze}]
             [clojure.tools.analyzer
-             [utils :refer [resolve-ns ctx -source-info dissoc-env const-val mmerge] :as u]
+             [utils :refer [resolve-ns ctx -source-info dissoc-env const-val mmerge update-vals] :as u]
              [ast :refer [prewalk postwalk]]
              [env :as env :refer [*env*]]
              [passes :refer [schedule]]]
@@ -420,18 +420,14 @@
        {:meta metadata}))))

 (defmethod parse 'def
-  [form env]
-  (let [{:keys [meta] :as ast} (ana/-parse form env)]
-    (if (and meta (= :map (:op meta)))
-      (let [const-map (zipmap (mapv const-val (:keys meta))
-                              (mapv const-val (:vals meta)))]
-        (if-let [test (:test meta)]
-          (-> ast
-            (assoc :test (ana/analyze-form test env))
-            (assoc :meta (ana/analyze-const (dissoc const-map :test) env))
-            (update-in [:children] (fnil conj []) :test))
-          (assoc ast :meta (ana/analyze-const const-map env))))
-      ast)))
+  [[_ sym & rest :as form] env]
+  (let [ks #{:ns :name :doc :arglists :file :line :column}
+        meta (meta sym)
+        m (merge {}
+                 (update-vals (select-keys meta ks) (fn [x] (list 'quote x)))
+                 (when (:test meta)
+                   {:test `(.-cljs$lang$test ~sym)}))]
+    (ana/-parse (with-meta `(def ~(with-meta sym m) ~@rest) (meta form)) env)))

 (def default-passes
   "Set of passes that will be run by default on the AST by #'run-passes"


Handle *1/2/3 vars and unbound vars in find-spec

--- src/main/clojure/com/stuartsierra/lazytest.clj
+++ src/main/clojure/com/stuartsierra/lazytest.clj
@@ -351,7 +351,9 @@
   or symbol.  If x is a symbol, attempts to reload the namespace named
   by the symbol."
   [x]
-  (cond (coll? x)
+  (cond (spec? x) x
+
+        (coll? x)
         (let [xs (filter identity (map find-spec x))]
           (if (seq xs)
             (SimpleContainer (vec xs)
@@ -362,7 +364,9 @@
         (instance? clojure.lang.Namespace x)
         (if-let [t (:spec (meta x))]
           (find-spec t)
-          (find-spec (vals (ns-interns x))))
+          ;; Omit the *1/*2/*3 REPL vars, in case they are specs:
+          (find-spec (filter #(not (#{#'*1 #'*2 #'*3} %))
+                             (vals (ns-interns x)))))

         (var? x)
         (let [m (meta x)]
@@ -376,12 +380,10 @@
                                   :file (:file m)
                                   :line (:line m)}
                                nil)
-              (let [v (var-get x)]
+              (let [v (try (var-get x) (catch Exception e nil))]
                 (when (spec? v) v)))))

         (symbol? x)
         (find-spec (find-ns x))

-        (spec? x) x
-
         :else nil))


delete dangling temporary file

delete dangling temporary file

--- src/test/clojure/stl_collector/core_test.clj
+++ src/test/clojure/stl_collector/core_test.clj
@@ -55,4 +55,5 @@
           read-file (r/read-stl real-file)
           write-file (w/write-stl read-file tmp-file)
           new-read-file (r/read-stl tmp-file)]
-      (= read-file new-read-file))))
+      (= read-file new-read-file)
+      (.delete tmp-file))))


Uped version of lein-tarsier.

Uped version of lein-tarsier.

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -1,6 +1,6 @@
-{:user {:plugins [[lein-tarsier "0.9.1"]
+{:user {:plugins [[clj-stacktrace "0.2.4"]
+                  [lein-tarsier "0.9.2-SNAPSHOT"]
                   [lein-swank "1.4.1"]
-                  [clj-stacktrace "0.2.4"]
                   [lein-pprint "1.1.1"]
                   [slamhound "1.2.0"]
                   [lein-cljsbuild "0.1.8"]


Add speclj-tmux to lein user profile.

Add speclj-tmux to lein user profile.

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -2,6 +2,7 @@
                        [org.clojure/tools.trace "0.7.5"]
                        [org.clojure/tools.namespace "0.2.3"]
                        [redl "0.1.0"]
+                       [speclj-tmux "1.0.0"]
                        [spyscope "0.1.3"]
                        [slamhound "1.3.3"]]
         :plugins [[lein-difftest "1.3.7"]


[lein] bump lein-ancient

[lein] bump lein-ancient

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -2,7 +2,7 @@
                   [lein-fore-prob                    "0.1.2"]

                   ; Check for outdated dependencies
-                  [lein-ancient                      "0.6.14"]
+                  [lein-ancient                      "0.6.15"]

                   ;; lein-test when something changes
                   [com.jakemccrary/lein-test-refresh "0.21.1"]


Only one kind of threading macro is needed here

--- src/vip/data_processor/validation/xml/v5.clj
+++ src/vip/data_processor/validation/xml/v5.clj
@@ -39,9 +39,9 @@
   [{:keys [import-id] :as ctx}]
   (let [xml-file (first (:input ctx))]
     (with-open [reader (util/bom-safe-reader xml-file)]
-      (->> (-> reader
-               xml/parse
-               :content)
+      (->> reader
+           xml/parse
+           :content
            (filter #(= (:tag %) :StreetSegment))
            (map (fn [ss] (-> ss
                              ss->map


rerender ui after reset

rerender ui after reset

--- app/views/viz/plot.cljs
+++ app/views/viz/plot.cljs
@@ -184,7 +184,9 @@
                            (om/set-state! owner :time-bound m)
                            (render owner (om/get-state owner :datoms)))
              e-chan (if (= m :reset)
-                      (om/set-state! owner :datoms [])))
+                      (do
+                        (om/set-state! owner :datoms [])
+                        (render owner (om/get-state owner :datoms)))))
            (recur (alts! [ws-sub-chan select-chan e-chan]))))))
    )
   (did-mount


ECHO-616: Adding remove provider policies method to transmit

--- transmit-lib/src/cmr/transmit/echo/soap/provider.clj
+++ transmit-lib/src/cmr/transmit/echo/soap/provider.clj
@@ -176,6 +176,21 @@
                     (when override-notification-enabled ["ns3:OverrideNotificationEnabled" override-notification-enabled])]])
     nil))

+(defn remove-provider-policies
+  "Removes provider policies for a provider. Takes a map containing the token, provider-id, and
+   provider-guid. provider-id and provider-guid are optional. If one or the other is specified they
+   will indicate the provider otherwise the provider will be assumed to be one the user has logged in
+   as."
+  [param-map]
+  (let [{:keys [token provider-id provider-guid]} param-map]
+    (soap/post-soap
+     :provider ["ns2:RemoveProviderPolicies"
+                soap/soap-ns-map
+                ["ns2:token" token]
+                (when provider-id ["ns2:providerId" provider-id])
+                (when provider-guid ["ns2:providerGuid" provider-guid])])
+    nil))
+
 (defn get-provider-policies
   "Get provider policies for the provider specified by the behalfOfProvider field of the specified token."
   [param-map]


Remove linneus globals (unused)

Remove linneus globals (unused)

--- src/chapter4/linneus.cljs
+++ src/chapter4/linneus.cljs
@@ -1,9 +1,6 @@
 (ns chapter4.linneus
   (:refer chapter3.match :only [match match-state atom?])
   (:refer clojure.test :only [with-test is run-tests]))
-;TODO: This is probably wrong -- should be locally scoped inside the conversation loop
-(def isa (atom {}))
-(def includes (atom {}))
 (with-test
   (defn add-to-list [aname x d]
     (if (d aname)


only update theme text when theme changes

--- src/client/game/core.cljs
+++ src/client/game/core.cljs
@@ -78,11 +78,13 @@
   "Temp state of the board when paused"
   (atom nil))

-(defn- update-theme [_ _ _ new-state]
-  (let [theme-num (:theme new-state)
-        theme (get themes theme-num)]
-    (.html ($ "#theme") (:year theme))
-    (.html ($ "#theme-details") (:platform theme))))
+(defn- update-theme [_ _ old-state new-state]
+  (if (not= (:theme old-state)
+            (:theme new-state))
+    (let [theme-num (:theme new-state)
+          theme (get themes theme-num)]
+      (.html ($ "#theme") (:year theme))
+      (.html ($ "#theme-details") (:platform theme)))))

 (add-watch state :theme-change update-theme)

@@ -369,7 +371,7 @@

 (defn change-theme!
   "Changes the boards theme"
-  [theme year platform event]
+  [theme event]
   (.preventDefault event)
   (swap! state assoc :theme theme)
   ;; TODO: set this in the atom watcher?
@@ -435,16 +437,16 @@
         key-down (fn [e]
                    (case (key-name e)
                     ;; TODO: remove this - replace with themes value
-                     :one   (change-theme! 0 "1984" "Electronika 60" e)
-                     :two   (change-theme! 1 "1986" "MS DOS" e)
-                     :three (change-theme! 2 "1986" "Tengen/Atari Arcade" e)
-                     :four  (change-theme! 3 "1989" "Gameboy" e)
-                     :five  (change-theme! 4 "1989" "NES" e)
-                     :six   (change-theme! 5 "1989" "Sega Genesis" e)
-                     :seven (change-theme! 6 "1998" "Gameboy color" e)
-                     :eight (change-theme! 7 "2000" "TI-83" e)
-                     :nine  (change-theme! 8 "2002" "Flash" e)
-                     :zero  (change-theme! 9 "2012" "Facebook" e)
+                     :one   (change-theme! 0 e)
+                     :two   (change-theme! 1 e)
+                     :three (change-theme! 2 e)
+                     :four  (change-theme! 3 e)
+                     :five  (change-theme! 4 e)
+                     :six   (change-theme! 5 e)
+                     :seven (change-theme! 6 e)
+                     :eight (change-theme! 7 e)
+                     :nine  (change-theme! 8 e)
+                     :zero  (change-theme! 9 e)
                      :p     (do (toggle-pause-game!) (.preventDefault e))
                      nil)
                    (if (and (:piece @state) (not @paused?))


* src/clj/cljs/compiler.clj: detect optimizable protocol fn invokes

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -695,6 +695,13 @@
         fn? (and *cljs-static-fns*
                  (not (:dynamic info))
                  (:fn-var info))
+        protocol (:protocol info)
+        proto? (let [tag (infer-tag (first (:args expr)))]
+                 (and protocol tag
+                      (or (and *cljs-static-fns* (:protocol-impl env))
+                          (:protocol-inline env))
+                      (when-let [ps (:protocols (resolve-existing-var (dissoc env :locals) tag))]
+                        (ps protocol))))
         opt-not? (and (= (:name info) 'cljs.core/not)
                       (= (infer-tag (first (:args expr))) 'boolean))
         ns (:ns info)


Eliminate intermediate sequence more

Eliminate intermediate sequence more

Co-Authored-By: alumi <116b7a68c8cecb5b0e630fff3330a0540dd39638@users.noreply.github.com>

--- src/cljam/algo/pileup.clj
+++ src/cljam/algo/pileup.clj
@@ -40,7 +40,7 @@
   (let [empty-qual? (and (= (.length qual) 1)
                          (= (.charAt qual 0) \*))]
     (if empty-qual?
-      (short-array (repeat (count idx) 93)) ;; \~
+      (short-array (count idx) (short 93)) ;; \~
       (->> idx
            (map (fn [[_ x]]
                   (if (number? x)


Don't copy & paste stuff.

Don't copy & paste stuff.

--- test/redis/tests.clj
+++ test/redis/tests.clj
@@ -428,7 +428,7 @@
   (redis/exec)
   (is (= "blahonga" (redis/get "key"))))

-(deftest multi-exec
+(deftest multi-discard
   (redis/set "key" "value")
   (redis/multi)
   (is (= "QUEUED" (redis/set "key" "blahonga")))


pass component to transact! instead of reconciler

possible by fixing the query hierarchy as explained in section "Common Mistakes" on
https://awkay.github.io/om-tutorial/#!/om_tutorial.E_UI_Queries_and_State

--- src/tudu/ui.cljs
+++ src/tudu/ui.cljs
@@ -10,7 +10,6 @@
     [cljs.core.async.macros :refer [go]]))

 (enable-console-print!)
-(declare reconciler)

 (def clean-item-editing {:title ""})

@@ -30,13 +29,12 @@
   Object
   (render [this]
           (let [{:keys [id status title]} (om/props this)
-                {:keys [close-item]} (om/get-computed this)
                 closed? (= status :close)
                 class-name (str "todo-list-item-title status-" (name status))]
             (dom/div #js {:className "todo-list-item" :key (str "todo-item-" id)}
                      (dom/input #js {:type "checkbox" :disabled closed?
                                      :checked closed?
-                                     :onClick #(close-item id)})
+                                     :onClick #(close-item this id)})

                      (dom/span #js {:className class-name} title)))))

@@ -46,15 +44,11 @@
   (if (= status :open) 0 1))

 (defui TodoListUI
-  static om/IQuery
-  (query [this]
-         [{:tudu/items (om/get-query TodoItemUI)}])
   Object
   (render [this]
-          (let [{:keys [tudu/items]} (om/props this)
-                tui-cprops {:close-item #(close-item reconciler %)}]
+          (let [{:keys [tudu/items]} (om/props this)]
             (dom/div #js {:className "todo-list-items"}
-                     (map #(todo-item-ui (om/computed % tui-cprops))
+                     (map todo-item-ui
                          (sort-by (juxt status-to-order :id) items))))))

 (def todo-list-ui (om/factory TodoListUI))
@@ -74,24 +68,18 @@
                             :tudu.item/editing :tudu/items]))

 (defui NewTodoItemUI
-  static om/IQuery
-  (query [this]
-         [:tudu.item/editing])
   Object
   (render [this]
           (let [{:keys [tudu.item/editing]} (om/props this)
                 {:keys [title]} editing
-                on-change (on-change-cb reconciler task-title-change)]
+                {:keys [create-task on-title-change]} (om/get-computed this)]
             (dom/div #js {:className "new-todo-item-form"}
                       (dom/div #js {:className "form-group"}
                                (dom/label nil "Task")
                                (dom/input #js {:value title
-                                               :onChange on-change}))
-                      ; NOTE: I have to pass the reconciler here and not the
-                      ; component otherwise I get:
-                      ; Error: No queries exist for component path (tudu.ui/UI tudu.ui/NewTodoItemUI)
+                                               :onChange on-title-change}))
                       (dom/button #js {:className "new-todo-item-create"
-                                       :onClick #(create-task reconciler editing)}
+                                       :onClick #(create-task editing)}
                                   "Create")))))

 (def new-todo-item-ui (om/factory NewTodoItemUI))
@@ -99,13 +87,15 @@
 (defui UI
   static om/IQuery
   (query [this]
-         (vec (concat (om/get-query TodoListUI)
-                      (om/get-query NewTodoItemUI))))
+         [:tudu.item/editing
+          {:tudu/items (om/get-query TodoItemUI)}])
   Object
   (render [this]
-          (let [props (om/props this)]
+          (let [props (om/props this)
+                nti-cprops {:on-title-change (on-change-cb this task-title-change)
+                            :create-task #(create-task this %)}]
             (dom/div nil
-                     (new-todo-item-ui props)
+                     (new-todo-item-ui (om/computed props nti-cprops))
                      (todo-list-ui props)))))

 (defmulti read om/dispatch)


Fixing auto login module tests

Fixing auto login module tests

Conflicts:
	storm-core/test/clj/backtype/storm/security/auth/auto_login_module_test.clj

--- storm-core/test/clj/org/apache/storm/security/auth/auto_login_module_test.clj
+++ storm-core/test/clj/org/apache/storm/security/auth/auto_login_module_test.clj
@@ -19,8 +19,12 @@
   (:import [org.apache.storm.security.auth.kerberos AutoTGT
             AutoTGTKrb5LoginModule AutoTGTKrb5LoginModuleTest])
   (:import [javax.security.auth Subject Subject])
-  (:import [javax.security.auth.kerberos KerberosTicket])
+  (:import [javax.security.auth.kerberos KerberosTicket KerberosPrincipal])
   (:import [org.mockito Mockito])
+  (:import [java.text SimpleDateFormat])
+  (:import [java.util Date])
+  (:import [java.util Arrays])
+  (:import [java.net InetAddress])
   )

 (deftest login-module-no-subj-no-tgt-test
@@ -82,7 +86,23 @@
     (let [login-module (AutoTGTKrb5LoginModuleTest.)
           _ (set! (. login-module client) (Mockito/mock
                                             java.security.Principal))
-          ticket (Mockito/mock KerberosTicket)]
+          endTime (.parse (java.text.SimpleDateFormat. "ddMMyyyy") "31122030")
+          asn1Enc (byte-array 10)
+          _ (Arrays/fill asn1Enc (byte 122))
+          sessionKey (byte-array 10)
+          _ (Arrays/fill sessionKey (byte 123))
+          ticket (KerberosTicket.
+                   asn1Enc
+                   (KerberosPrincipal. "client/localhost@local.com")
+                   (KerberosPrincipal. "server/localhost@local.com")
+                   sessionKey
+                   234
+                   (boolean-array (map even? (range 3 10)))
+                   (Date.)
+                   (Date.)
+                   endTime,
+                   endTime,
+                   (into-array InetAddress [(InetAddress/getByName "localhost")]))]
       (.initialize login-module (Subject.) nil nil nil)
       (.setKerbTicket login-module ticket)
       (is (.login login-module))


removed unused clojure.java.shell dependency

--- src/yar/core.clj
+++ src/yar/core.clj
@@ -1,6 +1,5 @@
 (ns yar.core
-  (:require [clojure.java.shell :refer [sh]]
-            [clojure.core.async :as a :refer [chan go >! >!! <! <!! alts!! alts! go-loop thread]]
+  (:require [clojure.core.async :as a :refer [chan go >! >!! <! <!! alts!! alts! go-loop thread]]
             [me.raynes.conch :as sh]
             [clj-yaml.core :as yaml]
             [cheshire.core :as json]))


Use ex-data and ex-message

Use ex-data and ex-message

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -554,8 +554,8 @@
   if the data indicates a reader or analysis issue."
   [e]
   {:pre [(instance? ExceptionInfo e)]}
-  (if (#{{:tag :cljs/analysis-error} {:type :reader-exception}} (.-data e))
-    (.-message e)
+  (if (#{{:tag :cljs/analysis-error} {:type :reader-exception}} (ex-data e))
+    (ex-message e)
     e))

 (defn print-error


No longer necessary.

No longer necessary.

--- support/build-support/src/main/clojure/fnbox/build/tools.clj
+++ support/build-support/src/main/clojure/fnbox/build/tools.clj
@@ -127,11 +127,6 @@
 (defn unquote-cookie-path [xml]
   (set-system-property xml "org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR" "false"))

-(defn add-xa-datasource [xml]
-  ;; currently a noop
-  xml)
-
-
 (defn transform-config [file]
   (let [in-file (io/file jboss-dir file)
         xml (xml/parse-trim in-file)
@@ -146,7 +141,6 @@
                     add-extensions
                     add-subsystems
                     set-welcome-root
-                    unquote-cookie-path
-                    add-xa-datasource)
+                    unquote-cookie-path)
                 :indent 4))
              out-file)))


secondary record updating

secondary record updating

--- test/er_cassandra/model/alia/upsert_test.clj
+++ test/er_cassandra/model/alia/upsert_test.clj
@@ -17,6 +17,17 @@
                    "(id timeuuid primary key, nick text)")
   (t/create-entity
    {:primary-table {:name :simple_upsert_test :key [:id]}}))
+
+(defn create-secondary-entity
+  []
+  (tu/create-table :secondary_upsert_test
+                   "(org_id timeuuid, id timeuuid, nick text, primary key (org_id, id))")
+  (tu/create-table :secondary_upsert_test_by_nick
+                   "(org_id timeuuid, nick text, id timeuuid, primary key (org_id, nick))")
+  (t/create-entity
+   {:primary-table {:name :secondary_upsert_test :key [:org_id :id]}
+    :secondary-tables [{:name :secondary_upsert_test_by_nick
+                        :key [:org_id :nick]}]}))

 (deftest delete-record-test
   (let [m (create-simple-entity)
@@ -43,6 +54,56 @@
     (is (= r record))
     (is (= :upserted reason))
     (is (= r (fetch-record :simple_upsert_test :id id)))))
+
+(deftest stale-secondary-key-value-test
+  (let [m (t/create-entity
+           {:primary-table {:name :foos :key [:id]}
+            :secondary-tables [{:name :foos_by_bar :key [:bar]}]})
+        st (-> m :secondary-tables first)]
+
+    (testing "ignores secondary keys when missing from new-record"
+      (is (= nil
+             (u/stale-secondary-key-value
+              m
+              {:id :a :bar :b}
+              {:id :a}
+              (-> m :secondary-tables first)))))
+
+    (testing "correctly identifies a stale singular secondary key value"
+      (is (= [:b]
+             (u/stale-secondary-key-value
+              m
+              {:id :a :bar :b}
+              {:id :a :bar nil}
+              (-> m :secondary-tables first)))))))
+
+(deftest delete-stale-secondaries-test
+  (let [m (create-secondary-entity)
+        [org-id id] [(uuid/v1) (uuid/v1)]
+        r {:org_id org-id :id id :nick "foo"}
+        _ @(r/insert tu/*model-session* :secondary_upsert_test r)
+        old-r (fetch-record :secondary_upsert_test [:org_id :id] [org-id id])
+        [status
+         record
+         reason] @(u/delete-stale-secondaries
+                   tu/*model-session*
+                   m
+                   old-r
+                   {:org_id org-id :id id :nick "bar"})]
+    (is (= r old-r))
+    (is (= nil (fetch-record :secondary_upsert_test_by_nick [:org_id :nick] [org-id "foo"])))))
+
+(deftest upsert-secondaries-test
+  (let [m (create-secondary-entity)
+        [org-id id] [(uuid/v1) (uuid/v1)]
+        r {:org_id org-id :id id :nick "bar"}
+        [status
+         record
+         reason] @(u/upsert-secondaries
+                   tu/*model-session*
+                   m
+                   r)]
+    (is (= r (fetch-record :secondary_upsert_test_by_nick [:org_id :nick] [org-id "bar"])))))

 (deftest stale-lookup-key-values-test
   (let [m (t/create-entity
@@ -77,27 +138,9 @@
                {:id :a :baz #{:c}}
                (-> m :lookup-key-tables second))))))))

-(deftest stale-secondary-key-value-test
-  (let [m (t/create-entity
-           {:primary-table {:name :foos :key [:id]}
-            :secondary-tables [{:name :foos_by_bar :key [:bar]}]})
-        st (-> m :secondary-tables first)]
+(deftest delete-stale-lookups-test)

-    (testing "ignores secondary keys when missing from new-record"
-      (is (= nil
-             (u/stale-secondary-key-value
-              m
-              {:id :a :bar :b}
-              {:id :a}
-              (-> m :secondary-tables first)))))
-
-    (testing "correctly identifies a stale singular secondary key value"
-      (is (= [:b]
-             (u/stale-secondary-key-value
-              m
-              {:id :a :bar :b}
-              {:id :a :bar nil}
-              (-> m :secondary-tables first)))))))
+(deftest lookup-record-seq-test)

 (deftest with-columns-option-for-lookups
   (let [m (t/create-entity
@@ -128,3 +171,14 @@
           :C1    (:c1 lrecord)
           :C2    (:c2 lrecord)
           false  (contains? lrecord :c3))))))
+
+(deftest upsert-lookups-test)
+
+(deftest copy-unique-keys-test)
+
+(deftest has-lookups?-test
+  )
+
+(deftest update-secondaries-and-lookups-test)
+
+(deftest upsert*-test)


update build header

update build header

--- frontend/components/build_head.cljs
+++ frontend/components/build_head.cljs
@@ -224,44 +224,46 @@
                      :href (build-model/path-for-parallelism build)}
                  (str (:parallel build) "x")]]]]]
             [:div.build-actions
-             (forms/stateful-button
-              [:button.retry_build
-               {:data-loading-text "Rebuilding",
-                :title "Retry the same tests",
-                :on-click #(put! controls-ch [:retry-build-clicked {:build-id build-id
-                                                                    :vcs-url vcs-url
-                                                                    :build-num build-num
-                                                                    :clear-cache? false}])}
-               "Rebuild"])
-             (forms/stateful-button
-              [:button.clear_cache_retry
-               {:data-loading-text "Rebuilding",
-                :title "Clear cache and retry",
-                :on-click #(put! controls-ch [:retry-build-clicked {:build-id build-id
-                                                                    :vcs-url vcs-url
-                                                                    :build-num build-num
-                                                                    :clear-cache? true}])}
-               "w/ cleared cache"])
-
-             (forms/stateful-button
-              [:button.ssh_build
-               {:data-loading-text "Rebuilding",
-                :title "Retry with SSH in VM",
-                :on-click #(put! controls-ch [:ssh-build-clicked build-id])}
-               "w/ ssh enabled"])
-             [:button.report_build
-              {:title "Report error with build",
-               :on-click #(put! controls-ch [:report-build-clicked {:build-url (:build_url @build)}])}
-              "Report"]
-             (when (build-model/can-cancel? build)
-               (forms/stateful-button
-                [:button.cancel_build
-                 {:data-loading-text "Canceling",
-                  :title "Cancel this build",
-                  :on-click #(put! controls-ch [:cancel-build-clicked {:build-id build-id
-                                                                       :vcs-url vcs-url
-                                                                       :build-num build-num}])}
-                 "Cancel"]))]]
+             [:div.actions
+              (forms/stateful-button
+               [:button.retry_build
+                {:data-loading-text "Rebuilding",
+                 :title "Retry the same tests",
+                 :on-click #(put! controls-ch [:retry-build-clicked {:build-id build-id
+                                                                     :vcs-url vcs-url
+                                                                     :build-num build-num
+                                                                     :clear-cache? false}])}
+                "Rebuild"])
+              (forms/stateful-button
+               [:button.clear_cache_retry
+                {:data-loading-text "Rebuilding",
+                 :title "Clear cache and retry",
+                 :on-click #(put! controls-ch [:retry-build-clicked {:build-id build-id
+                                                                     :vcs-url vcs-url
+                                                                     :build-num build-num
+                                                                     :clear-cache? true}])}
+                "& clear cache"])
+
+              (forms/stateful-button
+               [:button.ssh_build
+                {:data-loading-text "Rebuilding",
+                 :title "Retry with SSH in VM",
+                 :on-click #(put! controls-ch [:ssh-build-clicked build-id])}
+                "& enable ssh"])]
+             [:div.actions
+              [:button.report_build
+               {:title "Report error with build",
+                :on-click #(put! controls-ch [:report-build-clicked {:build-url (:build_url @build)}])}
+               "Report"]
+              (when (build-model/can-cancel? build)
+                (forms/stateful-button
+                 [:button.cancel_build
+                  {:data-loading-text "Canceling",
+                   :title "Cancel this build",
+                   :on-click #(put! controls-ch [:cancel-build-clicked {:build-id build-id
+                                                                        :vcs-url vcs-url
+                                                                        :build-num build-num}])}
+                  "Cancel"]))]]]
            (when (:show-usage-queue usage-queue-data)
              (om/build build-queue {:build build
                                     :builds (:builds usage-queue-data)}))


Remove unnecessary blank line

Remove unnecessary blank line

--- ring-core/src/ring/util/response.clj
+++ ring-core/src/ring/util/response.clj
@@ -7,7 +7,6 @@
   (:import [java.io File]
            [java.util Date]
            [java.net URL URLDecoder URLEncoder]))
-

 (def redirect-status-codes
   {:moved-permanently 301


Avoid hiccups at the start by delaying the drum loop

--- src/drum_machine/app.cljs
+++ src/drum_machine/app.cljs
@@ -53,6 +53,7 @@
 (defn run []
   ;; Beat generator
   (go
+    (<! (timeout 1000))
     (loop []
       (let [bpm (-> (parse [:settings/bpm]) :settings/bpm)]
         (<! (timeout (-> 60.0 (/ bpm) (* 1000))))


Fixing reference to link-to in users.clj

--- src/foreclojure/users.clj
+++ src/foreclojure/users.clj
@@ -1,7 +1,8 @@
 (ns foreclojure.users
   (:use foreclojure.utils
         somnium.congomongo
-        compojure.core))
+        compojure.core
+        [hiccup.page-helpers :only (link-to)]))

 (defn get-users []
   (let [users (from-mongo


Added 'test' task (see #11). Updated docstring.

--- src/leiningen/ancient.clj
+++ src/leiningen/ancient.clj
@@ -4,12 +4,14 @@
   (:require [leiningen.ancient.tasks.check :refer [run-check-task!]]
             [leiningen.ancient.tasks.get :refer [run-get-task!]]
             [leiningen.ancient.tasks.upgrade :refer [run-upgrade-task! run-upgrade-global-task!]]
+            [leiningen.ancient.tasks.test :refer [run-test-task!]]
             [ancient-clj.verbose :refer :all]))

 (def ^:private dispatch-table
   {"get"            run-get-task!
    "upgrade"        run-upgrade-task!
    "upgrade-global" run-upgrade-global-task!
+   "test"           run-test-task!
    nil              run-check-task!})

 (defn ^:no-project-needed ancient
@@ -19,29 +21,33 @@

      lein ancient [<options>]
      lein ancient get <package> [<options>]
+     lein ancient test [<options>]
      lein ancient upgrade [<options>]
      lein ancient upgrade-global [<options>]

    Tasks:

      get                  Retrieve artifact information from Maven repositories.
+     test                 Auto-detect test framework (clojure.test, midje, ...) and run tests.
      upgrade              Replace artifacts in your 'project.clj' with newer versions.
      upgrade-global       Replace plugins in '~/.lein/profiles.clj' with newer versions.

    Commandline Options:

+     :aggressive          Check all available repositories (= Do not stop after first artifact match).
      :all                 Check Dependencies and Plugins.
-     :dependencies        Check Dependencies. (default)
-     :plugins             Check Plugins.
-     :no-profiles         Do not check Dependencies/Plugins in Profiles.
      :allow-qualified     Allow '*-alpha*' versions & co. to be reported as new.
      :allow-snapshots     Allow '*-SNAPSHOT' versions to be reported as new.
      :check-clojure       Include Clojure (org.clojure/clojure) in checks.
-     :aggressive          Check all available repositories (= Do not stop after first artifact match).
+     :dependencies        Check Dependencies. (default)
      :interactive         Run ':upgrade' in interactive mode, prompting whether to apply changes.
+     :no-colors           Disable colorized output.
+     :no-profiles         Do not check Dependencies/Plugins in Profiles.
+     :no-tests            Do not run tests after upgrading a project.
+     :overwrite-backup    Do not prompt if a backup file exists when upgrading a project.
+     :plugins             Check Plugins.
      :print               Print result of ':upgrade' task instead of writing it to 'project.clj'.
      :verbose             Produce progress indicating messages.
-     :no-colors           Disable colorized output.
   "
   [project & args]
   (let [^String t (when-let [^String t (first args)]


Whitespace change...

Whitespace change...

--- src/leiningen/uberjar.clj
+++ src/leiningen/uberjar.clj
@@ -47,7 +47,7 @@
   (jar project)
   (let [jarname-root  (str (:name project) \- (:version project))]
     (with-open [out (-> (file (:root project) (str jarname-root "-standalone.jar"))
-                          (FileOutputStream.) (ZipOutputStream.))]
+                        (FileOutputStream.) (ZipOutputStream.))]
       ;; TODO: any way to make sure we skip dev dependencies?
       (let [deps (->> (file-seq (file (:library-path project)))
                       (filter #(.endsWith (.getName %) ".jar"))


have to use current db if we want this to work for older docs :(

--- src/pc/replay.clj
+++ src/pc/replay.clj
@@ -32,7 +32,7 @@
 (defn reproduce-transaction [db tx-id]
   (let [tx (d/entity db tx-id)]
     {:tx-data (tx-data tx)
-     :db-after (d/as-of db (:db/txInstant tx))}))
+     :db-after db}))

 (defn get-document-transactions
   "Returns a lazy sequence of transactions for a document in order of db/txInstant.


make copy-doc work again

make copy-doc work again

--- src/pc/replay.clj
+++ src/pc/replay.clj
@@ -1,5 +1,6 @@
 (ns pc.replay
-  (:require [datomic.api :as d]
+  (:require [clojure.set :as set]
+            [datomic.api :as d]
             [pc.datomic :as pcd]
             [pc.datomic.schema :as schema]
             [pc.datomic.web-peer :as web-peer])
@@ -32,11 +33,11 @@
 (defn reproduce-transaction [db tx-id]
   (let [tx (d/entity db tx-id)]
     {:tx-data (tx-data tx)
+     :tx tx
      :db-after db}))

 (defn get-document-transactions
-  "Returns a lazy sequence of transactions for a document in order of db/txInstant.
-   Has :tx-data and :db-after fields"
+  "Returns a lazy sequence of transactions for a document in order of db/txInstant."
   [db doc]
   (map (partial reproduce-transaction db)
        (get-document-tx-ids db doc)))
@@ -46,37 +47,76 @@
     (map (fn [tx]
            (if (= (:a tx) a)
              (assoc tx
-                    :v (UUID. doc-id (web-peer/client-part (:v tx)))
-                    :a (d/entid (pcd/default-db) :frontend/id))
+                    :v (UUID. doc-id (web-peer/client-part (:v tx))))
              tx))
          txes)))

+(defn doc-id-attr->ref-attr [db {:keys [e v] :as d}]
+  (let [ent (d/entity db e)]
+    (cond (:layer/type ent) :layer/document
+          (:chat/body ent)  :chat/document
+          (:layer/name ent) :layer/document
+          (= :layer (:entity/type ent)) :layer/document
+          (:layer/end-x ent) :layer/document
+          :else (throw (Exception. (format "couldn't find attr for %s" d))))))

+(defn replace-document-ids [db txes]
+  (let [a (d/entid db :document/id)]
+    (map (fn [tx]
+           (if (= (:a tx) a)
+             (assoc tx
+                    :a (doc-id-attr->ref-attr (d/as-of db (if (:added tx)
+                                                            (:tx tx)
+                                                            (dec (:tx tx))))
+                                              tx))
+             tx))
+         txes)))

 (defn copy-transactions [db doc new-doc & {:keys [sleep-ms]
                                            :or {sleep-ms 1000}}]
   (let [conn (pcd/conn)
-        tx-datas (->> (get-document-transactions db doc)
-                   (map (fn [t]
-                          (->> (:tx-data t)
-                            (remove #(= (:e %) (:db/id t)))
-                            (map #(if (= (:v %) (:db/id doc))
-                                    (assoc % :v (:db/id new-doc))
-                                    %))
-                            (replace-frontend-ids db (:db/id new-doc))))))
-        eid-translations (-> (apply concat (map #(map :e %) tx-datas))
-                           set
+        txes (->> (get-document-transactions db doc)
+               (map (fn [tx]
+                      (update-in tx
+                                 [:tx-data]
+                                 (fn [tx-data]
+                                   (->> tx-data
+                                     (remove #(= (:e %) (:db/id (:tx tx))))
+                                     (map #(if (= (:v %) (:db/id doc))
+                                             (assoc % :v (:db/id new-doc))
+                                             %))
+                                     (replace-frontend-ids db (:db/id new-doc))
+                                     (replace-document-ids db)))))))
+        eid-translations (-> (reduce (fn [acc {:keys [tx-data]}]
+                                       (set/union acc (set (map :e tx-data))))
+                                     #{} txes)
                            (disj (:db/id doc))
                            (zipmap (repeatedly #(d/tempid :db.part/user)))
-                           (assoc (:db/id doc) (:db/id new-doc)))]
-    (doseq [tx-data tx-datas]
-      (def my-tx-data tx-data)
-      (let [txid (d/tempid :db.part/tx)]
-        @(d/transact conn (conj (map #(-> %
-                                        (update-in [:e] eid-translations)
-                                        pcd/datom->transaction)
-                                     tx-data)
-                                {:db/id txid
-                                 :transaction/document (:db/id new-doc)
-                                 :transaction/broadcast true}))
-        (Thread/sleep sleep-ms)))))
+                           (assoc (:db/id doc) (:db/id new-doc)))
+        reverse-eid-translations (set/map-invert eid-translations)
+        new-eids (reduce (fn [new-eid-trans tx]
+                           (if-not (seq (:tx-data tx))
+                             new-eid-trans
+                             (let [txid (d/tempid :db.part/tx)
+                                   tempids (map #(get eid-translations %)
+                                                (remove #(get new-eid-trans %)
+                                                        (map :e (:tx-data tx))))
+                                   new-tx @(d/transact conn (conj (map #(-> %
+                                                                          (update-in [:e] (fn [e] (or (get new-eid-trans e)
+                                                                                (get eid-translations e))))
+                                                                          pcd/datom->transaction)
+                                                                       (:tx-data tx))
+                                                                  (merge
+                                                                   {:db/id txid
+                                                                    :transaction/document (:db/id new-doc)}
+                                                                   (when (:transaction/broadcast (:tx tx))
+                                                                     {:transaction/broadcast true}))))]
+                               (merge new-eid-trans
+                                      (zipmap (map #(get reverse-eid-translations %) tempids)
+                                              (map #(d/resolve-tempid (:db-after new-tx) (:tempids new-tx) %) tempids))))))
+                         {} txes)]
+    @(d/transact conn (map (fn [e]
+                             [:db/add e :frontend/id (UUID. (:db/id new-doc) e)])
+                           (remove #(:frontend/id (d/entity db %))
+                                   (vals new-eids))))
+    new-doc))


Move no-tint to Image category.

Move no-tint to Image category.

--- src/quil/core.clj
+++ src/quil/core.clj
@@ -2590,7 +2590,7 @@
 (defn
   ^{:requires-bindings true
     :processing-name "noTint()"
-    :category "Color"
+    :category "Image"
     :subcategory "Loading & Displaying"
     :added "1.0"}
   no-tint


Implimentation Rest in delete documents

Implimentation Rest in delete documents

--- src/rrms/core.clj
+++ src/rrms/core.clj
@@ -8,28 +8,50 @@
             [ring.middleware.cors :refer [wrap-cors]]
             [rrms.db.core :as db]
             [bouncer.core :as b]
-            [bouncer.validators :as v])
+            [bouncer.validators :as v]
+            [clj-time.core :as t])
   (:gen-class))

 (def content-type  "application/json; charset=utf-8")

+(defmulti parse-int type)
+(defmethod parse-int java.lang.Integer [n] n)
+(defmethod parse-int java.lang.String [s] (Integer/parseInt s))
+
 (defroutes app-routes
-  (GET "/documents/title/:title" [title] (rr/content-type
-                                          (rr/response  (db/get-documents-by-title
-                                                         {:title title}))
-                                          content-type))
+
+  (GET "/documents/title/:title" [title]
+       (rr/content-type
+        (rr/response  (db/get-documents-by-title
+                       {:title title}))
+        content-type))
+
+  (GET "/documents/id/:id" [id]
+       (rr/content-type
+        (rr/response (db/get-documents-by-id
+                      {:id (parse-int id)}))
+        content-type))
+
   (POST "/documents/add" {body :body}
-        (let [{dn "documentname" t "title"
-               en "employeename" lc "location"
+        (let [{dn "documentname" title "title"
+               en "employeename" d "date"
+               lc "location"
                br "barcode" ia "isactive"}
               body]
           (db/insert-documents {:documentname dn
-                                :title t
+                                :title title
                                 :employeename en
+                                :date d
                                 :location lc
                                 :barcode br
                                 :isactive ia})
           (rr/content-type (rr/response "") content-type)))
+
+  (GET "/documents/delete/:id" [id]
+       (rr/content-type
+        (rr/response (db/delete-documents-by-id
+                      {:id (parse-int id)}))
+        content-type))
   (route/not-found "
Page not found
"))

 (def app


remove debugging println

remove debugging println

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@6813 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/sequence_generator.clj
+++ acqEngine/src/org/micromanager/sequence_generator.clj
@@ -115,7 +115,6 @@
         e2 :wait-time-ms interval-ms))))

 (defn burst-valid [e1 e2]
-  (println e2)
   (and
     (#(or (nil? %) (>= (:exposure e2) %)) (:wait-time-ms e2))
     (select-values-match? e1 e2 [:exposure :position :slice :channel])


Fix html_spec extension.

Fix html_spec extension.

--- spec/incise/parsers/html_spec.clj
+++ spec/incise/parsers/html_spec.clj
@@ -13,6 +13,6 @@
                           :tags [:cool]
                           :category :blarg
                           :content "\n\nHey there!\n"
-                          :extension :html}) (File->Parse identity @short-md-file))))
+                          :extension "/index.html"}) (File->Parse identity @short-md-file))))

 (run-specs)


CMR-7028: Updated jackson-dataformat (#1152)

--- search-app/project.clj
+++ search-app/project.clj
@@ -4,6 +4,7 @@
   :exclusions [cheshire
                clj-time
                com.fasterxml.jackson.core/jackson-core
+               com.fasterxml.jackson.dataformat/jackson-dataformat-cbor
                commons-codec
                org.apache.httpcomponents/httpclient
                org.clojure/clojure
@@ -16,6 +17,7 @@
                  [com.fasterxml.jackson.core/jackson-annotations "2.12.0"]
                  [com.fasterxml.jackson.core/jackson-core "2.12.0"]
                  [com.fasterxml.jackson.core/jackson-databind "2.12.0"]
+                 [com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.12.1"]
                  [commons-codec/commons-codec "1.11"]
                  [commons-io/commons-io "2.6"]
                  [gov.nasa.earthdata/cmr-site-templates "0.1.1-SNAPSHOT"]


simpler flatmap appears to be much better

--- src/mediakeys/hotkeys.clj
+++ src/mediakeys/hotkeys.clj
@@ -73,17 +73,20 @@
 ;   "macro" loop somehow
 ;
 ;
-(defn mapcat-last< [f channel]
-    (let [return (chan)
-          last-value (atom nil)]
+
+(def not-nil? (comp not nil?))
+
+(defn flatmap< [f channel]
+    (let [return (chan)]
         (go-loop []
-            (reset! last-value (f (<! channel)))
-            (go-loop []
-                ; this seems like it might leak memory somehow, and won't actually do what
-                ; you want anyway, since @last-value is not a mutable variable
-                (>! return (<! @last-value))
-                (recur))
-            (recur))
+            (let [value (<! channel)]
+                (when not-nil? value
+                    (go-loop [unflattened (f value)]
+                        (let [inner-value (<! unflattened)]
+                            (when (not-nil? inner-value)
+                                (>! return inner-value)
+                                (recur unflattened))))
+                    (recur))))
         return))

 (def numbers (chan))
@@ -96,4 +99,4 @@
         (put! c (* 2 number))
         c))

-(def dubs (mapcat-last< silly-double numbers))+(def dubs (flatmap< silly-double numbers))


WIP: updated ServiceConfiguration<->Configuration mapping following schema change.

--- db-binding/src/com/sixsq/slipstream/db/serializers/ServiceConfigSerializer.clj
+++ db-binding/src/com/sixsq/slipstream/db/serializers/ServiceConfigSerializer.clj
@@ -37,25 +37,25 @@
    :connectorOrchPublicSSHKey  "cloud.connector.orchestrator.publicsshkey"
    :connectorLibcloudURL       "cloud.connector.library.libcloud.url"

-   :mail-username              "slipstream.mail.username"
-   :mail-password              "slipstream.mail.password"
-   :mail-host                  "slipstream.mail.host"
-   :mail-port                  "slipstream.mail.port"
-   :mail-ssl                   "slipstream.mail.ssl"
-   :mail-debug                 "slipstream.mail.debug"
+   :mailUsername               "slipstream.mail.username"
+   :mailPassword               "slipstream.mail.password"
+   :mailHost                   "slipstream.mail.host"
+   :mailPort                   "slipstream.mail.port"
+   :mailSSL                    "slipstream.mail.ssl"
+   :mailDebug                  "slipstream.mail.debug"

-   :quota-enable               "slipstream.quota.enable"
+   :quotaEnable                "slipstream.quota.enable"

-   :registration-enable        "slipstream.registration.enable"
-   :registration-email         "slipstream.registration.email"
+   :registrationEnable         "slipstream.registration.enable"
+   :registrationEmail          "slipstream.registration.email"

-   :prs-enable                 "slipstream.prs.enable"
-   :prs-endpoint               "slipstream.prs.endpoint"
+   :prsEnable                  "slipstream.prs.enable"
+   :prsEndpoint                "slipstream.prs.endpoint"

-   :metering-enable            "slipstream.metering.enable"
-   :metering-endpoint          "slipstream.metering.hostname"
+   :meteringEnable             "slipstream.metering.enable"
+   :meteringEndpoint           "slipstream.metering.hostname"

-   :service-catalog-enable     "slipstream.service.catalog.enable"
+   :serviceCatalogEnable       "slipstream.service.catalog.enable"
    })

 (def param->rname (set/map-invert rname->param))
@@ -64,17 +64,17 @@
   [s]
   (try
     (read-string s)
-  (catch RuntimeException ex
-    (if-not (s/starts-with? (.getMessage ex) "Invalid token")
-      (throw ex)
-      s))))
+    (catch RuntimeException ex
+      (if-not (s/starts-with? (.getMessage ex) "Invalid token")
+        (throw ex)
+        s))))

 (defn param-value
   [p]
   (let [v (.getValue p)]
-      (if (= (type (read-str v)) clojure.lang.Symbol)
-        v
-        (read-str v))))
+    (if (= (type (read-str v)) clojure.lang.Symbol)
+      v
+      (read-str v))))

 (defn param-name
   [p]


Use `nil-pool` instead of a new random UUID (#919)

--- scheduler/src/cook/mesos/pool.clj
+++ scheduler/src/cook/mesos/pool.clj
@@ -33,9 +33,11 @@
   "Returns:
    - The given pool name if not-nil
    - The default pool name, if configured
-   - A random UUID"
+   - `nil-pool`
+   Returning `nil-pool` instead of `nil` allows this to be used as an argument to a datomic function
+   or comparison operator"
   [pool-name]
-  (or pool-name (config/default-pool) (str (UUID/randomUUID))))
+  (or pool-name (config/default-pool) nil-pool))

 (defn default-pool?
   "Returns true if pool-name is equal to the default pool name"


Update an example project

Update an example project

--- example/project.clj
+++ example/project.clj
@@ -6,7 +6,7 @@

   ; List of plugins
-  :plugins [[lein-jslint "0.1.6"]]
+  :plugins [[lein-jslint "0.1.7"]]

   ; List of hooks
   ; It's used for running JSLint during compile phase


update java to 1.8

update java to 1.8

--- boot/worker/project.clj
+++ boot/worker/project.clj
@@ -14,7 +14,7 @@
   :license      {:name "Eclipse Public License"
                  :url "http://www.eclipse.org/legal/epl-v10.html"}
   :java-source-paths ["third_party/barbarywatchservice/src"]
-  :javac-options ["-target" "1.7" "-source" "1.7"]
+  :javac-options ["-target" "1.8" "-source" "1.8"]
   :dependencies [[org.clojure/clojure         "1.6.0"  :scope "provided"]
                  [boot/base                   ~version :scope "provided"]
                  [boot/aether                 ~version]