15 var logger = Logger('model/JobModel.js');
20 // define the downloadable status
21 var DOWNLOADABLE_STATUS = 'DONE';
22 // define the default status
23 var DEFAULT_STATUS = 'READY';
25 // describe the all the status of job
26 var JOB_STATUS_LIST = [
49 // set the config information for the app
50 Util.getAppConfig().then(function (data) {
54 var JobModel = function (paramObj) {
62 this.jobHasKsFile = false;
65 this.isDownload;//{boolean}
67 // for the href on a tag
79 JobModel.prototype.init = function (obj) {
80 logger.info('init: ' + JSON.stringify(obj));
82 this.setJobId(obj.job_id);
83 this.setJobStatus(obj.job_status);
84 this.setJobImageName(obj.job_image_name);
85 this.setJobImageSize(obj.job_image_size);
88 this.setJobImagePath();
89 this.setJobHasKsFile(obj.job_hasksfile);
94 this.setJobAbsImagePath();
95 this.setJobAbsKsPath();
96 this.setJobAbsLogPath();
98 this.setJobUptime(obj.job_uptime);
101 JobModel.prototype.getIsDownload = function () {
102 return this.isDownload;
105 JobModel.prototype.setIsDownload = function (value) {
106 this.isDownload = value || false;
109 JobModel.prototype.getJobUptime = function () {
110 return this.jobUptime;
113 JobModel.prototype.setJobUptime = function (value) {
114 this.jobUptime = value;
117 JobModel.prototype.getJobLogPath = function () {
118 return this.jobLogPath;
121 JobModel.prototype.setJobLogPath = function () {
122 this.jobLogPath = this.getJobPath() + AppConfig.TIC_WEB.LOG_FILE_NAME;
125 JobModel.prototype.getJobAbsLogPath = function () {
126 return this.jobAbsLogPath;
129 JobModel.prototype.setJobAbsLogPath = function () {
130 this.jobAbsLogPath = this.getJobAbsPath() + AppConfig.TIC_WEB.LOG_FILE_NAME;
133 JobModel.prototype.getJobKsPath = function () {
134 return this.jobKsPath;
137 JobModel.prototype.setJobKsPath = function () {
138 this.jobKsPath = this.getJobPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
141 JobModel.prototype.getJobAbsKsPath = function () {
142 return this.jobAbsKsPath;
145 JobModel.prototype.setJobAbsKsPath = function () {
146 this.jobAbsKsPath = this.getJobAbsPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
149 JobModel.prototype.getJobHasKsFile = function () {
153 JobModel.prototype.setJobHasKsFile = function (value) {
154 this.jobHasKsFile = value || false;
157 JobModel.prototype.getJobImagePath = function () {
158 return this.jobImagePath;
161 JobModel.prototype.setJobImagePath = function () {
162 this.jobImagePath = this.getJobPath() + this.getJobImageName();
165 JobModel.prototype.getJobImageSize = function () {
166 return this.jobImageSize;
169 JobModel.prototype.setJobImageSize = function (value) {
170 this.jobImageSize = value ? Util.bytesToSize(value) : '0KB';
173 JobModel.prototype.getJobPath = function () {
177 JobModel.prototype.setJobPath = function () {
178 this.jobPath = AppConfig.TIC_WEB.PATH + this.getJobId() + '/';
181 JobModel.prototype.getJobAbsImagePath = function () {
182 return this.jobAbsImagePath;
185 JobModel.prototype.setJobAbsImagePath = function () {
186 this.jobAbsImagePath = this.getJobAbsPath() + this.getJobImageName();
189 JobModel.prototype.getJobAbsPath = function () {
190 return this.jobAbsPath;
193 JobModel.prototype.setJobAbsPath = function () {
194 this.jobAbsPath = AppConfig.TIC_WEB.PATH_ABSTRACT + this.getJobId() + '/';
197 JobModel.prototype.getJobImageName = function () {
198 return this.jobImageName;
201 JobModel.prototype.setJobImageName = function (value) {
202 this.jobImageName = value ? value : '-';
205 JobModel.prototype.getJobStatusText = function (){
206 return this.jobStatusText;
209 JobModel.prototype.setJobStatusText = function (value){
210 this.jobStatusText = value || '';
213 JobModel.prototype.getJobStatus = function (){
214 return this.jobStatus;
217 JobModel.prototype.setJobStatus = function (status) {
218 var statusInfo, isDownloadable;
220 isDownloadable = false;
221 statusInfo = _.find(JOB_STATUS_LIST, {value: status}) || _.find(JOB_STATUS_LIST, {value: DEFAULT_STATUS});
223 this.jobStatus = statusInfo.value || '';
224 this.setJobStatusText(statusInfo.text);
226 if (this.getJobStatus() === DOWNLOADABLE_STATUS) {
227 isDownloadable = true;
230 this.setIsDownload(isDownloadable);
233 JobModel.prototype.getJobId = function () {
237 JobModel.prototype.setJobId = function (value) {
238 this.jobId = value || 0;