    :source       {:file {:path "###TSV-PATH###"}}
    :extractor    {:row {}}
    :transformers [{:csv {:separator "\t"}}
-                  {:vertex {:class "MetadataValue" :skipDuplicates true}}
+                  {:vertex {:class "MetadataValue"}}
                   {:edge
-                   {:class                "HasMetadataValue"
+                   {:class                "InCategory"
                     :lookup               "MetadataCategory.corpus_cat"
                     :joinFieldName        "corpus_cat"
-                    :direction            "in"
                     :unresolvedLinkAction "ERROR"}}]
    :loader       {:orientdb
                   {:dbURL               "remote:localhost/Glossa"

   :extractor    {:row {}}
   :transformers [{:csv {:separator "\t"}}
                  {:vertex {:class "MetadataValue"}}
                  {:edge
                   {:class                "HasMetadataValue"
                    :lookup               "MetadataCategory.corpus_cat"
                    :joinValue            "###CORPUS###_tid"
                    :direction            "in"
                    :unresolvedLinkAction "ERROR"}}]
   :loader       {:orientdb
                  {:dbURL               "remote:localhost/Glossa"

                                               [(str corpus "_tid") (first row)])
                                             rows)))))))

(defn- create-tid-config! [corpus config-path orig-tsv-path]
  (with-open [tsv-file (io/reader orig-tsv-path)]
    (let [other-cats     (->> (utils/read-csv tsv-file)
                              first
                              rest
                              (filter #(not (get #{"startpos" "endpos"} %1))))
          cat-edges      (map (fn [cat]
                                {:edge {:class                "HasMetadataValue"
                                        :lookup               (str "SELECT from MetadataValue WHERE corpus_cat = '"
                                                                   (str corpus "_" cat)
                                                                   "' AND value = ?")
                                        :joinFieldName        cat
                                        :unresolvedLinkAction "ERROR"}})
                              other-cats)
          field-removals (map (fn [cat]
                                {:field {:fieldName cat
                                         :operation "remove"}})
                              other-cats)]
      (spit config-path (-> tids-template
                            (update-in [:transformers] concat cat-edges field-removals)
                            (cheshire/generate-string {:pretty true})
                            (str/replace "###TSV-PATH###" orig-tsv-path)
                            (str/replace "###CORPUS###" corpus))))))

(defn import! [corpus]
  (let [orig-tsv-path       (-> (str "data/metadata_values/" corpus ".tsv") io/resource .getPath)
        non-tid-tsv-path    (.getPath (fs/temp-file "metadata_vals"))
        tid-config-path     (.getPath (fs/temp-file "tid_config"))
        non-tid-config-path (.getPath (fs/temp-file "metadata_val_config"))]
    (create-non-tid-tsv! corpus orig-tsv-path non-tid-tsv-path)
    (create-non-tid-config! non-tid-config-path non-tid-tsv-path)
    (create-tid-config! corpus tid-config-path orig-tsv-path)
    (utils/run-etl non-tid-config-path)
    (utils/run-etl tid-config-path)))
