1 package com.instantbank.lettertemplate.control.web.handlers;
2
3 import java.io.Serializable;
4 import java.rmi.RemoteException;
5 import java.text.SimpleDateFormat;
6 import javax.ejb.FinderException;
7
8 import com.instantbank.component.job.ejb.Job;
9 import com.instantbank.component.job.model.JobModel;
10
11 import com.instantbank.common.utilcomponents.JNDINames;
12 import com.instantbank.common.utilcomponents.LetterTemplateGlobals;
13 import com.instantbank.lettertemplate.control.web.ModelManager;
14 import com.instantbank.lettertemplate.control.web.ModelUpdateListener;
15 import com.instantbank.lettertemplate.control.ejb.LetterTemplateController;
16 import com.instantbank.lettertemplate.control.GeneralFailureException;
17 import com.instantbank.common.utilcomponents.Debug;
18
19
25 public class JobWebImpl extends JobModel
26 implements ModelUpdateListener, Serializable {
27
28 private ModelManager mm;
29 private Job jobejb;
30 private Debug debug = null;
31
32
33
36 public JobWebImpl() {
37 super();
38 debug = new Debug();
39 debug.setDebugginOn(true);
40 debug.setPreMessage("** JobWebImpl: ");
41 }
42
43
44
50 public JobWebImpl(ModelManager mm) {
51 super();
52 this.mm = mm;
53 mm.addListener(JNDINames.JOB_EJBHOME, this);
54 debug = new Debug();
55 debug.setDebugginOn(true);
56 debug.setPreMessage("** JobWebImpl: ");
57 }
58
59
60
64 public void performUpdate() {
65 debug.println("performUpdate method");
66
67 Long jobId = getJobId();
68 debug.println("jobId=" + jobId);
69
70
71 try {
72 jobejb = mm.getJobEJB(jobId);
73 }
74 catch(Exception a) {
75 debug.println("Exception: " + a.getMessage());
76 jobejb = null;
77 this.clean();
78 }
79
80 if(jobejb != null) {
81 try {
82 copy(jobejb.getState());
83 debug.println("model of Job ejb has been copied");
84 }
85 catch(RemoteException re) {
86 throw new GeneralFailureException(re.getMessage());
87 }
88 }
89 }
90
91
92
95 public void setJobNull() {
96 this.jobejb = null;
97 debug.println("jobejb has been set to null");
98 }
99
100
101
106 public String getActivationDateString() {
107 String activationDateString = "";
108 if(this.getActivationDate() != null) {
109 SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy");
110 activationDateString = sdf.format(this.getActivationDate());
111 }
112 return activationDateString;
113 }
114
115
116
119 public void clean() {
120
121 this.setMaster(null, null, null, null, null, null,
122 LetterTemplateGlobals.UNDEF, LetterTemplateGlobals.UNDEF,
123 null, null,
124 LetterTemplateGlobals.UNDEF, LetterTemplateGlobals.UNDEF,
125 null, null, null);
126 this.setJobORDER(null);
127 this.setJobSELECT(null);
128 this.setJobWHERE(null);
129 }
130
131 }
132
133