示例#1
0
  @Override
  public Page<JobExecution> find(Query query) {
    String sql = "from " + getTableName();

    MapSqlParameterSource params = new MapSqlParameterSource();

    if (query.getResult() != null) {
      sql += " where result = :result";

      params.addValue("result", query.getResult().name());
    }

    return getLogs(sql, params, query);
  }
示例#2
0
  private Page<JobExecution> getLogs(String sqlBase, SqlParameterSource params, Query query) {
    String sql = query.applySqlLimit("select * " + sqlBase + " order by startDate desc");

    List<JobExecution> executions =
        jdbcTemplate.query(
            sql,
            params,
            new RowMapper<JobExecution>() {
              @Override
              public JobExecution mapRow(ResultSet rs, int rowNum) throws SQLException {
                JobExecution execution = new JobExecution();

                execution.setId(rs.getLong("id"));
                execution.setStartDate(rs.getTimestamp("startDate"));
                execution.setEndDate(rs.getTimestamp("endDate"));
                execution.setEnded(rs.getBoolean("ended"));
                execution.setJobGroup(rs.getString("jobGroup"));
                execution.setJobName(rs.getString("jobName"));
                execution.setTriggerGroup(rs.getString("triggerGroup"));
                execution.setTriggerName(rs.getString("triggerName"));
                execution.setJobClass(rs.getString("jobClass"));
                execution.setDataMap(rs.getString("dataMap"));
                execution.setResult(JobExecutionResult.valueOf(rs.getString("result")));

                return execution;
              }
            });

    String countSql = "select count(*) " + sqlBase;

    Page<JobExecution> page = Page.fromQuery(query);

    page.setItems(executions);
    page.setTotalCount(jdbcTemplate.queryForInt(countSql, params));

    return page;
  }