Commit a13745c8 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Updated job start_time and end_time in JobDAO instead of relying on job_insert trigger

parent 659a26f0
Loading
Loading
Loading
Loading
+18 −4
Original line number Original line Diff line number Diff line
@@ -54,8 +54,22 @@ public class JobDAO {


        String sql
        String sql
                = "INSERT INTO job(job_id, owner_id, job_type, phase, job_info, transfer_details, "
                = "INSERT INTO job(job_id, owner_id, job_type, phase, job_info, transfer_details, "
                + " results, error_message, error_type, error_has_detail, error_detail) "
                + " results, error_message, error_type, error_has_detail, error_detail, start_time, end_time) "
                + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
                + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ";

        switch (jobSummary.getPhase()) {
            case EXECUTING:
                sql += "NOW(), NULL)";
                break;
            case ERROR:
            case COMPLETED:
            case ABORTED:
                sql += "NOW(), NOW())";
                break;
            default:
                sql += "NULL, NULL)";
                break;
        }


        jdbcTemplate.update(sql, ps -> {
        jdbcTemplate.update(sql, ps -> {
            int i = 0;
            int i = 0;
@@ -200,7 +214,7 @@ public class JobDAO {
            }
            }
            sb.append(")");
            sb.append(")");
        }
        }
        

        // Fill conditions on views list
        // Fill conditions on views list
        if (!viewList.isEmpty()) {
        if (!viewList.isEmpty()) {
            sb.append(" AND (")
            sb.append(" AND (")
@@ -310,7 +324,7 @@ public class JobDAO {
            ps.setString(++i, job.getJobId());
            ps.setString(++i, job.getJobId());
        });
        });
    }
    }
    

    public Transfer getTransferDetails(String jobId) {
    public Transfer getTransferDetails(String jobId) {


        String sql = "SELECT transfer_details FROM job WHERE job_id = ?";
        String sql = "SELECT transfer_details FROM job WHERE job_id = ?";