1 package com.instantbank.component.job.model;
2
3 import java.util.Collection;
4 import java.util.ArrayList;
5 import java.util.Hashtable;
6 import java.util.Iterator;
7 import java.io.Serializable;
8 import org.w3c.dom.Element;
9 import org.w3c.dom.Document;
10 import java.sql.Date;
11
12 import com.instantbank.component.job.model.JobSELECTelement;
13 import com.instantbank.component.job.model.JobWHEREelement;
14 import com.instantbank.component.job.model.JobORDERelement;
15
16
22 public class JobModel
23 implements Serializable {
24
25
26
27
28
31 private Long jobId;
32
35 private String companyId;
36
39 private String name;
40
43 private String frequency;
44
47 private String status;
48
51 private java.sql.Date activationDate;
52
55 private Long userId;
56
59 private java.sql.Date version;
60
61
62
65 private long templateCode;
66
69 private long queueTypeId;
70
73 private String description;
74
77 private String sqlText;
78
81 private java.sql.Date lastExecutionDate;
82
85 private long ftpPrimaryId;
86
89 private long ftpAlternateId;
90
91
92
95 private Collection jobSELECT;
96
99 private Collection jobWHERE;
100
101
106 private Collection jobORDER;
107
108
109
112 public JobModel() { }
113
114
115
140 public JobModel
141 (Long jobId, String companyId, String name, String frequency,
142 String status, Date activationDate, long ftpPrimaryId,
143 long ftpAlternateId, Long userId, java.sql.Date version,
144 long templateCode, long queueTypeId, String description,
145 String sqlText, Date lastExecutionDate,
146 Collection jobSELECT, Collection jobWHERE, Collection jobORDER) {
147
148 this.jobId = jobId;
149 this.companyId = companyId;
150 this.name = name;
151 this.frequency = frequency;
152 this.status = status;
153 this.activationDate = activationDate;
154 this.ftpPrimaryId = ftpPrimaryId;
155 this.ftpAlternateId = ftpAlternateId;
156 this.userId = userId;
157 this.version = version;
158 this.templateCode = templateCode;
159 this.queueTypeId = queueTypeId;
160 this.description = description;
161 this.sqlText = sqlText;
162 this.lastExecutionDate = lastExecutionDate;
163 this.jobSELECT = jobSELECT;
164 this.jobWHERE = jobWHERE;
165 this.jobORDER = jobORDER;
166 }
167
168
169
170
175 public Long getJobId() {
176 return jobId;
177 }
178
179
180
185 public String getCompanyId() {
186 return companyId;
187 }
188
189
190
195 public String getName() {
196 return name;
197 }
198
199
200
205 public String getFrequency() {
206 return frequency;
207 }
208
209
210
215 public String getStatus() {
216 return status;
217 }
218
219
220
225 public Date getActivationDate() {
226 return activationDate;
227 }
228
229
230
235 public long getFtpPrimaryId() {
236 return ftpPrimaryId;
237 }
238
239
240
245 public long getFtpAlternateId() {
246 return ftpAlternateId;
247 }
248
249
250
255 public java.sql.Date getVersion() {
256 return version;
257 }
258
259
260
265 public Long getUserId() {
266 return userId;
267 }
268
269
270
275 public long getTemplateCode() {
276 return templateCode;
277 }
278
279
280
285 public long getQueueTypeId() {
286 return queueTypeId;
287 }
288
289
290
295 public String getDescription() {
296 return description;
297 }
298
299
300
305 public java.sql.Date getLastExecutionDate() {
306 return lastExecutionDate;
307 }
308
309
310
315 public String getSqlText() {
316 return sqlText;
317 }
318
319
320
325 public Collection getJobSELECT() {
326 return jobSELECT;
327 }
328
329
330
335 public Collection getJobWHERE() {
336 return jobWHERE;
337 }
338
339
340
345 public Collection getJobORDER() {
346 return jobORDER;
347 }
348
349
350
355 public Hashtable getJobORDERtable() {
356 ArrayList jobORDERarray = (ArrayList)this.jobORDER;
357 if(jobORDERarray == null) {
358 return null;
359 }
360
361 Hashtable jobORDERhashtable = new Hashtable();
362 for(int i = 0; i < jobORDERarray.size(); i++) {
363 JobORDERelement element = (JobORDERelement)jobORDERarray.get(i);
364 jobORDERhashtable.put(new Long(element.getFieldId()), element);
365 }
366 return jobORDERhashtable;
367 }
368
369
370
371
372
377 public void setJobId(Long jobId) {
378 this.jobId = jobId;
379 }
380
381
382
387 public void setVersion(java.sql.Date version) {
388 this.version = version;
389 }
390
391
392
397 public void setDescription(String description) {
398 this.description = description;
399 }
400
401
402
407 public void setFtpPrimaryId(long ftpPrimaryId) {
408 this.ftpPrimaryId = ftpPrimaryId;
409 }
410
411
412
417 public void setFtpAlternateId(long ftpAlternateId) {
418 this.ftpAlternateId = ftpAlternateId;
419 }
420
421
422
427 public void setJobSELECT(Collection jobSELECT) {
428 this.jobSELECT = jobSELECT;
429 }
430
431
432
437 public void setJobWHERE(Collection jobWHERE) {
438 this.jobWHERE = jobWHERE;
439 }
440
441
442
447 public void setJobORDER(Collection jobORDER) {
448 this.jobORDER = jobORDER;
449 }
450
451
452
457 public void setSqlText(String sqlText) {
458 this.sqlText = sqlText;
459 }
460
461
462
467 public void setTemplateCode(long templateCode) {
468 this.templateCode = templateCode;
469 }
470
471
472
494 public void setMaster
495 (Long jobId, String companyId, String name, String frequency,
496 String status, Date activationDate, long ftpPrimaryId,
497 long ftpAlternateId, Long userId, Date version,
498 long templateCode, long queueTypeId, String description,
499 String sqlText, Date lastExecutionDate) {
500
501 this.jobId = jobId;
502 this.companyId = companyId;
503 this.name = name;
504 this.frequency = frequency;
505 this.status = status;
506 this.activationDate = activationDate;
507 this.ftpPrimaryId = ftpPrimaryId;
508 this.ftpAlternateId = ftpAlternateId;
509 this.userId = userId;
510 this.version = version;
511 this.templateCode = templateCode;
512 this.queueTypeId = queueTypeId;
513 this.description = description;
514 this.sqlText = sqlText;
515 this.lastExecutionDate = lastExecutionDate;
516 }
517
518
519
520
521
526 public String toString() {
527 String ret = null;
528 ret = "jobId = " + jobId + "\n";
529 ret += "companyId = " + companyId + "\n";
530 ret += "name = " + name + "\n";
531 ret += "frequency = " + frequency + "\n";
532 ret += "status = " + status + "\n";
533 ret += "activationDate = " + activationDate + "\n";
534 ret += "ftpPrimaryId = " + ftpPrimaryId + "\n";
535 ret += "ftpAlternateId = " + ftpAlternateId + "\n";
536 ret += "userId = " + userId + "\n";
537 ret += "version = " + version + "\n";
538 ret += "templateCode = " + templateCode + "\n";
539 ret += "queueTypeId = " + queueTypeId + "\n";
540 ret += "description = " + description + "\n";
541 ret += "sqlText = " + sqlText + "\n";
542
543 Iterator it;
544 it = (jobSELECT != null) ? jobSELECT.iterator() : null;
545 while((it != null) && it.hasNext()) {
546 JobSELECTelement item = (JobSELECTelement)it.next();
547 ret += "JobSELECT item = " + item.toString() + "\n";
548 }
549 it = (jobWHERE != null) ? jobWHERE.iterator() : null;
550 while((it != null) && it.hasNext()) {
551 JobWHEREelement item = (JobWHEREelement)it.next();
552 ret += "JobWHERE item = " + item.toString() + "\n";
553 }
554 it = (jobORDER != null) ? jobORDER.iterator() : null;
555 while((it != null) && it.hasNext()) {
556 JobORDERelement item = (JobORDERelement)it.next();
557 ret += "JobORDER item = " + item.toString() + "\n";
558 }
559 return ret;
560 }
561
562
563
569 public Element toXml(Document doc) {
570 Element root = doc.createElement("Job");
571 root.setAttribute("Id", jobId.toString());
572
573 Element node = null;
574
575 node = doc.createElement("CompanyId");
576 node.appendChild(doc.createTextNode(companyId));
577 root.appendChild(node);
578
579 node = doc.createElement("Name");
580 node.appendChild(doc.createTextNode(name));
581 root.appendChild(node);
582
583 node = doc.createElement("Frequency");
584 node.appendChild(doc.createTextNode(frequency));
585 root.appendChild(node);
586
587 node = doc.createElement("Status");
588 node.appendChild(doc.createTextNode(status));
589 root.appendChild(node);
590
591 node = doc.createElement("ActivationDate");
592 node.appendChild(doc.createTextNode(activationDate.toString()));
593 root.appendChild(node);
594
595 node = doc.createElement("FtpPrimaryId");
596 node.appendChild(doc.createTextNode(String.valueOf(ftpPrimaryId)));
597 root.appendChild(node);
598
599 node = doc.createElement("FtpAlternateId");
600 node.appendChild(doc.createTextNode(String.valueOf(ftpAlternateId)));
601 root.appendChild(node);
602
603 node = doc.createElement("UserId");
604 node.appendChild(doc.createTextNode(userId.toString()));
605 root.appendChild(node);
606
607 node = doc.createElement("Version");
608 node.appendChild(doc.createTextNode(version.toString()));
609 root.appendChild(node);
610
611 node = doc.createElement("TemplateCode");
612 node.appendChild(doc.createTextNode(String.valueOf(templateCode)));
613 root.appendChild(node);
614
615 node = doc.createElement("QueueTypeId");
616 node.appendChild(doc.createTextNode(String.valueOf(queueTypeId)));
617 root.appendChild(node);
618
619 node = doc.createElement("Description");
620 node.appendChild(doc.createTextNode(description));
621 root.appendChild(node);
622
623 node = doc.createElement("SqlText");
624 node.appendChild(doc.createTextNode(sqlText));
625 root.appendChild(node);
626
627 for(Iterator it = jobSELECT.iterator(); it.hasNext(); ) {
628 root.appendChild(((JobSELECTelement)it.next()).toXml(doc));
629 }
630 for(Iterator it = jobWHERE.iterator(); it.hasNext(); ) {
631 root.appendChild(((JobWHEREelement)it.next()).toXml(doc));
632 }
633 for(Iterator it = jobORDER.iterator(); it.hasNext(); ) {
634 root.appendChild(((JobORDERelement)it.next()).toXml(doc));
635 }
636 return root;
637 }
638
639
640
645 public void copy(JobModel other) {
646 this.jobId = other.jobId;
647 this.companyId = other.companyId;
648 this.name = other.name;
649 this.frequency = other.frequency;
650 this.status = other.status;
651 this.activationDate = other.activationDate;
652 this.ftpPrimaryId = other.ftpPrimaryId;
653 this.ftpAlternateId = other.ftpAlternateId;
654 this.userId = other.userId;
655 this.version = other.version;
656 this.templateCode = other.templateCode;
657 this.queueTypeId = other.queueTypeId;
658 this.description = other.description;
659 this.sqlText = other.sqlText;
660 this.jobSELECT = other.jobSELECT;
661 this.jobWHERE = other.jobWHERE;
662 this.jobORDER = other.jobORDER;
663 }
664 }
665
666