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.jobStatusClass = null;
36 this.jobImageName = null;
37 this.jobImageSize = null;
39 this.jobImagePath = null;
40 this.jobHasKsFile = false;
41 this.jobKsPath = null;
42 this.jobLogPath = null;
43 this.isDownload = false;
45 // for the href on a tag
46 this.jobAbsPath = null;
47 this.jobAbsImagePath = null;
48 this.jobAbsKsPath = null;
49 this.jobAbsLogPath = null;
50 this.jobUptime = null;
57 JobModel.prototype.init = function (obj) {
58 logger.info('init: ' + JSON.stringify(obj));
60 this.setJobId(obj.job_id);
61 this.setJobStatus(obj.job_status);
62 this.setJobImageName(obj.job_image_name);
63 this.setJobImageSize(obj.job_image_size);
66 this.setJobImagePath();
67 this.setJobHasKsFile(obj.job_hasksfile);
72 this.setJobAbsImagePath();
73 this.setJobAbsKsPath();
74 this.setJobAbsLogPath();
76 this.setJobUptime(obj.job_uptime);
79 JobModel.prototype.getIsDownload = function () {
80 return this.isDownload;
83 JobModel.prototype.setIsDownload = function (value) {
84 this.isDownload = value || false;
87 JobModel.prototype.getJobUptime = function () {
88 return this.jobUptime;
91 JobModel.prototype.setJobUptime = function (value) {
92 this.jobUptime = value;
95 JobModel.prototype.getJobLogPath = function () {
96 return this.jobLogPath;
99 JobModel.prototype.setJobLogPath = function () {
100 this.jobLogPath = this.getJobPath() + AppConfig.TIC_WEB.LOG_FILE_NAME;
103 JobModel.prototype.getJobAbsLogPath = function () {
104 return this.jobAbsLogPath;
107 JobModel.prototype.setJobAbsLogPath = function () {
108 this.jobAbsLogPath = this.getJobAbsPath() + AppConfig.TIC_WEB.LOG_FILE_NAME;
111 JobModel.prototype.getJobKsPath = function () {
112 return this.jobKsPath;
115 JobModel.prototype.setJobKsPath = function () {
116 this.jobKsPath = this.getJobPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
119 JobModel.prototype.getJobAbsKsPath = function () {
120 return this.jobAbsKsPath;
123 JobModel.prototype.setJobAbsKsPath = function () {
124 this.jobAbsKsPath = this.getJobAbsPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
127 JobModel.prototype.getJobHasKsFile = function () {
128 return this.jobHasKsFile;
131 JobModel.prototype.setJobHasKsFile = function (value) {
132 this.jobHasKsFile = value || false;
135 JobModel.prototype.getJobImagePath = function () {
136 return this.jobImagePath;
139 JobModel.prototype.setJobImagePath = function () {
140 this.jobImagePath = this.getJobPath() + this.getJobImageName();
143 JobModel.prototype.getJobImageSize = function () {
144 return this.jobImageSize;
147 JobModel.prototype.setJobImageSize = function (value) {
148 this.jobImageSize = value ? Util.bytesToSize(value) : '0KB';
151 JobModel.prototype.getJobPath = function () {
155 JobModel.prototype.setJobPath = function () {
156 this.jobPath = AppConfig.TIC_WEB.PATH + this.getJobId() + '/';
159 JobModel.prototype.getJobAbsImagePath = function () {
160 return this.jobAbsImagePath;
163 JobModel.prototype.setJobAbsImagePath = function () {
164 this.jobAbsImagePath = this.getJobAbsPath() + this.getJobImageName();
167 JobModel.prototype.getJobAbsPath = function () {
168 return this.jobAbsPath;
171 JobModel.prototype.setJobAbsPath = function () {
172 this.jobAbsPath = AppConfig.TIC_WEB.PATH_ABSTRACT + this.getJobId() + '/';
175 JobModel.prototype.getJobImageName = function () {
176 return this.jobImageName;
179 JobModel.prototype.setJobImageName = function (value) {
180 this.jobImageName = value ? value : '-';
183 JobModel.prototype.getJobStatusText = function () {
184 return this.jobStatusText;
187 JobModel.prototype.setJobStatusText = function (value) {
188 this.jobStatusText = value || '';
191 JobModel.prototype.getJobStatusClass = function (value) {
192 return this.jobStatusClass;
195 JobModel.prototype.setJobStatusClass = function (value) {
196 this.jobStatusClass = value || '';
199 JobModel.prototype.getJobStatus = function () {
200 return this.jobStatus;
203 JobModel.prototype.setJobStatus = function (status) {
204 var statusInfo, isDownloadable;
206 isDownloadable = false;
207 statusInfo = JobStatusModel.getStatusInfo(status);
216 this.jobStatus = statusInfo.value || '';
217 this.setJobStatusText(statusInfo.text);
218 this.setJobStatusClass(statusInfo.class);
220 if (this.getJobStatus() === DOWNLOADABLE_STATUS) {
221 isDownloadable = true;
224 this.setIsDownload(isDownloadable);
227 JobModel.prototype.getJobId = function () {
231 JobModel.prototype.setJobId = function (value) {
232 this.jobId = value || 0;