From 25ffcb2917d3f851f596af95eb1748e87e4bdabe Mon Sep 17 00:00:00 2001 From: Peter Hanak Date: Sun, 25 Aug 2013 09:32:30 +0200 Subject: [PATCH 1/2] fixing newlines --- common/project.clj | 14 +++++++------- .../itedge/service_hub/core/authorizators.clj | 2 +- core/src/itedge/service_hub/core/security.clj | 2 +- .../service_hub/core/test/services_util.clj | 4 ++-- persistence-datomic/project.clj | 18 +++++++++--------- persistence-korma/project.clj | 18 +++++++++--------- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/common/project.clj b/common/project.clj index 579c9f6..f67ce33 100644 --- a/common/project.clj +++ b/common/project.clj @@ -1,7 +1,7 @@ -(defproject itedge/service-hub.common "1.2.0" - :description "Service-Hub commonly used functionality" - :min-lein-version "2.0.0" - :url "https://github.com/ITEdge/ServiceHub" - :license {:name "Eclipse Public License" - :url "http://www.eclipse.org/legal/epl-v10.html"} - :dependencies [[org.clojure/clojure "1.5.1"]]) +(defproject itedge/service-hub.common "1.2.0" + :description "Service-Hub commonly used functionality" + :min-lein-version "2.0.0" + :url "https://github.com/ITEdge/ServiceHub" + :license {:name "Eclipse Public License" + :url "http://www.eclipse.org/legal/epl-v10.html"} + :dependencies [[org.clojure/clojure "1.5.1"]]) diff --git a/core/src/itedge/service_hub/core/authorizators.clj b/core/src/itedge/service_hub/core/authorizators.clj index 6032239..dad6015 100644 --- a/core/src/itedge/service_hub/core/authorizators.clj +++ b/core/src/itedge/service_hub/core/authorizators.clj @@ -12,5 +12,5 @@ "Authorize add service call, returns nil if authorization successful, otherwise returns authorization result") (authorize-list-call [this criteria auth] "Authorize list service call, returns nil if authorization successful, otherwise returns authorization result") - (restrict-list-call [this criteria auth] + (restrict-list-call [this criteria auth] "Restrict list service call according to authentication info, returns restricted criteria if restriction is neccessary")) diff --git a/core/src/itedge/service_hub/core/security.clj b/core/src/itedge/service_hub/core/security.clj index 365a135..1724452 100644 --- a/core/src/itedge/service_hub/core/security.clj +++ b/core/src/itedge/service_hub/core/security.clj @@ -21,7 +21,7 @@ (defn bcrypt-credential-fn "A bcrypt credentials function, returns credential map minus the password key from load-credentials-fn - if the provided cleartext password matches the encrypted password in credential map, otherwise returns nil." + if the provided cleartext password matches the encrypted password in credential map, otherwise returns nil." [load-credentials-fn {:keys [username password]}] (when-let [creds (load-credentials-fn username)] (when (memoized-checkpw password (:password creds)) diff --git a/core/test/itedge/service_hub/core/test/services_util.clj b/core/test/itedge/service_hub/core/test/services_util.clj index 70db7db..8ee69ab 100644 --- a/core/test/itedge/service_hub/core/test/services_util.clj +++ b/core/test/itedge/service_hub/core/test/services_util.clj @@ -47,8 +47,8 @@ (is (= (get-success-response "Operation succesful") (util/get-service-result :ok "Operation succesful")))) -(deftest test-get-success-delete-response - (is (= (get-success-delete-response "Operation succesful") +(deftest test-get-success-delete-response + (is (= (get-success-delete-response "Operation succesful") (util/get-service-result :delete-ok "Operation succesful")))) (deftest test-assoc-range-info diff --git a/persistence-datomic/project.clj b/persistence-datomic/project.clj index 60609d5..061a66e 100644 --- a/persistence-datomic/project.clj +++ b/persistence-datomic/project.clj @@ -1,9 +1,9 @@ -(defproject itedge/service-hub.persistence-datomic "1.2.0" - :description "Datomic persistence layer" - :min-lein-version "2.0.0" - :url "https://github.com/ITEdge/ServiceHub" - :license {:name "Eclipse Public License" - :url "http://www.eclipse.org/legal/epl-v10.html"} - :dependencies [[org.clojure/clojure "1.5.1"] - [itedge/service-hub.core "1.2.0"] - [com.datomic/datomic-free "0.8.4138"]]) +(defproject itedge/service-hub.persistence-datomic "1.2.0" + :description "Datomic persistence layer" + :min-lein-version "2.0.0" + :url "https://github.com/ITEdge/ServiceHub" + :license {:name "Eclipse Public License" + :url "http://www.eclipse.org/legal/epl-v10.html"} + :dependencies [[org.clojure/clojure "1.5.1"] + [itedge/service-hub.core "1.2.0"] + [com.datomic/datomic-free "0.8.4138"]]) diff --git a/persistence-korma/project.clj b/persistence-korma/project.clj index 7dc4040..1b9386c 100644 --- a/persistence-korma/project.clj +++ b/persistence-korma/project.clj @@ -1,9 +1,9 @@ -(defproject itedge/service-hub.persistence-korma "1.2.0" - :description "Service-Hub korma persistence layer (SQL abstraction layer)" - :min-lein-version "2.0.0" - :url "https://github.com/ITEdge/ServiceHub" - :license {:name "Eclipse Public License" - :url "http://www.eclipse.org/legal/epl-v10.html"} - :dependencies [[org.clojure/clojure "1.5.1"] - [itedge/service-hub.core "1.2.0"] - [korma-enhanced "0.3.1"]]) +(defproject itedge/service-hub.persistence-korma "1.2.0" + :description "Service-Hub korma persistence layer (SQL abstraction layer)" + :min-lein-version "2.0.0" + :url "https://github.com/ITEdge/ServiceHub" + :license {:name "Eclipse Public License" + :url "http://www.eclipse.org/legal/epl-v10.html"} + :dependencies [[org.clojure/clojure "1.5.1"] + [itedge/service-hub.core "1.2.0"] + [korma-enhanced "0.3.1"]]) From 290b2b50bdd34fcc788464be694d3255ad4f05a3 Mon Sep 17 00:00:00 2001 From: Peter Hanak Date: Sun, 25 Aug 2013 10:47:04 +0200 Subject: [PATCH 2/2] grammatical inaccuracies --- .../service_hub/core/authorizators_util.clj | 2 +- .../service_hub/core/convertors_util.clj | 6 ++--- core/src/itedge/service_hub/core/security.clj | 2 +- .../itedge/service_hub/core/services_util.clj | 6 ++--- core/src/itedge/service_hub/core/util.clj | 6 ++--- .../service_hub/core/validators_util.clj | 26 +++++++++---------- .../service_hub/core/test/validators_util.clj | 14 +++++----- .../service_hub/persistence_datomic/util.clj | 10 +++---- .../service_hub/persistence_korma/util.clj | 16 ++++++------ 9 files changed, 44 insertions(+), 44 deletions(-) diff --git a/core/src/itedge/service_hub/core/authorizators_util.clj b/core/src/itedge/service_hub/core/authorizators_util.clj index 4d72661..86d025c 100644 --- a/core/src/itedge/service_hub/core/authorizators_util.clj +++ b/core/src/itedge/service_hub/core/authorizators_util.clj @@ -22,7 +22,7 @@ (assoc criteria user-key id)) (defn entity-contains? - "Determines if single entity posses specified id or if collection of entities has such one which posses it" + "Determines if single entity possesses specified id or if collection of entities has one which possesses it" [entity-id id] (if (sequential? entity-id) (if (util/in? entity-id id) diff --git a/core/src/itedge/service_hub/core/convertors_util.clj b/core/src/itedge/service_hub/core/convertors_util.clj index 998b15d..ebbba0d 100644 --- a/core/src/itedge/service_hub/core/convertors_util.clj +++ b/core/src/itedge/service_hub/core/convertors_util.clj @@ -3,7 +3,7 @@ [itedge.service-hub.core.util :as util])) (defn- convert-value - "Converts specified value, if value is a map, recursivly update all map values" + "Converts specified value, if value is a map, recursively updates all map values" [convert-fn v] (if (map? v) (util/update-map-values v (partial convert-value convert-fn)) @@ -29,7 +29,7 @@ :else (throw (Exception. (str "Only converting of maps and sequences of maps is supported"))))) (defn format-property - "Returns function which formats property if property not nil" + "Returns function which formats property if property is not nil" [ft] (fn [property-value] (if property-value @@ -37,7 +37,7 @@ property-value))) (defn sanitize-iso-params - "Sanitize all whitespaces in params before conversion, should be + signs in case of ISO timestamps" + "Sanitizes all whitespaces in params before conversion, should be + signs in case of ISO timestamps" {:added "EBS 1.0"} [convert-fn param] (convert-fn (.replaceAll param "\\s" "+"))) diff --git a/core/src/itedge/service_hub/core/security.clj b/core/src/itedge/service_hub/core/security.clj index 1724452..df2f1ae 100644 --- a/core/src/itedge/service_hub/core/security.clj +++ b/core/src/itedge/service_hub/core/security.clj @@ -3,7 +3,7 @@ (defn hash-bcrypt "Hashes a given plaintext password using bcrypt and an optional - :work-factor (defaults to 10 as of this writing). Should be used to hash + :work-factor (defaults to 10 as of now). Should be used to hash passwords included in stored user credentials that are to be later verified using `bcrypt-credential-fn`." [password & {:keys [work-factor]}] diff --git a/core/src/itedge/service_hub/core/services_util.clj b/core/src/itedge/service_hub/core/services_util.clj index e140465..138a220 100644 --- a/core/src/itedge/service_hub/core/services_util.clj +++ b/core/src/itedge/service_hub/core/services_util.clj @@ -32,19 +32,19 @@ (service-validator service-call authorizator-fn)) (defmacro do-side-effects - "Macro which wraps some function, executes this function, does defined side effects and return result from this function" + "Macro which wraps some function, executes this function, does defined side effects and returns result from this function" [fn & side-effects] `(let [fn-result# ~fn] ~@side-effects fn-result#)) (defn get-success-response - "Function which create standard success response for handler result" + "Function which creates standard success response for handler result" [handler-result] (util/get-service-result :ok handler-result)) (defn get-success-delete-response - "Function which create standard success-delete response for handler result" + "Function which creates standard success-delete response for handler result" [handler-result] (util/get-service-result :delete-ok handler-result)) diff --git a/core/src/itedge/service_hub/core/util.clj b/core/src/itedge/service_hub/core/util.clj index 662c5e6..decf8b4 100644 --- a/core/src/itedge/service_hub/core/util.clj +++ b/core/src/itedge/service_hub/core/util.clj @@ -29,7 +29,7 @@ (reduce (fn [acc item] (conj acc (nth coll item))) [] (range from to)))) (defn sort-maps - "sort collection of maps according to given sort-attrs, which should have form [[:a :ASC] [:b :DESC] ...]" + "sorts collection of maps according to given sort-attrs, which should have form [[:a :ASC] [:b :DESC] ...]" [maps sort-attrs] (let [sort-fn (reduce (fn [acc item] (juxt acc (first item))) (first (first sort-attrs)) (rest sort-attrs))] (sort-by sort-fn maps))) @@ -46,12 +46,12 @@ (read-string s))) (defn abs - "Returns absolute value of number" + "Returns absolute value of a number" [x] (if (< x 0) (- x) x)) (defn get-service-result - "Create standard service result from supplied result-code and message" + "Creates standard service result from supplied result-code and message" [result-code message] {:return-code result-code :message message}) diff --git a/core/src/itedge/service_hub/core/validators_util.clj b/core/src/itedge/service_hub/core/validators_util.clj index 6f83afb..7ff7748 100644 --- a/core/src/itedge/service_hub/core/validators_util.clj +++ b/core/src/itedge/service_hub/core/validators_util.clj @@ -9,14 +9,14 @@ (nil? (val v))) (defn validate-insert-fields - "Validate mandatory fields for insertion of given entity" + "Validates mandatory fields for insertion of given entity" [attributes mandatory-set] (let [mandatory-map (select-keys attributes mandatory-set)] (when (or (not (= (count mandatory-set) (count mandatory-map))) (some empty-val? mandatory-map)) (util/get-service-result :conflict "one or more mandatory fields are missing or empty")))) (defn validate-update-fields - "Validate mandatory fields for update of given entity" + "Validates mandatory fields for update of given entity" [attributes mandatory-set] (let [mandatory-map (select-keys attributes mandatory-set)] (when (some empty-val? mandatory-map) @@ -31,22 +31,22 @@ (if (vector? relations) relations (vector relations)))) (defn validate-insert-update-relations - "Validate relation for insertion or update of given entity" + "Validates relation for insertion or update of given entity" [attributes entity-key entity-handler] (when-let [related-value (entity-key attributes)] (when (relations-not-exist related-value entity-handler) - (util/get-service-result :conflict "mandatory related entity with given primary key does not exists")))) + (util/get-service-result :conflict "mandatory related entity with given primary key does not exist")))) (defn validate-mandatory-insert-relations - "Validate mandatory relation for insertion of given entity" + "Validates mandatory relation for insertion of given entity" [attributes entity-key entity-handler] (if-let [related-value (entity-key attributes)] (when (relations-not-exist related-value entity-handler) - (util/get-service-result :conflict "mandatory related entity with given primary key does not exists")) - (util/get-service-result :conflict "mandatory related entity not present"))) + (util/get-service-result :conflict "mandatory related entity with given primary key does not exist")) + (util/get-service-result :conflict "mandatory related entity is not present"))) (defn validate-unique-fields - "Validate unique fields among existing entities" + "Validates unique fields among existing entities" [attributes entity-handler unique-set] (let [unique-map (select-keys attributes unique-set)] (when (some (fn [e] @@ -57,7 +57,7 @@ (util/get-service-result :conflict "one or more unique values in entity are not unique among other entities")))) (defn validate-entity-still-there - "Validate if given entity still exists in system for update operations" + "Validates if given entity still exists in system for update operations" [attributes entity-handler] (let [pk (handle-get-unique-identifier entity-handler)] (if-let [id (pk attributes)] @@ -92,15 +92,15 @@ (validate-range from to (handle-count-entities entity-handler criteria)))) (defn validate-implication-insert - "Validate implication of two properties for insert operation, eq. if first property is present and not null, + "Validates implication of two properties for insert operation, eq. if first property is present and not null, second must be present and not null too" [attributes first second] (when (first attributes) (when (not (second attributes)) - (util/get-service-result :conflict "Implicative properties relation violated")))) + (util/get-service-result :conflict "Implicative properties relation was violated")))) (defn validate-implication-update - "Validate implication of two properties for upadte operarion, eq if first property not null, + "Validates implication of two properties for update operation, eq if first property not null, second must be not null too" [attributes entity-handler first second] (let [id ((handle-get-unique-identifier entity-handler) attributes) @@ -108,7 +108,7 @@ (validate-implication-insert attributes first second))) (defn validate-date-times-chronology - "Validate two dates, sooner and later" + "Validates two dates, sooner and later" [attributes entity-handler sooner-key later-key] (let [sooner (sooner-key attributes) later (later-key attributes) diff --git a/core/test/itedge/service_hub/core/test/validators_util.clj b/core/test/itedge/service_hub/core/test/validators_util.clj index b834758..8446b48 100644 --- a/core/test/itedge/service_hub/core/test/validators_util.clj +++ b/core/test/itedge/service_hub/core/test/validators_util.clj @@ -31,14 +31,14 @@ (is (= (validate-insert-update-relations {:item 1} :item test-entity-handler) nil)) (is (= (validate-insert-update-relations {:item 4} :thing test-entity-handler) nil)) (is (= (validate-insert-update-relations {:item 4} :item test-entity-handler) - (util/get-service-result :conflict "mandatory related entity with given primary key does not exists")))) + (util/get-service-result :conflict "mandatory related entity with given primary key does not exist")))) (deftest test-validate-mandatory-insert-relations (is (= (validate-mandatory-insert-relations {:item 1} :item test-entity-handler) nil)) (is (= (validate-mandatory-insert-relations {:item 4} :thing test-entity-handler) - (util/get-service-result :conflict "mandatory related entity not present"))) + (util/get-service-result :conflict "mandatory related entity is not present"))) (is (= (validate-mandatory-insert-relations {:item 4} :item test-entity-handler) - (util/get-service-result :conflict "mandatory related entity with given primary key does not exists")))) + (util/get-service-result :conflict "mandatory related entity with given primary key does not exist")))) (deftest test-validate-unique-fields (is (= (validate-unique-fields {:id 1 :name "test-entity-one"} test-entity-handler #{:name}) nil)) @@ -76,17 +76,17 @@ (deftest test-validate-implication-insert (is (= (validate-implication-insert {:a 1 :b 2} :a :b) nil)) (is (= (validate-implication-insert {:a 1 :b nil} :a :b) - (util/get-service-result :conflict "Implicative properties relation violated"))) + (util/get-service-result :conflict "Implicative properties relation was violated"))) (is (= (validate-implication-insert {:a 1} :a :b) - (util/get-service-result :conflict "Implicative properties relation violated")))) + (util/get-service-result :conflict "Implicative properties relation was violated")))) (deftest test-validate-implication-update (is (= (validate-implication-update {:id 1 :thing 4 :name "changed"} test-entity-handler :thing :name) nil)) (is (= (validate-implication-update {:id 1 :thing 9} test-entity-handler :thing :name) nil)) (is (= (validate-implication-update {:id 1 :thing 11} test-entity-handler :thing :linked) - (util/get-service-result :conflict "Implicative properties relation violated"))) + (util/get-service-result :conflict "Implicative properties relation was violated"))) (is (= (validate-implication-update {:id 4 :thing 12} test-entity-handler :thing :linked) - (util/get-service-result :conflict "Implicative properties relation violated")))) + (util/get-service-result :conflict "Implicative properties relation was violated")))) (deftest test-validate-date-times-chronology (is (= (validate-date-times-chronology {:first "2013-06-28T22:15:00.000+02:00" diff --git a/persistence-datomic/src/itedge/service_hub/persistence_datomic/util.clj b/persistence-datomic/src/itedge/service_hub/persistence_datomic/util.clj index 2202b03..32d7f7a 100644 --- a/persistence-datomic/src/itedge/service_hub/persistence_datomic/util.clj +++ b/persistence-datomic/src/itedge/service_hub/persistence_datomic/util.clj @@ -15,7 +15,7 @@ (reduce (fn [acc item] (conj query [entity-symbol item])) query fieldset)) (defn exist-entity? - "Determines if entity with given fieldset and id exist in database" + "Determines if entity with given fieldset and id exists in database" [db fieldset id] (let [query (-> '[:find ?eid :in $ ?eid :where [?eid]] (add-fieldset '?eid fieldset))] @@ -24,7 +24,7 @@ false))) (defn get-entity - "Get entity with specified fieldset and id, if no such entity exist, returns nil" + "Gets entity with specified fieldset and id, if no such entity exists, returns nil" [db fieldset id] (when (exist-entity? db fieldset id) (convert-entity-to-map (entity db id)))) @@ -82,13 +82,13 @@ (convert-entity-to-map (entity (:db-after @(transact conn [attributes])) id)))) (defn delete-entity - "Strips entity with given fieldset and id of all attributes" + "Strips entity with given fieldset and id of all its attributes" [conn fieldset id] (when (exist-entity? (db conn) fieldset id) (:db/id (entity (:db-after @(transact conn [[:db.fn/retractEntity id]])) id)))) (defn count-entities - "Count entities with given fieldset in specified db" + "Counts entities with given fieldset in specified db" [db fieldset criteria] (let [query (-> '[:find (count ?e) :where] (add-fieldset '?e (unrestricted-fields fieldset criteria)) @@ -112,6 +112,6 @@ (util/get-ranged-vector unsorted-entities from to)))) (defn list-entities - "List entities with given fieldset, criteria, sorting and paging in specified db" + "Lists entities with given fieldset, criteria, sorting and paging in specified db" [db fieldset criteria sort-attrs from to] (list-entities-p db (list-entities-q fieldset criteria) sort-attrs from to)) diff --git a/persistence-korma/src/itedge/service_hub/persistence_korma/util.clj b/persistence-korma/src/itedge/service_hub/persistence_korma/util.clj index 144414c..b00892c 100644 --- a/persistence-korma/src/itedge/service_hub/persistence_korma/util.clj +++ b/persistence-korma/src/itedge/service_hub/persistence_korma/util.clj @@ -6,14 +6,14 @@ [korma.sql.fns :as korma-fns])) (defn- translate-wildcards - "Translate string value with wildcards (*) into korma like expression ([like \"%something%\"])" + "Translates string value with wildcards (*) into korma like expression ([like \"%something%\"])" [value] (if (.contains (str value) "*") (vector 'like (.replaceAll value "\\*" "%")) value)) (defn- translate - "Translate CQL expression into korma equivalent" + "Translates CQL expression into its korma equivalent" [expr] (let [k-e (key expr) v-e (val expr) @@ -28,13 +28,13 @@ [translated (translate-wildcards v-e)])) (defn- translate-expressions - "Translate CQL expressions into korma equivalents" + "Translates CQL expressions into korma equivalents" [k v] (let [reduce-fn (fn [k acc expr] (conj acc {k (translate expr)}))] (reduce (partial reduce-fn k) '() v))) (defn translate-relation-expressions - "Translate CQL expressions into korma equivalents for relation queries" + "Translates CQL expressions into korma equivalents for relation queries" [criteria] (util/update-map-values criteria (fn [e] (if (map? e) (translate (first e)) e)))) @@ -48,14 +48,14 @@ (list {k (translate-wildcards v)})))) (defn- construct-list - "Construct final query expression in form of list (expr1 expr2...)" + "Constructs final query expression in form of list (expr1 expr2...)" [exprs] (let [reduce-fn (fn [acc expr] (concat acc (process-expr expr)))] (reduce reduce-fn '() exprs))) (defn construct-and-list - "construct and list from list of expressions if there is more then one expression, otherwise return first expression" + "Constructs and lists from list of expressions if there is more than one expression, otherwise returns first expression" [exprs] (let [exprs-list (construct-list exprs) exprs-count (count exprs-list)] @@ -64,7 +64,7 @@ (first exprs-list)))) (defn- construct-relations - "Construct relations from attributes" + "Constructs relations from attributes" [attributes] (into {} (map (fn [entry] (let [k (key entry) @@ -74,7 +74,7 @@ (hash-map k (if (map? v) (:id v) v))))) attributes))) (defn- extract-id - "Extract id from db insert results" + "Extracts id from db insert results" [results] (if (map? results) (first (vals results))