private static IdUuidPair toIdUuidPair(PurgeableAnalysisDto snapshot) { return new IdUuidPair(snapshot.getAnalysisId(), snapshot.getAnalysisUuid()); }
private List<PurgeableAnalysisDto> delete(String rootUuid, List<PurgeableAnalysisDto> snapshots, DbSession session) { if (LOG.isDebugEnabled()) { LOG.debug("<- Delete analyses of component {}: {}", rootUuid, Joiner.on(", ").join( snapshots.stream() .map(snapshot -> snapshot.getAnalysisUuid() + "@" + DateUtils.formatDateTime(snapshot.getDate())) .collect(MoreCollectors.toArrayList(snapshots.size())))); } purgeDao.deleteAnalyses( session, profiler, snapshots.stream().map(DefaultPeriodCleaner::toIdUuidPair).collect(MoreCollectors.toList(snapshots.size()))); return snapshots; }
private static PurgeableAnalysisDto getById(List<PurgeableAnalysisDto> snapshots, String uuid) { return snapshots.stream() .filter(snapshot -> uuid.equals(snapshot.getAnalysisUuid())) .findFirst() .orElse(null); }
private static List<String> analysisUuids(List<PurgeableAnalysisDto> snapshotDtos) { return snapshotDtos.stream().map(input -> input.getAnalysisUuid()).collect(Collectors.toList()); }
@Test public void shouldIgnoreTimeWhenGroupingByIntervals() { List<PurgeableAnalysisDto> snapshots = Arrays.asList( DbCleanerTestUtils.createAnalysisWithDateTime("u1", "2011-05-25T00:16:48+0100"), DbCleanerTestUtils.createAnalysisWithDateTime("u2", "2012-01-26T00:16:48+0100"), DbCleanerTestUtils.createAnalysisWithDateTime("u3", "2012-01-27T00:16:48+0100") ); List<Interval> intervals = Interval.group(snapshots, DateUtils.parseDateTime("2011-05-25T00:00:00+0100"), DateUtils.parseDateTime("2012-01-26T00:00:00+0100"), Calendar.MONTH); assertThat(intervals.size()).isEqualTo(1); assertThat(intervals.get(0).count()).isEqualTo(1); assertThat(intervals.get(0).get().get(0).getAnalysisUuid()).isEqualTo(("u2")); } }
private List<PurgeableAnalysisDto> delete(String rootUuid, List<PurgeableAnalysisDto> snapshots, DbSession session) { if (LOG.isDebugEnabled()) { LOG.debug("<- Delete analyses of component {}: {}", rootUuid, Joiner.on(", ").join( snapshots.stream() .map(snapshot -> snapshot.getAnalysisUuid() + "@" + DateUtils.formatDateTime(snapshot.getDate())) .collect(Collectors.toArrayList(snapshots.size())))); } purgeDao.deleteAnalyses( session, profiler, snapshots.stream().map(DefaultPeriodCleaner::toIdUuidPair).collect(Collectors.toList(snapshots.size()))); return snapshots; }
private static IdUuidPair toIdUuidPair(PurgeableAnalysisDto snapshot) { return new IdUuidPair(snapshot.getAnalysisId(), snapshot.getAnalysisUuid()); }