 (ns reports.scheduler
   (:refer-clojure :exclude [key])
-  (:import [org.quartz Scheduler])
+  (:import [org.quartz JobExecutionContext Scheduler])
   (:require [clojure.string :as string :only (split join)]
             [clojurewerkz.quartzite [conversion :as conversion]
                                     [jobs :as jobs]


(def cache (ref {}))

(jobs/defjob ExportJob [context]
  (let [{:strs [baseURL exportType surveyId opts reportId]} (conversion/from-job-data context)
        report (export-report exportType baseURL surveyId opts)
        path (string/join "/" (take-last 2 (string/split (.getAbsolutePath report) #"/")))]
    (dosync


(defn- filter-executing-jobs [key]
  "Filter the list of executing jobs by key (usually returns just 1 job)"
  (filter #(= (.. ^JobExecutionContext % (getJobDetail) (getKey)) (jobs/key key))
          (get-executing-jobs)))

(defn- job-executing? [key]
