          '[clojure.java.io :as io])
 
 (defn define-attributes [c]
-  (d/transact c
+  (d/transact c ; User attributes
+              [{:db/id (d/tempid :db.part/db)
+                :db/ident :user/name
+                :db/valueType :db.type/string
+                :db/cardinality :db.cardinality/one
+                :db/doc "Username"
+                :db.install/_attribute :db.part/db}
+               {:db/id (d/tempid :db.part/db)
+                :db/ident :user/properties
+                :db/valueType :db.type/long
+                :db/cardinality :db.cardinality/one
+                :db/doc "Defines user rights (admin/user etc.)"
+                :db.install/_attribute :db.part/db}
+               {:db/id (d/tempid :db.part/db)
+                :db/ident :user/uid
+                :db/valueType :db.type/long
+                :db/cardinality :db.cardinality/one
+                :db/doc "UID"
+                :db.install/_attribute :db.part/db}
+               {:db/id (d/tempid :db.part/db)
+                :db/ident :user/rating
+                :db/valueType :db.type/double
+                :db/cardinality :db.cardinality/one
+                :db/doc "User work rating."
+                :db.install/_attribute :db.part/db}
+               {:db/id (d/tempid :db.part/db)
+                :db/ident :user/worklist
+                :db/valueType :db.type/ref
+                :db/cardinality :db.cardinality/many
+                :db/doc "List of lines user working on."
+                :db.install/_attribute :db.part/db}])
+  (d/transact c ; Line attributes
               [{:db/id (d/tempid :db.part/db)
                 :db/ident :line/pname
                 :db/valueType :db.type/string

      (println "Database" db-name "already exist, its fine."))
    (println "Connection established!")))

(defn create-line [& {:keys [pname id text male-text female-text translator],
                      :or {male-text "" female-text "" translator ""}}]
  {:db/id (d/tempid :db.part/user)
   :line/pname pname
   :line/num (java.lang.Long. id)
   :line/original text
   :line/male male-text
   :line/female female-text
   :line/translator translator})

(defn get-n-words [n coll]
  (let [sum (atom 0)
        db (d/db conn)]
    (reduce (fn [x y]
              (if (< @sum n)
                (do
                  (swap! sum + (count (clojure.string/split (:line/original (d/touch (d/entity db y))) #"\s")))
                  (conj x y))
                x))
          []
          coll)))

(defn dump-project [project-name]
  (let [db (d/db conn)
        content (d/q '[:find [?line ...]
                       :in $ ?pname
                       :where [?line :line/pname ?pname]]
                     db project-name)]
    (println (str "dumped " content))
    (with-open [out-file (io/writer (str "/tmp/" project-name ".csv"))]
      (csv/write-csv out-file
                     (sort #(compare (first %1) (first %2))
                             (map #(let [ent (d/touch (d/entity db %))]

                :db.install/_attribute :db.part/db}
               {:db/id (d/tempid :db.part/db)
                :db/ident :line/translator
                :db/valueType :db.type/long
                :db/cardinality :db.cardinality/one
                :db/doc "Text line translator."
                :db.install/_attribute :db.part/db}
               {:db/id (d/tempid :db.part/db)
                :db/ident :line/redactor
                :db/valueType :db.type/long
                :db/cardinality :db.cardinality/one
                :db/doc "Text line translator."
                :db.install/_attribute :db.part/db}
               {:db/id (d/tempid :db.part/db)
                :db/ident :line/reserved
                :db/valueType :db.type/long
                :db/cardinality :db.cardinality/one
                :db/doc "UID of person that is currently working on this line."
                :db.install/_attribute :db.part/db}
               {:db/id (d/tempid :db.part/db)
                :db/ident :line/original
