Revision 4971
Added by daigle almost 15 years ago
ScheduledJobParamAccess.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* '$RCSfile$' |
3 |
* Purpose: A Class that manages database access of scheduled task |
|
4 |
* information. |
|
3 |
* Purpose: A Class that manages database access of scheduled task parameter |
|
4 |
* information. These parameters allow us to maintain the concept of |
|
5 |
* a generic job with specific parameters. Note that the methods in |
|
6 |
* this class are all protected. They should only be accessed from the |
|
7 |
* ScheduledJobAccess class in conjunction with some action being taken |
|
8 |
* on a job. |
|
5 | 9 |
* Copyright: 2009 Regents of the University of California and the |
6 | 10 |
* National Center for Ecological Analysis and Synthesis |
7 | 11 |
* Authors: Michael Daigle |
... | ... | |
44 | 48 |
|
45 | 49 |
private Logger logMetacat = Logger.getLogger(ScheduledJobParamAccess.class); |
46 | 50 |
|
51 |
// Constructor |
|
47 | 52 |
public ScheduledJobParamAccess() throws AccessException { |
48 | 53 |
super("ScheduledJobParamsAccess"); |
49 | 54 |
} |
50 | 55 |
|
56 |
/** |
|
57 |
* Insert job parameters into the database. |
|
58 |
* |
|
59 |
* @param jobId |
|
60 |
* the id of the job that these parameters belong to |
|
61 |
* @param jobParams |
|
62 |
* a map of the job parameters |
|
63 |
*/ |
|
51 | 64 |
protected void createJobParams(Long jobId, HashMap<String, String> jobParams) throws AccessException { |
52 | 65 |
|
66 |
// iterate through and insert each job parameter |
|
53 | 67 |
for(String paramKey : jobParams.keySet()) { |
54 | 68 |
ScheduledJobParamDAO jobParamsDAO = new ScheduledJobParamDAO(); |
55 | 69 |
jobParamsDAO.setStatus(StatusUtil.ACTIVE); |
... | ... | |
96 | 110 |
} |
97 | 111 |
} |
98 | 112 |
|
113 |
/** |
|
114 |
* Remove change a job status to deleted in the database. |
|
115 |
* |
|
116 |
* @param jobId |
|
117 |
* the id of the job to update |
|
118 |
*/ |
|
99 | 119 |
protected void deleteJobParams(Long jobId) throws AccessException { |
100 | 120 |
PreparedStatement pstmt = null; |
101 | 121 |
|
122 |
// change the status to deleted |
|
102 | 123 |
try { |
103 | 124 |
String sql = "UPDATE scheduled_job_params SET status = ? WHERE jobId = ?"; |
104 | 125 |
pstmt.setString(1, StatusUtil.DELETED); |
... | ... | |
125 | 146 |
|
126 | 147 |
} |
127 | 148 |
|
128 |
protected Vector<ScheduledJobParamDAO> getJobParamsForJobId(Long jobId) throws AccessException { |
|
129 |
|
|
149 |
/** |
|
150 |
* Get all the job parameters for a given job id |
|
151 |
* |
|
152 |
* @param jobId |
|
153 |
* the job id whose parameters we want to return |
|
154 |
* @return a list of the job parameter data objects |
|
155 |
*/ |
|
156 |
protected Vector<ScheduledJobParamDAO> getJobParamsForJobId(Long jobId) throws AccessException { |
|
130 | 157 |
Vector<ScheduledJobParamDAO> jobParamList = new Vector<ScheduledJobParamDAO>(); |
131 | 158 |
|
159 |
// Get the job parameters for the job id |
|
132 | 160 |
PreparedStatement pstmt = null; |
133 | 161 |
ScheduledJobParamDAO jobParamDAO = null; |
134 | 162 |
try { |
... | ... | |
169 | 197 |
|
170 | 198 |
} |
171 | 199 |
|
172 |
protected Vector<ScheduledJobParamDAO> getAllJobParams() throws AccessException { |
|
173 |
|
|
200 |
/** |
|
201 |
* Get all job parameters |
|
202 |
* |
|
203 |
* @return a list of all job parameters in the database |
|
204 |
*/ |
|
205 |
protected Vector<ScheduledJobParamDAO> getAllJobParams() throws AccessException { |
|
174 | 206 |
Vector<ScheduledJobParamDAO> jobParamList = new Vector<ScheduledJobParamDAO>(); |
175 | 207 |
|
208 |
// get all job parameters |
|
176 | 209 |
PreparedStatement pstmt = null; |
177 | 210 |
ScheduledJobParamDAO jobParamDAO = null; |
178 | 211 |
try { |
... | ... | |
210 | 243 |
|
211 | 244 |
} |
212 | 245 |
|
246 |
/** |
|
247 |
* Populate a job parameter data object with the current row in a resultset |
|
248 |
* |
|
249 |
* @param resultSet |
|
250 |
* the result set which is already pointing to the desired row. |
|
251 |
* @return a scheduled job data parameter object |
|
252 |
*/ |
|
213 | 253 |
protected ScheduledJobParamDAO populateDAO(ResultSet resultSet) throws SQLException { |
214 | 254 |
|
215 | 255 |
ScheduledJobParamDAO jobParamDAO = new ScheduledJobParamDAO(); |
Also available in: Unified diff
Beef up comments