Skip to content

Commit

Permalink
And more
Browse files Browse the repository at this point in the history
  • Loading branch information
tvirolai committed Sep 25, 2018
1 parent 752fd37 commit 3926a12
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion dev-src/translation_merge.clj
Expand Up @@ -26,7 +26,7 @@
(loop []
(when-let [l (.readLine orig)]
(let [[k lang] (s/split l #"\s")]
(when (not (@writed-keys [k lang]))
(when-not (@writed-keys [k lang])
(swap! writed-keys conj [k lang])
(.write out (str l \newline))
(when (and (translations k) (= lang "\"fi\""))
Expand Down
2 changes: 1 addition & 1 deletion src/lupapalvelu/backing_system/krysp/reader.clj
Expand Up @@ -555,7 +555,7 @@
(let [area-coordinates (area-coordinates xml)
source-projection (common/->polygon-source-projection xml)
converted-coordinates (map #(coordinate/convert source-projection target-projection 6 (ss/split % #",")) area-coordinates)
converted-coordinates-str (apply str (mapv #(str (first %) " " (last %) ", ") converted-coordinates))
converted-coordinates-str (ss/join (mapv #(str (first %) " " (last %) ", ") converted-coordinates))
first-coordinate (first converted-coordinates)
first-coordinate-str (str (first first-coordinate) " " (last first-coordinate))]
(str geometry-type "((" converted-coordinates-str first-coordinate-str "))")))
Expand Down
20 changes: 10 additions & 10 deletions src/lupapalvelu/document/model.clj
Expand Up @@ -58,7 +58,7 @@
(not (.canEncode (latin1-encoder) v)) [:warn "illegal-value:not-latin1-string"]
(> (.length v) (or max-len default-max-len)) [:err "illegal-value:too-long"]
(and
(> (.length v) 0)
(pos? (.length v))
(< (.length v) (or min-len 0))) [:warn "illegal-value:too-short"]
:else (subtype/subtype-validation elem v))))

Expand All @@ -67,8 +67,9 @@
(not (string? v)) [:err "illegal-value:not-a-string"]
(> (.length v) (or (:max-len elem) default-max-len)) [:err "illegal-value:too-long"]
(and
(> (.length v) 0)
(< (.length v) (or (:min-len elem) 0))) [:warn "illegal-value:too-short"]))
(pos? (.length v))
(< (.length v)
(or (:min-len elem) 0))) [:warn "illegal-value:too-short"]))

(defmethod validate-field :hetu [_ _ v]
(cond
Expand Down Expand Up @@ -164,12 +165,11 @@
;;

(defn- resolve-element-loc-key [info element path]
(if (:i18nkey element)
(:i18nkey element)
(-> (str (ss/join "." (cons (-> info :document :locKey) (map name path)))
(when (= :select (:type element)) "._group_label"))
(ss/replace #"\.+\d+\." ".") ;; removes numbers in the middle: "a.1.b" => "a.b"
(ss/replace #"\.+" ".")))) ;; removes multiple dots: "a..b" => "a.b"
(or (:i18nkey element)
(-> (str (ss/join "." (cons (-> info :document :locKey) (map name path)))
(when (= :select (:type element)) "._group_label"))
(ss/replace #"\.+\d+\." ".") ;; removes numbers in the middle: "a.1.b" => "a.b"
(ss/replace #"\.+" ".")))) ;; removes multiple dots: "a..b" => "a.b"

(declare find-by-name)

Expand Down Expand Up @@ -336,7 +336,7 @@
value (get-in data (conj current-path :value))
validation-error (when required
(if (instance? Long value)
(when (not (some? value))
(when-not (some? value)
(->validation-result info nil current-path element [:tip "illegal-value:required"]))
(when (ss/blank? value)
(->validation-result info nil current-path element [:tip "illegal-value:required"]))))
Expand Down
2 changes: 1 addition & 1 deletion src/lupapalvelu/document/tools.clj
Expand Up @@ -236,7 +236,7 @@
(seq? node)
(and
(map? node)
(not (= :select (:type node)))
(not= :select (:type node))
(contains? node :body))))

(def schema-leaf? (complement schema-branch?))
Expand Down
9 changes: 3 additions & 6 deletions src/lupapalvelu/document/yleiset_alueet_canonical.clj
Expand Up @@ -222,15 +222,12 @@
tyomaasta-vastaava (when (:tyomaasta-vastaava config)
(get-tyomaasta-vastaava (-> documents-by-type :tyomaastaVastaava first :data)))
;; If tyomaasta-vastaava does not have :osapuolitieto, we filter out the resulting nil.
osapuolitieto (vec (filter :Osapuoli [hakija
tyomaasta-vastaava]))
osapuolitieto (filterv :Osapuoli [hakija tyomaasta-vastaava])
;; If tyomaasta-vastaava does not have :vastuuhenkilotieto, we filter the resulting nil out.
vastuuhenkilotieto (when (or (:tyomaasta-vastaava config) (not (:dummy-maksaja config)))
(vec (filter :Vastuuhenkilo [tyomaasta-vastaava
maksaja])))
(filterv :Vastuuhenkilo [tyomaasta-vastaava maksaja]))
johtoselvitysviitetieto (when (:johtoselvitysviitetieto config)
{:Johtoselvitysviite {:vaadittuKytkin false}})
]
{:Johtoselvitysviite {:vaadittuKytkin false}})]
{:kasittelytietotieto (get-kasittelytieto application)
:luvanTunnisteTiedot (get-luvan-tunniste-tiedot application)
:alkuPvm alku-pvm
Expand Down
2 changes: 1 addition & 1 deletion src/lupapalvelu/email.clj
Expand Up @@ -80,7 +80,7 @@
(defmethod ->str :hr [_] hr-as-text)
(defmethod ->str :blockquote [element] (-> element :content ->str* (ss/replace #"\n{2,}" "\n ") (ss/replace #"^\n" " ")))
(defmethod ->str :table [element] (str \newline (->str* (filter map? (:content element))) \newline))
(defmethod ->str :tr [element] (let [contents (filter #(map? %) (:content element))]
(defmethod ->str :tr [element] (let [contents (filter map? (:content element))]
(ss/join \tab (map #(ss/join (:content %)) contents))))

;;
Expand Down
5 changes: 2 additions & 3 deletions src/lupapalvelu/event_log_parser.clj
Expand Up @@ -7,7 +7,7 @@
"Parses Clojure maps from event log lines"
[filename]
(with-open [rdr (io/reader filename)]
(into []
(vec
(for [line (line-seq rdr)
:let [i (.indexOf line "{")
event (subs line i (.length line))]
Expand All @@ -26,5 +26,4 @@

(write "mongo_scripts/prod/muutoslupa.json"
(map (fn [e] (str (json/encode {:_id (e "created") :user (select-keys (get e "user") (map name lupapalvelu.user/summary-keys) ), :sourceAppId (get-in e ["data" "id"])}) \newline))
(parse-events "muutoslupa.txt")))
)
(parse-events "muutoslupa.txt"))))
4 changes: 2 additions & 2 deletions src/lupapalvelu/find_address.clj
Expand Up @@ -46,8 +46,8 @@
(defn municipality-codes [municipality-name-starts]
(let [index (apply concat (vals @municipality-index))
n (ss/lower-case (ss/trim municipality-name-starts))]
(when (not (ss/blank? n))
(->> (filter #(ss/starts-with (first %) n) index)
(when-not (ss/blank? n)
(->> (filter (fn* [p1__399098#] (ss/starts-with (first p1__399098#) n)) index)
(map second)
set))))

Expand Down

0 comments on commit 3926a12

Please sign in to comment.