modules and components

Josha von Gizycki 5 years ago
parent 42c9de86d1
commit a005e05e71

@ -25,7 +25,7 @@
"MATCH (coc:instance {uuid:{coc_uuid}}), "MATCH (coc:instance {uuid:{coc_uuid}}),
(rschema:schema {uuid:{roleschema_uuid}}), (rschema:schema {uuid:{roleschema_uuid}}),
(role:instance)-[:of]->(rschema), (role:instance)-[:of]->(rschema),
(coc)--(:link)--(role:instance) (coc)--(:link)--(role)
OPTIONAL MATCH OPTIONAL MATCH
(lschema:schema {uuid:{levelschema_uuid}}), (lschema:schema {uuid:{levelschema_uuid}}),
(level:instance)-[:of]->(lschema), (level:instance)-[:of]->(lschema),
@ -39,7 +39,10 @@
(group-by :role) (group-by :role)
(map (fn [[role rows]] (map (fn [[role rows]]
{:role role {:role role
:levels (filter some? (map :level rows))})))) :levels (->> (map :level rows)
(filter some?)
(sort-by :name))}))
(sort-by #(-> % :role :name))))
(comment (comment
(roles-with-levels-of-coc! "dev") (roles-with-levels-of-coc! "dev")
@ -57,3 +60,42 @@
first first
:coc :coc
(assoc :key coc-key))) (assoc :key coc-key)))
(neo4j/defquery level
"MATCH (level:instance {uuid:{uuid}})
RETURN level")
(defn level! [uuid]
(-> (neo4j/exec-query! level
{:uuid uuid})
first
:level))
(neo4j/defquery modules-with-comps
"MATCH (level:instance {uuid:{level_uuid}}),
(mschema:schema {uuid:{moduleschema_uuid}}),
(module:instance)-[:of]->(mschema),
(level)--(:link)--(module)
OPTIONAL MATCH
(cschema:schema {uuid:{compschema_uuid}}),
(comp:instance)-[:of]->(cschema),
(module)--(:link)--(comp)
RETURN module, comp")
(defn modules-with-comps! [level-uuid]
(->> (neo4j/exec-query! modules-with-comps
{:level_uuid level-uuid
:moduleschema_uuid (:module schema-uuids)
:compschema_uuid (:component schema-uuids)})
(group-by :module)
(map (fn [[module rows]]
{:module module
:comps (->> (map :comp rows)
(filter some?)
(sort-by :name))}))
(sort-by #(-> % :module :name))))
(comment
(modules-with-comps! "140962fb-f55e-45ab-87fc-680c012bd8dc")
(neo4j/exec-query! modules-with-comps
{:level_uuid "140962fb-f55e-45ab-87fc-680c012bd8dc"
:moduleschema_uuid (:module schema-uuids)
:compschema_uuid (:component schema-uuids)}))

@ -7,10 +7,19 @@
(defn index [] (defn index []
(view-public/index)) (view-public/index))
(defn show-roles [coc-key] (defn show-coc [coc-key]
(view-public/show-coc (db-public/coc! coc-key) (view-public/show-coc (db-public/coc! coc-key)
(db-public/roles-with-levels-of-coc! coc-key))) (db-public/roles-with-levels-of-coc! coc-key)))
(defn show-modules [coc-key level-uuid]
(view-public/show-modules
(db-public/coc! coc-key)
(db-public/level! level-uuid)
(db-public/modules-with-comps! level-uuid)))
(defroutes routes (defroutes routes
(GET (register! :public-index "/public") [] (index)) (GET (register! :public-index "/public") [] (index))
(GET (register! :public-coc "/public/:coc") [coc] (show-roles coc))) (GET (register! :public-coc-roles "/public/:coc") [coc] (show-coc coc))
(GET (register! :public-role-modules "/public/:coc/:level")
[coc level]
(show-modules coc level)))

@ -30,13 +30,13 @@
[:menu.global-nav [:menu.global-nav
[:ol.global-nav__card-nav [:ol.global-nav__card-nav
[:li.global-nav__card-nav-item [:li.global-nav__card-nav-item
[:a.global-nav__link {:href (path :public-coc {:coc "dev"})} [:a.global-nav__link {:href (path :public-coc-roles {:coc "dev"})}
"Development"]] "Development"]]
[:li.global-nav__card-nav-item [:li.global-nav__card-nav-item
[:a.global-nav__link {:href (path :public-coc {:coc "prk"})} [:a.global-nav__link {:href (path :public-coc-roles {:coc "prk"})}
"Projekte"]] "Projekte"]]
[:li.global-nav__card-nav-item [:li.global-nav__card-nav-item
[:a.global-nav__link {:href (path :public-coc {:coc "req"})} [:a.global-nav__link {:href (path :public-coc-roles {:coc "req"})}
"Req. Eng."]]]] "Req. Eng."]]]]
(into [:div.content] content)]])) (into [:div.content] content)]]))
@ -64,16 +64,56 @@
[:tbody [:tbody
(for [row roles-with-levels (for [row roles-with-levels
:let [{:keys [role levels]} row :let [{:keys [role levels]} row
rest-levels (rest levels)]] level (first levels)]]
(list (list
[:tr [:tr
[:td {:rowspan (max 1 (count levels))} (h (:name role))] [:td {:rowspan (max 1 (count levels))}
[:td (h (-> levels first :name))]] (h (:name role))]
(for [level rest-levels] [:td
[:a {:href (path :public-role-modules
{:coc (:key coc)
:level (:uuid level)})}
(h (:name level))]]]
(for [level (rest levels)]
[:tr [:tr
[:td (h (:name level))]])))]]]] [:td [:a {:href (path :public-role-modules
{:coc (:key coc)
:level (:uuid level)})}
(h (:name level))]]])))]]]]
[:nav [:nav
[:ol.breadcrumb [:ol.breadcrumb
[:li.breadcrumb-item [:li.breadcrumb-item
[:a {:href (path :public-index)} "Start"]] [:a {:href (path :public-index)} "Start"]]
[:li.breadcrumb-item.active (h (:name coc))]]]])) [:li.breadcrumb-item.active (h (:name coc))]]]]))
(defn show-modules [coc level modules-with-comps]
(layout
[[:main.main
[:h1 "Erfahrungsstufe " (h (:name level))]
[:div.table-responsive
[:table.table
[:thead
[:tr
[:th "Modul"]
[:th "Komponente"]]]
[:tbody
(for [row modules-with-comps
:let [{:keys [module comps]} row
compo (first comps)]]
(list
[:tr
[:td {:rowspan (max 1 (count comps))}
(h (:name module))]
[:td (h (:name compo))]]
(for [compo (rest comps)]
[:tr
[:td (h (:name compo))]])))]]]]
[:nav
[:ol.breadcrumb
[:li.breadcrumb-item
[:a {:href (path :public-index)} "Start"]]
[:li.breadcrumb-item
[:a {:href (path :public-coc-roles
{:coc (:key coc)})}
(h (:name coc))]]
[:li.breadcrumb-item.active (h (:name level))]]]]))

Loading…
Cancel
Save