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

  "Generates a unique identifier based on the map"
  (format "id%s" (hash (str m))))

(defn- get-job [jtype id params]
  "Returns a Job specification for the given parameters"
  (jobs/build
    (jobs/of-type jtype)
    (jobs/using-job-data (conj params {"reportId" id} ))
    (jobs/with-identity (jobs/key id))))


                          :baseURL baseURL} path}))
    (scheduler/delete-job (jobs/key reportId))))

(defn- get-executing-jobs []
  "Returns a list of executing jobs in the form of ^org.quartz.JobExecutionContext"
  (.getCurrentlyExecutingJobs ^Scheduler @scheduler/*scheduler*))

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

(defn- job-executing? [key]
