|
11 | 11 | [apps.service.apps.util :refer [paths-accessible?]] |
12 | 12 | [apps.util.service :as service] |
13 | 13 | [apps.util.config :as config] |
| 14 | + [apps.util.db :as db] |
14 | 15 | [apps.util.conversions :refer [remove-nil-vals]] |
| 16 | + [clojure.java.jdbc :as jdbc] |
15 | 17 | [clojure-commons.exception-util :as cxu] |
16 | | - [korma.core :refer [fields join order select subselect where]] |
| 18 | + [honey.sql :as sql] |
| 19 | + [honey.sql.helpers :as h] |
| 20 | + [korma.core :refer [fields join order select where]] |
17 | 21 | [slingshot.slingshot :refer [try+ throw+]])) |
18 | 22 |
|
19 | 23 | (defn- format-step-resource-requirements |
|
33 | 37 |
|
34 | 38 | (defn- mapped-input-subselect |
35 | 39 | [step-id] |
36 | | - (subselect [:workflow_io_maps :wm] |
37 | | - (join [:input_output_mapping :iom] {:wm.id :iom.mapping_id}) |
38 | | - (where {:iom.input :p.id |
39 | | - :wm.target_step step-id}))) |
40 | | - |
41 | | -(defn- add-hidden-parameters-clause |
42 | | - [query include-hidden-params?] |
43 | | - (if-not include-hidden-params? |
44 | | - (where query {:p.is_visible true}) |
45 | | - query)) |
| 40 | + (-> (h/select :*) |
| 41 | + (h/from [:workflow_io_maps :wm]) |
| 42 | + (h/join [:input_output_mapping :iom] [:= :wm.id :iom.mapping_id]) |
| 43 | + (h/where [:and |
| 44 | + [:= :iom.input :p.id] |
| 45 | + [:= :wm.target_step step-id]]))) |
| 46 | + |
| 47 | +(defn- get-parameters-query |
| 48 | + [step-id group-id include-hidden-params?] |
| 49 | + (-> (mp/hsql-params-base-query) |
| 50 | + (h/order-by :p.display-order) |
| 51 | + (h/where [:and |
| 52 | + [:= :p.parameter_group_id group-id] |
| 53 | + (when include-hidden-params? :p.is_visible) |
| 54 | + [:and |
| 55 | + [:not [:exists (mapped-input-subselect step-id)]] |
| 56 | + [:or |
| 57 | + [:= :p.value_type "Input"] |
| 58 | + [:not [:coalesce :is_implicit false]]]]]) |
| 59 | + (sql/format))) |
46 | 60 |
|
47 | 61 | (defn- get-parameters |
48 | | - [step-id group-id include-hidden-params?] |
49 | | - (-> (mp/params-base-query) |
50 | | - (order :p.display_order) |
51 | | - (where {:p.parameter_group_id group-id}) |
52 | | - (add-hidden-parameters-clause include-hidden-params?) |
53 | | - (where (and [:not [:exists (mapped-input-subselect step-id)]] |
54 | | - (or {:value_type "Input"} |
55 | | - {:is_implicit nil} |
56 | | - {:is_implicit false}))) |
57 | | - select)) |
| 62 | + [step-id group-id include-hidden-parameters] |
| 63 | + (db/with-transaction [tx] |
| 64 | + (jdbc/query tx (get-parameters-query step-id group-id include-hidden-parameters)))) |
58 | 65 |
|
59 | 66 | (defn- get-default-value |
60 | 67 | [user type values] |
|
0 commit comments