private static void deleteNonRootComponentsInView(Set<ComponentDto> nonRootComponents, PurgeCommands purgeCommands) { List<IdUuidPair> subviewsOrProjectCopies = nonRootComponents.stream() .filter(PurgeDao::isModuleOrSubview) .map(PurgeDao::toIdUuidPair) .collect(MoreCollectors.toList()); purgeCommands.deleteByRootAndModulesOrSubviews(subviewsOrProjectCopies); List<String> nonRootComponentUuids = nonRootComponents.stream().map(ComponentDto::uuid).collect(MoreCollectors.toList(nonRootComponents.size())); purgeCommands.deleteComponentMeasures(nonRootComponentUuids); purgeCommands.deleteComponents(nonRootComponentUuids); }
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); }