add filter doc/videos

This commit is contained in:
dalia.florinda
2026-01-19 09:32:03 +01:00
parent 4f850e8983
commit ea543cf7c2
2 changed files with 21 additions and 2 deletions

View File

@@ -51,7 +51,16 @@ public class KSDocumentService {
User principal = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); User principal = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
try { try {
return ksdocRepo.findByProjectName(principal.getSelectedProject().getInternal_name(), Sort.by(Sort.Direction.DESC, "ingestionDate")); List<KSDocument> documents = ksdocRepo.findByProjectName(principal.getSelectedProject().getInternal_name(), Sort.by(Sort.Direction.DESC, "ingestionDate"));
// Filtra i documenti: mostra solo quelli senza ingestionStatusV2 o con valore vuoto/nullo
if (documents != null) {
return documents.stream()
.filter(doc -> doc.getIngestionStatusV2() == null || doc.getIngestionStatusV2().trim().isEmpty())
.collect(Collectors.toList());
}
return documents;
} catch (Exception e) { } catch (Exception e) {
logger.error("Error in findByProjectNameAndApplicationName function: " + e.getMessage()); logger.error("Error in findByProjectNameAndApplicationName function: " + e.getMessage());
} }

View File

@@ -4,6 +4,7 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -40,7 +41,16 @@ public class KSVideoService {
} }
public List<KSVideo> findByGroupId(String groupId) { public List<KSVideo> findByGroupId(String groupId) {
return ksVideoRepository.findByGroupId(groupId, Sort.by(Sort.Direction.DESC, "ingestionDate")); List<KSVideo> videos = ksVideoRepository.findByGroupId(groupId, Sort.by(Sort.Direction.DESC, "ingestionDate"));
// Filtra i video: mostra solo quelli senza ingestionStatusV2 o con valore vuoto/nullo
if (videos != null) {
return videos.stream()
.filter(video -> video.getIngestionStatusV2() == null || video.getIngestionStatusV2().trim().isEmpty())
.collect(Collectors.toList());
}
return videos;
} }
public ResponseEntity<Resource> downloadKSVideo(KSVideo video) { public ResponseEntity<Resource> downloadKSVideo(KSVideo video) {