mulesoft/quartz-mongodb — Issue #5: addJob with replacement
Author: eingrad
Created: 2012-01-13 02:03:17+00:00
State: open

Seems like you havent implemented/finished the case for

> addJob(someJob, true/false)

this is how I've fixed it right now:

protected ObjectId storeJobInMongo(JobDetail newJob, boolean replaceExisting) throws ObjectAlreadyExistsException {
JobKey key = newJob.getKey();

BasicDBObject job = keyAsDBObject(key);

DBObject replaceJob = null;
if (replaceExisting) {
replaceJob = jobCollection.findOne(job);
}

job.put(JOB_KEY_NAME, key.getName());
job.put(JOB_KEY_GROUP, key.getGroup());
job.put(JOB_DESCRIPTION, newJob.getDescription());
job.put(JOB_CLASS, newJob.getJobClass().getName());

job.putAll(newJob.getJobDataMap());

try {
if (replaceExisting && replaceJob != null) {
jobCollection.update(replaceJob, job);
} else {
jobCollection.insert(job);
}

return (ObjectId) job.get("_id");
} catch (DuplicateKey e) {
throw new ObjectAlreadyExistsException(e.getMessage());
}
}

hope this helps