Permalink
Browse files

Updating schema

  • Loading branch information...
Zack Maril
Zack Maril committed Jul 15, 2014
1 parent 4f2fa5e commit 97e051cbaa5f6094a1c10197638683f3c7704aff
Showing with 201 additions and 130 deletions.
  1. +88 −0 src/echelon/ali.clj
  2. +113 −130 src/echelon/schema.clj
View
@@ -0,0 +1,88 @@
+(ns echelon.ali)
+
+(def alis
+ {"ACC" "Accounting"
+ "ADV" "Advertising"
+ "AER" "Aerospace"
+ "AGR" "Agriculture"
+ "ALC" "Alcohol & Drug Abuse"
+ "ANI" "Animals"
+ "APP" "Apparel/Clothing Industry/Textiles"
+ "ART" "Arts/Entertainment"
+ "AUT" "Automotive Industry"
+ "AVI" "Aviation/Aircraft/Airlines"
+ "BAN" "Banking"
+ "BEV" "Beverage Industry"
+ "BNK" "Bankruptcy"
+ "BUD" "Budget/Appropriations"
+ "CAW" "Clean Air & Water (Quality)"
+ "CDT" "Commodities (Big Ticket)"
+ "CHM" "Chemicals/Chemical Industry"
+ "CIV" "Civil Rights/Civil Liberties"
+ "COM" "Communications/Broadcasting/Radio/TV"
+ "CON" "Constitution"
+ "CPI" "Computer Industry"
+ "CPT" "Copyright/Patent/Trademark"
+ "CSP" "Consumer Issues/Safety/Protection"
+ "DEF" "Defense"
+ "DIS" "Disaster Planning/Emergencies"
+ "DOC" "District of Columbia"
+ "ECN" "Economics/Economic Development"
+ "EDU" "Education"
+ "ENG" "Energy/Nuclear"
+ "ENV" "Environmental/Superfund"
+ "FAM" "Family Issues/Abortion/Adoption"
+ "FIN" "Financial Institutions/Investments/Securities"
+ "FIR" "Firearms/Guns/Ammunition"
+ "FOO" "Food Industry (Safety, Labeling, etc.)"
+ "FOR" "Foreign Relations"
+ "FUE" "Fuel/Gas/Oil"
+ "GAM" "Gaming/Gambling/Casino"
+ "GOV" "Government Issues"
+ "HCR" "Health Issues"
+ "HOM" "Homeland Security"
+ "HOU" "Housing"
+ "IMM" "Immigration"
+ "IND" "Indian/Native American Affairs"
+ "INS" "Insurance"
+ "INT" "Intelligence and Surveillance"
+ "LAW" "Law Enforcement/Crime/Criminal Justice"
+ "LBR" "Labor Issues/Antitrust/Workplace"
+ "MAN" "Manufacturing"
+ "MAR" "Marine/Maritime/Boating/Fisheries"
+ "MED" "Medical/Disease Research/Clinical Labs"
+ "MIA" "Media (Information/Publishing)"
+ "MMM" "Medicare/Medicaid"
+ "MON" "Minting/Money/Gold Standard"
+ "NAT" "Natural Resources"
+ "PHA" "Pharmacy"
+ "POS" "Postal"
+ "REL" "Religion"
+ "RES" "Real Estate/Land Use/Conservation"
+ "RET" "Retirement"
+ "ROD" "Roads/Highway"
+ "RRR" "Railroads"
+ "SCI" "Science/Technology"
+ "SMB" "Small Business"
+ "SPO" "Sports/Athletics"
+ "TAR" "Miscellaneous Tariff Bills"
+ "TAX" "Taxation/Internal Revenue Code"
+ "TEC" "Telecommunications"
+ "TOB" "Tobacco"
+ "TOR" "Torts"
+ "TOU" "Travel/Tourism"
+ "TRA" "Transportation"
+ "TRD" "Trade (Domestic & Foreign)"
+ "TRU" "Trucking/Shipping"
+ "UNM" "Unemployment"
+ "URB" "Urban Development/Municipalities"
+ "UTI" "Utilities"
+ "VET" "Veterans"
+ "WAS" "Waste (hazardous/solid/interstate/nuclear)"
+ "WEL" "Welfare"})
+
+(def alis-attributes
+ (for [[code description] alis]
+ {:db/id #db/id[:db.part/db]
+ :db/ident (keyword (str "lobbying.alis/" code))
+ :db/doc (str "Code for activities relating to \"" description "\".")}))
View
@@ -1,6 +1,11 @@
(ns echelon.schema
(:require [echelon.ali :refer [alis-attributes]]))
+;;Helper functions for datomic. We're not doing too many fancy things
+;;here with datomic and the main struggle has just been understanding
+;;the layout of the data, so we've abstracted away the creation of the
+;;attribute maps for datomic.
+
(defn- enum [key] {:db/id #db/id[:db.part/user] :db/ident key})
(defn- proto-prop [prop doc]
@@ -40,142 +45,120 @@
:db/cardinality :db.cardinality/many
:db/isComponent true}))
-
-;;Subsections of the schema
-(def client-schema
- [(enum :lobbying.records/:client)
- (string-prop
- :lobbying.client/name
- "Client name.")
- (string-prop
- :lobbying.client/description
- "Client description.")
- (component-prop
- :lobbying.client/main-address
- "Main address for the client.")
- (component-prop
- :lobbying.client/principal-place-of-business
- "Primary location where a taxpayers's business is
- performed (bit.ly/1s3ZbG7)")])
-
-(def registrant-schema
- [(string-prop
- :lobbying.registrant/name
- "Registrant name.")
- (string-prop
- :lobbying.registrant/description
- "Registrant description.")
- (component-prop
- :lobbying.registrant/main-address
- "Main address for reaching the registrant.")
- (component-prop
- :lobbying.registrant/principal-place-of-business
- "Primary location where a taxpayers's business is
- performed (bit.ly/1s3ZbG7)")])
-
-(def proto-schema
- [ ;;Transaction annotations
- (ref-prop :data/source "Where the data came from.")
- (enum :data.source/sopr-html)
- (string-prop :data.sopr-html/document-id
- "Id of a document (provided by sopr).")
-
- ;;Various types of records related to lobbying.
- (ref-prop :records/type "A record's type.")
- (enum :being.records/:being)
- (string-prop :being/id "A uuid for the being")
-
- ;;Common parts of each form
- (string-prop :lobbying.identifier/house-id
- "Id given out the clerk of the house of
- representatives identiying a client and registrant.")
- (string-prop :lobbying.identifier/senate-id
- "Id given out the senate identiying a client and
- registrant.")
- (instant-prop :lobbying.form/signature-date
- "We have no idea what this means.")
-
-
- (component-prop :lobbying.form/client
+;;Various grouping of attributes from the schema
+
+(def being-framework-attributes
+ [(enum :being.records/being)
+ (string-prop :being/id "A uuid for the being")
+ (ref-prop :records/type "A record's type.")
+ (ref-prop :record/represents
+ "Indicates that the record entity with this
+ attribute represents a being. This should be the
+ only property that will ever be overwritten.")])
+
+(def address-attributes
+ [(string-prop :address/first-line "First line for an address")
+ (string-prop :address/second-line "Second line for an address")
+ (string-prop :address/zipcode "Zipcode for an address")
+ (string-prop :address/state "State for an address")
+ (string-prop :address/country "Country for an address")])
+
+(def client-attributes
+ [(enum :lobbying.records/client)
+ (string-prop :lobbying.client/name "Client name.")
+ (string-prop :lobbying.client/description "Client description.")
+ (component-prop :lobbying.client/main-address "Main address for the client.")
+ (component-prop :lobbying.client/principal-place-of-business
+ "Primary location where a taxpayers's business is
+ performed (bit.ly/1s3ZbG7)")])
+
+(def registrant-attributes
+ [(enum :lobbying.records/registrant)
+ (string-prop :lobbying.registrant/name "Registrant name.")
+ (string-prop :lobbying.registrant/description "Registrant description.")
+ (component-prop :lobbying.registrant/main-address
+ "Main address for reaching the registrant.")
+ (component-prop :lobbying.registrant/principal-place-of-business
+ "Primary location where a taxpayers's business is
+ performed (bit.ly/1s3ZbG7)")])
+
+(def contact-attributes
+ [(enum :lobbying.records/contact)
+ (string-prop :lobbying.contact/name-prefix "Contact name prefix.")
+ (string-prop :lobbying.contact/name "Contact name.")
+ (string-prop :lobbying.contact/phone "Contact phone.")
+ (string-prop :lobbying.contact/email "Contact email.")])
+
+(def lobbyist-attributes
+ [(enum :lobbying.records/lobbyist)
+ (string-prop :lobbying.lobbyist/first-name "First name of lobbyist.")
+ (string-prop :lobbying.lobbyist/last-name "Last name of lobbyist.")
+ (string-prop :lobbying.lobbyist/suffix "Suffix of lobbyist.")
+ (string-prop :lobbying.lobbyist/covered-official-position
+ "No idea, this is often blank.")])
+
+(def activity-attributes
+ [(enum :lobbying.records/activity)
+ (string-prop :lobbying.activity/issues-details
+ "Details about the lobbying generally done by the
+ registrant for the client on various issues.")
+ (component-props :lobbying.activity/issue-codes
+ "The issue codes generally associated with the activity.")
+ (component-props :lobbying.activity/lobbyists
+ "The foreign entities for the activity.")])
+
+(def transaction-annotations-attributes
+ )
+
+;;(enum :lobbying.records/affiliated-organization)
+;;(enum :lobbying.records/foreign-entity)
+;;(enum :lobbying.records/individual)
+
+(def common-form-attributes
+ [;;Common parts of each form
+ (string-prop :lobbying.form/house-id
+ "Id given out the clerk of the house of
+ representatives identiying a client and registrant.")
+ (string-prop :lobbying.form/senate-id
+ "Id given out the senate identiying a client and
+ registrant.")
+ (instant-prop :lobbying.form/signature-date
+ "We have no idea what this means.")
+ (component-prop :lobbying.form/client
"The client for the form.")
- (component-prop :lobbying.form/registrant
+ (component-prop :lobbying.form/registrant
"The registrant for the form.")
-
- (enum :lobbying.records/:contact)
- (component-prop :lobbying.form/contact
+ (component-prop :lobbying.form/contact
"The contact for the form.")
-
- (component-prop :lobbying.engagement/individual
- "Potentially used, if the registrant is an individual for the form.")
-
- (enum :lobbying.records/:activity)
- (string-prop :lobbying.activity/issues-details
- "Details about the lobbying generally done by the
- registrant for the client on various issues.")
- (component-props :lobbying.activity/issue-codes
- "The issue codes generally associated with the engagement.")
- (component-props :lobbying.activity/lobbyists
- "The foreign entities for the activity.")
-
- ;;LD1 forms
- (enum :lobbying.records/:registration)
- (instant-prop :lobbying.engagement/effective-date
- "No idea what this one actually means.")
+ (component-prop :lobbying.form/individual
+ "Potentially used, if the registrant is an individual for the form.")
+ (ref-prop :lobbying.form/source "Where the data came from.")
+ (enum :lobbying.form/sopr-html)
+ (string-prop :lobbying.formd/document-id
+ "Id of a document (provided by sopr).")])
+
+(def registration-form-attributes
+ [(enum :lobbying.records/registration)
+ (instant-prop :lobbying.engagement/effective-date
+ "No idea what this one actually means.")
(component-props :lobbying.engagement/affiliated-organizations
"The affiliated organizations for the engagement.")
(component-props :lobbying.engagement/foreign-entity
- "The foreign entities for the engagement.")
-
- ;;LD2 forms
- (enum :lobbying.records/:report)
-
- (enum :lobbying.records/:affiliated-organization)
- (enum :lobbying.records/:foreign-entity)
- (enum :lobbying.records/:individual)
- (enum :lobbying.records/:lobbyist)
- (enum :lobbying.records/:registrant)
-
- (string-prop :lobbying.activity/issues-details
- "Details about the lobbying activity done by the
- registrant for the client on various issues")
-
-
- (component-props :lobbying.activity/issue-codes,
- "The issue codes associated with the activity.")
-
- (ref-prop :record/represents
- "Indicates that the record entity with this attribute
- represents a being. This should be the only property that
- will ever be overwritten.")
-
-
-
-
- (string-prop
- :lobbying.contact/name
- "Contact name.")
- (string-prop
- :lobbying.contact/phone
- "Contact phone.")
- (string-prop
- :lobbying.contact/email
- "Contact email.")
-
- (string-prop :address/first-line "First line for an address")
- (string-prop :address/second-line "Second line for an address")
- (string-prop :address/zipcode "Zipcode for an address") ;;TODO: ref prop
- (string-prop :address/state "State for an address") ;;TODO: ref prop
- (string-prop :address/country "Country for an address") ;;TODO: ref prop
+ "The foreign entities for the engagement.")])
- (string-prop :lobbying.lobbyist/first-name
- "First name of lobbyist.")
- (string-prop :lobbying.lobbyist/last-name
- "Last name of lobbyist.")
- (string-prop :lobbying.lobbyist/suffix
- "Suffix of lobbyist.")
- (string-prop :lobbying.lobbyist/covered-official-position
- "No idea, this is often blank.")])
+(def report-form-attributes
+ [(enum :lobbying.records/report)])
(def schema
- (concat alis-attributes proto-schema))
-schema
+ (concat alis-attributes
+ address-attributes
+ being-framework-attributes
+ client-attributes
+ registrant-attributes
+ contact-attributes
+ lobbyist-attributes
+ activity-attributes
+ transaction-annotations-attributes
+ common-form-attributes
+ registration-form-attributes
+ report-form-attributes))

0 comments on commit 97e051c

Please sign in to comment.