src/main/java/com/novemberain/quartz/mongodb/MongoDBJobStore.java
@Override
	public boolean removeTrigger(TriggerKey triggerKey) {
		BasicDBObject dbObject = Keys.keyToDBObject(triggerKey);
		DBCursor triggers = this.triggerCollection.find(dbObject);
		try {
			if (triggers.count() > 0) {
				DBObject trigger = triggers.next();
				if (trigger.containsField(TRIGGER_JOB_ID)) {
					// There is only 1 job per trigger so no need to look further than 1
					// job.
					DBObject job = this.jobCollection.findOne(new BasicDBObject("_id", trigger.get(TRIGGER_JOB_ID)));
					// Durability is not yet implemented in MongoDBJOBStore so next will
					// always be true
					if (!job.containsField(JOB_DURABILITY) || job.get(JOB_DURABILITY).toString() == "false") {
						// Check if this job is referenced by other triggers.
						BasicDBObject query = new BasicDBObject();
						query.put(TRIGGER_JOB_ID, job.get("_id"));
						DBCursor referencedTriggers = this.triggerCollection.find(query);
						try {
							if (referencedTriggers.count() <= 1) {
								this.jobCollection.remove(job);
							}
						}
						finally {
							referencedTriggers.close();
						}
					}
				}
				else {
					this.log.debug("The triggger had no associated jobs");
				}
				this.triggerCollection.remove(dbObject);

				return true;
			}

			return false;
		}
		finally {
			triggers.close();
		}
	}
// then the job should be removed also.
then the job should be removed also.
then the job should be removed also .
@Override
	public boolean removeTrigger(TriggerKey triggerKey) {
		BasicDBObject dbObject = Keys.keyToDBObject(triggerKey);
		DBCursor triggers = this.triggerCollection.find(dbObject);
		try {
			if (triggers.count() > 0) {
				DBObject trigger = triggers.next();
				if (trigger.containsField(TRIGGER_JOB_ID)) {
					DBObject job = this.jobCollection.findOne(new BasicDBObject("_id", trigger.get(TRIGGER_JOB_ID)));
					if (!job.containsField(JOB_DURABILITY) || job.get(JOB_DURABILITY).toString() == "false") {
						BasicDBObject query = new BasicDBObject();
						query.put(TRIGGER_JOB_ID, job.get("_id"));
						DBCursor referencedTriggers = this.triggerCollection.find(query);
						try {
							if (referencedTriggers.count() <= 1) {
								this.jobCollection.remove(job);
							}
						}
						finally {
							referencedTriggers.close();
						}
					}
				}
				else {
					this.log.debug("The triggger had no associated jobs");
				}
				this.triggerCollection.remove(dbObject);
				return true;
			}
			return false;
		}
		finally {
			triggers.close();
		}
	}
@ Override public boolean removeTrigger ( TriggerKey triggerKey ) { BasicDBObject dbObject = Keys . keyToDBObject ( triggerKey ) ; DBCursor triggers = this . triggerCollection . find ( dbObject ) ; try { if ( triggers . count ( ) > 0 ) { DBObject trigger = triggers . next ( ) ; if ( trigger . containsField ( TRIGGER_JOB_ID ) ) { DBObject job = this . jobCollection . findOne ( new BasicDBObject ( "_id" , trigger . get ( TRIGGER_JOB_ID ) ) ) ; if ( ! job . containsField ( JOB_DURABILITY ) || job . get ( JOB_DURABILITY ) . toString ( ) == "false" ) { BasicDBObject query = new BasicDBObject ( ) ; query . put ( TRIGGER_JOB_ID , job . get ( "_id" ) ) ; DBCursor referencedTriggers = this . triggerCollection . find ( query ) ; try { if ( referencedTriggers . count ( ) <= 1 ) { this . jobCollection . remove ( job ) ; } } finally { referencedTriggers . close ( ) ; } } } else { this . log . debug ( "The triggger had no associated jobs" ) ; } this . triggerCollection . remove ( dbObject ) ; return true ; } return false ; } finally { triggers . close ( ) ; } }
then the job should be removed also.
then the job should be removed also .
// There is only 1 job per trigger so no need to look further than 1 // job. // Durability is not yet implemented in MongoDBJOBStore so next will // always be true // Check if this job is referenced by other triggers.