From 741ca5d5a2c0a74de96a352bc89f17ad70f5d42a Mon Sep 17 00:00:00 2001 From: vladp Date: Wed, 18 Mar 2026 19:05:07 +0700 Subject: [PATCH] dev add violation notion --- .../service/violation/ViolationService.java | 96 ------------------- 1 file changed, 96 deletions(-) diff --git a/src/main/java/ru/soune/nocopy/service/violation/ViolationService.java b/src/main/java/ru/soune/nocopy/service/violation/ViolationService.java index 8133dcf..6174d01 100644 --- a/src/main/java/ru/soune/nocopy/service/violation/ViolationService.java +++ b/src/main/java/ru/soune/nocopy/service/violation/ViolationService.java @@ -94,58 +94,6 @@ public class ViolationService { .collect(Collectors.toList()); } - public List violationsByFileId(FileEntity file) { - return violationRepository.findByFileEntity(file); - } - - public void changeStatusViolation(Long violationId, String status) { - Violation violation = violationRepository.findById(violationId) - .orElseThrow(() -> new ViolationNotFoundException("Violation not found with id: " + violationId)); - violation.setStatus(status); - violationRepository.save(violation); - } - - public Page getViolationsByFile(FileEntity file, int page, int size, String sortDirection) { - Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC, "createdDate"); - Pageable pageable = PageRequest.of(page, size, sort); - return violationRepository.findByFileEntity(file, pageable); - } - - public Page getViolationsByFileAndStatus(FileEntity file, String status, int page, int size, String sortDirection) { - Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC, "createdDate"); - Pageable pageable = PageRequest.of(page, size, sort); - return violationRepository.findByFileEntityAndStatus(file, status, pageable); - } - - public Page getViolationsByFileAndDateRange(FileEntity file, LocalDateTime startDate, LocalDateTime endDate, - int page, int size, String sortDirection) { - Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC, "createdDate"); - Pageable pageable = PageRequest.of(page, size, sort); - return violationRepository.findByFileEntityAndCreatedDateBetween(file, startDate, endDate, pageable); - } - - public Map getGroupedViolations(FileEntity file, String groupBy, String status, - LocalDateTime startDate, LocalDateTime endDate) { - - List violations; - - if (status != null && !status.isEmpty() && startDate != null && endDate != null) { - violations = violationRepository.findByFileEntityAndStatusAndCreatedDateBetween(file, status, startDate, endDate); - } else if (status != null && !status.isEmpty()) { - violations = violationRepository.findByFileEntityAndStatus(file, status); - } else if (startDate != null && endDate != null) { - violations = violationRepository.findByFileEntityAndCreatedDateBetween(file, startDate, endDate); - } else { - violations = violationRepository.findByFileEntity(file); - } - - return violations.stream() - .collect(Collectors.groupingBy( - v -> extractGroupKey(v.getPageUrl(), groupBy), - Collectors.counting() - )); - } - public Page getViolationsByFiles(List files, int page, int size, String sortDirection) { Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC, "createdDate"); Pageable pageable = PageRequest.of(page, size, sort); @@ -165,50 +113,6 @@ public class ViolationService { return violationRepository.findByFileEntityInAndCreatedDateBetween(files, startDate, endDate, pageable); } - public Map getGroupedViolations(List files, String groupBy, String status, - LocalDateTime startDate, LocalDateTime endDate) { - List violations; - - if (status != null && !status.isEmpty() && startDate != null && endDate != null) { - violations = violationRepository.findByFileEntityInAndStatusAndCreatedDateBetween(files, status, startDate, endDate); - } else if (status != null && !status.isEmpty()) { - violations = violationRepository.findByFileEntityInAndStatus(files, status); - } else if (startDate != null && endDate != null) { - violations = violationRepository.findByFileEntityInAndCreatedDateBetween(files, startDate, endDate); - } else { - violations = violationRepository.findByFileEntityIn(files); - } - - return violations.stream() - .collect(Collectors.groupingBy( - v -> extractGroupKey(v.getPageUrl(), groupBy), - Collectors.counting())); - } - -// public Map getGroupedViolations(List files, String groupBy, String status, -// LocalDateTime startDate, LocalDateTime endDate, -// String sortDirection) { -// List violations; -// -// Sort sort = Sort.by(sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC, -// "createdDate"); -// -// if (status != null && !status.isEmpty() && startDate != null && endDate != null) { -// violations = violationRepository.findByFileEntityInAndStatusAndCreatedDateBetween(files, status, startDate, endDate, sort); -// } else if (status != null && !status.isEmpty()) { -// violations = violationRepository.findByFileEntityInAndStatus(files, status, sort); -// } else if (startDate != null && endDate != null) { -// violations = violationRepository.findByFileEntityInAndCreatedDateBetween(files, startDate, endDate, sort); -// } else { -// violations = violationRepository.findByFileEntityIn(files, sort); -// } -// -// return violations.stream() -// .collect(Collectors.groupingBy( -// v -> extractGroupKey(v.getPageUrl(), groupBy), -// Collectors.counting())); -// } - public Map getGroupedViolations(List files, String groupBy, String status, LocalDateTime startDate, LocalDateTime endDate, String sortDirection) {