four more forms are created

four more forms are created

--- src_cljs/rrms/corecljs.cljs
+++ src_cljs/rrms/corecljs.cljs
@@ -270,6 +270,21 @@

 (defn field-click [event]
   (secretary/dispatch! "/fieldbook"))
+
+(defn misc-click [event]
+  (secretary/dispatch! "/misc"))
+
+(defn o2-click [event]
+  (secretary/dispatch! "/o2register"))
+
+(defn o4-click [event]
+  (secretary/dispatch! "/o4register"))
+
+(defn o6-click [event]
+  (secretary/dispatch! "/o6register"))
+
+
+

 ;;.............. End of Tab Events ......

@@ -1468,7 +1483,7 @@
        [:div{:class "col-xs-6 col-centered col-max"} [shared-state 0]]]]]]])

 ;; ---------------------------------------------------------
-;; rvenue-records
+;; fieldbook-records

 (defn fieldbook-form-validator [data-set]
   (first (b/validate data-set
@@ -1680,8 +1695,789 @@
                                          :class "btn btn-danger btn-sm glyphicon glyphicon-remove"}]]])]]
        [:div{:class "col-xs-6 col-centered col-max"} [shared-state 0]]]]]]])

-;; -------------------------------------------------------------------------------
-
+;; ---------------------------------------------------------
+;; misc-records
+
+(defn misc-form-validator [data-set]
+  (first (b/validate data-set
+                     :filenumber [[v/required :message "Field is required"]]
+                     :subject [[v/required :message "Field is required"]]
+                     :title [[v/required :message "Field is required"]]
+                     :remarks [[v/required :message "Field is required"]]
+                     :dispatcheddate [[v/required :message "Field is required"]]
+                     :receiveddate [[v/required :message "Field is required"]]
+                     )))
+
+
+;; (defn misc-input-int-row [id label ttype data-set focus]
+;;   (let [input-focus (r/atom nil)]
+;;     (fn []
+;;       [:div.form-group
+;;        [:label.col-sm-3.control-label label]
+;;        [:div.col-sm-6 [input-int id ttype data-set label input-focus]]
+;;        [:div.col-sm-3 (if (or @input-focus @focus)
+;;                         (if (= nil (misc-form-validator @data-set))
+;;                           [:div]
+;;                           [:div {:style  {:color "red"}}
+;;                            [:b (str (first ((misc-form-validator @data-set) id)))]])
+;;                         [:div])]])))
+
+(defn misc-input-row [id label ttype data-set focus]
+  (let [input-focus (r/atom nil)]
+    (fn []
+      [:div.form-group
+       [:label.col-sm-3.control-label label]
+       [:div.col-sm-6 [input-element id ttype data-set label input-focus]]
+       [:div.col-sm-3 (if (or @input-focus @focus)
+                        (if (= nil (misc-form-validator @data-set))
+                          [:div]
+                          [:div {:style  {:color "red"}}
+                           [:b (str (first ((misc-form-validator @data-set) id)))]])
+                        [:div])]])))
+
+
+(defn misc-template [doc-name data-set focus save-function]
+ [:div.container
+  [:div.col-md-12
+   [:div.box.box-info
+    [:div.box-header.with-border
+     [:h2.box-title doc-name]]
+    [:div.form-horizontal
+     [:div.box-body
+       [misc-input-row :filenumber "File Numbar" "text" data-set focus]
+       [misc-input-row :subject "Subject" "text" data-set focus]
+       [misc-input-row :title "Title" "text" data-set focus]
+       [misc-input-row :remarks "Remarks" "text" data-set focus]
+       [misc-input-row :dispatcheddate "Dispatched Date" "date" data-set focus]
+       [misc-input-row :receiveddate "Recevied Date" "date" data-set focus]
+    [:div.box-footer
+      [:button.btn.btn-default {:on-click misc-form-cancel} "Cancel"]
+      [:button.btn.btn-info.pull-right {:on-click save-function} "Save"]]]]]]])
+
+(defn misc-add-template []
+  (let [add-data (r/atom {:isactive true})
+        focus (r/atom nil)]
+    (fn [] [misc-template
+              "misc Add Form"
+               add-data
+               focus
+               #(misc-add-form-onclick add-data focus)])))
+
+(defn misc-update-template [id dmt]
+  (let [update-data (r/atom {:id (int id)
+                             :filenumber (.-filenumber dmt)
+                             :subject (.-subject dmt)
+                             :title (.-title dmt)
+                             :remarks (.-remarks dmt)
+                             :dispatcheddate (.-dispatcheddate dmt)
+                             :receiveddate (.-receiveddate dmt)
+                             })
+        focus (r/atom nil)]
+    (fn [] [misc-template
+            "misc Update Form"
+            update-data
+            focus
+            #(misc-update-form-onclick update-data focus)])))
+
+
+(defn misc-add-form-onclick [data-set focus]
+  (if (= nil (misc-form-validator @data-set))
+    (let [onres (fn[json] (secretary/dispatch! "/misc"))]
+          (http-post (str serverhost "miscs") onres  (.serialize (Serializer.) (clj->js @data-set))))
+  (reset! focus "on")))
+
+
+(defn misc-update-form-onclick [data-set focus]
+  (if (= nil (misc-form-validator @data-set))
+      (let [onres (fn[data] (secretary/dispatch! "/misc"))]
+          (http-put (str serverhost "miscs/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set))))
+    (reset! focus "on")))
+
+(defn misc-form-cancel [event]
+  (secretary/dispatch! "/misc"))
+
+(defn misc-add [event]
+  (secretary/dispatch! "/misc/add"))
+
+(defn misc-update[id]
+  (secretary/dispatch! (str "/misc/update/" id)))
+
+(defn misc-delete[id]
+  (let [onres (fn [json]
+                (secretary/dispatch! "/misc"))]
+    (http-delete (str serverhost "miscs/" id)  onres)))
+
+
+(defroute misc-list "/misc" []
+  (let [onres (fn [json]
+                (let [dt (getdata json)]
+                  (set-key-value :miscs (.-data dt))
+                  (set-key-value :total-pages (get-total-rec-no (.-pagesCount dt)))
+                  (set-key-value :page-location  [render-misc (get-value! :miscs)])))]
+    (set-key-value :is-searched-results false)
+    (http-get (str serverhost "miscs?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres)))
+
+
+(defroute misc-add-path "/misc/add" []
+  (let [onres (fn[json](
+                        (set-key-value :villages (getdata json))
+                        (set-page! [misc-add-template])))]
+    (http-get (str serverhost "villages") onres)))
+
+(defroute misc-upd-path "/misc/update/:id" [id]
+  (let [onres (fn[json](
+                        (set-key-value :villages (getdata json))
+                        (set-page! [misc-update-template id
+                                    (first (filter (fn[obj]
+                                                     (=(.-id obj) (.parseInt js/window id))) (get-value! :miscs)))])))]
+    (http-get (str serverhost "villages") onres)))
+
+
+
+(defn render-misc [miscs]
+  [:div
+   [:div {:class "box"}
+    [:div {:class "box-header"}
+     [:h3 "List of misc Records"]]
+    [:div.row
+     [:div.col-md-12
+      [:div.form-group
+       [:input {:type "button" :value "Add"
+                :class "btn btn-primary" :on-click misc-add}]
+       ;; [:input {:id "getall" :type "button" :value "Refresh"
+       ;;          :class "btn btn-primary" :on-click get-all-click}]
+       ]
+      [:div {:class "box-body"}
+
+       [:table {:class "table table-bordered table-striped dataTable"}
+        [:thead
+         [:tr
+          [:th "Fille Number"]
+          [:th "Subject"]
+          [:th "Title"]
+          [:th "Remarks"]
+          [:th "Dispatched Date"]
+          [:th "Received Date"]
+          [:th " "]
+          [:th " "]
+          ]]
+        [:tbody
+         (for [mt miscs]
+           ^{:key (.-id mt)} [:tr
+                              [:td (.-filenumber mt)]
+                              [:td (.-subject mt)]
+                              [:td (.-title mt)]
+                              [:td (.-remarks mt)]
+                              [:td (.-dispatcheddate mt)]
+                              [:td (.-receiveddate mt)]
+                              [:td [:a {:href "javascript:;"
+                                        :on-click  #(misc-update(.-id mt))
+                                        :class "btn btn-success btn-sm glyphicon glyphicon-edit"}]]
+                              [:td  [:a {:href "javascript:;" :on-click #(misc-delete(.-id mt))
+                                         :class "btn btn-danger btn-sm glyphicon glyphicon-remove"}]]])]]
+       [:div{:class "col-xs-6 col-centered col-max"} [shared-state 0]]]]]]])
+
+;; ---------------------------------------------------------
+;; o2register-records
+
+(defn o2register-form-validator [data-set]
+  (first (b/validate data-set
+                     :serialnumber [[v/required :message "Field is required Must be number"]]
+                     :tehsil [[v/required :message "Field is required"]]
+                     :dateofinstitution [[v/required :message "Field is required"]]
+                     :sourceofreceipt [[v/required :message "Field is required"]]
+                     :nameofthefirstparty [[v/required :message "Field is required"]]
+                     :dateofreceiptfrompanchayat [[v/required :message "Field is required"]]
+                     :dateandgistoffinalorder [[v/required :message "Field is required"]]
+                     :racknumber [[v/required :message "Field is required"]]
+                     :startingyear [[v/required :message "Field is required Must be number"]]
+                     :endingyear [[v/required :message "Field is required Must be number"]])))
+
+
+(defn o2register-input-int-row [id label ttype data-set focus]
+  (let [input-focus (r/atom nil)]
+    (fn []
+      [:div.form-group
+       [:label.col-sm-3.control-label label]
+       [:div.col-sm-6 [input-int id ttype data-set label input-focus]]
+       [:div.col-sm-3 (if (or @input-focus @focus)
+                        (if (= nil (o2register-form-validator @data-set))
+                          [:div]
+                          [:div {:style  {:color "red"}}
+                           [:b (str (first ((o2register-form-validator @data-set) id)))]])
+                        [:div])]])))
+
+(defn o2register-input-row [id label ttype data-set focus]
+  (let [input-focus (r/atom nil)]
+    (fn []
+      [:div.form-group
+       [:label.col-sm-3.control-label label]
+       [:div.col-sm-6 [input-element id ttype data-set label input-focus]]
+       [:div.col-sm-3 (if (or @input-focus @focus)
+                        (if (= nil (o2register-form-validator @data-set))
+                          [:div]
+                          [:div {:style  {:color "red"}}
+                           [:b (str (first ((o2register-form-validator @data-set) id)))]])
+                        [:div])]])))
+
+
+(defn o2register-template [doc-name data-set focus save-function]
+ [:div.container
+  [:div.col-md-12
+   [:div.box.box-info
+    [:div.box-header.with-border
+     [:h2.box-title doc-name]]
+    [:div.form-horizontal
+     [:div.box-body
+       [o2register-input-int-row :serialnumber "Serial Number" "text" data-set focus]
+       [o2register-input-row :tehsil "Tehsil" "text" data-set focus]
+       [o2register-input-row :dateofinstitution "Date Of Institution" "date" data-set focus]
+       [o2register-input-row :sourceofreceipt "Source Of Receipt" "text" data-set focus]
+       [o2register-input-select "Village Name" data-set focus ]
+       [o2register-input-row :nameofthefirstparty "Name Of The First Party" "text" data-set focus]
+       [o2register-input-row :dateofreceiptfrompanchayat "Date Of Receipt From Panchayat" "date" data-set focus]
+       [o2register-input-row :dateandgistoffinalorder "Date and gist of Final Order" "date" data-set focus]
+       [o2register-input-row :racknumber "Rack Number" "text" data-set focus]
+       [o2register-input-int-row :startingyear "Starting Year" "text" data-set focus]
+       [o2register-input-int-row :endingyear "Ending Year" "text" data-set focus]
+    [:div.box-footer
+      [:button.btn.btn-default {:on-click o2register-form-cancel} "Cancel"]
+      [:button.btn.btn-info.pull-right {:on-click save-function} "Save"]]]]]]])
+
+
+(defn o2register-add-form-onclick [data-set focus]
+  (if (= nil (o2register-form-validator @data-set))
+    (do (reset! data-set (assoc @data-set :villageid (int (.-value (.getElementById js/document "o2register-districts")))))
+        (let [onres (fn[json] (secretary/dispatch! "/o2register"))]
+          (http-post (str serverhost "o2registers") onres  (.serialize (Serializer.) (clj->js @data-set)))))
+  (reset! focus "on")))
+
+
+(defn o2register-update-form-onclick [data-set focus]
+  (if (= nil (o2register-form-validator @data-set))
+    (do (reset! data-set (assoc @data-set :villageid (int (.-value (.getElementById js/document "o2register-districts")))))
+        (let [onres (fn[data] (secretary/dispatch! "/o2register"))]
+          (http-put (str serverhost "o2registers/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set)))))
+    (reset! focus "on")))
+
+(defn o2register-form-cancel [event]
+  (secretary/dispatch! "/o2register"))
+
+(defn o2register-on-change [event]
+  (let [ele (.getElementById js/document "id")
+        eval (.-value ele)
+        onresp (fn [json]
+                 (let [dt (getdata json)]
+                   (set-key-value :villages dt)))]
+    (set-key-value :villages [])
+    (when-not ( >  1 (.-length eval))
+      (http-get (str serverhost "villages/search?name=" eval) onresp))))
+
+
+(defn o2register-tags-template [data-set]
+  (cond (nil? (:villageid @data-set)) [:select.form-control {:id "o2register-districts"}
+                                       (for [d (get-value! :villages)]
+                                         ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)])]
+        :else [:select.form-control {:id "o2register-districts" :defaultValue (:villageid @data-set)}
+               (doall (for [d (get-value! :villages)]
+                        ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)]))]))
+
+(defn o2register-input-select [label data-set focus]
+  (let [input-focus (r/atom nil)]
+    (fn []
+      [:div.form-group
+       [:label.col-sm-3.control-label label]
+       [:div#tagdiv.col-sm-6 [o2register-tags-template data-set]]
+       [:div.col-sm-3 [:div]]])))
+
+
+(defn o2register-add-template []
+  (let [add-data (r/atom {:isactive true})
+        focus (r/atom nil)]
+    (fn [] [o2register-template
+          "o2register Add Form"
+            add-data focus
+             #(o2register-add-form-onclick add-data focus)])))
+
+(defn o2register-update-template [id dmt]
+  (let [update-data (r/atom {:id (int id)
+                             :serialnumber (.-serialnumber dmt)
+                             :dateofinstitution (.-dateofinstitution dmt)
+                             :villageid (.-villageid dmt)
+                             :villagename (.-villagename dmt)
+                             :tehsil (.-tehsil dmt)
+                             :sourceofreceipt (.-sourceofreceipt dmt)
+                             :nameofthefirstparty (.-nameofthefirstparty dmt)
+                             :dateofreceiptfrompanchayat (.-dateofreceiptfrompanchayat dmt)
+                             :dateandgistoffinalorder (.-dateandgistoffinalorder dmt)
+                             :racknumber (.-racknumber dmt)
+                             :startingyear (.-startingyear dmt)
+                             :endingyear (.-endingyear dmt)
+                             })
+        focus (r/atom nil)]
+    (fn [] [o2register-template
+            "o2register Update Form"
+            update-data focus
+            #(o2register-update-form-onclick update-data focus)])))
+
+
+(defn o2register-update[id]
+  (secretary/dispatch! (str "/o2register/update/" id)))
+
+(defn o2register-delete[id]
+  (let [onres (fn [json]
+                (secretary/dispatch! "/o2register"))]
+    (http-delete (str serverhost "o2registers/" id)  onres)))
+
+
+(defroute o2register-list "/o2register" []
+  (let [onres (fn [json]
+                (let [dt (getdata json)]
+                  (set-key-value :o2registers (.-data dt))
+                  (set-key-value :total-pages (get-total-rec-no (.-pagesCount dt)))
+                  (set-key-value :page-location  [render-o2register (get-value! :o2registers)])))]
+    (set-key-value :is-searched-results false)
+    (http-get (str serverhost "o2registers?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres)))
+
+
+(defroute o2register-add-path "/o2register/add" []
+  (let [onres (fn[json](
+                        (set-key-value :villages (getdata json))
+                        (set-page! [o2register-add-template])))]
+    (http-get (str serverhost "villages") onres)))
+
+(defroute o2register-upd-path "/o2register/update/:id" [id]
+  (let [onres (fn[json](
+                        (set-key-value :villages (getdata json))
+                        (set-page! [o2register-update-template id
+                                    (first (filter (fn[obj]
+                                                     (=(.-id obj) (.parseInt js/window id))) (get-value! :o2registers)))])))]
+    (http-get (str serverhost "villages") onres)))
+
+(defn o2register-add [event]
+  (secretary/dispatch! "/o2register/add"))
+
+(defn render-o2register [o2registers]
+  [:div
+   [:div {:class "box"}
+    [:div {:class "box-header"}
+     [:h3 "List of o2register Records"]]
+    [:div.row
+     [:div.col-md-12
+      [:div.form-group
+       [:input {:type "button" :value "Add"
+                :class "btn btn-primary" :on-click o2register-add}]
+       ;; [:input {:id "getall" :type "button" :value "Refresh"
+       ;;          :class "btn btn-primary" :on-click get-all-click}]
+       ]
+      [:div {:class "box-body"}
+
+       [:table {:class "table table-bordered table-striped dataTable"}
+        [:thead
+         [:tr
+          [:th "S.No"]
+          [:th "Tehsil"]
+          [:th "Date of Institution"]
+          [:th "Source of Receipt"]
+          [:th "Village Name"]
+          [:th "Name of the First Party"]
+          [:th "Date of Receipt"]
+          [:th "Date of Gist Final Order"]
+          [:th "Rack NUmber"]
+          [:th "Starting Year"]
+          [:th "Ending Year"]
+          [:th " "]
+          [:th " "]
+          ]]
+        [:tbody
+         (for [mt o2registers]
+           ^{:key (.-id mt)} [:tr
+                              [:td (.-serialnumber mt)]
+                              [:td (.-tehsil mt)]
+                              [:td (.-dateofinstitution mt)]
+                              [:td (.-sourceofreceipt mt)]
+                              [:td (.-villagename mt)]
+                              [:td (.-nameofthefirstparty mt)]
+                              [:td (.-dateofreceiptfrompanchayat mt)]
+                              [:td (.-dateandgistoffinalorder mt)]
+                              [:td (.-racknumber mt)]
+                              [:td (.-startingyear mt)]
+                              [:td (.-endingyear mt)]
+                              [:td [:a {:href "javascript:;"
+                                        :on-click  #(o2register-update(.-id mt))
+                                        :class "btn btn-success btn-sm glyphicon glyphicon-edit"}]]
+                              [:td  [:a {:href "javascript:;" :on-click #(o2register-delete(.-id mt))
+                                         :class "btn btn-danger btn-sm glyphicon glyphicon-remove"}]]])]]
+       [:div{:class "col-xs-6 col-centered col-max"} [shared-state 0]]]]]]])
+
+;; ---------------------------------------------------------
+;; o4register-records
+
+(defn o4register-form-validator [data-set]
+  (first (b/validate data-set
+                     :tehsil [[v/required :message "Field is required"]]
+                     :khatakhatuninumber [[v/required :message "Field is required"]]
+                     :numberanddateoforder [[v/required :message "Field is required"]]
+                     :khasranumber [[v/required :message "Field is required"]]
+                     :area [[v/required :message "Field is required"]]
+                     :revenuerentofshareofplotstransferred [[v/required :message "Field is required"]]
+                     :nameanddescriptionofthepersonsremoved [[v/required :message "Field is required"]]
+                     )))
+
+(defn o4register-input-row [id label ttype data-set focus]
+  (let [input-focus (r/atom nil)]
+    (fn []
+      [:div.form-group
+       [:label.col-sm-3.control-label label]
+       [:div.col-sm-6 [input-element id ttype data-set label input-focus]]
+       [:div.col-sm-3 (if (or @input-focus @focus)
+                        (if (= nil (o4register-form-validator @data-set))
+                          [:div]
+                          [:div {:style  {:color "red"}}
+                           [:b (str (first ((o4register-form-validator @data-set) id)))]])
+                        [:div])]])))
+
+
+(defn o4register-template [doc-name data-set focus save-function]
+ [:div.container
+  [:div.col-md-12
+   [:div.box.box-info
+    [:div.box-header.with-border
+     [:h2.box-title doc-name]]
+    [:div.form-horizontal
+     [:div.box-body
+       [o4register-input-row :tehsil "Tehsil" "text" data-set focus]
+       [o4register-input-row :khatakhatuninumber "Khata Khatuni Number" "text" data-set focus]
+       [o4register-input-row :numberanddateoforder "Number and Date Of Order" "date" data-set focus]
+       [o4register-input-row :khasranumber "Khasra Number" "text" data-set focus]
+       [o4register-input-row :area "Area" "text" data-set focus]
+       [o4register-input-row :revenuerentofshareofplotstransferred "Revenue Rent Of Share Of Plots Transfered" "text" data-set focus]
+       [o4register-input-row :nameanddescriptionofthepersonsremoved "Name and Description Of the Persons Removed" "text" data-set focus]
+    [:div.box-footer
+      [:button.btn.btn-default {:on-click o4register-form-cancel} "Cancel"]
+      [:button.btn.btn-info.pull-right {:on-click save-function} "Save"]]]]]]])
+
+(defn o4register-add-template []
+  (let [add-data (r/atom {:isactive true})
+        focus (r/atom nil)]
+    (fn [] [o4register-template
+              "o4register Add Form"
+               add-data
+               focus
+               #(o4register-add-form-onclick add-data focus)])))
+
+(defn o4register-update-template [id dmt]
+  (let [update-data (r/atom {:id (int id)
+                             :tehsil (.-tehsil dmt)
+                             :khatakhatuninumber (.-khatakhatuninumber dmt)
+                             :numberanddateoforder (.-numberanddateoforder dmt)
+                             :khasranumber (.-khasranumber dmt)
+                             :area (.-area dmt)
+                             :revenuerentofshareofplotstransferred (.-revenuerentofshareofplotstransferred dmt)
+                             :nameanddescriptionofthepersonsremoved (.-nameanddescriptionofthepersonsremoved dmt)
+                             })
+        focus (r/atom nil)]
+    (fn [] [o4register-template
+            "o4register Update Form"
+            update-data
+            focus
+            #(o4register-update-form-onclick update-data focus)])))
+
+
+(defn o4register-add-form-onclick [data-set focus]
+  (if (= nil (o4register-form-validator @data-set))
+    (let [onres (fn[json] (secretary/dispatch! "/o4register"))]
+          (http-post (str serverhost "o4registers") onres  (.serialize (Serializer.) (clj->js @data-set))))
+  (reset! focus "on")))
+
+
+(defn o4register-update-form-onclick [data-set focus]
+  (if (= nil (o4register-form-validator @data-set))
+      (let [onres (fn[data] (secretary/dispatch! "/o4register"))]
+          (http-put (str serverhost "o4registers/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set))))
+    (reset! focus "on")))
+
+(defn o4register-form-cancel [event]
+  (secretary/dispatch! "/o4register"))
+
+(defn o4register-add [event]
+  (secretary/dispatch! "/o4register/add"))
+
+(defn o4register-update[id]
+  (secretary/dispatch! (str "/o4register/update/" id)))
+
+(defn o4register-delete[id]
+  (let [onres (fn [json]
+                (secretary/dispatch! "/o4register"))]
+    (http-delete (str serverhost "o4registers/" id)  onres)))
+
+
+(defroute o4register-list "/o4register" []
+  (let [onres (fn [json]
+                (let [dt (getdata json)]
+                  (set-key-value :o4registers (.-data dt))
+                  (set-key-value :total-pages (get-total-rec-no (.-pagesCount dt)))
+                  (set-key-value :page-location  [render-o4register (get-value! :o4registers)])))]
+    (set-key-value :is-searched-results false)
+    (http-get (str serverhost "o4registers?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres)))
+
+
+(defroute o4register-add-path "/o4register/add" []
+  (let [onres (fn[json](
+                        (set-key-value :villages (getdata json))
+                        (set-page! [o4register-add-template])))]
+    (http-get (str serverhost "villages") onres)))
+
+(defroute o4register-upd-path "/o4register/update/:id" [id]
+  (let [onres (fn[json](
+                        (set-key-value :villages (getdata json))
+                        (set-page! [o4register-update-template id
+                                    (first (filter (fn[obj]
+                                                     (=(.-id obj) (.parseInt js/window id))) (get-value! :o4registers)))])))]
+    (http-get (str serverhost "villages") onres)))
+
+
+
+(defn render-o4register [o4registers]
+  [:div
+   [:div {:class "box"}
+    [:div {:class "box-header"}
+     [:h3 "List of o4register Records"]]
+    [:div.row
+     [:div.col-md-12
+      [:div.form-group
+       [:input {:type "button" :value "Add"
+                :class "btn btn-primary" :on-click o4register-add}]
+       ;; [:input {:id "getall" :type "button" :value "Refresh"
+       ;;          :class "btn btn-primary" :on-click get-all-click}]
+       ]
+      [:div {:class "box-body"}
+
+       [:table {:class "table table-bordered table-striped dataTable"}
+        [:thead
+         [:tr
+          [:th "Tehsil"]
+          [:th "Khata Khatuni Number"]
+          [:th "Number and Date of Order"]
+          [:th "Khasra Number"]
+          [:th "Area"]
+          [:th "Revenue of Share of Plots Transfered"]
+          [:th "Name and Description of the Persons Removed"]
+          [:th " "]
+          [:th " "]
+          ]]
+        [:tbody
+         (for [mt o4registers]
+           ^{:key (.-id mt)} [:tr
+                              [:td (.-tehsil mt)]
+                              [:td (.-khatakhatuninumber mt)]
+                              [:td (.-numberanddateoforder mt)]
+                              [:td (.-khasranumber mt)]
+                              [:td (.-area mt)]
+                              [:td (.-revenuerentofshareofplotstransferred mt)]
+                              [:td (.-nameanddescriptionofthepersonsremoved mt)]
+                              [:td [:a {:href "javascript:;"
+                                        :on-click  #(o4register-update(.-id mt))
+                                        :class "btn btn-success btn-sm glyphicon glyphicon-edit"}]]
+                              [:td  [:a {:href "javascript:;" :on-click #(o4register-delete(.-id mt))
+                                         :class "btn btn-danger btn-sm glyphicon glyphicon-remove"}]]])]]
+       [:div{:class "col-xs-6 col-centered col-max"} [shared-state 0]]]]]]])
+
+
+;; ---------------------------------------------------------
+;; o6register-records
+
+(defn o6register-form-validator [data-set]
+  (first (b/validate data-set
+                     :tehsil [[v/required :message "Field is required"]]
+                     :year [[v/required :message "Field is required"]]
+                     :mehsilnumber [[v/required :message "Field is required"]]
+                     :dateoforderlevy [[v/required :message "Field is required"]]
+                     :nameofpersonwhomrecoveryismade [[v/required :message "Field is required"]])))
+
+
+(defn o6register-input-row [id label ttype data-set focus]
+  (let [input-focus (r/atom nil)]
+    (fn []
+      [:div.form-group
+       [:label.col-sm-3.control-label label]
+       [:div.col-sm-6 [input-element id ttype data-set label input-focus]]
+       [:div.col-sm-3 (if (or @input-focus @focus)
+                        (if (= nil (o6register-form-validator @data-set))
+                          [:div]
+                          [:div {:style  {:color "red"}}
+                           [:b (str (first ((o6register-form-validator @data-set) id)))]])
+                        [:div])]])))
+
+
+(defn o6register-template [doc-name data-set focus save-function]
+ [:div.container
+  [:div.col-md-12
+   [:div.box.box-info
+    [:div.box-header.with-border
+     [:h2.box-title doc-name]]
+    [:div.form-horizontal
+     [:div.box-body
+       [o6register-input-row :tehsil "Tehsil" "text" data-set focus]
+       [o6register-input-row :year "Year" "date" data-set focus]
+       [o6register-input-row :mehsilnumber "Mehsil Number" "text" data-set focus]
+       [o6register-input-row :dateoforderlevy "Date of Order Levy" "date" data-set focus]
+       [o6register-input-select "Village Name" data-set focus ]
+       [o6register-input-row :nameofpersonwhomrecoveryismade "Name of Person Whom Recovery is Made" "text" data-set focus]
+    [:div.box-footer
+      [:button.btn.btn-default {:on-click o6register-form-cancel} "Cancel"]
+      [:button.btn.btn-info.pull-right {:on-click save-function} "Save"]]]]]]])
+
+
+(defn o6register-add-form-onclick [data-set focus]
+  (if (= nil (o6register-form-validator @data-set))
+    (do (reset! data-set (assoc @data-set :villageid (int (.-value (.getElementById js/document "o6register-districts")))))
+        (let [onres (fn[json] (secretary/dispatch! "/o6register"))]
+          (http-post (str serverhost "o6registers") onres  (.serialize (Serializer.) (clj->js @data-set)))))
+  (reset! focus "on")))
+
+
+(defn o6register-update-form-onclick [data-set focus]
+  (if (= nil (o6register-form-validator @data-set))
+    (do (reset! data-set (assoc @data-set :villageid (int (.-value (.getElementById js/document "o6register-districts")))))
+        (let [onres (fn[data] (secretary/dispatch! "/o6register"))]
+          (http-put (str serverhost "o6registers/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set)))))
+    (reset! focus "on")))
+
+(defn o6register-form-cancel [event]
+  (secretary/dispatch! "/o6register"))
+
+(defn o6register-on-change [event]
+  (let [ele (.getElementById js/document "id")
+        eval (.-value ele)
+        onresp (fn [json]
+                 (let [dt (getdata json)]
+                   (set-key-value :villages dt)))]
+    (set-key-value :villages [])
+    (when-not ( >  1 (.-length eval))
+      (http-get (str serverhost "villages/search?name=" eval) onresp))))
+
+
+(defn o6register-tags-template [data-set]
+  (cond (nil? (:villageid @data-set)) [:select.form-control {:id "o6register-districts"}
+                                       (for [d (get-value! :villages)]
+                                         ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)])]
+        :else [:select.form-control {:id "o6register-districts" :defaultValue (:villageid @data-set)}
+               (doall (for [d (get-value! :villages)]
+                        ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)]))]))
+
+(defn o6register-input-select [label data-set focus]
+  (let [input-focus (r/atom nil)]
+    (fn []
+      [:div.form-group
+       [:label.col-sm-3.control-label label]
+       [:div#tagdiv.col-sm-6 [o6register-tags-template data-set]]
+       [:div.col-sm-3 [:div]]])))
+
+
+(defn o6register-add-template []
+  (let [add-data (r/atom {:isactive true})
+        focus (r/atom nil)]
+    (fn [] [o6register-template
+          "o6register Add Form"
+            add-data focus
+             #(o6register-add-form-onclick add-data focus)])))
+
+(defn o6register-update-template [id dmt]
+  (let [update-data (r/atom {:id (int id)
+                             :tehsil (.-tehsil dmt)
+                             :year (.-year dmt)
+                             :mehsilnumber (.-mehsilnumber dmt)
+                             :dateoforderlevy (.-dateoforderlevy dmt)
+                             :villageid (.-villageid dmt)
+                             :villagename (.-villagename dmt)
+                             :nameofpersonwhomrecoveryismade (.-nameofpersonwhomrecoveryismade dmt)})
+        focus (r/atom nil)]
+    (fn [] [o6register-template
+            "o6register Update Form"
+            update-data focus
+            #(o6register-update-form-onclick update-data focus)])))
+
+
+(defn o6register-update[id]
+  (secretary/dispatch! (str "/o6register/update/" id)))
+
+(defn o6register-delete[id]
+  (let [onres (fn [json]
+                (secretary/dispatch! "/o6register"))]
+    (http-delete (str serverhost "o6registers/" id)  onres)))
+
+
+(defroute o6register-list "/o6register" []
+  (let [onres (fn [json]
+                (let [dt (getdata json)]
+                  (set-key-value :o6registers (.-data dt))
+                  (set-key-value :total-pages (get-total-rec-no (.-pagesCount dt)))
+                  (set-key-value :page-location  [render-o6register (get-value! :o6registers)])))]
+    (set-key-value :is-searched-results false)
+    (http-get (str serverhost "o6registers?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres)))
+
+
+(defroute o6register-add-path "/o6register/add" []
+  (let [onres (fn[json](
+                        (set-key-value :villages (getdata json))
+                        (set-page! [o6register-add-template])))]
+    (http-get (str serverhost "villages") onres)))
+
+(defroute o6register-upd-path "/o6register/update/:id" [id]
+  (let [onres (fn[json](
+                        (set-key-value :villages (getdata json))
+                        (set-page! [o6register-update-template id
+                                    (first (filter (fn[obj]
+                                                     (=(.-id obj) (.parseInt js/window id))) (get-value! :o6registers)))])))]
+    (http-get (str serverhost "villages") onres)))
+
+(defn o6register-add [event]
+  (secretary/dispatch! "/o6register/add"))
+
+(defn render-o6register [o6registers]
+  [:div
+   [:div {:class "box"}
+    [:div {:class "box-header"}
+     [:h3 "List of o6register Records"]]
+    [:div.row
+     [:div.col-md-12
+      [:div.form-group
+       [:input {:type "button" :value "Add"
+                :class "btn btn-primary" :on-click o6register-add}]
+       ;; [:input {:id "getall" :type "button" :value "Refresh"
+       ;;          :class "btn btn-primary" :on-click get-all-click}]
+       ]
+      [:div {:class "box-body"}
+
+       [:table {:class "table table-bordered table-striped dataTable"}
+        [:thead
+         [:tr
+          [:th "Tehsil"]
+          [:th "Year"]
+          [:th  "Mehsil Number"]
+          [:th "Date of Orederlevy"]
+          [:th "Village Name"]
+          [:th "name of Person Whom Recovery is Made"]
+          [:th " "]
+          [:th " "]
+          ]]
+        [:tbody
+         (for [mt o6registers]
+           ^{:key (.-id mt)} [:tr
+                              [:td (.-tehsil mt)]
+                              [:td (.-year mt)]
+                              [:td (.-mehsilnumber mt)]
+                              [:td (.-dateoforderlevy mt)]
+                              [:td (.-villagename mt)]
+                              [:td (.-nameofpersonwhomrecoveryismade mt)]
+                              [:td [:a {:href "javascript:;"
+                                        :on-click  #(o6register-update(.-id mt))
+                                        :class "btn btn-success btn-sm glyphicon glyphicon-edit"}]]
+                              [:td  [:a {:href "javascript:;" :on-click #(o6register-delete(.-id mt))
+                                         :class "btn btn-danger btn-sm glyphicon glyphicon-remove"}]]])]]
+       [:div{:class "col-xs-6 col-centered col-max"} [shared-state 0]]]]]]])
+;; ----------------------------------------------------------------------------------

 (defn table-mount []


slack: add test case for extended-formatter

The `slack/extended-formatter` function is a formatting helper function
made available to users, but not used by default.

--- test/riemann/slack_test.clj
+++ test/riemann/slack_test.clj
@@ -47,7 +47,7 @@
           (is (= (:url @post-request)
                  "https://test-account.slack.com/services/hooks/incoming-webhook?token=test-token"))))

-      (testing "formats event by default"
+      (testing "formats event by default with default formatter"
         (let [slacker (slack/slack "any" "any" "test-user" "#test-channel")]
           (slacker {:host "localhost", :service "mailer", :state "error",
                     :description "Mailer failed", :metric 42, :tags ["first", "second"]})
@@ -58,6 +58,26 @@
                   "channel" "#test-channel"
                   "username" "test-user"
                   "icon_emoji" ":warning:"}))))
+
+      (testing "formats event with bundled extended formatter"
+        (let [slacker (slack/slack any-account (with-formatter slack/extended-formatter))]
+          (slacker {:host "localhost", :service "mailer", :state "error",
+                    :description "Mailer failed", :metric 42, :tags ["first", "second"]})
+          (is (= (json/parse-string (:body @post-request))
+                  {"text" "This event requires your attention!"
+                   "attachments" [{"text" "Mailer failed"
+                                   "pretext" "Event Details:"
+                                   "color" "warning"
+                                   "fields" [{"title" "Host" "value" "localhost" "short" true}
+                                             {"title" "Service" "value" "mailer" "short" true}
+                                             {"title" "Metric" "value" 42 "short" true}
+                                             {"title" "State" "value" "error" "short" true}
+                                             {"title" "Description" "value" "Mailer failed" "short" true}
+                                             {"title" "Tags" "value" "[\"first\" \"second\"]" "short" true}]
+                                   "fallback" "*Host:* localhost *Service:* mailer *State:* error *Description:* Mailer failed *Metric:* 42"}]
+                   "channel" "any"
+                   "username" "any"
+                   "icon_emoji" ":warning:"}))))

       (testing "allows formatting characters in main message text with custom formatter"
         (let [formatter (fn [e] {:text (str "<http://health.check.api/" (:service e) "|" (:service e) ">")})


Reformatted middleware_test.clj by zprint

--- test/zg/middleware_test.clj
+++ test/zg/middleware_test.clj
@@ -19,48 +19,48 @@
 ;

 (defn callable?
-    "Test if given function-name is bound to the real function."
-    [function-name]
-    (clojure.test/function? function-name))
+  "Test if given function-name is bound to the real function."
+  [function-name]
+  (clojure.test/function? function-name))

 ;
 ; Tests for various functions existence
 ;

 (deftest test-inject-configuration-existence
-    "Check that the zg.middleware/inject-configuration definition exists."
-    (testing "if the zg.middleware/inject-configuration definition exists."
-        (is (callable? 'zg.middleware/inject-configuration))))
+  "Check that the zg.middleware/inject-configuration definition exists."
+  (testing "if the zg.middleware/inject-configuration definition exists."
+           (is (callable? 'zg.middleware/inject-configuration))))

 ;
 ; Tests for function behaviours.
 ;

 (deftest test-inject-confuguration-1
-    "Check the behaviour of function zg.middleware/inject-configuration."
-    (testing "The function zg.middleware/inject-configuration."
-        (let [function (inject-configuration (fn [x] x) :cfg)]
-            (are [x y] (= x y)
-                {:configuration :cfg} (function nil)
-                {:configuration :cfg} (function {})
-                {:configuration :cfg :foo :bar} (function {:foo :bar})))))
+  "Check the behaviour of function zg.middleware/inject-configuration."
+  (testing "The function zg.middleware/inject-configuration."
+           (let [function (inject-configuration (fn [x] x) :cfg)]
+             (are [x y] (= x y)
+                  {:configuration :cfg}            (function nil)
+                  {:configuration :cfg}            (function {})
+                  {:configuration :cfg, :foo :bar} (function {:foo :bar})))))

 (deftest test-inject-confuguration-2
-    "Check the behaviour of function zg.middleware/inject-configuration."
-    (testing "The function zg.middleware/inject-configuration."
-        (let [function (inject-configuration (fn [x] nil) :cfg)]
-            (are [x y] (= x y)
-                nil (function nil)
-                nil (function {})
-                nil (function {:foo :bar})
-                nil (function {:foo :bar :baz :bar})))))
+  "Check the behaviour of function zg.middleware/inject-configuration."
+  (testing "The function zg.middleware/inject-configuration."
+           (let [function (inject-configuration (fn [x] nil) :cfg)]
+             (are [x y] (= x y)
+                  nil (function nil)
+                  nil (function {})
+                  nil (function {:foo :bar})
+                  nil (function {:foo :bar, :baz :bar})))))

 (deftest test-inject-confuguration-not-NPE
-    "Check the behaviour of function zg.middleware/inject-configuration."
-    (testing "The function zg.middleware/inject-configuration."
-        (let [function (inject-configuration (fn [x] x) nil)]
-            (are [x y] (= x y)
-                {:configuration nil} (function nil)
-                {:configuration nil} (function {})
-                {:configuration nil :foo :bar} (function {:foo :bar})))))
+  "Check the behaviour of function zg.middleware/inject-configuration."
+  (testing "The function zg.middleware/inject-configuration."
+           (let [function (inject-configuration (fn [x] x) nil)]
+             (are [x y] (= x y)
+                  {:configuration nil}            (function nil)
+                  {:configuration nil}            (function {})
+                  {:configuration nil, :foo :bar} (function {:foo :bar})))))


Version 0.1.4-SNAPSHOT

Version 0.1.4-SNAPSHOT

--- metlog-agent/project.clj
+++ metlog-agent/project.clj
@@ -1,4 +1,4 @@
-(defproject metlog-agent "0.1.3"
+(defproject metlog-agent "0.1.4-SNAPSHOT"
   :description "Metlog agent - polls data sources for upload to vault."

   :license {:name "Eclipse Public License"


CMR-2362: Reset db to in-memory

CMR-2362: Reset db to in-memory

--- dev-system/dev/user.clj
+++ dev-system/dev/user.clj
@@ -46,8 +46,8 @@

   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-  (system/set-dev-system-message-queue-type! :in-memory)
-  ; (system/set-dev-system-message-queue-type! :external)
+  ; (system/set-dev-system-message-queue-type! :in-memory)
+  (system/set-dev-system-message-queue-type! :external)

   (let [s (system/create-system)]
     (alter-var-root #'system


CMR-1700: Fixed db setting:

CMR-1700: Fixed db setting:

--- dev-system/dev/user.clj
+++ dev-system/dev/user.clj
@@ -37,8 +37,8 @@
   (system/set-dev-system-echo-type! :in-memory)
   ; (system/set-dev-system-echo-type! :external)

-  ; (system/set-dev-system-db-type! :in-memory)
-  (system/set-dev-system-db-type! :external)
+  (system/set-dev-system-db-type! :in-memory)
+  ; (system/set-dev-system-db-type! :external)

   (system/set-dev-system-message-queue-type! :in-memory)
   ; (system/set-dev-system-message-queue-type! :external)


use 'our' s3 bucket rather than old embed.

--- dev/photo_migration.clj
+++ dev/photo_migration.clj
@@ -9,14 +9,6 @@
             [clojure.tools.logging            :as log]
             [kixi.hecuba.webutil              :refer (uuid)]))

-;; temp hack - we should put this in the config as a separate
-;; component, but this is a throwaway migration so fudge it for now.
-;; you need to fill this in.
-
-(def old-embed-s3-session (s3/mk-session {:access-key ""
-                                          :secret-key ""
-                                          :file-bucket "get-embed-data"
-                                          :download-dir "/tmp"}))

 (defn path-from [p]
   (try
@@ -27,27 +19,30 @@
       (log/error (str "parsing " p)))))

 ;; TODO - need to look at the path things end up at in s3.
-(defn get-item-from-old-embed-bucket [key]
+(defn get-item-from-old-embed-bucket [s3-session key]
   (let [outfile (ioplus/mk-temp-file! "photo-migration" "")]
     (.deleteOnExit outfile)
     (println key)
-    (when (s3/item-exists? old-embed-s3-session key)
-      (with-open [in (s3/get-object-by-metadata old-embed-s3-session {:key key})]
+    (when (s3/item-exists? s3-session key)
+      (with-open [in (s3/get-object-by-metadata s3-session {:key key})]
         (io/copy in outfile))
       {:src-name  "uploads"
-       :feed-name "photo-migrations"
+       :feed-name "images"
        :uuid      (uuid)
        :dir       (.getParent outfile)
        :filename  (.getName outfile)})))

 (defn migrate-photos [{:keys [store]}]
-  (db/with-session [session (:hecuba-session store)]
-    (doseq [{:keys [id photos]} (entities/get-all session)]
-      (log/info "migrating photos for " id)
-      (if-let [paths (not-empty (keep path-from photos))]
-        (doseq [item (keep get-item-from-old-embed-bucket paths)]
-          (log/info "migrating path for " item)
-          (upload/image-upload store  (assoc item :entity_id id)))))))
+  (let [s3 (:s3 store)
+        get-old (partial get-item-from-old-embed-bucket (assoc s3 :file-bucket "get-embed-data"))
+        ]
+    (db/with-session [session (:hecuba-session store)]
+      (doseq [{:keys [id photos]} (entities/get-all session)]
+        (log/info "migrating photos for " id)
+        (if-let [paths (not-empty (keep path-from photos))]
+          (doseq [item (keep get-old paths)]
+            (log/info "migrating path for " item)
+            (upload/image-upload store  (assoc item :entity_id id))))))))

 (comment
   ;; from 'user ns after (go)


Fix example from merge

Fix example from merge

--- dev/src/yada/dev/examples.clj
+++ dev/src/yada/dev/examples.clj
@@ -330,18 +330,18 @@

 (defrecord ProducesContentTypeNegotiationJson []
   Example
-  (resource-map [_] '{:state (fn [ctx] {:foo "bar"})
+  (resource [_] '{:state (fn [ctx] {:foo "bar"})
                      :produces #{"application/json" "application/edn"}})
-  (make-handler [ex] (yada (eval (resource-map ex))))
+  (make-handler [ex] (yada (eval (resource ex))))
   (request [_] {:method :get
                 :headers {"Accept" "application/json"}})
   (expected-response [_] {:status 200}))

 (defrecord ProducesContentTypeNegotiationEdn []
   Example
-  (resource-map [_] '{:state (fn [ctx] {:foo "bar"})
+  (resource [_] '{:state (fn [ctx] {:foo "bar"})
                      :produces #{"application/json" "application/edn"}})
-  (make-handler [ex] (yada (eval (resource-map ex))))
+  (make-handler [ex] (yada (eval (resource ex))))
   (request [_] {:method :get
                 :headers {"Accept" "application/edn"}})
   (expected-response [_] {:status 200}))


Add default followers to new user

Add default followers to new user

This allows them to complete the following list challenge without the
follow/unfollow buttons.

--- tutorial.vent/src/tutorial/vent/db.clj
+++ tutorial.vent/src/tutorial/vent/db.clj
@@ -31,7 +31,9 @@
           (->edn
             {:users {"sparks0id" {:name "Malcolm Sparks"}
                      "m0nr03" {:name "Dominic Monroe"
-                               :follows ["sparks0id"]}}
+                               :follows ["sparks0id"]}
+                     "works_for_pizza" {:name "Edit Me!"
+                                        :follows ["m0nr03"]}}
              :vents [{:username "m0nr03"
                       :text "Vim rules! jjjjjjjjjk<ESC><Enter>"}
                      {:username "sparks0id"


error handling pushes bad messages to <stream>-errors

--- core/src/samsara_core/samza.clj
+++ core/src/samsara_core/samza.clj
@@ -1,14 +1,16 @@
 (ns samsara-core.samza
   (:refer-clojure :exclude [var-get var-set])
-  (:require [clojure.string :as s])
+  (:require [clojure.string :as s]
+            [taoensso.timbre :as log])
   (:require [samsara-core.core :as core])
   (:require [moebius.kv :as kv])
   (:require [samsara.utils :refer [to-json from-json invariant]])
-  (:require [samsara.trackit :refer [track-time count-tracker distribution-tracker]])
-  (:import [org.apache.samza.job JobRunner]
-           [org.apache.samza.config MapConfig]
-           [org.apache.samza.system OutgoingMessageEnvelope
-            IncomingMessageEnvelope SystemStream]
+  (:require [samsara.trackit :refer [track-time track-count
+                                     count-tracker distribution-tracker]])
+  (:import org.apache.samza.config.MapConfig
+           org.apache.samza.job.JobRunner
+           [org.apache.samza.system IncomingMessageEnvelope
+            OutgoingMessageEnvelope SystemStream]
            [org.apache.samza.task MessageCollector TaskCoordinator]))

 ;; runtime pipeline initialized by init-pipeline!
@@ -217,30 +219,39 @@
    ^String partition
    ^String message]

-  (if (= stream (kvstore-topic!))
-    ;; messages for the kvstore are dispatched directly to the restore function
-    ;; and this function doesn't emit anything
-    (kv-restore! message)
-    ;; other messages are processed by the normal pipeline, however here
-    ;; we need to emit the state messages as well.
-
-    ;; this ugly stuff works because *store* is thread-local
-    (let [state (var-get *store*)
-          [new-state rich-events] (pipeline state message)
-          txlog     (kv/tx-log new-state)
-          txlog-msg (tx-log->messages txlog)
-          all-output (concat txlog-msg rich-events)]
-
-      ;; emitting the output
-      (doseq [[oStream oKey oMessage] all-output]
-        ;; TODO: remove this and remove the INPUT: one as well
-        (println "OUTPUT[" oStream "/" oKey "]:" oMessage)
-        (.send collector (OutgoingMessageEnvelope.
-                          (topic->stream oStream) oKey oMessage )))
-
-      ;; flushing tx-log
-      (let [new-state' (kv/flush-tx-log new-state txlog)]
-        (var-set *store* new-state')))))
+  (try
+    (if (= stream (kvstore-topic!))
+      ;; messages for the kvstore are dispatched directly to the restore function
+      ;; and this function doesn't emit anything
+      (kv-restore! message)
+      ;; other messages are processed by the normal pipeline, however here
+      ;; we need to emit the state messages as well.
+
+      ;; this ugly stuff works because *store* is thread-local
+      (let [state (var-get *store*)
+            [new-state rich-events] (pipeline state message)
+            txlog     (kv/tx-log new-state)
+            txlog-msg (tx-log->messages txlog)
+            all-output (concat txlog-msg rich-events)]
+
+        ;; emitting the output
+        (doseq [[oStream oKey oMessage] all-output]
+          ;; TODO: remove this and remove the INPUT: one as well
+          (println "OUTPUT[" oStream "/" oKey "]:" oMessage)
+          (.send collector (OutgoingMessageEnvelope.
+                            (topic->stream oStream) oKey oMessage )))
+
+        ;; flushing tx-log
+        (let [new-state' (kv/flush-tx-log new-state txlog)]
+          (var-set *store* new-state'))))
+    ;;
+    ;; ERROR Handling
+    ;;
+    (catch Exception x
+      (log/warn x "Error processing message from [" stream "]:" message)
+      (track-count (str "pipeline." stream ".errors"))
+      (.send collector (OutgoingMessageEnvelope.
+                        (topic->stream (str stream "-errors")) partition message)))))


deleted core-test.

deleted core-test.

--- test/forma/core_test.clj
+++ test/forma/core_test.clj
@@ -1,5 +0,0 @@
-(ns forma.core-test
-  (:use [forma.core] :reload
-        midje.sweet
-        clojure.test))
-


Add common compressor stream functions

Add common compressor stream functions


Initial commit to write access log messages to stdout

--- common-lib/src/cmr/common/api/web_server.clj
+++ common-lib/src/cmr/common/api/web_server.clj
@@ -4,7 +4,9 @@
             [ring.adapter.jetty :as jetty]
             [cmr.common.log :refer (debug info warn error)])
   (:import org.eclipse.jetty.server.Server
-           org.eclipse.jetty.server.handler.GzipHandler))
+           org.eclipse.jetty.server.NCSARequestLog
+           org.eclipse.jetty.server.handler.GzipHandler
+           org.eclipse.jetty.server.handler.RequestLogHandler))

 (def MIN_THREADS
   "The minimum number of threads for Jetty to use to process requests. The was originally set to the
@@ -54,19 +56,38 @@
                                                     :min-threads MIN_THREADS
                                                     :max-threads MAX_THREADS})]

-        (when use-compression?
+
+
+            ; ;; Replace the existing handler with the gzip handler
+            ; (doto server
+            ;   (.stop)
+            ;   (.setHandler new-handler)
+            ;   (.start))))
+
+        (let [access-log-handler (doto (RequestLogHandler.)
+                                   (.setHandler (.getHandler server))
+                                   (.setRequestLog
+                                     (doto (NCSARequestLog.)
+                                       (.setLogLatency true))))]
+
+
+
+          (when use-compression?
           ;; Create a GZIP handler to handle compression of responses
-          (let [new-handler (doto (GzipHandler.)
-                              (.setHandler (.getHandler server))
+            (let [gzip-handler (doto (GzipHandler.)
+                              (.setHandler access-log-handler)
                               (.setMinGzipSize MIN_GZIP_SIZE))]
-            ;; Replace the existing handler with the gzip handler
+              (doto server
+                (.stop)
+                (.setHandler gzip-handler)
+                (.start)))
             (doto server
               (.stop)
-              (.setHandler new-handler)
-              (.start))))
+              (.setHandler access-log-handler)
+              (.start)))))

         (info "Jetty started on port" port)
-        (assoc this :server server))
+        (assoc this :server server)
       (catch Exception e
         (info "Failed to start jetty on port" port)
         (throw e))))


removed println trace

removed println trace


another test

another test


[#532] Add isLower filter

[#532] Add isLower filter

--- backend/src/akvo/lumen/lib/visualisation/filter.clj
+++ backend/src/akvo/lumen/lib/visualisation/filter.clj
@@ -20,49 +20,61 @@
 (defn escape-sql-str [s]
   (str/replace s "'" "''"))

+(defn comparison [op column-type column-name value]
+  (condp = column-type
+    "number" (format "%s %s %s"
+                     column-name
+                     op
+                     (parse-number value))
+    "date" (format "%s %s '%s'::timestamptz"
+                   column-name
+                   op
+                   (parse-date value))
+    (throw (ex-info "Invalid type" {:type column-type}))))
+
 (defmethod filter-sql "isHigher"
   [{:strs [column operation value]}]
-  (let [op (if (= operation "keep") ">" "<=")]
-    (condp = (get column "type")
+  (let [{column-type "type" column-name "columnName"} column
+        op (if (= operation "keep") ">" "<=")]
+    (comparison op column-type column-name value)))
+
+(defmethod filter-sql "isLower"
+  [{:strs [column operation value]}]
+  (let [{column-type "type" column-name "columnName"} column
+        op (if (= operation "keep") "<" ">=")]
+    (comparison op column-type column-name value)))
+
+(defmethod filter-sql "is"
+  [{:strs [column operation value]}]
+  (let [{column-type "type" column-name "columnName"} column
+        op (if (= operation "keep") "=" "<>")]
+    (condp = column-type
       "number" (format "%s %s %s"
-                       (get column "columnName")
+                       column-name
                        op
                        (parse-number value))
       "date" (format "%s %s '%s'::timestamptz"
-                     (get column "columnName")
-                     op
-                     (parse-date value))
-      (throw (ex-info "Invalid type" {:type (get column "type")})))))
-
-(defmethod filter-sql "is"
-  [{:strs [column operation value]}]
-  (let [op (if (= operation "keep") "=" "<>")]
-    (condp = (get column "type")
-      "number" (format "%s %s %s"
-                       (get column "columnName")
-                       op
-                       (parse-number value))
-      "date" (format "%s %s '%s'::timestamptz"
-                     (get column "columnName")
+                     column-name
                      op
                      (parse-date value))
       "text" (format "%s %s '%s'"
-                     (get column "columnName")
+                     column-name
                      op
                      (escape-sql-str value))
-      (throw (ex-info "Invalid type" {:type (get column "type")})))))
+      (throw (ex-info "Invalid type" {:type column-type})))))

 (defmethod filter-sql "isEmpty"
   [{:strs [column operation]}]
-  (if (= (get column "type") "text")
-    (format "coalesce(%s, '') %s ''"
-            (get column "columnName")
-            (if (= operation "keep") "<>" "="))
-    (format "%s IS %s"
-            (get column "columnName")
-            (if (= operation "keep")
-              "NULL"
-              "NOT NULL"))))
+  (let [{column-type "type" column-name "columnName"} column]
+    (if (= column-type "text")
+      (format "coalesce(%s, '') %s ''"
+              column-name
+              (if (= operation "keep") "<>" "="))
+      (format "%s IS %s"
+              column-name
+              (if (= operation "keep")
+                "NULL"
+                "NOT NULL")))))

 (defmethod filter-sql :default [filter]
   (throw (ex-info "Invalid filter" {:filter filter}))


use logback in elephantdb-server

use logback in elephantdb-server

--- elephantdb-server/project.clj
+++ elephantdb-server/project.clj
@@ -2,7 +2,8 @@
   :min-lein-version "2.0.0"
   :source-paths ["src/clj"]
   :jvm-opts ["-Xmx768m" "-server" "-Djava.net.preferIPv4Stack=true" "-XX:+UseCompressedOops"]
-  :dependencies [[org.slf4j/slf4j-log4j12 "1.6.4"]
+  :dependencies [[ch.qos.logback/logback-classic "1.0.11"]
+                 [org.slf4j/log4j-over-slf4j "1.7.4"]
                  [com.yammer.metrics/metrics-graphite "2.2.0"]
                  [com.yammer.metrics/metrics-ganglia "2.2.0"]
                  [elephantdb/elephantdb-core "0.4.3-SNAPSHOT"]


Add a run-app entry point

Add a run-app entry point

--- ClojureScript/src/bocko_ios/core.cljs
+++ ClojureScript/src/bocko_ios/core.cljs
@@ -1,5 +1,9 @@
 (ns bocko-ios.core
   (:require bocko.core))
+
+(defn run-app
+  []
+  (comment "Code here will be run when app launches"))

 (defn ^:export init
   [canvas-view-controller]
@@ -17,4 +21,6 @@
                           new-color (nth new-col y)]
                       (when-not (= old-color new-color)
                         (let [[r g b] (new-color color-map)]
-                          (.plotXYRedGreenBlue canvas-view-controller x y r g b))))))))))))))+                          (.plotXYRedGreenBlue canvas-view-controller x y r g b)))))))))))))
+  (run-app))
+


Update to ClojureScript 1.9.655

Update to ClojureScript 1.9.655

--- planck-cljs/project.clj
+++ planck-cljs/project.clj
@@ -1,6 +1,6 @@
 (defproject planck "0.1.0"
   :profiles {:dev
-             {:dependencies [[org.clojure/clojurescript "1.9.562"]
+             {:dependencies [[org.clojure/clojurescript "1.9.655"]
                              [org.clojure/test.check "0.10.0-alpha1"]
                              [tubular "1.0.0"]]
               :source-paths ["dev"]}
@@ -9,7 +9,7 @@
              :build-commit
              {}}
   :dependencies [[org.clojure/clojure "1.8.0"]
-                 [org.clojure/clojurescript "1.9.562"]
+                 [org.clojure/clojurescript "1.9.655"]
                  [org.clojure/test.check "0.10.0-alpha1"]
                  [org.clojure/tools.reader "1.0.0"]
                  [com.cognitect/transit-clj "0.8.300"]


fix ip address in the ssh table

fix ip address in the ssh table

--- frontend/components/build_head.cljs
+++ frontend/components/build_head.cljs
@@ -125,7 +125,7 @@
                  (list
                   [:dt (when (> 1 (count nodes)) [:span (:index node)])]
                   [:dd {:class (when (:ssh_enabled node) "connected")}
-                   [:span (gstring/format "ssh -p %s %s@%s " (:port node) (:username node) (:ip_addr node))]
+                   [:span (gstring/format "ssh -p %s %s@%s " (:port node) (:username node) (:public_ip_addr node))]
                    (when-not (:ssh_enabled node)
                      [:span.loading-spinner common/spinner])]))
                nodes)]]


Queue prefixes on resolver to rate-limit workers in resolver.

--- src/chronograph/import/resolver.clj
+++ src/chronograph/import/resolver.clj
@@ -83,17 +83,22 @@

     (let [to-resolve (k/select d/resolutions (k/where {:resolved false}))
           dois (map :doi to-resolve)
+          ; Split into seq of seqs, partitioned by DOI prefix. Each of these lists is sent to a worker.
+          ; This ensures that the DOIs for a particular publisher are (generally) processed serially and won't overload a site.
+          doi-queues (partition-by (fn [doi] (first (.split #"/" doi))) dois)
           doi-resolve-channels (apply vector (map (fn [i] (chan)) (range num-return-chans)))
           resolve-channel (async/merge doi-resolve-channels)]

       ; Run concurrent resolvers that poll from the doi-channel and send back results back on their own channels.
       (doseq [ch doi-resolve-channels]
         (go
-           (loop [doi (<! doi-channel)]
-             (when doi
-                   (let [result (get-resolutions doi)]
-                     (when result
-                       (let [[first-redirect last-redirect] result]
+           ; Get a chunk of DOIs, all with the same prefix.
+           (loop [doi-list (<! doi-channel)]
+             (when doi-list
+                   (let [; Resolve each DOI
+                         results (map (fn [doi] [doi (get-resolutions doi)]) doi-list)]
+                     (doseq [result results]
+                       (let [[doi [first-redirect last-redirect]] result]
                            (>! ch [doi first-redirect last-redirect]))))
                    (recur (<! doi-channel))))

@@ -103,9 +108,9 @@

       ; Stick the DOIs on a channel for them to be resolved asynchronously and returned via doi-resolve-channels.
       (go
-        (doseq [doi dois]
-          (locking *out* (prn "Spool" doi))
-          (>! doi-channel doi))
+        (doseq [doi-queue doi-queues]
+          (locking *out* (prn "Spool queue" doi-queue))
+          (>! doi-channel doi-queue))
         (prn "Closing DOI channel")
         (close! doi-channel))


Reformat retrigger_test

Reformat retrigger_test

--- test/clj/lambdacd/execution/internal/retrigger_test.clj
+++ test/clj/lambdacd/execution/internal/retrigger_test.clj
@@ -41,11 +41,11 @@
 (defn some-pipeline-state []
   (atom {}))

-(defn some-control-flow [& _] ; just a mock, we don't actually execute this
+(defn some-control-flow [& _]                               ; just a mock, we don't actually execute this
   (fn [args ctx]
     (throw (IllegalStateException. "This shouldn't be called"))))

-(defn some-step-that-fails-if-retriggered [ & _]
+(defn some-step-that-fails-if-retriggered [& _]
   (throw (IllegalStateException. "This step shouldn't be called")))

 (defn some-control-flow-thats-called [& steps]
@@ -58,8 +58,8 @@
 (deftest retrigger-mock-step-test
   (testing "that it returns the result of the original step"
     (let [some-original-result {:foo :bar}
-          initial-state        { 0 {[1] some-original-result
-                                    [2] {:some :other :steps :result}}
+          initial-state        {0 {[1] some-original-result
+                                   [2] {:some :other :steps :result}}
                                 1 {[1] {:some :other :builds :result}}}
           ctx                  (some-ctx-with :initial-pipeline-state initial-state
                                               :step-id [1])
@@ -69,9 +69,9 @@
   (testing "that it reports the results of its children"
     (let [some-original-result  {:foo :bar}
           some-childs-result    {:bar :baz}
-          initial-state         {0 {[1] some-original-result
+          initial-state         {0 {[1]   some-original-result
                                     [1 1] some-childs-result
-                                    [2] {:some :other :steps :result}}
+                                    [2]   {:some :other :steps :result}}
                                  1 {[1] {:some :other :builds :result}}}
           ctx                   (some-ctx-with :initial-pipeline-state initial-state
                                                :build-number 1
@@ -82,85 +82,85 @@
       (mock-step {} ctx)
       (is (= [{:build-number 1
                :step-id      [1 1]
-               :step-result expected-child-result}]
+               :step-result  expected-child-result}]
              (slurp-chan step-finished-events))))))

 (deftest retrigger-test
-         (testing "that retriggering results in a completely new pipeline-run where not all the steps are executed"
-                  (let [initial-state { 0 {[1] { :status :success }
-                                           [1 1] {:status :success :out "I am nested"}
-                                           [2] { :status :failure }}}
-                        pipeline `((some-control-flow some-step) some-successful-step)
-                        context (some-ctx-with :initial-pipeline-state initial-state)]
-                    (execution-core/retrigger-pipeline pipeline context 0 [2] 1)
-                    (wait-for (step-success? context 1 [2]))
-                    (is (= {[1] { :status :success }
+  (testing "that retriggering results in a completely new pipeline-run where not all the steps are executed"
+    (let [initial-state {0 {[1]   {:status :success}
                             [1 1] {:status :success :out "I am nested"}
-                            [2] { :status :failure }}
-                           (without-ts (state/get-step-results context 0))))
-                    (is (= {[1] { :status :success :retrigger-mock-for-build-number 0 }
-                            [1 1] {:status :success :out "I am nested" :retrigger-mock-for-build-number 0}
-                            [2] { :status :success }}
-                           (without-ts (state/get-step-results context 1))))))
-         (testing "that retriggering consumes the pipeline structure for the new pipeline-run"
-                  (let [initial-state { 0 {[1] { :status :success }
-                                           [1 1] {:status :success :out "I am nested"}
-                                           [2] { :status :failure }}}
-                        pipeline `((some-control-flow some-step) some-successful-step)
-                        context (some-ctx-with :initial-pipeline-state initial-state)]
-                    (execution-core/retrigger-pipeline pipeline context 0 [2] 1)
-                    (wait-for (step-success? context 1 [2]))
-                    (is (not= nil (state/get-pipeline-structure context 1)))))
-         (testing "that we can retrigger a pipeline from the initial step as well"
-                  (let [pipeline `(some-successful-step some-other-step some-failing-step)
-                        initial-state { 0 {[1] {:status :to-be-retriggered}
-                                           [2] {:status :to-be-overwritten-by-next-run}
-                                           [3] {:status :to-be-overwritten-by-next-run}}}
-                        context (some-ctx-with :initial-pipeline-state initial-state)]
-                    (execution-core/retrigger-pipeline pipeline context 0 [1] 1)
-                    (wait-for (step-failure? context 1 [3]))
-                    (is (= {[1] {:status :success}
-                            [2] {:status :success :foo :baz}
-                            [3] {:status :failure}}
-                           (without-ts (state/get-step-results context 1))))))
-         (testing "that steps after the retriggered step dont get the retrigger-metadata"
-                  (let [pipeline `(some-successful-step some-step-caring-about-retrigger-metadata)
-                        initial-state { 0 {[1] {:status :to-be-retriggered}
-                                           [2] {:status :to-be-overwritten-by-next-run}
-                                           [3] {:status :to-be-overwritten-by-next-run}}}
-                        context (some-ctx-with :initial-pipeline-state initial-state)]
-                    (execution-core/retrigger-pipeline pipeline context 0 [1] 1)
-                    (wait-for (step-success? context 1 [2]))
-                    (is (= {[1] {:status :success}
-                            [2] {:status :success :retriggered-build-number nil :retriggered-step-id nil}}
-                           (without-ts (state/get-step-results context 1))))))
-         (testing "that retriggering works for nested steps"
-                  (let [initial-state { 0 {[1] { :status :success }
-                                           [1 1] {:status :success :out "I am nested"}
-                                           [2 1] {:status :unknown :out "this will be retriggered"}}}
-                        pipeline `((some-control-flow-thats-called some-step-that-fails-if-retriggered some-step-to-retrigger) some-successful-step)
-                        context (some-ctx-with :initial-pipeline-state initial-state)]
-                    (execution-core/retrigger-pipeline pipeline context 0 [2 1] 1)
-                    (wait-for (step-success? context 1 [2]))
-                    (is (= {[1] { :status :success }
+                            [2]   {:status :failure}}}
+          pipeline      `((some-control-flow some-step) some-successful-step)
+          context       (some-ctx-with :initial-pipeline-state initial-state)]
+      (execution-core/retrigger-pipeline pipeline context 0 [2] 1)
+      (wait-for (step-success? context 1 [2]))
+      (is (= {[1]   {:status :success}
+              [1 1] {:status :success :out "I am nested"}
+              [2]   {:status :failure}}
+             (without-ts (state/get-step-results context 0))))
+      (is (= {[1]   {:status :success :retrigger-mock-for-build-number 0}
+              [1 1] {:status :success :out "I am nested" :retrigger-mock-for-build-number 0}
+              [2]   {:status :success}}
+             (without-ts (state/get-step-results context 1))))))
+  (testing "that retriggering consumes the pipeline structure for the new pipeline-run"
+    (let [initial-state {0 {[1]   {:status :success}
                             [1 1] {:status :success :out "I am nested"}
-                            [2 1] {:status :unknown :out "this will be retriggered"}}
-                           (without-ts (state/get-step-results context 0))))
-                    (is (= {[1] {:status :success
-                                 :outputs {[1 1] {:status :success :out "I am nested" :retrigger-mock-for-build-number 0 }
-                                           [2 1] {:the-some :val :status :success }}}
-                            [1 1] {:status :success :out "I am nested" :retrigger-mock-for-build-number 0}
-                            [2 1] {:the-some :val :status :success}
-                            [2] { :status :success }}
-                           (without-ts (state/get-step-results context 1))))))
-         (testing "that retriggering updates timestamps of container steps (#56)"
-                  (let [initial-state { 0 {[1] { :status :unknown :first-updated-at (t/date-time 1970) }
-                                           [1 1] {:status :success :out "I am nested"}
-                                           [2 1] {:status :unknown :out "this will be retriggered"}}}
-                        pipeline `((some-control-flow-thats-called some-step-that-fails-if-retriggered some-step-to-retrigger) some-successful-step)
-                        context (some-ctx-with :initial-pipeline-state initial-state)]
-                    (execution-core/retrigger-pipeline pipeline context 0 [2 1] 1)
-                    (wait-for (step-success? context 1 [2]))
-                    (let [new-container-step-result (state/get-step-result context 1 [1])]
-                      (is (= :success (:status new-container-step-result)))
-                      (is (not= 1970 (t/year (:first-updated-at new-container-step-result))))))))
+                            [2]   {:status :failure}}}
+          pipeline      `((some-control-flow some-step) some-successful-step)
+          context       (some-ctx-with :initial-pipeline-state initial-state)]
+      (execution-core/retrigger-pipeline pipeline context 0 [2] 1)
+      (wait-for (step-success? context 1 [2]))
+      (is (not= nil (state/get-pipeline-structure context 1)))))
+  (testing "that we can retrigger a pipeline from the initial step as well"
+    (let [pipeline      `(some-successful-step some-other-step some-failing-step)
+          initial-state {0 {[1] {:status :to-be-retriggered}
+                            [2] {:status :to-be-overwritten-by-next-run}
+                            [3] {:status :to-be-overwritten-by-next-run}}}
+          context       (some-ctx-with :initial-pipeline-state initial-state)]
+      (execution-core/retrigger-pipeline pipeline context 0 [1] 1)
+      (wait-for (step-failure? context 1 [3]))
+      (is (= {[1] {:status :success}
+              [2] {:status :success :foo :baz}
+              [3] {:status :failure}}
+             (without-ts (state/get-step-results context 1))))))
+  (testing "that steps after the retriggered step dont get the retrigger-metadata"
+    (let [pipeline      `(some-successful-step some-step-caring-about-retrigger-metadata)
+          initial-state {0 {[1] {:status :to-be-retriggered}
+                            [2] {:status :to-be-overwritten-by-next-run}
+                            [3] {:status :to-be-overwritten-by-next-run}}}
+          context       (some-ctx-with :initial-pipeline-state initial-state)]
+      (execution-core/retrigger-pipeline pipeline context 0 [1] 1)
+      (wait-for (step-success? context 1 [2]))
+      (is (= {[1] {:status :success}
+              [2] {:status :success :retriggered-build-number nil :retriggered-step-id nil}}
+             (without-ts (state/get-step-results context 1))))))
+  (testing "that retriggering works for nested steps"
+    (let [initial-state {0 {[1]   {:status :success}
+                            [1 1] {:status :success :out "I am nested"}
+                            [2 1] {:status :unknown :out "this will be retriggered"}}}
+          pipeline      `((some-control-flow-thats-called some-step-that-fails-if-retriggered some-step-to-retrigger) some-successful-step)
+          context       (some-ctx-with :initial-pipeline-state initial-state)]
+      (execution-core/retrigger-pipeline pipeline context 0 [2 1] 1)
+      (wait-for (step-success? context 1 [2]))
+      (is (= {[1]   {:status :success}
+              [1 1] {:status :success :out "I am nested"}
+              [2 1] {:status :unknown :out "this will be retriggered"}}
+             (without-ts (state/get-step-results context 0))))
+      (is (= {[1]   {:status  :success
+                     :outputs {[1 1] {:status :success :out "I am nested" :retrigger-mock-for-build-number 0}
+                               [2 1] {:the-some :val :status :success}}}
+              [1 1] {:status :success :out "I am nested" :retrigger-mock-for-build-number 0}
+              [2 1] {:the-some :val :status :success}
+              [2]   {:status :success}}
+             (without-ts (state/get-step-results context 1))))))
+  (testing "that retriggering updates timestamps of container steps (#56)"
+    (let [initial-state {0 {[1]   {:status :unknown :first-updated-at (t/date-time 1970)}
+                            [1 1] {:status :success :out "I am nested"}
+                            [2 1] {:status :unknown :out "this will be retriggered"}}}
+          pipeline      `((some-control-flow-thats-called some-step-that-fails-if-retriggered some-step-to-retrigger) some-successful-step)
+          context       (some-ctx-with :initial-pipeline-state initial-state)]
+      (execution-core/retrigger-pipeline pipeline context 0 [2 1] 1)
+      (wait-for (step-success? context 1 [2]))
+      (let [new-container-step-result (state/get-step-result context 1 [1])]
+        (is (= :success (:status new-container-step-result)))
+        (is (not= 1970 (t/year (:first-updated-at new-container-step-result))))))))


fighweel.main: get ::build info from -co flag input as well

--- figwheel-main/src/figwheel/main.cljc
+++ figwheel-main/src/figwheel/main.cljc
@@ -173,10 +173,21 @@
           (ex-info (str "Couldn't read the file:" f)
                    {::error true} t)))))

+(defn read-edn-string [s & [fail-msg]]
+  (try
+    (edn/read-string s)
+    (catch Throwable e
+      (throw (ex-info (str
+                       (.getMessage e) "\n"
+                       (or fail-msg "Failed to read EDN string: ")
+                       (pr-str s))
+                      {::error true}
+                      e)))))
+
 (defn read-edn-opts [str]
   (letfn [(read-rsrc [rsrc-str orig-str]
             (if-let [rsrc (io/resource rsrc-str)]
-              (edn/read-string (slurp rsrc))
+              (read-edn-string (slurp rsrc))
               (cljs.cli/missing-resource orig-str)))]
     (cond
      (string/starts-with? str "@/") (read-rsrc (subs str 2) str)
@@ -187,21 +198,54 @@
          (read-edn-file f)
          (cljs.cli/missing-file str))))))

+(defn merge-meta [m m] (with-meta (merge m m) (merge (meta m) (meta m))))
+
 (defn load-edn-opts [str]
-  (reduce merge {} (map read-edn-opts (cljs.util/split-paths str))))
+  (reduce merge-meta {} (map read-edn-opts (cljs.util/split-paths str))))
+
+(defn fallback-id [edn]
+  (let [m (meta edn)]
+    (cond
+      (and (:id m) (not (string/blank? (str (:id m)))))
+      (:id m)
+      ;;(:main edn)      (munge (str (:main edn)))
+      :else
+      (str "build-"
+           (.getValue (doto (java.util.zip.CRC32.)
+                        (.update (.getBytes (pr-str (into (sorted-map) edn))))))))))
+
+(defn compile-opts-opt
+  [cfg copts]
+  (let [copts (string/trim copts)
+        edn   (if (or (string/starts-with? copts "{")
+                      (string/starts-with? copts "^"))
+                (read-edn-string copts "Error reading EDN from command line flag: -co ")
+                (load-edn-opts copts))
+        config  (meta edn)
+        id
+        (if (or (string/starts-with? copts "{")
+                (string/starts-with? copts "^"))
+          (and (map? edn) (fallback-id edn))
+          (some->
+           (->>
+            (cljs.util/split-paths copts)
+            (filter #(not (.startsWith % "@")))
+            (map io/file)
+            (filter #(.isFile %)))
+           first
+           .getName
+           (string/split #"\.")
+           first))]
+    (cond-> cfg
+      edn (update :options merge edn)
+      id  (update-in [::build :id] #(if-not % id %))
+      config (update-in [::build :config] merge config))))

 (defn figwheel-opts-opt
   [cfg ropts]
   (let [ropts (string/trim ropts)
         edn   (if (string/starts-with? ropts "{")
-                (try
-                  (edn/read-string ropts)
-                  (catch Throwable e
-                    (throw (ex-info (str
-                                     (.getMessage e) "\n"
-                                     "Error reading EDN from command line: -fwo " (pr-str ropts))
-                                    {::error true}
-                                    e))))
+                (read-edn-string ropts "Error reading EDN from command line flag: -fwo ")
                 (load-edn-opts ropts))]
     (validate-config! edn "Error validating figwheel options EDN provided to -fwo CLI flag")
     (update cfg ::config merge edn)))
@@ -270,9 +314,9 @@
   (let [options (get-build bn)]
     (-> cfg
         (update :options merge options)
-        (assoc-in [::build] (cond-> {:id bn}
-                              (meta options)
-                              (assoc :config (meta options)))))))
+        (assoc  ::build (cond-> {:id bn}
+                          (meta options)
+                          (assoc :config (meta options)))))))

 (defn build-once-opt [cfg bn]
   (let [cfg (build-opt cfg bn)]
@@ -374,6 +418,12 @@
           {:group :cljs.cli/compile :fn figwheel-opts-opt
            :arg "edn"
            :doc (str "Options to configure figwheel.main, can be an EDN string or "
+                     "system-dependent path-separated list of EDN files / classpath resources. Options "
+                     "will be merged left to right.")}
+          ["-co" "--compile-opts"]
+          {:group :cljs.cli/main&compile :fn compile-opts-opt
+           :arg "edn"
+           :doc (str "Options to configure the build, can be an EDN string or "
                      "system-dependent path-separated list of EDN files / classpath resources. Options "
                      "will be merged left to right.")}
           ;; TODO uncertain about this
@@ -1203,6 +1253,7 @@
           (println (.getMessage e))
           (throw e))))))

+
 ))

 #_(def test-args


[examples/scrabble] Update to newer version of clojure.

--- examples/scrabble/project.clj
+++ examples/scrabble/project.clj
@@ -1,4 +1,4 @@
 (defproject scrabble "0.1.0-SNAPSHOT"
-  :dependencies [[org.clojure/clojure "1.6.0"]
+  :dependencies [[org.clojure/clojure "1.8.0"]
                  [thinktopic/cortex "0.1.0-SNAPSHOT"]]
   :main scrabble.core)


Don't get blacklisted ticket fields

Don't get blacklisted ticket fields

--- src/cljs/iframe_app/fetch_data.cljs
+++ src/cljs/iframe_app/fetch_data.cljs
@@ -38,7 +38,8 @@
   {:name            (:title ticket-field)
    :id              (:id ticket-field)
    :type            (:type ticket-field)
-   :possible-values (possible-values-for-field ticket-field groups)})
+   :possible-values (possible-values-for-field ticket-field groups)
+   :show-to-end-user (:visible_in_poral ticket-field)})

 (defn get-data-from-response [response]
   (-> response
@@ -57,6 +58,11 @@
             (fn [response]
               (put! fetch-data-chan response))))

+(def field-types-to-ignore #{"assignee" "subject" "description" "ccs" "ticketsharing" "status"})
+
+(defn valid-ticket-field [{:keys [active type]}]
+  (and active
+       (not (field-types-to-ignore type))))

 (defn fetch-ticket-forms [ticket-forms-chan]
   (go
@@ -66,16 +72,18 @@

     (when parent-app
       (let [fetch-data-chan (chan)
-           _ (request-data :groups fetch-data-chan)
-           groups (get-data-from-response (<! fetch-data-chan))
+            _ (request-data :groups fetch-data-chan)
+            groups (get-data-from-response (<! fetch-data-chan))

-           _ (request-data :ticket-fields fetch-data-chan)
-           ticket-fields (map (partial process-ticket-field groups)
-                              (get-data-from-response (<! fetch-data-chan)))
+            _ (request-data :ticket-fields fetch-data-chan)
+            ticket-fields (->> (<! fetch-data-chan)
+                               (get-data-from-response)
+                               (filter valid-ticket-field)
+                               (map (partial process-ticket-field groups)))

-           _ (request-data :ticket-forms fetch-data-chan)
-           ticket-forms (map (partial process-ticket-form ticket-fields)
-                             (get-data-from-response (<! fetch-data-chan)))]
+            _ (request-data :ticket-forms fetch-data-chan)
+            ticket-forms (map (partial process-ticket-form ticket-fields)
+                              (get-data-from-response (<! fetch-data-chan)))]

-       (put! ticket-forms-chan ticket-forms)))))
+        (put! ticket-forms-chan ticket-forms)))))


Remove String type hint on hmac functions.

--- src/clojure/buddy/core/mac/hmac.clj
+++ src/clojure/buddy/core/mac/hmac.clj
@@ -72,37 +72,37 @@

 (extend-protocol HMac
   (Class/forName "[B")
-  (make-hmac [^bytes data ^String key ^String algorithm]
+  (make-hmac [^bytes data key ^String algorithm]
     (make-hmac-for-plain-data data key algorithm))
   (verify-hmac [^bytes data ^bytes signature ^String key ^String algorithm]
     (verify-hmac-for-plain-data data signature key algorithm))

   java.lang.String
-  (make-hmac [^String data ^String key ^String algorithm]
+  (make-hmac [^String data key ^String algorithm]
     (make-hmac-for-plain-data (->byte-array data) key algorithm))
   (verify-hmac [^String data ^bytes signature ^String key ^String algorithm]
     (verify-hmac-for-plain-data (->byte-array data) signature key algorithm))

   java.io.InputStream
-  (make-hmac [^java.io.InputStream data ^String key ^String algorithm]
+  (make-hmac [^java.io.InputStream data key ^String algorithm]
     (make-hmac-for-stream data key algorithm))
   (verify-hmac [^java.io.InputStream data ^bytes signature ^String key ^String algorithm]
     (verify-hmac-for-stream data signature key algorithm))

   java.io.File
-  (make-hmac [^java.io.File data ^String key ^String algorithm]
+  (make-hmac [^java.io.File data key ^String algorithm]
     (make-hmac-for-stream (io/input-stream data) key algorithm))
   (verify-hmac [^java.io.File data ^bytes signature ^String key ^String algorithm]
     (verify-hmac-for-stream (io/input-stream data) signature key algorithm))

   java.net.URL
-  (make-hmac [^java.net.URL data ^String key ^String algorithm]
+  (make-hmac [^java.net.URL data key ^String algorithm]
     (make-hmac-for-stream (io/input-stream data) key algorithm))
   (verify-hmac [^java.net.URL data ^bytes signature ^String key ^String algorithm]
     (verify-hmac-for-stream (io/input-stream data) signature key algorithm))

   java.net.URI
-  (make-hmac [^java.net.URI data ^String key ^String algorithm]
+  (make-hmac [^java.net.URI data key ^String algorithm]
     (make-hmac-for-stream (io/input-stream data) key algorithm))
   (verify-hmac [^java.net.URI data ^bytes signature ^String key ^String algorithm]
     (verify-hmac-for-stream (io/input-stream data) signature key algorithm)))
@@ -111,13 +111,13 @@
   "Generic function that implement salted variant
 of keyed-hash message authentication code (hmac).
 This is a low level function and always return bytes."
-  [data ^String key salt ^String algorithm]
+  [data key salt ^String algorithm]
   (let [key (concat-byte-arrays (->byte-array key)
                                 (->byte-array salt))]
     (make-hmac data (sha512 key) algorithm)))

 (defn- verify-salted-hmac
-  [data ^bytes signature ^String key salt ^String algorithm]
+  [data ^bytes signature key salt ^String algorithm]
   (let [key (concat-byte-arrays (->byte-array key)
                                 (->byte-array salt))]
     (verify-hmac data signature (sha512 key) algorithm)))
@@ -127,11 +127,11 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defn hmac
-  [data ^String key ^String algorithm]
+  [data key ^String algorithm]
   (make-hmac data key algorithm))

 (defn hmac-verify
-  [data ^bytes signature ^String key ^String algorithm]
+  [data ^bytes signature key ^String algorithm]
   (verify-hmac data signature key algorithm))

 (defn shmac
@@ -145,7 +145,7 @@
   "Generic function that exposes a high level
 interface for salted variant of keyed-hash message
 authentication code verification algorithm."
-  [data ^bytes signature ^String key ^String salt ^String algorithm]
+  [data ^bytes signature key ^String salt ^String algorithm]
   (verify-salted-hmac data signature key salt algorithm))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Fix copyright year on hmac ns.

Fix copyright year on hmac ns.

--- src/clojure/buddy/core/mac/hmac.clj
+++ src/clojure/buddy/core/mac/hmac.clj
@@ -1,4 +1,4 @@
-;; Copyright (c) 2013-2014 Andrey Antukh <niwi@niwi.be>
+;; Copyright (c) 2013-2015 Andrey Antukh <niwi@niwi.be>
 ;;
 ;; Licensed under the Apache License, Version 2.0 (the "License")
 ;; you may not use this file except in compliance with the License.


Added structure function to pdaparse module

--- src/clojure/neveragain/pdaparse.clj
+++ src/clojure/neveragain/pdaparse.clj
@@ -277,8 +277,8 @@
   stop] identifying a substring of s and its name. Returns a map of names to
   sets of substrings identified in parts as having that name. Used with the
   second value in the output of `parse`. If optional argument `singles` is
-  true will assume only one instance of each capture will appear and will
-  return a map of string rather than lists."
+  true, will assume only one instance of each capture will appear and will
+  return a map of string rather than lsit values."
   [s parts &{:keys [singles]
               :or  {singles false}}]
   (let [len (count s)]
@@ -292,4 +292,45 @@
                         (conj (get r part)
                               (subs s (- len start) (- len end)))
                         (subs s (- len start) (- len end)))))))))
-
+(def l (list [:a 1 20]
+             [:b 1 5]
+             [:c 6 20]
+             [:d 10 15]
+             [:e 23 30]))
+
+(defn structure
+  [s parts]
+  (reduce (fn [x [c s e]]
+            (let [chain (loop [[[cc cs ce] & subss] x
+                               chain []]
+                          (if (and cc cs ce
+                                   (<= cs s)
+                                   (>= ce e))
+                            (recur (last subss)
+                                   (conj chain (-> subss count)))
+                            (conj (into [] (butlast chain))
+                                  (inc (last chain)))))]
+              (assoc-in x chain [[c s e]])))
+          [[:S 0 (count s)]]
+          parts))
+
+(structure "012345678901234567890123456789" l)
+
+;->
+;([0 30]
+; ([1 20]
+;  ([1 5])
+;  ([6 20]
+;   (([10 15]))))
+; ([23 30]))
+
+
+
+(defn chain-extract
+  "Operates similar to extract but instead of returning a map, returns nested
+  lists. The car of each list is the capture symbol the rest of the list
+  mathes. The remaining items are matching substrings if they are strings, or
+  contained captures if they are collections."
+  [s parts]
+  (let [structured (structure s parts)] nil)
+


Reimplemented with-fuzzy-logic

Reimplemented with-fuzzy-logic

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/contrib/fuzzy/logics.clj
+++ src/conexp/contrib/fuzzy/logics.clj
@@ -52,7 +52,7 @@
   UnsupportedOperationException when called. The operator is meant to be
   rebound."
   [name arity]
-  `(defn ~(with-meta name {:dynamic true}) ~(vec (map (fn [_] (gensym)) (range arity)))
+  `(defn ~name ~(vec (map (fn [_] (gensym)) (range arity)))
      (unsupported-operation "You need to choose a logic with with-fuzzy-logic.")))

 (define-fuzzy-operator f-star 2)
@@ -66,12 +66,15 @@
   dynamic environment where the fuzzy logic for norm is in effect."
   [norm & body]
   `(let [[x# y#] (t-norm ~norm)]
-     (binding [~'f-star x#,
-               ~'f-impl y#,
-               ~'f-and (fn [x# y#] (f-star x# (f-impl x# y#))),
-               ~'f-or  (fn [x# y#] (f-and (f-impl (f-impl x# y#) y#)
-                                          (f-impl (f-impl y# x#) x#))),
-               ~'f-neg (fn [x#] (f-impl x# 0))]
+     (with-altered-vars [~'f-star (constantly x#),
+                         ~'f-impl (constantly y#),
+                         ~'f-and  (constantly
+                                   (fn [x# y#] (f-star x# (f-impl x# y#)))),
+                         ~'f-or   (constantly
+                                   (fn [x# y#] (f-and (f-impl (f-impl x# y#) y#)
+                                                      (f-impl (f-impl y# x#) x#)))),
+                         ~'f-neg  (constantly
+                                   (fn [x#] (f-impl x# 0)))]
        ~@body)))

 ;;;


add html/tweet-button

add html/tweet-button

--- src/html.clj
+++ src/html.clj
@@ -69,3 +69,14 @@

 (defn links [& title-url-pairs]
   (ul #(apply link %) (partition 2 title-url-pairs)))
+
+(defn tweet-button [& {:keys [id label lang] :or {id "tweet_button", label "Tweet", lang "en"}}]
+  [:div {:id id}
+    [:a {:href "https://twitter.com/share"
+         :class "twitter-share-button"
+         :data-count "horizontal"
+         :data-lang lang}
+     label]
+    (js "//platform.twitter.com/widgets.js")])
+
+


Simplify the Compojure routes for the hello and grid views

--- src/main.clj
+++ src/main.clj
@@ -76,8 +76,8 @@

 (defroutes html-routes
   (GET "/hello" [] hello-world)
-  (GET "/cascade/grid" [] (fn [_] (grid 3 5)))
-  (GET "/cascade/grid/:width/:height" [width height] (fn [_] (grid (parse-int width) (parse-int height))))
+  (GET "/cascade/grid" [] (grid 3 5))
+  (GET "/cascade/grid/:width/:height" [width height] (grid (parse-int width) (parse-int height)))
   ; /hello/fail provokes an exception:
   (GET "/hello/fail" [] (try (/ 0 0) (catch Exception e (throw (RuntimeException. "Failure dividing by zero." e))))))


bg changing sort of

bg changing sort of

--- src-cljs/main/pomodoro.cljs
+++ src-cljs/main/pomodoro.cljs
@@ -1,7 +1,7 @@
 (ns main.pomodoro
   (:require-macros [cljs.core.async.macros :refer [go]])
   (:require [reagent.core :as reagent :refer [atom]]
-            [cljs.core.async :refer [put! <! chan]]
+            [cljs.core.async :refer [put! <! >! chan]]
             [clojure.string :as string]
             [cljs-time.format :refer [date-formatters]]))

@@ -68,6 +68,13 @@
 (def sound (js/Audio. sound-src))
 (defn play-sound [] (do (set! (.-src sound) sound-src) (.play sound)))

+(def ^:constant images ["bg2.jpg"
+                        "bg3.jpg"])
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; History
+(def history (atom []))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; App Setup

@@ -85,9 +92,12 @@
   ([time]
      (let [tmap (time-map time)]
        (merge tmap {:today (get-in tmap [:stime])
+                    :bg (first images)
                     :on? false}))))

 (def state (atom (default-state)))
+(def bg-chan (chan))
+(def end-chan (chan))

 (defn get-state
   ([key & keys]
@@ -109,9 +119,14 @@
   (if (= (:twenty-five presets) time)
     (:five presets)
     (:twenty-five presets)))
+
+(defn pomodoro? [five twenty-five]
+  (and (= (presets :twenty-five) twenty-five)
+       (= (presets :five) five)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Timer logic
-(def ^:constant time-speed 1e3)
+(def ^:constant time-speed 1)

 (def timer-chan
   (let [c (chan)
@@ -125,11 +140,29 @@
       (when-not (apply expired? (get-state :stime :etime))
         (set-state! :etime (dec-time (get-state :etime))))))

+
 (add-watch state :end
            (fn [k r os ns]
              (when (and (get-state :on?) (apply expired? (get-state :stime :etime)))
-               (play-sound)
-               (set-state! (default-state (next-time (get-state :time)))))))
+               (put! end-chan true))))
+
+(go (while true
+      (<! end-chan)
+      (>! bg-chan true)
+      (play-sound) ;; ding!
+      (set-state! (default-state (next-time (get-state :time)))))) ;; set next pomodoro session
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Background logic
+(defn set-bg! [bg]
+  (let [img (nth images (rand-int 2))]
+    (set-state! :bg img)))
+
+(go (while true
+      (<! bg-chan)
+      (swap! history conj (get-state :time))
+      (when (apply pomodoro? (take-last 2 @history))
+        (set-bg! (get-state :bg)))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Generic Views
@@ -156,7 +189,7 @@
         on5 #(when-not (get-state :on?) (set-time! (presets :five)))
         on-toggle #(set-state! :on? (not (get-state :on?)))
         on-reset #(when-not (get-state :on?)
-                    (set-state! (default-state (get-state :stime))))]
+                    (set-state! (default-state (get-state :time))))]

    [:div {:class "col-md-2 buttons"}
     [btn-lg {:on-click on25} 25]
@@ -178,6 +211,14 @@
    [:h2 (pretty-date (get-state :today))]])

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Style View
+(defn bg->style [val] (str "background: url(/images/" val ") center center no-repeat; background-size: cover;"))
+
+(defn bg-view []
+  [:style (str "body {" (bg->style (get-state :bg)) "}")])
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Rendering
 (reagent/render-component [timer-view] (. js/document (getElementById "timer")))
 (reagent/render-component [today-view] (. js/document (getElementById "today")))
+(reagent/render-component [bg-view] (. js/document (getElementById "style")))


Include group name in app directories

Include group name in app directories

--- edge-app-template/src/clj/new/edge_app_template.clj
+++ edge-app-template/src/clj/new/edge_app_template.clj
@@ -8,6 +8,7 @@
 (defn edge-app-template
   "FIXME: write documentation"
   [name & opts]
+  (binding [*dir* (sanitize-ns name)]
   (let [opts (set (map #(keyword (subs % 2)) opts))
         data {:name (project-name name)
               :sanitized (name-to-path name)
@@ -37,4 +38,4 @@
                  ["src/public/{{name}}.css" (render "app.css" data)]))
       (when (:cljs data)
         (->files data
-                 ["src/{{sanitized}}/frontend/main.cljs" (render "main.cljs" data)])))))
+                   ["src/{{sanitized}}/frontend/main.cljs" (render "main.cljs" data)]))))))