Moved job models to its own namespace

This commit is contained in:
Daniel García Aubert 2016-05-17 18:59:39 +02:00
parent 6acc02e998
commit ef9dfae189
6 changed files with 15 additions and 11 deletions

View File

@ -1,9 +1,6 @@
'use strict';
var JobSimple = require('./job_simple');
var JobMultiple = require('./job_multiple');
var JobFallback = require('./job_fallback');
var jobClasses = [ JobSimple, JobMultiple, JobFallback ];
var jobModels = require('./models');
function JobFactory() {
}
@ -15,9 +12,9 @@ JobFactory.create = function (data) {
throw new Error('You must indicate a valid SQL');
}
for (var i = 0; i < jobClasses.length; i++) {
if (jobClasses[i].is(data.query)) {
return new jobClasses[i](data);
for (var i = 0; i < jobModels.length; i++) {
if (jobModels[i].is(data.query)) {
return new jobModels[i](data);
}
}

7
batch/models/index.js Normal file
View File

@ -0,0 +1,7 @@
'use strict';
var JobSimple = require('./job_simple');
var JobMultiple = require('./job_multiple');
var JobFallback = require('./job_fallback');
module.exports = [ JobSimple, JobMultiple, JobFallback ];

View File

@ -2,7 +2,7 @@
var assert = require('assert');
var uuid = require('node-uuid');
var jobStatus = require('./job_status');
var jobStatus = require('../job_status');
var validStatusTransitions = [
[jobStatus.PENDING, jobStatus.RUNNING],
[jobStatus.PENDING, jobStatus.CANCELLED],

View File

@ -2,7 +2,7 @@
var util = require('util');
var JobBase = require('./job_base');
var jobStatus = require('./job_status');
var jobStatus = require('../job_status');
function JobFallback(data) {
JobBase.call(this, data);

View File

@ -2,7 +2,7 @@
var util = require('util');
var JobBase = require('./job_base');
var jobStatus = require('./job_status');
var jobStatus = require('../job_status');
function JobMultiple(data) {
JobBase.call(this, data);

View File

@ -2,7 +2,7 @@
var util = require('util');
var JobBase = require('./job_base');
var jobStatus = require('./job_status');
var jobStatus = require('../job_status');
function JobSimple(data) {
JobBase.call(this, data);