Pull request #610: RED-5256: added consumes to getDossierInformation-endpoint and changed it from GET to POST && dossiers were not filtered before getting dossier information, if filteredDossierId was empty

Merge in RED/persistence-service from RED-5256-A to master

* commit '19c87fa6bc92a52c8867d9c9792002e4b2754545':
  RED-5256:  refactored checks and added findAllById for dossiers
  RED-5256:  added consumes to getDossierInformation-endpoint and changed it from GET to POST && dossiers were not filtered before getting dossier information, if filteredDossierId was empty
  RED-5256:  added consumes to getDossierInformation-endpoint and changed it from GET to POST && dossiers were not filtered before getting dossier information, if filteredDossierId was empty
This commit is contained in:
Ali Oezyetimoglu 2023-02-17 16:52:59 +01:00
commit 51c2ee2fdd
4 changed files with 24 additions and 10 deletions

View File

@ -26,7 +26,7 @@ public interface DossierResource {
String REST_PATH = "/dossier";
String DOSSIER_TEMPLATE_PATH = "/dossier-template";
String INFO_PATH = "/info";
String INFO_PATH = "/dossier-info";
String DELETED_DOSSIERS_PATH = "/deletedDossiers";
String HARD_DELETE_PATH = "/hardDelete";
String UNDELETE_PATH = "/undelete";
@ -75,7 +75,7 @@ public interface DossierResource {
@RequestParam(name = INCLUDE_DELETED_PARAM, defaultValue = "false", required = false) boolean includeDeleted);
@GetMapping(value = REST_PATH + INFO_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = INFO_PATH, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
DossierInformation getDossierInformation(@RequestBody List<String> filteredDossierIds);

View File

@ -4,16 +4,16 @@ import static com.iqser.red.service.persistence.management.v1.processor.exceptio
import java.time.OffsetDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import com.iqser.red.service.persistence.management.v1.processor.exception.ConflictException;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.DossierEntity;
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
@ -28,8 +28,6 @@ import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.do
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
@ -171,6 +169,17 @@ public class DossierPersistenceService {
public List<DossierEntity> findAllDossiers() {
return dossierRepository.findAll();
}
public List<DossierEntity> findAllDossiers(List<String> dossierIds) {
if (!dossierIds.isEmpty()) {
return dossierRepository.findAllById(dossierIds);
} else {
return Collections.emptyList();
}
}

View File

@ -4,6 +4,7 @@ import static com.iqser.red.service.persistence.management.v1.processor.exceptio
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
import java.time.OffsetDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@ -143,10 +144,8 @@ public class DossierController implements DossierResource {
DossierInformation dossierInformation = new DossierInformation();
var dossiers = dossierService.getAllDossiers();
if (filteredDossierIds != null && !filteredDossierIds.isEmpty()) {
dossiers = dossiers.stream().filter(d -> filteredDossierIds.contains(d.getId())).collect(Collectors.toList());
}
var dossiers = dossierService.getAllDossiers(filteredDossierIds != null ? filteredDossierIds : Collections.emptyList());
dossiers.forEach(d -> {
if (d.getHardDeletedTime() != null) {
dossierInformation.setNumberOfHardDeletedDossiers(dossierInformation.getNumberOfHardDeletedDossiers() + 1);

View File

@ -133,6 +133,12 @@ public class DossierService {
}
public List<DossierEntity> getAllDossiers(List<String> dossierIds) {
return dossierPersistenceService.findAllDossiers(dossierIds);
}
public List<DossierEntity> getAllDossiersForDossierTemplateId(String dossierTemplateId) {
return dossierPersistenceService.findAllDossiersForDossierTemplateId(dossierTemplateId);