16 var logger = Logger('model/JobModel.js');
21 // define the downloadable status
22 var DOWNLOADABLE_STATUS = 'DONE';
23 // define the default status
24 var DEFAULT_STATUS = 'READY';
26 // set the config information for the app
27 Util.getAppConfig().then(function (data) {
31 var JobModel = function (paramObj) {
33 this.jobStatus = null;
34 this.jobStatusText = null;
35 this.jobImageName = null;
36 this.jobImageSize = null;
38 this.jobImagePath = null;
39 this.jobHasKsFile = false;
40 this.jobKsPath = null;
41 this.jobLogPath = null;
42 this.isDownload = false;
44 // for the href on a tag
45 this.jobAbsPath = null;
46 this.jobAbsImagePath = null;
47 this.jobAbsKsPath = null;
48 this.jobAbsLogPath = null;
49 this.jobUptime = null;
56 JobModel.prototype.init = function (obj) {
57 logger.info('init: ' + JSON.stringify(obj));
59 this.setJobId(obj.job_id);
60 this.setJobStatus(obj.job_status);
61 this.setJobImageName(obj.job_image_name);
62 this.setJobImageSize(obj.job_image_size);
65 this.setJobImagePath();
66 this.setJobHasKsFile(obj.job_hasksfile);
71 this.setJobAbsImagePath();
72 this.setJobAbsKsPath();
73 this.setJobAbsLogPath();
75 this.setJobUptime(obj.job_uptime);
78 JobModel.prototype.getIsDownload = function () {
79 return this.isDownload;
82 JobModel.prototype.setIsDownload = function (value) {
83 this.isDownload = value || false;
86 JobModel.prototype.getJobUptime = function () {
87 return this.jobUptime;
90 JobModel.prototype.setJobUptime = function (value) {
91 this.jobUptime = value;
94 JobModel.prototype.getJobLogPath = function () {
95 return this.jobLogPath;
98 JobModel.prototype.setJobLogPath = function () {
99 this.jobLogPath = this.getJobPath() + AppConfig.TIC_WEB.LOG_FILE_NAME;
102 JobModel.prototype.getJobAbsLogPath = function () {
103 return this.jobAbsLogPath;
106 JobModel.prototype.setJobAbsLogPath = function () {
107 this.jobAbsLogPath = this.getJobAbsPath() + AppConfig.TIC_WEB.LOG_FILE_NAME;
110 JobModel.prototype.getJobKsPath = function () {
111 return this.jobKsPath;
114 JobModel.prototype.setJobKsPath = function () {
115 this.jobKsPath = this.getJobPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
118 JobModel.prototype.getJobAbsKsPath = function () {
119 return this.jobAbsKsPath;
122 JobModel.prototype.setJobAbsKsPath = function () {
123 this.jobAbsKsPath = this.getJobAbsPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
126 JobModel.prototype.getJobHasKsFile = function () {
127 return this.jobHasKsFile;
130 JobModel.prototype.setJobHasKsFile = function (value) {
131 this.jobHasKsFile = value || false;
134 JobModel.prototype.getJobImagePath = function () {
135 return this.jobImagePath;
138 JobModel.prototype.setJobImagePath = function () {
139 this.jobImagePath = this.getJobPath() + this.getJobImageName();
142 JobModel.prototype.getJobImageSize = function () {
143 return this.jobImageSize;
146 JobModel.prototype.setJobImageSize = function (value) {
147 this.jobImageSize = value ? Util.bytesToSize(value) : '0KB';
150 JobModel.prototype.getJobPath = function () {
154 JobModel.prototype.setJobPath = function () {
155 this.jobPath = AppConfig.TIC_WEB.PATH + this.getJobId() + '/';
158 JobModel.prototype.getJobAbsImagePath = function () {
159 return this.jobAbsImagePath;
162 JobModel.prototype.setJobAbsImagePath = function () {
163 this.jobAbsImagePath = this.getJobAbsPath() + this.getJobImageName();
166 JobModel.prototype.getJobAbsPath = function () {
167 return this.jobAbsPath;
170 JobModel.prototype.setJobAbsPath = function () {
171 this.jobAbsPath = AppConfig.TIC_WEB.PATH_ABSTRACT + this.getJobId() + '/';
174 JobModel.prototype.getJobImageName = function () {
175 return this.jobImageName;
178 JobModel.prototype.setJobImageName = function (value) {
179 this.jobImageName = value ? value : '-';
182 JobModel.prototype.getJobStatusText = function () {
183 return this.jobStatusText;
186 JobModel.prototype.setJobStatusText = function (value) {
187 this.jobStatusText = value || '';
190 JobModel.prototype.getJobStatus = function () {
191 return this.jobStatus;
194 JobModel.prototype.setJobStatus = function (status) {
195 var statusInfo, isDownloadable;
197 isDownloadable = false;
198 statusInfo = JobStatusModel.getStatusInfo(status);
200 this.jobStatus = statusInfo.value || '';
201 this.setJobStatusText(statusInfo.text);
203 if (this.getJobStatus() === DOWNLOADABLE_STATUS) {
204 isDownloadable = true;
207 this.setIsDownload(isDownloadable);
210 JobModel.prototype.getJobId = function () {
214 JobModel.prototype.setJobId = function (value) {
215 this.jobId = value || 0;