move specs from attribute.db to attribute.domain, rename aliases

neo4j-4
Josha von Gizycki 5 years ago
parent 8479133d58
commit 61dbceb364

@ -1,20 +1,7 @@
(ns wanijo.attribute.db
(:require [clojure.spec.alpha :as spec]
[wanijo.specs :as specs]
[wanijo.infrastructure.neo4j :as neo4j]))
(:require [wanijo.infrastructure.neo4j :as neo4j]))
(def types
#{"string" "markdown"})
(spec/def ::type types)
(spec/def ::name
(spec/and ::specs/name (complement empty?)))
(spec/def ::attribute
(spec/keys ::req-un [::name
::type
::specs/created-at]))
(neo4j/defquery
findy-by-schema
(neo4j/defquery findy-by-schema
"MATCH (a:attribute)-->(s:schema)
WHERE s.uuid = {uuid}
RETURN a

@ -0,0 +1,13 @@
(ns wanijo.attribute.domain
(:require [wanijo.specs :as specs]
[clojure.spec.alpha :as spec]))
(def types
#{"string" "markdown"})
(spec/def ::type types)
(spec/def ::name
(spec/and ::specs/name (complement empty?)))
(spec/def ::attribute
(spec/keys ::req-un [::name
::type
::specs/created-at]))

@ -6,8 +6,6 @@
[wanijo.infrastructure.routing :refer [register! path]]
[wanijo.attribute.db :as domain]
[wanijo.schema
[view :as schema-view]
[db :as schema-domain]
[routes :as schema-routes]
[forms :as schema-forms]
[middleware :as schema-middleware]]))

@ -3,9 +3,9 @@
[wanijo.specs :as specs]
[wanijo.infrastructure.neo4j :as neo4j]
[wanijo.schema.db :as domain-schema]
[wanijo.attribute.db :as domain-attr]
[wanijo.tag.db :as domain-tag]
[wanijo.link.db :as domain-link]))
[wanijo.attribute.domain :as domain-attr]
[wanijo.tag.db :as db-tag]
[wanijo.link.db :as db-link]))
(spec/def ::instance
(spec/keys :req-un [::neo4j/uuid
@ -21,7 +21,7 @@
(spec/def ::target ::instance)
(spec/def ::source ::instance)
(spec/def ::tags
(spec/coll-of ::domain-tag/tag))
(spec/coll-of ::db-tag/tag))
(spec/def ::contains-schema
(spec/keys :req-un [::domain-schema/schema]))
@ -194,7 +194,7 @@
(spec/def ::links-out
(spec/coll-of
(spec/keys :req-un [::domain-link/link
(spec/keys :req-un [::db-link/link
::target
::domain-schema/schema
::tags])))
@ -212,7 +212,7 @@
(spec/def ::links-in
(spec/coll-of
(spec/keys :req-un [::domain-link/link
(spec/keys :req-un [::db-link/link
::source
::domain-schema/schema
::tags])))
@ -247,7 +247,7 @@
:links-in
(incoming-links! uuid)
:tags
(domain-tag/tags-by-instance! uuid)))
(db-tag/tags-by-instance! uuid)))
(neo4j/defquery is-starred
"MATCH (u:user {uuid:{user_uuid}}),

@ -12,22 +12,22 @@
[middleware :as middleware-schema]]
[wanijo.link.db :as domain-link]
[wanijo.infrastructure.routing :refer [register! path]]
[wanijo.attribute.db :as domain-attr]))
[wanijo.attribute.db :as db-attr]))
(defn list! [schema-uuid req]
(view/list! (domain-schema/find-by-uuid! schema-uuid)
(domain/find-by-schema! schema-uuid)
(forms-inst/with-attributes (domain-attr/required! schema-uuid))
(forms-inst/with-attributes (db-attr/required! schema-uuid))
req))
(defn new! [req]
(let [schema-uuid (get-in req [:params :schema-uuid])
user-uuid (get-in req [:session :uuid])
req-attrs (domain-attr/required! schema-uuid)
req-attrs (db-attr/required! schema-uuid)
form-def (forms-inst/with-attributes req-attrs)]
(if (form/valid? form-def req)
(let [form-data (form/form-data form-def req)
req-attrs (domain-attr/required! schema-uuid)
req-attrs (db-attr/required! schema-uuid)
instance (forms-inst/form-data->instance form-data
req-attrs)]
(domain/create! user-uuid
@ -55,7 +55,7 @@
(defn edit-form! [uuid req]
(let [instance (instance! uuid)
attrs (domain-attr/find-by-instance! uuid)
attrs (db-attr/find-by-instance! uuid)
user-uuid (get-in req [:session :uuid])]
(view/edit! instance
(form! attrs)
@ -64,7 +64,7 @@
req)))
(defn edit! [uuid req]
(let [attrs (domain-attr/find-by-instance! uuid)
(let [attrs (db-attr/find-by-instance! uuid)
form-def (form! attrs)]
(if (form/valid? form-def req)
(let [form-data (form/form-data form-def req)

@ -1,5 +1,6 @@
(ns wanijo.schema.forms
(:require [wanijo.attribute.db :as attr-domain]
(:require [wanijo.attribute.db :as db-attr]
[wanijo.attribute.domain :as domain-attr]
[clojure.string :refer [capitalize]]
[clojure.spec.alpha :as spec]))
@ -7,7 +8,7 @@
(let [schema-uuid (get-in req [:params :schema])
attr-uuid (get-in req [:params :uuid])
name (get-in req [:params :name])
duplicates (->> (attr-domain/find-by-schema! schema-uuid)
duplicates (->> (db-attr/find-by-schema! schema-uuid)
(map #(if (or (and (empty? attr-uuid)
(= name (:name %)))
(and (seq attr-uuid)
@ -29,13 +30,13 @@
(def attr-form
{:fields {:name {:label "Name"
:required true
:spec ::attr-domain/name}
:spec ::domain-attr/name}
:type {:label "Type"
:required true
:spec ::attr-domain/type
:spec ::domain-attr/type
:widget :select
:options (map #(vector (capitalize %) %)
attr-domain/types)}
domain-attr/types)}
:required {:label "Required"
:required false
:widget :checkbox

@ -10,7 +10,7 @@
[forms :as schema-forms]
[db :as domain]
[middleware :as middleware]]
[wanijo.attribute.db :as domain-attr]))
[wanijo.attribute.db :as db-attr]))
(defn new! [req]
(if (form/valid? schema-forms/schema req)
@ -28,7 +28,7 @@
(defn view! [uuid req]
(schema-view/show-schema!
(domain/find-with-assigned-entities! uuid)
(domain-attr/find-by-schema! uuid)
(db-attr/find-by-schema! uuid)
(assoc-in schema-forms/assign-form
[:fields :assigned :options]
(map #(vector (:ident %) (:uuid %))

Loading…
Cancel
Save