CartoDB-SQL-API/batch/models/job_simple.js

35 lines
751 B
JavaScript
Raw Normal View History

2016-05-14 00:50:55 +08:00
'use strict';
var util = require('util');
var JobBase = require('./job_base');
2016-05-18 00:59:39 +08:00
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
};