220 |
220 |
}
|
221 |
221 |
|
222 |
222 |
@Override
|
223 |
|
public List<StoredJob> getJobsOfUser(String userName) {
|
|
223 |
public List<StoredJob> getJobs(String userName, String jobType, Integer offset, Integer limit) {
|
224 |
224 |
ResultSet rs = null;
|
225 |
225 |
Connection con = null;
|
226 |
226 |
PreparedStatement stmt = null;
|
227 |
227 |
List<StoredJob> retList = new ArrayList<StoredJob>();
|
228 |
|
logger.debug("Accessing DB to get Submitted Jobs of user: "+userName);
|
|
228 |
logger.debug("Accessing DB to get Submitted Jobs of user: "+userName + " and type: " + jobType);
|
229 |
229 |
try {
|
230 |
230 |
con = getConnection();
|
231 |
|
String query;
|
|
231 |
String beginQuery="SELECT j.validation_type, j.content_job_status, j.usage_job_status, j.content_job_score, j.usage_job_score, j.started, j.ended, j.user_email, j.repo, j.duration, r.short_name, j.guidelines, j.id, j.error_information, j.job_type, j.records_tested FROM jobs j, rulesets r WHERE j.guidelines = r.guidelines_acronym";
|
|
232 |
String endQuery=" ORDER BY j.id DESC";
|
232 |
233 |
if (userName != null) {
|
233 |
|
query="SELECT j.validation_type, j.content_job_status, j.usage_job_status, j.content_job_score, j.usage_job_score, j.started, j.ended, j.user_email, j.repo, j.duration, r.short_name, j.guidelines, j.id, j.error_information, j.job_type, j.records_tested FROM jobs j, rulesets r WHERE user_email=? AND j.guidelines = r.guidelines_acronym ORDER BY j.started DESC";
|
234 |
|
stmt = con.prepareStatement(query);
|
235 |
|
stmt.setString(1, userName);
|
236 |
|
} else {
|
237 |
|
query="SELECT j.validation_type, j.content_job_status, j.usage_job_status, j.content_job_score, j.usage_job_score, j.started, j.ended, j.user_email, j.repo, j.duration, r.short_name, j.guidelines, j.id, j.error_information, j.job_type, j.records_tested FROM jobs j, rulesets r WHERE j.guidelines = r.guidelines_acronym ORDER BY j.started DESC";
|
238 |
|
stmt = con.prepareStatement(query);
|
|
234 |
beginQuery += " AND j.user_email=?";
|
239 |
235 |
}
|
|
236 |
if (jobType != null) {
|
|
237 |
beginQuery += " AND j.job_type=?";
|
|
238 |
}
|
|
239 |
if (offset != null) {
|
|
240 |
endQuery += " OFFSET ?";
|
|
241 |
}
|
|
242 |
if (limit != null) {
|
|
243 |
endQuery += " LIMIT ?";
|
|
244 |
}
|
|
245 |
String finalQuery = beginQuery + endQuery;
|
|
246 |
logger.debug("finalQuery" + finalQuery);
|
|
247 |
stmt = con.prepareStatement(finalQuery);
|
|
248 |
int index = 1;
|
|
249 |
if (userName != null) {
|
|
250 |
stmt.setString(index++, userName);
|
|
251 |
}
|
|
252 |
if (jobType != null) {
|
|
253 |
stmt.setString(index++, jobType);
|
|
254 |
}
|
|
255 |
if (offset != null) {
|
|
256 |
stmt.setInt(index++, offset);
|
|
257 |
}
|
|
258 |
if (limit != null) {
|
|
259 |
stmt.setInt(index++, limit);
|
|
260 |
}
|
|
261 |
|
240 |
262 |
rs = stmt.executeQuery();
|
241 |
263 |
if (rs!=null){
|
242 |
264 |
while (rs.next()) {
|
... | ... | |
265 |
287 |
retJob.setCris(true);
|
266 |
288 |
this.getJobForCris(retJob);
|
267 |
289 |
}
|
268 |
|
|
269 |
|
// else if (retJob.getJobType().equals("Compatibility Test"))
|
270 |
|
// compList.add(retJob);
|
271 |
|
// else if (retJob.getJobType().equals("Workflow Request"))
|
272 |
|
// workflowList.add(retJob);
|
273 |
290 |
retList.add(retJob);
|
274 |
291 |
}
|
275 |
292 |
}
|
... | ... | |
289 |
306 |
return retList;
|
290 |
307 |
}
|
291 |
308 |
|
|
309 |
@Override
|
|
310 |
public int getJobsTotalNumber(String userName, String jobType) {
|
|
311 |
ResultSet rs = null;
|
|
312 |
Connection con = null;
|
|
313 |
PreparedStatement stmt = null;
|
|
314 |
int sum = 0;
|
|
315 |
logger.debug("Accessing DB to get total number of Jobs of user: "+userName + " and type: " + jobType);
|
|
316 |
try {
|
|
317 |
con = getConnection();
|
|
318 |
String query="SELECT count(*) as count FROM jobs WHERE";
|
|
319 |
if (userName != null) {
|
|
320 |
query += " user_email=? AND";
|
|
321 |
}
|
|
322 |
if (jobType != null) {
|
|
323 |
query += " job_type=?";
|
|
324 |
}
|
|
325 |
logger.debug(query);
|
|
326 |
stmt = con.prepareStatement(query);
|
|
327 |
int index = 1;
|
|
328 |
if (userName != null) {
|
|
329 |
stmt.setString(index++, userName);
|
|
330 |
}
|
|
331 |
if (jobType != null) {
|
|
332 |
stmt.setString(index++, jobType);
|
|
333 |
}
|
|
334 |
rs = stmt.executeQuery();
|
|
335 |
if (rs!=null){
|
|
336 |
if (rs.next()) {
|
|
337 |
sum = rs.getInt("count");
|
|
338 |
}
|
|
339 |
}
|
|
340 |
|
|
341 |
} catch (SQLException e) {
|
|
342 |
logger.error("Error while accessing DB to get total number of Jobs of user: "+e);
|
|
343 |
} finally {
|
|
344 |
if (stmt != null) {
|
|
345 |
try {
|
|
346 |
stmt.close();
|
|
347 |
} catch (SQLException e) {
|
|
348 |
logger.error("Error while accessing DB to get total number of Jobs of user: "+e);
|
|
349 |
}
|
|
350 |
}
|
|
351 |
}
|
|
352 |
return sum;
|
|
353 |
}
|
|
354 |
|
|
355 |
|
292 |
356 |
@Deprecated
|
293 |
357 |
public Date setJobFinished(int jobId, String error, Boolean failed) {
|
294 |
358 |
Date date_ended = null;
|
... | ... | |
653 |
717 |
Connection con = null;
|
654 |
718 |
PreparedStatement stmt = null;
|
655 |
719 |
logger.debug("Accessing DB to delete old Jobs");
|
656 |
|
String interval = "<=";
|
|
720 |
String interval = "<";
|
657 |
721 |
if (period.equalsIgnoreCase("older"))
|
658 |
|
interval = "<=";
|
|
722 |
interval = "<";
|
659 |
723 |
else if (period.equalsIgnoreCase("newer"))
|
660 |
|
interval = ">=";
|
|
724 |
interval = ">";
|
661 |
725 |
if (period.equalsIgnoreCase("exact"))
|
662 |
726 |
interval = "=";
|
663 |
727 |
|
updated jobsDao to support pagination while getting StoredJobs