@Test public void assertAddTaskRunningStatistics() { assertTrue(repository.add(new TaskRunningStatistics(100, new Date()))); }
public boolean add(final TaskResultStatistics taskResultStatistics) { boolean result = false; String sql = "INSERT INTO `" + TABLE_TASK_RESULT_STATISTICS + "_" + taskResultStatistics.getStatisticInterval() + "` (`success_count`, `failed_count`, `statistics_time`, `creation_time`) VALUES (?, ?, ?, ?);"; try ( Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql)) { preparedStatement.setInt(1, taskResultStatistics.getSuccessCount()); preparedStatement.setInt(2, taskResultStatistics.getFailedCount()); preparedStatement.setTimestamp(3, new Timestamp(taskResultStatistics.getStatisticsTime().getTime())); preparedStatement.setTimestamp(4, new Timestamp(taskResultStatistics.getCreationTime().getTime())); preparedStatement.execute(); result = true; } catch (final SQLException ex) { log.error("Insert taskResultStatistics to DB error:", ex); } return result; }
StatisticRdbRepository { public boolean add(final TaskResultStatistics taskResultStatistics) { boolean result = false; String sql = "INSERT INTO `" + TABLE_TASK_RESULT_STATISTICS + "_" + taskResultStatistics.getStatisticInterval() + "` (`success_count`, `failed_count`, `statistics_time`, `creation_time`) VALUES (?, ?, ?, ?);"; try ( Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql)) { preparedStatement.setInt(1, taskResultStatistics.getSuccessCount()); preparedStatement.setInt(2, taskResultStatistics.getFailedCount()); preparedStatement.setTimestamp(3, new Timestamp(taskResultStatistics.getStatisticsTime().getTime())); preparedStatement.setTimestamp(4, new Timestamp(taskResultStatistics.getCreationTime().getTime())); preparedStatement.execute(); result = true; } catch (final SQLException ex) { log.error("Insert taskResultStatistics to DB error:", ex); } return result; } }
StatisticRdbRepository { public boolean add(final TaskResultStatistics taskResultStatistics) { boolean result = false; String sql = "INSERT INTO `" + TABLE_TASK_RESULT_STATISTICS + "_" + taskResultStatistics.getStatisticInterval() + "` (`success_count`, `failed_count`, `statistics_time`, `creation_time`) VALUES (?, ?, ?, ?);"; try ( Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql)) { preparedStatement.setInt(1, taskResultStatistics.getSuccessCount()); preparedStatement.setInt(2, taskResultStatistics.getFailedCount()); preparedStatement.setTimestamp(3, new Timestamp(taskResultStatistics.getStatisticsTime().getTime())); preparedStatement.setTimestamp(4, new Timestamp(taskResultStatistics.getCreationTime().getTime())); preparedStatement.execute(); result = true; } catch (final SQLException ex) { log.error("Insert taskResultStatistics to DB error:", ex); } return result; } StatisticRdbRepository(final DataSource dataSource); }
StatisticRdbRepository { public boolean add(final TaskResultStatistics taskResultStatistics) { boolean result = false; String sql = "INSERT INTO `" + TABLE_TASK_RESULT_STATISTICS + "_" + taskResultStatistics.getStatisticInterval() + "` (`success_count`, `failed_count`, `statistics_time`, `creation_time`) VALUES (?, ?, ?, ?);"; try ( Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql)) { preparedStatement.setInt(1, taskResultStatistics.getSuccessCount()); preparedStatement.setInt(2, taskResultStatistics.getFailedCount()); preparedStatement.setTimestamp(3, new Timestamp(taskResultStatistics.getStatisticsTime().getTime())); preparedStatement.setTimestamp(4, new Timestamp(taskResultStatistics.getCreationTime().getTime())); preparedStatement.execute(); result = true; } catch (final SQLException ex) { log.error("Insert taskResultStatistics to DB error:", ex); } return 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 boolean add(final TaskResultStatistics taskResultStatistics) { boolean result = false; String sql = "INSERT INTO `" + TABLE_TASK_RESULT_STATISTICS + "_" + taskResultStatistics.getStatisticInterval() + "` (`success_count`, `failed_count`, `statistics_time`, `creation_time`) VALUES (?, ?, ?, ?);"; try ( Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql)) { preparedStatement.setInt(1, taskResultStatistics.getSuccessCount()); preparedStatement.setInt(2, taskResultStatistics.getFailedCount()); preparedStatement.setTimestamp(3, new Timestamp(taskResultStatistics.getStatisticsTime().getTime())); preparedStatement.setTimestamp(4, new Timestamp(taskResultStatistics.getCreationTime().getTime())); preparedStatement.execute(); result = true; } catch (final SQLException ex) { log.error("Insert taskResultStatistics to DB error:", ex); } return 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();  }