diff --git a/src/adl/to_hugsql_queries.clj b/src/adl/to_hugsql_queries.clj index 578f4ee..dbb0508 100644 --- a/src/adl/to_hugsql_queries.clj +++ b/src/adl/to_hugsql_queries.clj @@ -392,13 +392,10 @@ (defn queries "Generate all standard queries for this `entity` in this `application`; if - no entity is specified, generate all queris for the application." + no entity is specified, generate all queries for the application." ([application entity] (merge - (if - (link-table? entity) - (link-table-queries entity application) - {}) + ;; TODO: queries that look through link tables (insert-query entity) (update-query entity) (delete-query entity) diff --git a/src/adl/to_json_routes.clj b/src/adl/to_json_routes.clj index e6e9346..afb0426 100644 --- a/src/adl/to_json_routes.clj +++ b/src/adl/to_json_routes.clj @@ -47,12 +47,12 @@ (f/unparse (f/formatters :basic-date-time) (t/now))) (list :require + '[clojure.java.io :as io] + '[compojure.core :refer [defroutes GET POST]] + '[hugsql.core :as hugsql] '[noir.response :as nresponse] '[noir.util.route :as route] - '[compojure.core :refer [defroutes GET POST]] '[ring.util.http-response :as response] - '[clojure.java.io :as io] - '[hugsql.core :as hugsql] (vector (symbol (str (safe-name (:name (:attrs application))) ".db.core")) :as 'db)))) diff --git a/src/adl/to_selmer_routes.clj b/src/adl/to_selmer_routes.clj index 37e5a71..f58c00d 100644 --- a/src/adl/to_selmer_routes.clj +++ b/src/adl/to_selmer_routes.clj @@ -44,12 +44,12 @@ (f/unparse (f/formatters :basic-date-time) (t/now))) (list :require + '[clojure.java.io :as io] + '[compojure.core :refer [defroutes GET POST]] + '[hugsql.core :as hugsql] '[noir.response :as nresponse] '[noir.util.route :as route] - '[compojure.core :refer [defroutes GET POST]] '[ring.util.http-response :as response] - '[clojure.java.io :as io] - '[hugsql.core :as hugsql] (vector (symbol (str (:name (:attrs application)) ".layout")) :as 'l) (vector (symbol (str (:name (:attrs application)) ".db.core")) :as 'db) (vector (symbol (str (:name (:attrs application)) ".routes.manual")) :as 'm)))) diff --git a/src/adl/to_selmer_templates.clj b/src/adl/to_selmer_templates.clj index a1616e1..05673e0 100644 --- a/src/adl/to_selmer_templates.clj +++ b/src/adl/to_selmer_templates.clj @@ -480,7 +480,7 @@ (list-page-control true)]}) -(defn- list-to-template +(defn list-to-template "Generate a template as specified by this `list` element for this `entity`, taken from this `application`. If `list` is nill, generate a default list template for the entity." @@ -502,9 +502,9 @@ `entity` in this `application`" [entity application] (let - [forms (children entity #(= (:tag %) :form)) - pages (children entity #(= (:tag %) :page)) - lists (children entity #(= (:tag %) :list))] + [forms (children-with-tag entity :form) + pages (children-with-tag entity :page) + lists (children-with-tag entity :list)] (if (and (= (:tag entity) :entity) ;; it seems to be an ADL entity diff --git a/src/adl/utils.clj b/src/adl/utils.clj index fb9c5f2..8767c47 100644 --- a/src/adl/utils.clj +++ b/src/adl/utils.clj @@ -281,14 +281,6 @@ (safe-name string)))))) -(defn link-table? - "Return true if this `entity` represents a link table." - [entity] - (let [properties (children entity #(= (:tag %) :property)) - links (filter #(-> % :attrs :entity) properties)] - (= (count properties) (count links)))) - - (defn read-adl [url] (let [adl (x/parse url) valid? (valid-adl? adl)] @@ -371,6 +363,14 @@ `(filter insertable? (key-properties entity))) +(defn link-table? + "Return true if this `entity` represents a link table." + [entity] + (let [properties (all-properties entity) + links (filter #(-> % :attrs :entity) properties)] + (= (count properties) (count links)))) + + (defn key-names [entity] (remove nil?