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 (ns wanijo.attribute.db
(:require [clojure.spec.alpha :as spec] (:require [wanijo.infrastructure.neo4j :as neo4j]))
[wanijo.specs :as specs]
[wanijo.infrastructure.neo4j :as neo4j]))
(def types (neo4j/defquery findy-by-schema
#{"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
"MATCH (a:attribute)-->(s:schema) "MATCH (a:attribute)-->(s:schema)
WHERE s.uuid = {uuid} WHERE s.uuid = {uuid}
RETURN a 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.infrastructure.routing :refer [register! path]]
[wanijo.attribute.db :as domain] [wanijo.attribute.db :as domain]
[wanijo.schema [wanijo.schema
[view :as schema-view]
[db :as schema-domain]
[routes :as schema-routes] [routes :as schema-routes]
[forms :as schema-forms] [forms :as schema-forms]
[middleware :as schema-middleware]])) [middleware :as schema-middleware]]))

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

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

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

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

Loading…
Cancel
Save