RED-9717: made fileId field required and removed it from WarningModel
This commit is contained in:
parent
b977a2e46e
commit
2908477ce8
@ -308,7 +308,7 @@ public class StatusController implements StatusResource {
|
||||
|
||||
accessControlService.checkAccessPermissionsToDossier(dossierId);
|
||||
accessControlService.verifyUserIsApprover(dossierId);
|
||||
ApproveResponse approveResponse = new ApproveResponse(fileId, false, new HashMap<>());
|
||||
ApproveResponse approveResponse = new ApproveResponse(fileId, false, new ArrayList<>());
|
||||
if (!force) {
|
||||
approveResponse = approvalVerificationService.verifyApprovalOfFile(dossierId, fileId);
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public class ApprovalVerificationService {
|
||||
|
||||
public ApproveResponse verifyApprovalOfFile(String dossierId, String fileId) {
|
||||
|
||||
ApproveResponse approveResponse = new ApproveResponse();
|
||||
ApproveResponse approveResponse = new ApproveResponse(fileId);
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, true);
|
||||
List<EntityLogEntry> entityLogEntries = entityLog.getEntityLogEntry();
|
||||
List<LegalBasisEntity> legalBasisMappings = legalBasisMappingPersistenceService.getLegalBasisMapping(dossierRepository.findDossierTemplateId(dossierId));
|
||||
@ -42,18 +42,18 @@ public class ApprovalVerificationService {
|
||||
for (EntityLogEntry entry : entityLogEntries) {
|
||||
if (entry.getState().equals(EntryState.APPLIED) && !entry.getEntryType().equals(EntryType.IMAGE) && !entry.getEntryType().equals(EntryType.IMAGE_HINT)) {
|
||||
if (StringUtils.isEmpty(entry.getLegalBasis())) {
|
||||
addWarning(entry, fileId, WarningType.LEGAL_BASIS_MISSING, approveResponse);
|
||||
addWarning(entry, WarningType.LEGAL_BASIS_MISSING, approveResponse);
|
||||
} else {
|
||||
var legalBasisEntity = legalBasisMappings.stream()
|
||||
.filter(mapping -> mapping.getReason().equals(entry.getLegalBasis()))
|
||||
.findFirst();
|
||||
if (legalBasisEntity.isEmpty() || StringUtils.isEmpty(legalBasisEntity.get().getTechnicalName())) {
|
||||
addWarning(entry, fileId, WarningType.UNMAPPED_JUSTIFICATION, approveResponse);
|
||||
addWarning(entry, WarningType.UNMAPPED_JUSTIFICATION, approveResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entry.getState().equals(EntryState.PENDING)) {
|
||||
addWarning(entry, fileId, WarningType.PENDING_CHANGE, approveResponse);
|
||||
addWarning(entry, WarningType.PENDING_CHANGE, approveResponse);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,10 +62,9 @@ public class ApprovalVerificationService {
|
||||
}
|
||||
|
||||
|
||||
private void addWarning(EntityLogEntry entry, String fileId, WarningType warningType, ApproveResponse approveResponse) {
|
||||
private void addWarning(EntityLogEntry entry, WarningType warningType, ApproveResponse approveResponse) {
|
||||
|
||||
approveResponse.addFileWarning(fileId,
|
||||
WarningModel.builder()
|
||||
approveResponse.addFileWarning(WarningModel.builder()
|
||||
.id(entry.getId())
|
||||
.pages(entry.getPositions()
|
||||
.stream()
|
||||
|
||||
@ -3,39 +3,32 @@ package com.iqser.red.service.persistence.service.v1.api.shared.model.warning;
|
||||
import static com.iqser.red.service.persistence.service.v1.api.shared.model.warning.WarningsComparatorUtils.WARNING_MODEL_COMPARATOR;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@Data
|
||||
@Builder
|
||||
public class ApproveResponse {
|
||||
|
||||
@NonNull
|
||||
private String fileId;
|
||||
|
||||
private boolean hasWarnings;
|
||||
|
||||
private Map<String, List<WarningModel>> fileWarnings = new HashMap<>();
|
||||
private ArrayList<WarningModel> fileWarnings = new ArrayList<>();
|
||||
|
||||
|
||||
public void addFileWarning(String fileId, WarningModel warningModel) {
|
||||
public void addFileWarning(WarningModel warningModel) {
|
||||
|
||||
if (fileWarnings.containsKey(fileId)) {
|
||||
fileWarnings.get(fileId).add(warningModel);
|
||||
} else {
|
||||
List<WarningModel> warningModels = new ArrayList<>();
|
||||
warningModels.add(warningModel);
|
||||
fileWarnings.put(fileId, warningModels);
|
||||
}
|
||||
fileWarnings.add(warningModel);
|
||||
|
||||
fileWarnings.get(fileId).sort(WARNING_MODEL_COMPARATOR);
|
||||
fileWarnings.sort(WARNING_MODEL_COMPARATOR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user