2016-05-14 00:50:55 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var util = require('util');
|
2019-10-04 00:24:39 +08:00
|
|
|
var JobBase = require('./job-base');
|
|
|
|
var jobStatus = require('../job-status');
|
2016-05-14 00:50:55 +08:00
|
|
|
|
2016-05-23 17:37:09 +08:00
|
|
|
function JobSimple(jobDefinition) {
|
|
|
|
JobBase.call(this, jobDefinition);
|
2016-05-17 07:00:27 +08:00
|
|
|
|
|
|
|
if (!this.data.status) {
|
|
|
|
this.data.status = jobStatus.PENDING;
|
|
|
|
}
|
2016-05-14 00:50:55 +08:00
|
|
|
}
|
|
|
|
util.inherits(JobSimple, JobBase);
|
|
|
|
|
|
|
|
module.exports = JobSimple;
|
|
|
|
|
2016-05-16 07:22:47 +08:00
|
|
|
JobSimple.is = function (query) {
|
2016-05-14 00:50:55 +08:00
|
|
|
return typeof query === 'string';
|
|
|
|
};
|
|
|
|
|
|
|
|
JobSimple.prototype.getNextQuery = function () {
|
2016-05-16 07:22:47 +08:00
|
|
|
if (this.isPending()) {
|
2016-05-14 00:50:55 +08:00
|
|
|
return this.data.query;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
JobSimple.prototype.setQuery = function (query) {
|
2016-05-16 07:22:47 +08:00
|
|
|
if (!JobSimple.is(query)) {
|
|
|
|
throw new Error('You must indicate a valid SQL');
|
2016-05-14 00:50:55 +08:00
|
|
|
}
|
|
|
|
|
2016-05-16 07:22:47 +08:00
|
|
|
JobSimple.super_.prototype.setQuery.call(this, query);
|
2016-05-14 00:50:55 +08:00
|
|
|
};
|