module.exports.start = function(params, error, done) {
	console.log('MetadataToCaptions service started.');

	if (!validateInput(params)) {
		console.log('MetadataToCaptions - Some vital parameters are missing.');
		return error();
	}
	_transactionId = params.transactionId;

	// Make sure we haven't done this job already
	JobsService.findJobStatus(_transactionId)
		.then(function(jobStatus) {
			if (jobStatus.statuses.indexOf(_jobStatusTag) > -1) {
				// case we've already performed the action, ack the message
				return Promise.resolve();
			}
			return performCaptionsChain(params.metadatas);
		})
		.then(function() {
			done();
			return Promise.resolve();
		})
		.then(updateJobStatus)
		.catch(function(err) {
			if (err) {
				console.log(err);
				error();
			}
		});
};
module.exports.start = function(params, error, done) {
	console.log('Video Boundries service started.');
	var _transactionId = params.transactionId; // Queue job identifier
	var _videoId = params.videoId; // Video to bound
	// throw error for no video or job
	if (!_transactionId || !_videoId) {
		console.log('Some parameters are missing.');
		return error();
	}
	// Retrive Job object by id
	JobsService.findJobStatus(_transactionId)
		// Make sure we haven't performed this job already
		.then(validateJob)
		.then(function() {
			// Return a bounding polygon
			return getBoundingPolygon(_videoId);
		})
		.then(function(mergedPolygon) {
			console.log('got merged polygon');
			// Save bounding polygon to video object in db
			return saveToMongo(mergedPolygon, _videoId);
		})
		.then(function() {
			done();
			console.log('finished Job sucessfuly');
			// Notify for job complete
			return updateJobStatus(_transactionId);
		})
		.catch(function(err) {
			console.log(err);
			error();
		});
};
		.then(function(video) {
			_transactionId = video.jobStatusId;
			return JobService.findJobStatus(_transactionId);
		})