@Test public void assertFindLatestJobRunningStatisticsWhenTableIsEmpty() { assertFalse(repository.findLatestJobRunningStatistics().isPresent()); }
public Optional<JobRunningStatistics> findLatestJobRunningStatistics() { JobRunningStatistics result = null; String sql = String.format("SELECT id, running_count, statistics_time, creation_time FROM %s order by id DESC LIMIT 1", TABLE_JOB_RUNNING_STATISTICS); try ( Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql); ResultSet resultSet = preparedStatement.executeQuery() ) { while (resultSet.next()) { result = new JobRunningStatistics(resultSet.getLong(1), resultSet.getInt(2), new Date(resultSet.getTimestamp(3).getTime()), new Date(resultSet.getTimestamp(4).getTime())); } } catch (final SQLException ex) { log.error("Fetch latest jobRunningStatistics from DB error:", ex); } return Optional.ofNullable(result); }
StatisticRdbRepository { public Optional<JobRunningStatistics> findLatestJobRunningStatistics() { JobRunningStatistics result = null; String sql = String.format("SELECT id, running_count, statistics_time, creation_time FROM %s order by id DESC LIMIT 1", TABLE_JOB_RUNNING_STATISTICS); try ( Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql); ResultSet resultSet = preparedStatement.executeQuery() ) { while (resultSet.next()) { result = new JobRunningStatistics(resultSet.getLong(1), resultSet.getInt(2), new Date(resultSet.getTimestamp(3).getTime()), new Date(resultSet.getTimestamp(4).getTime())); } } catch (final SQLException ex) { log.error("Fetch latest jobRunningStatistics from DB error:", ex); } return Optional.ofNullable(result); } }
StatisticRdbRepository { public Optional<JobRunningStatistics> findLatestJobRunningStatistics() { JobRunningStatistics result = null; String sql = String.format("SELECT id, running_count, statistics_time, creation_time FROM %s order by id DESC LIMIT 1", TABLE_JOB_RUNNING_STATISTICS); try ( Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql); ResultSet resultSet = preparedStatement.executeQuery() ) { while (resultSet.next()) { result = new JobRunningStatistics(resultSet.getLong(1), resultSet.getInt(2), new Date(resultSet.getTimestamp(3).getTime()), new Date(resultSet.getTimestamp(4).getTime())); } } catch (final SQLException ex) { log.error("Fetch latest jobRunningStatistics from DB error:", ex); } return Optional.ofNullable(result); } StatisticRdbRepository(final DataSource dataSource); }
StatisticRdbRepository { public Optional<JobRunningStatistics> findLatestJobRunningStatistics() { JobRunningStatistics result = null; String sql = String.format("SELECT id, running_count, statistics_time, creation_time FROM %s order by id DESC LIMIT 1", TABLE_JOB_RUNNING_STATISTICS); try ( Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql); ResultSet resultSet = preparedStatement.executeQuery() ) { while (resultSet.next()) { result = new JobRunningStatistics(resultSet.getLong(1), resultSet.getInt(2), new Date(resultSet.getTimestamp(3).getTime()), new Date(resultSet.getTimestamp(4).getTime())); } } catch (final SQLException ex) { log.error("Fetch latest jobRunningStatistics from DB error:", ex); } return Optional.ofNullable(result); } StatisticRdbRepository(final DataSource dataSource); boolean add(final TaskResultStatistics taskResultStatistics); boolean add(final TaskRunningStatistics taskRunningStatistics); boolean add(final JobRunningStatistics jobRunningStatistics); boolean add(final JobRegisterStatistics jobRegisterStatistics); List<TaskResultStatistics> findTaskResultStatistics(final Date from, final StatisticInterval statisticInterval); TaskResultStatistics getSummedTaskResultStatistics(final Date from, final StatisticInterval statisticInterval); Optional<TaskResultStatistics> findLatestTaskResultStatistics(final StatisticInterval statisticInterval); List<TaskRunningStatistics> findTaskRunningStatistics(final Date from); List<JobRunningStatistics> findJobRunningStatistics(final Date from); Optional<TaskRunningStatistics> findLatestTaskRunningStatistics(); Optional<JobRunningStatistics> findLatestJobRunningStatistics(); List<JobRegisterStatistics> findJobRegisterStatistics(final Date from); Optional<JobRegisterStatistics> findLatestJobRegisterStatistics(); }
StatisticRdbRepository { public Optional<JobRunningStatistics> findLatestJobRunningStatistics() { JobRunningStatistics result = null; String sql = String.format("SELECT id, running_count, statistics_time, creation_time FROM %s order by id DESC LIMIT 1", TABLE_JOB_RUNNING_STATISTICS); try ( Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql); ResultSet resultSet = preparedStatement.executeQuery() ) { while (resultSet.next()) { result = new JobRunningStatistics(resultSet.getLong(1), resultSet.getInt(2), new Date(resultSet.getTimestamp(3).getTime()), new Date(resultSet.getTimestamp(4).getTime())); } } catch (final SQLException ex) { log.error("Fetch latest jobRunningStatistics from DB error:", ex); } return Optional.ofNullable(result); } StatisticRdbRepository(final DataSource dataSource); boolean add(final TaskResultStatistics taskResultStatistics); boolean add(final TaskRunningStatistics taskRunningStatistics); boolean add(final JobRunningStatistics jobRunningStatistics); boolean add(final JobRegisterStatistics jobRegisterStatistics); List<TaskResultStatistics> findTaskResultStatistics(final Date from, final StatisticInterval statisticInterval); TaskResultStatistics getSummedTaskResultStatistics(final Date from, final StatisticInterval statisticInterval); Optional<TaskResultStatistics> findLatestTaskResultStatistics(final StatisticInterval statisticInterval); List<TaskRunningStatistics> findTaskRunningStatistics(final Date from); List<JobRunningStatistics> findJobRunningStatistics(final Date from); Optional<TaskRunningStatistics> findLatestTaskRunningStatistics(); Optional<JobRunningStatistics> findLatestJobRunningStatistics(); List<JobRegisterStatistics> findJobRegisterStatistics(final Date from); Optional<JobRegisterStatistics> findLatestJobRegisterStatistics();  }