CartoDB-SQL-API/lib/batch/models/job-simple.js

35 lines
752 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');
var jobStatus = require('../job-status');
2016-05-14 00:50:55 +08:00
2019-12-24 01:19:08 +08:00
function JobSimple (jobDefinition) {
2016-05-23 17:37:09 +08:00
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
};