Done ticket GEPAFINBE-172
This commit is contained in:
@@ -119,6 +119,15 @@ public class ApplicationAmendmentRequestDao {
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private EvaluationFormRepository evaluationFormRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationFormFieldRepository applicationEvaluationFormFieldRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationFormRepository applicationEvaluationFormRepository;
|
||||
|
||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
|
||||
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
||||
@@ -132,16 +141,10 @@ public class ApplicationAmendmentRequestDao {
|
||||
if(file != null){
|
||||
evaluationFileRequests=Utils.convertJsonStringToList(file,FieldRequest.class);
|
||||
}
|
||||
Boolean allValid = evaluationFileRequests.stream()
|
||||
.anyMatch(fieldRequest -> fieldRequest.getValid() == null);
|
||||
if(checkList != null) {
|
||||
checklistRequests=Utils.convertJsonStringToList(checkList,ChecklistRequest.class);
|
||||
}
|
||||
boolean resultCheckList = checklistRequests.stream()
|
||||
.anyMatch(checklistRequest -> Boolean.TRUE.equals(checklistRequest.getValid())) ? false : true;
|
||||
|
||||
if(Boolean.TRUE.equals(allValid) || Boolean.TRUE.equals(resultCheckList)){
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.All_DOCUMENT_CHECKED_AND_ONE_CHECKLIST_CHECKED));
|
||||
if(applicationEvaluationEntity.getEvaluationVersion().equals(EvaluationVersionEnum.V1.getValue())) {
|
||||
checklistValidationForEvaluationV1(evaluationFileRequests, checkList, checklistRequests);
|
||||
} else if (applicationEvaluationEntity.getEvaluationVersion().equals(EvaluationVersionEnum.V2.getValue())) {
|
||||
validationCheckEvaluationV2(applicationEvaluationEntity, application);
|
||||
}
|
||||
// Set common application-level details
|
||||
String callName = application.getCall().getName();
|
||||
@@ -186,6 +189,47 @@ public class ApplicationAmendmentRequestDao {
|
||||
return response;
|
||||
}
|
||||
|
||||
private void validationCheckEvaluationV2(ApplicationEvaluationEntity applicationEvaluationEntity, ApplicationEntity application) {
|
||||
Long callId= applicationEvaluationEntity.getAssignedApplicationsEntity().getApplication().getCall().getId();
|
||||
EvaluationFormEntity evaluationFormEntity=evaluationFormRepository.findByCallIdAndIsDeletedFalse(callId);
|
||||
Long numberOfCheck= application.getCall().getNumberOfCheck();
|
||||
ApplicationEvaluationFormEntity applicationEvaluationForm=applicationEvaluationFormRepository.findByApplicationEvaluation_IdAndIsDeletedFalse(applicationEvaluationEntity.getId());
|
||||
List<ContentResponseBean> contentResponseBeans=Utils.convertJsonStringToList(evaluationFormEntity.getContent(),ContentResponseBean.class);
|
||||
int count = 0;
|
||||
for (ContentResponseBean content : contentResponseBeans) {
|
||||
if (GepafinConstant.SWITCH.equals(content.getName()) && content.getSettings().stream()
|
||||
.anyMatch(setting -> GepafinConstant.IS_CHECK_LIST_ITEM.equals(setting.getName()))) {
|
||||
|
||||
ApplicationEvaluationFormFieldEntity field = applicationEvaluationFormFieldRepository
|
||||
.findByFieldIdAndApplicationEvaluationFormId(content.getId(), applicationEvaluationForm.getId());
|
||||
|
||||
if (field != null && Utils.isValidBoolean(field.getFieldValue())) {
|
||||
Boolean fieldValueAsBoolean = Boolean.parseBoolean(field.getFieldValue());
|
||||
|
||||
if (Boolean.FALSE.equals(fieldValueAsBoolean)) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,GepafinConstant.VALIDATION_FAILED_FOR_CHECKLIST);
|
||||
}
|
||||
|
||||
if (++count >= numberOfCheck) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checklistValidationForEvaluationV1(List<FieldRequest> evaluationFileRequests, String checkList, List<ChecklistRequest> checklistRequests) {
|
||||
Boolean allValid = evaluationFileRequests.stream()
|
||||
.anyMatch(fieldRequest -> fieldRequest.getValid() == null);
|
||||
if(checkList != null) {
|
||||
checklistRequests =Utils.convertJsonStringToList(checkList,ChecklistRequest.class);
|
||||
}
|
||||
boolean resultCheckList = checklistRequests.stream()
|
||||
.anyMatch(checklistRequest -> Boolean.TRUE.equals(checklistRequest.getValid())) ? false : true;
|
||||
|
||||
if(Boolean.TRUE.equals(allValid) || Boolean.TRUE.equals(resultCheckList)){
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.All_DOCUMENT_CHECKED_AND_ONE_CHECKLIST_CHECKED));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<AmendmentFormFieldResponse> getIdAndLabelFromResult(List<Map<String, Object>> result) {
|
||||
List<AmendmentFormFieldResponse> formFieldResponses = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user