void deleteAnalyses(PurgeSnapshotQuery... queries) { List<IdUuidPair> snapshotIds = Arrays.stream(queries) .flatMap(q -> purgeMapper.selectAnalysisIdsAndUuids(q).stream()) .collect(Collectors.toList()); deleteAnalyses(snapshotIds); }
public void deleteAnalyses(DbSession session, PurgeProfiler profiler, List<IdUuidPair> analysisIdUuids) { new PurgeCommands(session, profiler).deleteAnalyses(analysisIdUuids); }
private static void deleteAbortedAnalyses(String rootUuid, PurgeCommands commands) { LOG.debug("<- Delete aborted builds"); PurgeSnapshotQuery query = new PurgeSnapshotQuery() .setIslast(false) .setStatus(UNPROCESSED_STATUS) .setComponentUuid(rootUuid); commands.deleteAnalyses(query); }
private static void deleteRootComponent(String rootUuid, PurgeMapper mapper, PurgeCommands commands) { List<IdUuidPair> rootAndModulesOrSubviews = mapper.selectRootAndModulesOrSubviewsByProjectUuid(rootUuid); long rootId = rootAndModulesOrSubviews.stream() .filter(pair -> pair.getUuid().equals(rootUuid)) .map(IdUuidPair::getId) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Couldn't find root component with uuid " + rootUuid)); commands.deletePermissions(rootId); commands.deleteLinks(rootUuid); commands.deleteAnalyses(rootUuid); commands.deleteByRootAndModulesOrSubviews(rootAndModulesOrSubviews); commands.deleteComponents(rootUuid); commands.deleteIssues(rootUuid); commands.deleteFileSources(rootUuid); commands.deleteCeActivity(rootUuid); commands.deleteCeQueue(rootUuid); commands.deleteWebhooks(rootUuid); commands.deleteWebhookDeliveries(rootUuid); commands.deleteProjectMappings(rootUuid); commands.deleteProjectAlmBindings(rootUuid); commands.deleteBranch(rootUuid); commands.deleteLiveMeasures(rootUuid); }
@Test public void shouldDeleteAnalyses() { dbTester.prepareDbUnit(getClass(), "shouldDeleteResource.xml"); PurgeCommands purgeCommands = new PurgeCommands(dbTester.getSession(), profiler); purgeCommands.deleteAnalyses("uuid_1"); assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(1); assertThat(dbTester.countRowsOfTable("snapshots")).isZero(); assertThat(dbTester.countRowsOfTable("analysis_properties")).isZero(); assertThat(dbTester.countRowsOfTable("events")).isZero(); assertThat(dbTester.countRowsOfTable("issues")).isEqualTo(1); assertThat(dbTester.countRowsOfTable("issue_changes")).isEqualTo(1); }
/** * Test that SQL queries execution do not fail with a huge number of parameter */ @Test public void should_not_fail_when_deleting_huge_number_of_analyses() { new PurgeCommands(dbTester.getSession(), profiler).deleteAnalyses(getHugeNumberOfIdUuidPairs()); // The goal of this test is only to check that the query do no fail, not to check result }
void deleteAnalyses(PurgeSnapshotQuery... queries) { List<IdUuidPair> snapshotIds = from(asList(queries)) .transformAndConcat(purgeMapper::selectAnalysisIdsAndUuids) .toList(); deleteAnalyses(snapshotIds); }
public void deleteAnalyses(DbSession session, PurgeProfiler profiler, List<IdUuidPair> analysisIdUuids) { new PurgeCommands(session, profiler).deleteAnalyses(analysisIdUuids); }
void deleteAnalyses(String rootUuid) { deleteAnalyses(purgeMapper.selectAnalysisIdsAndUuids(new PurgeSnapshotQuery().setComponentUuid(rootUuid))); }
private static void deleteProject(String rootUuid, PurgeMapper mapper, PurgeCommands commands) { List<IdUuidPair> childrenIds = mapper.selectComponentsByProjectUuid(rootUuid); commands.deleteAnalyses(rootUuid); commands.deleteComponents(childrenIds); commands.deleteFileSources(rootUuid); commands.deleteCeActivity(rootUuid); commands.deleteWebhookDeliveries(rootUuid); }
private static void deleteAbortedAnalyses(String rootUuid, PurgeCommands commands) { LOG.debug("<- Delete aborted builds"); PurgeSnapshotQuery query = new PurgeSnapshotQuery() .setIslast(false) .setStatus(UNPROCESSED_STATUS) .setComponentUuid(rootUuid); commands.deleteAnalyses(query); }