Last active
April 27, 2018 19:22
-
-
Save eraserhd/23ab2c6d65c26638b0b5ab342521bfa7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[:find ?result . | |
:in $ % | |
:where | |
(or-join [?result] | |
(and | |
[(ground false) ?false] | |
[?attr :string/non-blank? true] | |
[?eid ?attr ""] | |
[(get-else $ ?attr :db/ident "<missing ident>") ?attr-kw] | |
[(str ?attr-kw " cannot be blank.") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid ?attr ?result-2) | |
[(identity ?result-2) ?result]) | |
(and | |
[(ground false) ?false] | |
[?attr :string/pattern ?regex] | |
[(re-pattern ?regex) ?pattern] | |
[?eid ?attr ?value] | |
(not [(re-matches ?pattern ?value)]) | |
[(str "\"" ?value "\" does not match /" ?regex "/.") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid ?attr ?result-2) | |
[(identity ?result-2) ?result]) | |
(and | |
[(ground false) ?false] | |
[?eid :program/program-offering ?po] | |
[?eid :program/university ?u] | |
[?u :university/shortname ?un] | |
(not [(clojure.string/replace ?po #"-.*$" "") ?un]) | |
[?attr :db/ident :program/program-offering] | |
[(str "\"" ?po "\" does not start with \"" ?un | |
"\" (the university's short name) followed by a dash.") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid ?attr ?result-2) | |
[(identity ?result-2) ?result]) | |
(and | |
[(ground false) ?false] | |
[?eid1 :program/application-groupings ?ag] | |
[?eid2 :program/application-groupings ?ag] | |
[(not= ?eid1 ?eid2)] | |
[?eid1 :program/dns-domain ?dns1] | |
[?eid2 :program/dns-domain ?dns2] | |
[(not= ?dns1 ?dns2)] | |
[?attr1 :db/ident :program/application-groupings] | |
[?attr2 :db/ident :program/application-groupings] | |
[(get-else $ ?eid1 :program/program-offering "<missing program-offering>") ?po1] | |
[(get-else $ ?eid2 :program/program-offering "<missing program-offering>") ?po2] | |
[(get-else $ ?dns1 :dns-domain/name "<missing DNS name>") ?name1] | |
[(get-else $ ?dns2 :dns-domain/name "<missing DNS name>") ?name2] | |
[(get-else $ ?ag :application-grouping/name "<missing application grouping name>") ?ag-name] | |
[(str ?po1 " and " ?po2 " have different DNS domains (" ?name1 " and " ?name2 | |
") but are in the same application grouping (" ?ag-name ").") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid1 ?attr1 ?result-2) | |
(add-field ?result-2 ?eid2 ?attr2 ?result-3) | |
[(identity ?result-3) ?result]) | |
(and | |
[(ground false) ?false] | |
[?eid1 :program/dns-domain ?dns] | |
[?eid2 :program/dns-domain ?dns] | |
[(not= ?eid1 ?eid2)] | |
(not-join | |
[?eid1 ?eid2] | |
[?eid1 :program/university ?u] | |
[?eid2 :program/university ?u]) | |
[?attr1 :db/ident :program/dns-domain] | |
[?attr2 :db/ident :program/dns-domain] | |
[(get-else $ ?eid1 :program/program-offering "<missing program-offering>") ?po1] | |
[(get-else $ ?eid2 :program/program-offering "<missing program-offering>") ?po2] | |
[(get-else $ ?dns :dns-domain/name "<missing DNS name>") ?name] | |
[(str ?po1 " and " ?po2 " have the same DNS domain (" ?name | |
") even though they are at different universities.") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid1 ?attr1 ?result-2) | |
(add-field ?result-2 ?eid2 ?attr2 ?result-3) | |
[(identity ?result-3) ?result]) | |
(and | |
[(ground false) ?false] | |
[?eid1 :program/legacy-degree-offering ?ldo] | |
[?eid2 :program/legacy-degree-offering ?ldo] | |
[(not= ?eid1 ?eid2)] | |
[?eid1 :program/salesforce-grouping ?sg1] | |
[?eid2 :program/salesforce-grouping ?sg2] | |
[(not= ?sg1 ?sg2)] | |
[?attr1 :db/ident :program/legacy-degree-offering] | |
[?attr2 :db/ident :program/legacy-degree-offering] | |
[(get-else $ ?eid1 :program/program-offering "<missing program-offering>") ?po1] | |
[(get-else $ ?eid2 :program/program-offering "<missing program-offering>") ?po2] | |
[(get-else $ ?sg1 :salesforce-grouping/name "<missing grouping name>") ?sg1-name] | |
[(get-else $ ?sg2 :salesforce-grouping/name "<missing grouping name>") ?sg2-name] | |
[(str ?po1 " and " ?po2 " have the same legacy degree offering (" ?ldo | |
") but are in different salesforce groupings (" ?sg1-name " versus " | |
?sg2-name ")") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid1 ?attr1 ?result-2) | |
(add-field ?result-2 ?eid2 ?attr2 ?result-3) | |
[(identity ?result-3) ?result]) | |
(and | |
[(ground false) ?false] | |
[?eid1 :program/school ?sch] | |
[?eid2 :program/school ?sch] | |
[(not= ?eid1 ?eid2)] | |
[?eid1 :program/university ?u1] | |
[?eid2 :program/university ?u2] | |
[(not= ?u1 ?u2)] | |
[(get-else $ ?eid1 :program/program-offering "<missing program offering>") ?po1] | |
[(get-else $ ?eid2 :program/program-offering "<missing program offering>") ?po2] | |
[(get-else $ ?u1 :university/shortname "<missing university shortname>") ?usn1] | |
[(get-else $ ?u2 :university/shortname "<missing university shortname>") ?usn2] | |
[?attr1 :db/ident :program/school] | |
[?attr2 :db/ident :program/school] | |
[(str ?po1 " and " ?po2 " are at the same school, even though they are at " | |
"different universities (" ?usn1 " versus " ?usn2 ").") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid1 ?attr1 ?result-2) | |
(add-field ?result-2 ?eid2 ?attr2 ?result-3) | |
[(identity ?result-3) ?result]) | |
(and | |
[(ground false) ?false] | |
[?eid2 :school/branding ?eid1] | |
[?eid2 :school/full-name ?school-name] | |
[?eid1 :branding/brand-name ?brand-name] | |
[(not= ?school-name ?brand-name)] | |
[?attr1 :db/ident :branding/brand-name] | |
[?attr2 :db/ident :school/full-name] | |
[(str "Brand name “" ?brand-name "” must be the school full name, “" | |
?school-name "”.") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid1 ?attr1 ?result-2) | |
(add-field ?result-2 ?eid2 ?attr2 ?result-3) | |
[(identity ?result-3) ?result]) | |
(and | |
[(ground false) ?false] | |
[?eid2 :university/branding ?eid1] | |
[?eid2 :university/full-name ?uni-name] | |
[?eid1 :branding/brand-name ?brand-name] | |
[(not= ?uni-name ?brand-name)] | |
[?attr1 :db/ident :branding/brand-name] | |
[?attr2 :db/ident :university/full-name] | |
[(str "Brand name “" ?brand-name "” must be the university full name, “" | |
?uni-name "”.") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid1 ?attr1 ?result-2) | |
(add-field ?result-2 ?eid2 ?attr2 ?result-3) | |
[(identity ?result-3) ?result]) | |
(and | |
[(ground false) ?false] | |
[?eid2 :university/branding ?eid1] | |
[?eid2 :university/shortname ?uname] | |
[?eid1 :branding/name ?found] | |
[(str ?uname "-umt") ?expected] | |
[(not= ?expected ?found)] | |
[?attr1 :db/ident :branding/name] | |
[?attr2 :db/ident :university/shortname] | |
[(str "Branding " ?found " is the university branding for " ?uname | |
", but it should be named " ?expected ".") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid1 ?attr1 ?result-2) | |
(add-field ?result-2 ?eid2 ?attr2 ?result-3) | |
[(identity ?result-3) ?result]) | |
(and | |
[(ground false) ?false] | |
[?p :program/branding ?eid1] | |
[?eid1 :branding/name ?bname] | |
(not | |
[(ground ["ud-edu" "yu-med" "hu-cba" "wu-llm" "ud-mba" "vu-edu"]) [?bname ...]]) | |
[?p :program/university ?eid2] | |
[?eid2 :university/shortname ?uname] | |
[(str ?uname "-") ?prefix] | |
(not [(clojure.string/starts-with? ?bname ?prefix)]) | |
[?attr1 :db/ident :branding/name] | |
[?attr2 :db/ident :university/shortname] | |
[(get-else $ ?p :program/program-offering "<missing program-offering>") ?po] | |
[(str "Branding " ?bname " (associated with program “" ?po | |
"”) should start with “" ?prefix "”.") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid1 ?attr1 ?result-2) | |
(add-field ?result-2 ?eid2 ?attr2 ?result-3) | |
[(identity ?result-3) ?result]) | |
(and | |
[(ground false) ?false] | |
[?p :program/school ?s] | |
[?s :school/branding ?eid1] | |
[?eid1 :branding/name ?bname] | |
[?p :program/university ?eid2] | |
[?eid2 :university/shortname ?uname] | |
[(str ?uname "-") ?prefix] | |
(not [(clojure.string/starts-with? ?bname ?prefix)]) | |
[?attr1 :db/ident :branding/name] | |
[?attr2 :db/ident :university/shortname] | |
[(get-else $ ?p :school/full-name "<missing school full-name>") | |
?sname] | |
[(str "Branding " ?bname " (associated with school “" ?sname | |
"”) should start with “" ?prefix "”.") ?msg] | |
(new-result ?msg ?result-1) | |
(add-field ?result-1 ?eid1 ?attr1 ?result-2) | |
(add-field ?result-2 ?eid2 ?attr2 ?result-3) | |
[(identity ?result-3) ?result]))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[(new-result ?msg ?result) | |
[(hash-map :message ?msg :fields []) ?result]] | |
[(add-field ?in-result ?eid ?attr ?out-result) | |
(or-join [?in-result ?eid ?attr ?out-result] | |
(and [?eid ?uuid-attr ?uuid] | |
[?uuid-attr :db/valueType :db.type/uuid] | |
[(hash-map :uuid ?uuid) ?field-1] | |
(or-join [?field-1 ?attr ?field-2] | |
(and [?attr :db/ident ?attr-kw-2] | |
[(str ?attr-kw-2) ?attr-name-1] | |
[(subs ?attr-name-1 1) ?attr-name-2] | |
[(assoc ?field-1 :field ?attr-name-2) ?field-2]) | |
(and (not [?attr :db/ident]) | |
[(identity ?field-1) ?field-2])) | |
[(update ?in-result :fields conj ?field-2) ?out-result]) | |
(and (not-join [?eid] | |
[?eid ?uuid-attr ?uuid] | |
[?uuid-attr :db/valueType :db.type/uuid]) | |
[(identity ?in-result) ?out-result]))]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment