Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grammatical inaccuracies #2

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions common/project.clj
Original file line number Diff line number Diff line change
@@ -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"]])
2 changes: 1 addition & 1 deletion core/src/itedge/service_hub/core/authorizators.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
2 changes: 1 addition & 1 deletion core/src/itedge/service_hub/core/authorizators_util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions core/src/itedge/service_hub/core/convertors_util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -29,15 +29,15 @@
: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
(format ft property-value)
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" "+")))
Expand Down
4 changes: 2 additions & 2 deletions core/src/itedge/service_hub/core/security.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]}]
Expand All @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions core/src/itedge/service_hub/core/services_util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
6 changes: 3 additions & 3 deletions core/src/itedge/service_hub/core/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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})

Expand Down
26 changes: 13 additions & 13 deletions core/src/itedge/service_hub/core/validators_util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand All @@ -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)]
Expand Down Expand Up @@ -92,23 +92,23 @@
(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)
attributes (merge (handle-find-entity entity-handler id) attributes)]
(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)
Expand Down
4 changes: 2 additions & 2 deletions core/test/itedge/service_hub/core/test/services_util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions core/test/itedge/service_hub/core/test/validators_util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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"
Expand Down
18 changes: 9 additions & 9 deletions persistence-datomic/project.clj
Original file line number Diff line number Diff line change
@@ -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"]])
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand All @@ -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))))
Expand Down Expand Up @@ -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))
Expand All @@ -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))
18 changes: 9 additions & 9 deletions persistence-korma/project.clj
Original file line number Diff line number Diff line change
@@ -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"]])
Loading