Skip to content
Open
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
40 changes: 22 additions & 18 deletions bases/behave_schema/src/behave/schema/group_variable.cljc
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
(ns behave.schema.group-variable
(:require [clojure.spec.alpha :as s]
[behave.schema.utils :refer [valid-key? uuid-string? zero-pos?]]))
(:require [behave.schema.utils :refer [valid-key? uuid-string? zero-pos?]]
[clojure.spec.alpha :as s]))

;;; Validation Fns

(def ^:private valid-direction? (s/and keyword? #(#{:heading :backing :flanking} %)))

;;; Spec

(s/def :bp/uuid uuid-string?)
(s/def :bp/nid string?)
(s/def :group-variable/cpp-class string?)
(s/def :group-variable/cpp-function string?)
(s/def :group-variable/cpp-namespace string?)
(s/def :group-variable/cpp-parameter string?)
(s/def :group-variable/help-key valid-key?)
(s/def :group-variable/order zero-pos?)
(s/def :group-variable/translation-key valid-key?)
(s/def :group-variable/research? boolean?)
(s/def :group-variable/hide-graph? boolean?)
(s/def :group-variable/direction valid-direction?)


(s/def :bp/uuid uuid-string?)
(s/def :bp/nid string?)
(s/def :group-variable/cpp-class string?)
(s/def :group-variable/cpp-function string?)
(s/def :group-variable/cpp-namespace string?)
(s/def :group-variable/cpp-parameter string?)
(s/def :group-variable/help-key valid-key?)
(s/def :group-variable/order zero-pos?)
(s/def :group-variable/translation-key valid-key?)
(s/def :group-variable/research? boolean?)
(s/def :group-variable/hide-graph? boolean?)
(s/def :group-variable/direction valid-direction?)
(s/def :group-variable/direction-variables (s/coll-of int?))

(s/def :behave/group-variable (s/keys :req [:bp/uuid
:bp/nid
:group-variable/order
:group-variable/translation-key
:group-variable/help-key]
:opt [:group-variable/research?
:group-variable/direction-variables
:group-variable/hide-graph?
:group-variable/direction
:group-variable/cpp-class
Expand Down Expand Up @@ -88,6 +88,11 @@
:db/cardinality :db.cardinality/many
:db/isComponent true}

{:db/ident :group-variable/direction-variables
:db/doc "Group variable's reference to group variables that have directionality."
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}

{:db/ident :group-variable/direction
:db/doc "Group variable's direction."
:db/valueType :db.type/keyword
Expand Down Expand Up @@ -164,5 +169,4 @@
:group-variable/help-key "behave:contain:fire:group:var:help"
:group-variable/cpp-class "BehaveContain"
:group-variable/cpp-namespace "global"
:group-variable/cpp-function "setFireSize"})
)
:group-variable/cpp-function "setFireSize"}))
11 changes: 6 additions & 5 deletions components/schema_migrate/src/schema_migrate/core.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(ns schema-migrate.core
(:require
[clojure.walk :as walk]
[clojure.spec.alpha :as spec]
[clojure.string :as s]
[clojure.walk :as walk]
[datascript.core :refer [squuid]]
[datomic.api :as d]
[datomic-store.main :as ds]
[clojure.spec.alpha :as spec]
[datomic.api :as d]
[nano-id.core :refer [nano-id]]))

(def
Expand Down Expand Up @@ -378,7 +378,7 @@

(defn ->variable
[_conn {:keys [nname domain-uuid list-eid translation-key help-key kind bp6-label bp6-code map-units-convertible?
dimension-uuid native-unit-uuid metric-unit-uuid english-unit-uuid] :as params}]
dimension-uuid native-unit-uuid metric-unit-uuid english-unit-uuid] :as params}]
(let [payload (cond-> {}
(nil? (:bp/uuid params)) (assoc :bp/uuid (rand-uuid))
(not (:bp/nid params)) (assoc :bp/nid (nano-id))
Expand Down Expand Up @@ -406,7 +406,7 @@
"Payload for a new Group Variable."
[conn {:keys
[parent-group-eid order variable-eid cpp-namespace cpp-class cpp-function cpp-parameter translation-key conditionally-set? actions
hide-result-conditionals hide-result? disable-multi-valued-input-conditionals disable-multi-valued-input-conditional-operator] :as params}]
hide-result-conditionals hide-result? disable-multi-valued-input-conditionals disable-multi-valued-input-conditional-operator direction-variables] :as params}]
(let [payload (if (spec/valid? :behave/group-variable params)
params
(cond-> {}
Expand All @@ -422,6 +422,7 @@
cpp-class (assoc :group-variable/cpp-class (cpp-class->uuid conn cpp-namespace cpp-class))
cpp-function (assoc :group-variable/cpp-function (cpp-fn->uuid conn cpp-namespace cpp-class cpp-function))
cpp-parameter (assoc :group-variable/cpp-parameter (cpp-param->uuid conn cpp-namespace cpp-class cpp-function cpp-parameter))
(seq direction-variables) (assoc :group-variable/direction-variables direction-variables)
translation-key (assoc :group-variable/translation-key translation-key)
translation-key (assoc :group-variable/result-translation-key (s/replace translation-key ":output:" ":result:"))
translation-key (assoc :group-variable/help-key (str translation-key ":help"))
Expand Down
Loading