Email notification for document and application status.
This commit is contained in:
@@ -29,33 +29,51 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationService applicationService;
|
||||
|
||||
@Autowired
|
||||
private CallRepository callRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationRepository applicationRepository;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private EvaluationCriteriaRepository evaluationCriteriaRepository;
|
||||
|
||||
@Autowired
|
||||
private FormRepository formRepository;
|
||||
|
||||
@Autowired
|
||||
private CallTargetAudienceChecklistRepository callTargetAudienceChecklistRepository;
|
||||
|
||||
@Autowired
|
||||
private DocumentRepository documentRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationFormRepository applicationFormRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationFormFieldRepository applicationFormFieldRepository;
|
||||
|
||||
@Autowired
|
||||
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||
|
||||
@Autowired
|
||||
private CriteriaFormFieldRepository criteriaFormFieldRepository;
|
||||
|
||||
@Autowired
|
||||
private EmailNotificationDao emailNotificationDao;
|
||||
|
||||
@Autowired
|
||||
ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
|
||||
|
||||
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
|
||||
|
||||
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
||||
|
||||
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplciationId).orElse(null);
|
||||
@@ -73,6 +91,7 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
private ApplicationEvaluationResponse convertToResponse(ApplicationEvaluationEntity entity) {
|
||||
|
||||
ApplicationEvaluationResponse response = new ApplicationEvaluationResponse();
|
||||
populateBasicDetails(entity, response);
|
||||
|
||||
@@ -91,16 +110,16 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
private void populateBasicDetails(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response) {
|
||||
|
||||
response.setId(entity.getId());
|
||||
response.setApplicationId(entity.getApplicationId());
|
||||
|
||||
List<AssignedApplicationsEntity> assignedApplicationsList =
|
||||
assignedApplicationsRepository.findAllByApplicationId(entity.getApplicationId());
|
||||
List<AssignedApplicationsEntity> assignedApplicationsList = assignedApplicationsRepository.findAllByApplicationId(entity.getApplicationId());
|
||||
|
||||
if (assignedApplicationsList.isEmpty()) {
|
||||
response.setAssignedApplicationId(null);
|
||||
} else {
|
||||
// AssignedApplicationsEntity assignedApplications = assignedApplicationsList.get(0);
|
||||
// AssignedApplicationsEntity assignedApplications = assignedApplicationsList.get(0);
|
||||
response.setAssignedApplicationId(entity.getAssignedApplicationsEntity().getId());
|
||||
}
|
||||
|
||||
@@ -110,20 +129,18 @@ public class ApplicationEvaluationDao {
|
||||
response.setUpdatedDate(entity.getUpdatedDate());
|
||||
}
|
||||
|
||||
|
||||
private void setCriteriaResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List<EvaluationCriteriaEntity> evaluationCriterias) {
|
||||
List<CriteriaResponse> criteriaResponsesFromEntity = entity.getCriteria() != null
|
||||
? Utils.convertJsonToList(entity.getCriteria(), new TypeReference<List<CriteriaResponse>>() {
|
||||
})
|
||||
: new ArrayList<>();
|
||||
|
||||
List<CriteriaResponse> criteriaResponsesFromEntity = entity.getCriteria() != null ?
|
||||
Utils.convertJsonToList(entity.getCriteria(), new TypeReference<List<CriteriaResponse>>() {
|
||||
}) :
|
||||
new ArrayList<>();
|
||||
|
||||
List<CriteriaResponse> criteriaResponsesFromDB = getCriteriaResponse(entity.getApplicationId());
|
||||
addMissingCriteriaResponses(criteriaResponsesFromEntity, criteriaResponsesFromDB, entity.getApplicationId());
|
||||
criteriaResponsesFromEntity.forEach(criteriaResponse -> {
|
||||
EvaluationCriteriaEntity matchingEvaluationCriteria = evaluationCriterias.stream()
|
||||
.filter(evaluationCriteria -> evaluationCriteria.getId().equals(criteriaResponse.getId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
.filter(evaluationCriteria -> evaluationCriteria.getId().equals(criteriaResponse.getId())).findFirst().orElse(null);
|
||||
|
||||
if (matchingEvaluationCriteria != null) {
|
||||
criteriaResponse.setLabel(matchingEvaluationCriteria.getLookupData().getValue());
|
||||
@@ -138,9 +155,8 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
private void addMissingCriteriaResponses(List<CriteriaResponse> criteriaResponsesFromEntity, List<CriteriaResponse> criteriaResponsesFromDB, Long applicationId) {
|
||||
Set<Long> existingCriteriaIds = criteriaResponsesFromEntity.stream()
|
||||
.map(CriteriaResponse::getId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<Long> existingCriteriaIds = criteriaResponsesFromEntity.stream().map(CriteriaResponse::getId).collect(Collectors.toSet());
|
||||
|
||||
for (CriteriaResponse dbResponse : criteriaResponsesFromDB) {
|
||||
if (!existingCriteriaIds.contains(dbResponse.getId())) {
|
||||
@@ -152,8 +168,8 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
private List<CriteriaMappedField> getMappedFieldsForCriteria(Long evaluationCriteriaId, Long applicationId) {
|
||||
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository
|
||||
.findByEvaluationCriteriaIdAndIsDeletedFalse(evaluationCriteriaId);
|
||||
|
||||
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository.findByEvaluationCriteriaIdAndIsDeletedFalse(evaluationCriteriaId);
|
||||
List<CriteriaMappedField> mappedFields = new ArrayList<>();
|
||||
|
||||
Set<String> uniqueFieldIds = new HashSet<>();
|
||||
@@ -170,25 +186,22 @@ public class ApplicationEvaluationDao {
|
||||
FormEntity formEntity = formRepository.findById(formField.getFormId()).orElse(null);
|
||||
if (formEntity != null) {
|
||||
List<ContentResponseBean> contentBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
contentBeans.stream()
|
||||
.filter(contentBean -> contentBean.getId().equals(formFieldId))
|
||||
.findFirst()
|
||||
.ifPresent(contentBean -> {
|
||||
String label = contentBean.getLabel();
|
||||
if (contentBean.getSettings() != null) {
|
||||
for (SettingResponseBean setting : contentBean.getSettings()) {
|
||||
if ("label".equals(setting.getName())) {
|
||||
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
contentBeans.stream().filter(contentBean -> contentBean.getId().equals(formFieldId)).findFirst().ifPresent(contentBean -> {
|
||||
String label = contentBean.getLabel();
|
||||
if (contentBean.getSettings() != null) {
|
||||
for (SettingResponseBean setting : contentBean.getSettings()) {
|
||||
if ("label".equals(setting.getName())) {
|
||||
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||
break;
|
||||
}
|
||||
mappedField.setFieldLabel(label);
|
||||
});
|
||||
}
|
||||
}
|
||||
mappedField.setFieldLabel(label);
|
||||
});
|
||||
}
|
||||
|
||||
Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
||||
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(formFieldId, applicationForm.getId(), applicationId);
|
||||
Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||
formFieldId, applicationForm.getId(), applicationId);
|
||||
|
||||
formFieldEntityOptional.ifPresent(field -> mappedField.setFieldValue(field.getFieldValue()));
|
||||
|
||||
@@ -201,19 +214,18 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
private void setChecklistResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List<CallTargetAudienceChecklistEntity> checklistEntities) {
|
||||
List<ChecklistResponse> checklistResponsesFromEntity = entity.getChecklist() != null
|
||||
? Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {
|
||||
})
|
||||
: new ArrayList<>();
|
||||
|
||||
List<ChecklistResponse> checklistResponsesFromEntity = entity.getChecklist() != null ?
|
||||
Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {
|
||||
}) :
|
||||
new ArrayList<>();
|
||||
|
||||
List<ChecklistResponse> checklistResponsesFromDB = getChecklistResponse(entity.getApplicationId());
|
||||
addMissingChecklistResponses(checklistResponsesFromEntity, checklistResponsesFromDB);
|
||||
|
||||
checklistResponsesFromEntity.forEach(checklistResponse -> {
|
||||
CallTargetAudienceChecklistEntity matchingChecklist = checklistEntities.stream()
|
||||
.filter(checklistEntity -> checklistEntity.getId().equals(checklistResponse.getId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
CallTargetAudienceChecklistEntity matchingChecklist = checklistEntities.stream().filter(checklistEntity -> checklistEntity.getId().equals(checklistResponse.getId()))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
if (matchingChecklist != null) {
|
||||
checklistResponse.setLabel(matchingChecklist.getLookupData().getValue());
|
||||
@@ -224,9 +236,8 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
private void addMissingChecklistResponses(List<ChecklistResponse> checklistResponsesFromEntity, List<ChecklistResponse> checklistResponsesFromDB) {
|
||||
Set<Long> existingChecklistIds = checklistResponsesFromEntity.stream()
|
||||
.map(ChecklistResponse::getId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<Long> existingChecklistIds = checklistResponsesFromEntity.stream().map(ChecklistResponse::getId).collect(Collectors.toSet());
|
||||
|
||||
for (ChecklistResponse dbResponse : checklistResponsesFromDB) {
|
||||
if (!existingChecklistIds.contains(dbResponse.getId())) {
|
||||
@@ -236,10 +247,9 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
private void setFieldResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List<ApplicationFormEntity> applicationFormEntities) {
|
||||
List<FieldResponse> fieldResponsesFromEntity = entity.getFile() != null
|
||||
? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {
|
||||
})
|
||||
: new ArrayList<>();
|
||||
|
||||
List<FieldResponse> fieldResponsesFromEntity = entity.getFile() != null ? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {
|
||||
}) : new ArrayList<>();
|
||||
List<FieldResponse> fieldResponsesFromDB = getFieldResponses(entity.getApplicationId());
|
||||
addMissingFieldResponses(fieldResponsesFromEntity, fieldResponsesFromDB);
|
||||
|
||||
@@ -267,10 +277,9 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
fieldResponse.setLabel(label);
|
||||
|
||||
Optional<ApplicationFormFieldEntity> optionalFormField = applicationFormFieldRepository
|
||||
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||
fieldResponse.getId(), applicationForm.getId(), entity.getApplicationId()
|
||||
);
|
||||
Optional<ApplicationFormFieldEntity> optionalFormField =
|
||||
applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||
fieldResponse.getId(), applicationForm.getId(), entity.getApplicationId());
|
||||
|
||||
if (optionalFormField.isPresent()) {
|
||||
ApplicationFormFieldEntity formField = optionalFormField.get();
|
||||
@@ -307,9 +316,8 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
private void addMissingFieldResponses(List<FieldResponse> fieldResponsesFromEntity, List<FieldResponse> fieldResponsesFromDB) {
|
||||
Set<String> existingFieldIds = fieldResponsesFromEntity.stream()
|
||||
.map(FieldResponse::getId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<String> existingFieldIds = fieldResponsesFromEntity.stream().map(FieldResponse::getId).collect(Collectors.toSet());
|
||||
|
||||
for (FieldResponse dbResponse : fieldResponsesFromDB) {
|
||||
if (!existingFieldIds.contains(dbResponse.getId())) {
|
||||
@@ -319,6 +327,7 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
private void setApplicationDetails(ApplicationEvaluationResponse response, ApplicationEvaluationEntity entity) {
|
||||
|
||||
ApplicationEntity application = applicationService.validateApplication(entity.getApplicationId() != null ? entity.getApplicationId() : null);
|
||||
UserEntity user = userService.validateUser(application.getUserId());
|
||||
|
||||
@@ -329,16 +338,16 @@ public class ApplicationEvaluationDao {
|
||||
String beneficiary = String.join(" ", firstName, lastName).trim();
|
||||
response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus()));
|
||||
response.setBeneficiary(beneficiary);
|
||||
response.setMinScore(call.getThreshold()!=null?call.getThreshold():null);
|
||||
response.setCallName(application.getCall().getName()!=null?application.getCall().getName():null);
|
||||
response.setMinScore(call.getThreshold() != null ? call.getThreshold() : null);
|
||||
response.setCallName(application.getCall().getName() != null ? application.getCall().getName() : null);
|
||||
response.setProtocolNumber(application.getProtocol() != null ? application.getProtocol().getProtocolNumber() : null);
|
||||
response.setSubmissionDate(application.getSubmissionDate() != null ? application.getSubmissionDate() : null);
|
||||
response.setEvaluationDate(application.getSubmissionDate() != null ? application.getSubmissionDate().plusDays(30) : null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
|
||||
|
||||
Optional<ApplicationEvaluationEntity> existingEntityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplciationId);
|
||||
ApplicationEvaluationEntity entity;
|
||||
|
||||
@@ -358,189 +367,157 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
private List<ChecklistRequest> filterNonNullChecklist(List<ChecklistRequest> checklistRequests) {
|
||||
return checklistRequests.stream()
|
||||
.filter(request -> request.getValid() != null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return checklistRequests.stream().filter(request -> request.getValid() != null).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<CriteriaRequest> filterNonNullCriteria(List<CriteriaRequest> criteriaRequests) {
|
||||
return criteriaRequests.stream()
|
||||
.filter(request -> request.getScore() != null && request.getValid() != null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return criteriaRequests.stream().filter(request -> request.getScore() != null && request.getValid() != null).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<FieldRequest> filterNonNullFields(List<FieldRequest> fieldRequests) {
|
||||
return fieldRequests.stream()
|
||||
.filter(request -> request.getValid() != null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return fieldRequests.stream().filter(request -> request.getValid() != null).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<CriteriaRequest> processCriteria(ApplicationEvaluationEntity entity, ApplicationEvaluationRequest req) {
|
||||
List<CriteriaResponse> existingCriteriaList = entity.getCriteria() != null
|
||||
? Utils.convertJsonToList(entity.getCriteria(), new TypeReference<List<CriteriaResponse>>() {
|
||||
})
|
||||
: new ArrayList<>();
|
||||
|
||||
Map<Long, CriteriaResponse> existingCriteriaMap = existingCriteriaList.stream()
|
||||
.collect(Collectors.toMap(CriteriaResponse::getId, criteria -> criteria));
|
||||
List<CriteriaResponse> existingCriteriaList = entity.getCriteria() != null ? Utils.convertJsonToList(entity.getCriteria(), new TypeReference<List<CriteriaResponse>>() {
|
||||
}) : new ArrayList<>();
|
||||
|
||||
List<CriteriaRequest> updatedCriteriaList = req.getCriteria().stream()
|
||||
.map(incoming -> {
|
||||
CriteriaRequest request = new CriteriaRequest();
|
||||
request.setId(incoming.getId());
|
||||
request.setScore(incoming.getScore());
|
||||
request.setValid(incoming.getValid());
|
||||
Map<Long, CriteriaResponse> existingCriteriaMap = existingCriteriaList.stream().collect(Collectors.toMap(CriteriaResponse::getId, criteria -> criteria));
|
||||
|
||||
CriteriaResponse existingCriteria = existingCriteriaMap.get(incoming.getId());
|
||||
if (existingCriteria != null) {
|
||||
request.setScore(incoming.getScore() != null ? incoming.getScore() : null);
|
||||
request.setValid(incoming.getValid() != null ? incoming.getValid() : null);
|
||||
}
|
||||
return request;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
List<CriteriaRequest> updatedCriteriaList = req.getCriteria().stream().map(incoming -> {
|
||||
CriteriaRequest request = new CriteriaRequest();
|
||||
request.setId(incoming.getId());
|
||||
request.setScore(incoming.getScore());
|
||||
request.setValid(incoming.getValid());
|
||||
|
||||
CriteriaResponse existingCriteria = existingCriteriaMap.get(incoming.getId());
|
||||
if (existingCriteria != null) {
|
||||
request.setScore(incoming.getScore() != null ? incoming.getScore() : null);
|
||||
request.setValid(incoming.getValid() != null ? incoming.getValid() : null);
|
||||
}
|
||||
return request;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
List<CriteriaRequest> missingCriteriaRequests = existingCriteriaList.stream()
|
||||
.filter(existing -> !updatedCriteriaList.stream()
|
||||
.map(CriteriaRequest::getId)
|
||||
.toList()
|
||||
.contains(existing.getId()))
|
||||
.map(existing -> {
|
||||
.filter(existing -> !updatedCriteriaList.stream().map(CriteriaRequest::getId).toList().contains(existing.getId())).map(existing -> {
|
||||
CriteriaRequest request = new CriteriaRequest();
|
||||
request.setId(existing.getId());
|
||||
request.setScore(existing.getScore());
|
||||
request.setValid(existing.getValid());
|
||||
return request;
|
||||
})
|
||||
.toList();
|
||||
}).toList();
|
||||
|
||||
updatedCriteriaList.addAll(missingCriteriaRequests);
|
||||
return updatedCriteriaList;
|
||||
}
|
||||
|
||||
private List<ChecklistRequest> processChecklist(ApplicationEvaluationEntity entity, ApplicationEvaluationRequest req) {
|
||||
List<ChecklistResponse> existingChecklistList = entity.getChecklist() != null
|
||||
? Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {
|
||||
})
|
||||
: new ArrayList<>();
|
||||
|
||||
Map<Long, ChecklistResponse> existingChecklistMap = existingChecklistList.stream()
|
||||
.collect(Collectors.toMap(ChecklistResponse::getId, checklist -> checklist));
|
||||
List<ChecklistResponse> existingChecklistList = entity.getChecklist() != null ?
|
||||
Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {
|
||||
}) :
|
||||
new ArrayList<>();
|
||||
|
||||
List<ChecklistRequest> updatedChecklistList = req.getChecklist().stream()
|
||||
.map(incoming -> {
|
||||
ChecklistRequest request = new ChecklistRequest();
|
||||
request.setId(incoming.getId());
|
||||
request.setValid(incoming.getValid());
|
||||
Map<Long, ChecklistResponse> existingChecklistMap = existingChecklistList.stream().collect(Collectors.toMap(ChecklistResponse::getId, checklist -> checklist));
|
||||
|
||||
ChecklistResponse existingChecklist = existingChecklistMap.get(incoming.getId());
|
||||
if (existingChecklist != null && incoming.getValid() == null) {
|
||||
request.setValid(null);
|
||||
}
|
||||
return request;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
List<ChecklistRequest> updatedChecklistList = req.getChecklist().stream().map(incoming -> {
|
||||
ChecklistRequest request = new ChecklistRequest();
|
||||
request.setId(incoming.getId());
|
||||
request.setValid(incoming.getValid());
|
||||
|
||||
ChecklistResponse existingChecklist = existingChecklistMap.get(incoming.getId());
|
||||
if (existingChecklist != null && incoming.getValid() == null) {
|
||||
request.setValid(null);
|
||||
}
|
||||
return request;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
List<ChecklistRequest> missingChecklistRequests = existingChecklistList.stream()
|
||||
.filter(existing -> !updatedChecklistList.stream()
|
||||
.map(ChecklistRequest::getId)
|
||||
.toList()
|
||||
.contains(existing.getId()))
|
||||
.map(existing -> {
|
||||
.filter(existing -> !updatedChecklistList.stream().map(ChecklistRequest::getId).toList().contains(existing.getId())).map(existing -> {
|
||||
ChecklistRequest request = new ChecklistRequest();
|
||||
request.setId(existing.getId());
|
||||
request.setValid(existing.getValid() != null ? existing.getValid() : null);
|
||||
return request;
|
||||
})
|
||||
.toList();
|
||||
}).toList();
|
||||
|
||||
updatedChecklistList.addAll(missingChecklistRequests);
|
||||
return updatedChecklistList;
|
||||
}
|
||||
|
||||
private List<FieldRequest> processField(ApplicationEvaluationEntity entity, ApplicationEvaluationRequest req) {
|
||||
List<FieldResponse> existingFieldList = entity.getFile() != null
|
||||
? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {
|
||||
})
|
||||
: new ArrayList<>();
|
||||
|
||||
Map<String, FieldResponse> existingFieldMap = existingFieldList.stream()
|
||||
.collect(Collectors.toMap(FieldResponse::getId, field -> field));
|
||||
List<FieldResponse> existingFieldList = entity.getFile() != null ? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {
|
||||
}) : new ArrayList<>();
|
||||
|
||||
List<FieldRequest> updatedFieldList = req.getFiles().stream()
|
||||
.map(incoming -> {
|
||||
FieldRequest request = new FieldRequest();
|
||||
request.setId(incoming.getId());
|
||||
request.setValid(incoming.getValid());
|
||||
Map<String, FieldResponse> existingFieldMap = existingFieldList.stream().collect(Collectors.toMap(FieldResponse::getId, field -> field));
|
||||
|
||||
FieldResponse existingField = existingFieldMap.get(incoming.getId());
|
||||
if (existingField != null) {
|
||||
request.setValid(incoming.getValid() != null ? incoming.getValid() : null);
|
||||
}
|
||||
return request;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
List<FieldRequest> updatedFieldList = req.getFiles().stream().map(incoming -> {
|
||||
FieldRequest request = new FieldRequest();
|
||||
request.setId(incoming.getId());
|
||||
request.setValid(incoming.getValid());
|
||||
|
||||
FieldResponse existingField = existingFieldMap.get(incoming.getId());
|
||||
if (existingField != null) {
|
||||
request.setValid(incoming.getValid() != null ? incoming.getValid() : null);
|
||||
}
|
||||
return request;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
List<FieldRequest> missingFieldRequests = existingFieldList.stream()
|
||||
.filter(existing -> !updatedFieldList.stream()
|
||||
.map(FieldRequest::getId)
|
||||
.toList()
|
||||
.contains(existing.getId()))
|
||||
.map(existing -> {
|
||||
.filter(existing -> !updatedFieldList.stream().map(FieldRequest::getId).toList().contains(existing.getId())).map(existing -> {
|
||||
FieldRequest request = new FieldRequest();
|
||||
request.setId(existing.getId());
|
||||
request.setValid(existing.getValid());
|
||||
return request;
|
||||
})
|
||||
.toList();
|
||||
}).toList();
|
||||
|
||||
updatedFieldList.addAll(missingFieldRequests);
|
||||
return updatedFieldList;
|
||||
}
|
||||
|
||||
public ApplicationEvaluationEntity validateApplicationEvaluation(Long id) {
|
||||
|
||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(id);
|
||||
if (entityOptional.isEmpty()) {
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.APPLICATION_EVALUATION_NOT_FOUND, id));
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.APPLICATION_EVALUATION_NOT_FOUND, id));
|
||||
}
|
||||
return entityOptional.get();
|
||||
}
|
||||
|
||||
|
||||
public List<ApplicationEvaluationResponse> getApplicationEvaluationByApplicationId(UserEntity user, Long applicationId, Long assignedApplicationId) {
|
||||
|
||||
if (applicationId != null && assignedApplicationId == null) {
|
||||
applicationService.validateApplication(applicationId);
|
||||
List<ApplicationEvaluationEntity> evaluationEntities = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
|
||||
return evaluationEntities.stream()
|
||||
.map(this::convertToResponse)
|
||||
.collect(Collectors.toList());
|
||||
return evaluationEntities.stream().map(this::convertToResponse).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Optional<ApplicationEvaluationEntity> entityOptional =
|
||||
(applicationId != null && assignedApplicationId != null)
|
||||
? applicationEvaluationRepository.findByApplicationIdAndAssignedApplicationsEntity_IdAndIsDeletedFalse(applicationId, assignedApplicationId)
|
||||
: applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId);
|
||||
Optional<ApplicationEvaluationEntity> entityOptional = (applicationId != null && assignedApplicationId != null) ?
|
||||
applicationEvaluationRepository.findByApplicationIdAndAssignedApplicationsEntity_IdAndIsDeletedFalse(applicationId, assignedApplicationId) :
|
||||
applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId);
|
||||
|
||||
return entityOptional
|
||||
.map(entity -> Collections.singletonList(convertToResponse(entity)))
|
||||
return entityOptional.map(entity -> Collections.singletonList(convertToResponse(entity)))
|
||||
.orElseGet(() -> Collections.singletonList(getEvaluationResponseByApplicationid(user, applicationId, assignedApplicationId)));
|
||||
}
|
||||
|
||||
|
||||
public ApplicationEvaluationResponse getEvaluationResponseByApplicationid(UserEntity user, Long applicationId, Long assignedApplicationId) {
|
||||
|
||||
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
||||
ApplicationEvaluationResponse response = new ApplicationEvaluationResponse();
|
||||
CallEntity call = null;
|
||||
ApplicationEntity application=null;
|
||||
ApplicationEntity application = null;
|
||||
AssignedApplicationsEntity assignedApplications = null;
|
||||
if (applicationId != null && assignedApplicationId==null) {
|
||||
if (applicationId != null && assignedApplicationId == null) {
|
||||
application = applicationService.validateApplication(applicationId);
|
||||
call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||
assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId).orElse(null);
|
||||
} else if (assignedApplicationId != null) {
|
||||
assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationId).orElseThrow(() ->
|
||||
new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_MSG)));
|
||||
assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationId)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_MSG)));
|
||||
application = applicationService.validateApplication(assignedApplications.getApplication().getId());
|
||||
call = callRepository.findCallEntityByApplicationId(application.getId());
|
||||
|
||||
@@ -556,7 +533,7 @@ public class ApplicationEvaluationDao {
|
||||
response.setNote(null);
|
||||
response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus()));
|
||||
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(ApplicationEvaluationStatusTypeEnum.OPEN.getValue()));
|
||||
response.setMinScore(call.getThreshold()!=null?call.getThreshold():null);
|
||||
response.setMinScore(call.getThreshold() != null ? call.getThreshold() : null);
|
||||
setCriteriaResponses(entity, application.getId(), response, evaluationCriterias);
|
||||
setChecklistResponses(entity, application.getId(), response, checklistEntities);
|
||||
setFileResponses(entity, application.getId(), response, applicationFormEntities);
|
||||
@@ -566,17 +543,15 @@ public class ApplicationEvaluationDao {
|
||||
return response;
|
||||
}
|
||||
|
||||
private void setCriteriaResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response, List<EvaluationCriteriaEntity> evaluationCriterias) {
|
||||
List<CriteriaResponse> criteriaResponses = entity.getCriteria() != null
|
||||
? Utils.convertJsonToList(entity.getCriteria(), new TypeReference<List<CriteriaResponse>>() {
|
||||
})
|
||||
: getCriteriaResponse(applicationId);
|
||||
private void setCriteriaResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response,
|
||||
List<EvaluationCriteriaEntity> evaluationCriterias) {
|
||||
|
||||
List<CriteriaResponse> criteriaResponses = entity.getCriteria() != null ? Utils.convertJsonToList(entity.getCriteria(), new TypeReference<List<CriteriaResponse>>() {
|
||||
}) : getCriteriaResponse(applicationId);
|
||||
|
||||
criteriaResponses.forEach(criteriaResponse -> {
|
||||
EvaluationCriteriaEntity matchingEvaluationCriteria = evaluationCriterias.stream()
|
||||
.filter(evaluationCriteria -> evaluationCriteria.getId().equals(criteriaResponse.getId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
.filter(evaluationCriteria -> evaluationCriteria.getId().equals(criteriaResponse.getId())).findFirst().orElse(null);
|
||||
|
||||
List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(applicationId);
|
||||
Map<String, CriteriaMappedField> mappedFieldMap = new HashMap<>();
|
||||
@@ -585,8 +560,7 @@ public class ApplicationEvaluationDao {
|
||||
criteriaResponse.setLabel(matchingEvaluationCriteria.getLookupData().getValue());
|
||||
criteriaResponse.setMaxScore(matchingEvaluationCriteria.getScore());
|
||||
|
||||
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository
|
||||
.findByEvaluationCriteriaIdAndIsDeletedFalse(matchingEvaluationCriteria.getId());
|
||||
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository.findByEvaluationCriteriaIdAndIsDeletedFalse(matchingEvaluationCriteria.getId());
|
||||
|
||||
for (ApplicationFormEntity applicationForm : applicationForms) {
|
||||
for (CriteriaFormFieldEntity criteriaFormField : criteriaFormFields) {
|
||||
@@ -598,24 +572,22 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
if (formEntity != null) {
|
||||
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
contentResponseBeans.stream()
|
||||
.filter(bean -> bean.getId().equals(formFieldId))
|
||||
.findFirst()
|
||||
.ifPresent(contentResponseBean -> {
|
||||
String label = contentResponseBean.getLabel();
|
||||
if (contentResponseBean.getSettings() != null) {
|
||||
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||
if ("label".equals(setting.getName())) {
|
||||
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
contentResponseBeans.stream().filter(bean -> bean.getId().equals(formFieldId)).findFirst().ifPresent(contentResponseBean -> {
|
||||
String label = contentResponseBean.getLabel();
|
||||
if (contentResponseBean.getSettings() != null) {
|
||||
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||
if ("label".equals(setting.getName())) {
|
||||
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||
break;
|
||||
}
|
||||
mappedField.setFieldLabel(label);
|
||||
});
|
||||
}
|
||||
}
|
||||
mappedField.setFieldLabel(label);
|
||||
});
|
||||
}
|
||||
Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
||||
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(formFieldId, applicationForm.getId(), applicationId);
|
||||
Optional<ApplicationFormFieldEntity> formFieldEntityOptional =
|
||||
applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||
formFieldId, applicationForm.getId(), applicationId);
|
||||
|
||||
formFieldEntityOptional.ifPresent(formField -> mappedField.setFieldValue(formField.getFieldValue()));
|
||||
mappedFieldMap.put(formFieldId, mappedField);
|
||||
@@ -629,17 +601,15 @@ public class ApplicationEvaluationDao {
|
||||
response.setCriteria(criteriaResponses);
|
||||
}
|
||||
|
||||
private void setChecklistResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response, List<CallTargetAudienceChecklistEntity> checklistEntities) {
|
||||
List<ChecklistResponse> checklistResponses = entity.getChecklist() != null
|
||||
? Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {
|
||||
})
|
||||
: getChecklistResponse(applicationId);
|
||||
private void setChecklistResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response,
|
||||
List<CallTargetAudienceChecklistEntity> checklistEntities) {
|
||||
|
||||
List<ChecklistResponse> checklistResponses = entity.getChecklist() != null ? Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {
|
||||
}) : getChecklistResponse(applicationId);
|
||||
|
||||
checklistResponses.forEach(checklistResponse -> {
|
||||
CallTargetAudienceChecklistEntity matchingChecklist = checklistEntities.stream()
|
||||
.filter(checklistEntity -> checklistEntity.getId().equals(checklistResponse.getId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
CallTargetAudienceChecklistEntity matchingChecklist = checklistEntities.stream().filter(checklistEntity -> checklistEntity.getId().equals(checklistResponse.getId()))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
if (matchingChecklist != null) {
|
||||
checklistResponse.setLabel(matchingChecklist.getLookupData().getValue());
|
||||
@@ -649,11 +619,11 @@ public class ApplicationEvaluationDao {
|
||||
response.setChecklist(checklistResponses);
|
||||
}
|
||||
|
||||
private void setFileResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response, List<ApplicationFormEntity> applicationFormEntities) {
|
||||
List<FieldResponse> fieldResponses = entity.getFile() != null
|
||||
? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {
|
||||
})
|
||||
: getFieldResponses(applicationId);
|
||||
private void setFileResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response,
|
||||
List<ApplicationFormEntity> applicationFormEntities) {
|
||||
|
||||
List<FieldResponse> fieldResponses = entity.getFile() != null ? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {
|
||||
}) : getFieldResponses(applicationId);
|
||||
Set<String> processedFieldIds = new HashSet<>();
|
||||
|
||||
fieldResponses.forEach(fieldResponse -> {
|
||||
@@ -678,8 +648,9 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
fieldResponse.setLabel(label);
|
||||
|
||||
Optional<ApplicationFormFieldEntity> optionalFormField = applicationFormFieldRepository
|
||||
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(fieldResponse.getId(), applicationForm.getId(), applicationId);
|
||||
Optional<ApplicationFormFieldEntity> optionalFormField =
|
||||
applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||
fieldResponse.getId(), applicationForm.getId(), applicationId);
|
||||
|
||||
if (optionalFormField.isPresent() && optionalFormField.get().getFieldValue() != null) {
|
||||
String[] documentIds = optionalFormField.get().getFieldValue().split(",");
|
||||
@@ -715,8 +686,8 @@ public class ApplicationEvaluationDao {
|
||||
response.setFiles(fieldResponses);
|
||||
}
|
||||
|
||||
|
||||
private void setApplicationDetails(ApplicationEvaluationResponse response, Long applicationId, UserEntity user) {
|
||||
|
||||
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
||||
userService.validateUser(application.getUserId());
|
||||
String firstName = user.getFirstName() != null ? user.getFirstName() : "";
|
||||
@@ -725,7 +696,7 @@ public class ApplicationEvaluationDao {
|
||||
String beneficiary = String.join(" ", firstName, lastName).trim();
|
||||
response.setBeneficiary(beneficiary);
|
||||
|
||||
response.setCallName(application.getCall().getName()!=null?application.getCall().getName():null);
|
||||
response.setCallName(application.getCall().getName() != null ? application.getCall().getName() : null);
|
||||
response.setProtocolNumber(application.getProtocol() != null ? application.getProtocol().getProtocolNumber() : null);
|
||||
response.setSubmissionDate(application.getSubmissionDate() != null ? application.getSubmissionDate() : null);
|
||||
response.setEvaluationDate(application.getSubmissionDate() != null ? application.getSubmissionDate().plusDays(30) : null);
|
||||
@@ -733,6 +704,7 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
List<CriteriaResponse> getCriteriaResponse(Long applicationId) {
|
||||
|
||||
CallEntity call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||
List<EvaluationCriteriaEntity> evaluationCriterias = evaluationCriteriaRepository.findByCallId(call.getId());
|
||||
|
||||
@@ -744,8 +716,7 @@ public class ApplicationEvaluationDao {
|
||||
response.setMaxScore(criteria.getScore());
|
||||
response.setValid(null);
|
||||
|
||||
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository
|
||||
.findByEvaluationCriteriaIdAndIsDeletedFalse(criteria.getId());
|
||||
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository.findByEvaluationCriteriaIdAndIsDeletedFalse(criteria.getId());
|
||||
|
||||
List<CriteriaMappedField> mappedFields = new ArrayList<>();
|
||||
Set<String> processedFormFieldIds = new HashSet<>();
|
||||
@@ -760,32 +731,24 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
FormEntity formEntity = formRepository.findById(criteriaFormField.getFormId()).orElse(null);
|
||||
if (formEntity != null) {
|
||||
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(
|
||||
formEntity.getContent(), ContentResponseBean.class);
|
||||
contentResponseBeans.stream()
|
||||
.filter(bean -> bean.getId().equals(criteriaFormField.getFormFieldId()))
|
||||
.findFirst()
|
||||
.ifPresent(contentResponseBean -> {
|
||||
String label = contentResponseBean.getLabel();
|
||||
if (contentResponseBean.getSettings() != null) {
|
||||
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||
if ("label".equals(setting.getName())) {
|
||||
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
contentResponseBeans.stream().filter(bean -> bean.getId().equals(criteriaFormField.getFormFieldId())).findFirst().ifPresent(contentResponseBean -> {
|
||||
String label = contentResponseBean.getLabel();
|
||||
if (contentResponseBean.getSettings() != null) {
|
||||
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||
if ("label".equals(setting.getName())) {
|
||||
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||
break;
|
||||
}
|
||||
mappedField.setFieldLabel(label);
|
||||
});
|
||||
}
|
||||
}
|
||||
mappedField.setFieldLabel(label);
|
||||
});
|
||||
}
|
||||
|
||||
applicationFormRepository.findByApplicationId(applicationId).stream()
|
||||
.flatMap(applicationForm -> applicationFormFieldRepository
|
||||
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||
criteriaFormField.getFormFieldId(), applicationForm.getId(), applicationId)
|
||||
.stream())
|
||||
.findFirst()
|
||||
.ifPresent(formField -> mappedField.setFieldValue(formField.getFieldValue()));
|
||||
applicationFormRepository.findByApplicationId(applicationId).stream().flatMap(
|
||||
applicationForm -> applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(criteriaFormField.getFormFieldId(),
|
||||
applicationForm.getId(), applicationId).stream()).findFirst().ifPresent(formField -> mappedField.setFieldValue(formField.getFieldValue()));
|
||||
|
||||
mappedFields.add(mappedField);
|
||||
processedFormFieldIds.add(criteriaFormField.getFormFieldId());
|
||||
@@ -799,6 +762,7 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
List<ChecklistResponse> getChecklistResponse(Long applicationId) {
|
||||
|
||||
CallEntity call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||
List<CallTargetAudienceChecklistEntity> checklistEntities = callTargetAudienceChecklistRepository.findByCallId(call.getId());
|
||||
List<ChecklistResponse> checklistResponses = checklistEntities.stream().map(checklist -> {
|
||||
@@ -814,6 +778,7 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
public List<FieldResponse> getFieldResponses(Long applicationId) {
|
||||
|
||||
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(applicationId);
|
||||
List<FieldResponse> fieldResponses = new ArrayList<>();
|
||||
|
||||
@@ -828,8 +793,8 @@ public class ApplicationEvaluationDao {
|
||||
String fieldId = contentResponseBean.getId();
|
||||
Long applicationFormId = applicationForm.getId();
|
||||
|
||||
Optional<ApplicationFormFieldEntity> optionalFormField = applicationFormFieldRepository
|
||||
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(fieldId, applicationFormId, applicationId);
|
||||
Optional<ApplicationFormFieldEntity> optionalFormField = applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||
fieldId, applicationFormId, applicationId);
|
||||
|
||||
if (optionalFormField.isPresent()) {
|
||||
ApplicationFormFieldEntity formField = optionalFormField.get();
|
||||
@@ -881,33 +846,43 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
public void deleteById(Long id) {
|
||||
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = validateApplicationEvaluation(id);
|
||||
applicationEvaluationEntity.setIsDeleted(true);
|
||||
applicationEvaluationEntity = saveApplicationEvaluationEntity(applicationEvaluationEntity);
|
||||
}
|
||||
|
||||
public ApplicationEvaluationEntity saveApplicationEvaluationEntity(ApplicationEvaluationEntity applicationEvaluationEntityData) {
|
||||
|
||||
return applicationEvaluationRepository.save(applicationEvaluationEntityData);
|
||||
}
|
||||
|
||||
public ApplicationEvaluationResponse updateApplicationEvaluationStatus(ApplicationEntity application, AssignedApplicationsEntity assignedApplicationsEntity) {
|
||||
Optional<ApplicationEvaluationEntity> existingEntityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationsEntity.getId());
|
||||
ApplicationEvaluationEntity entity = null;
|
||||
|
||||
Optional<ApplicationEvaluationEntity> existingEntityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(
|
||||
assignedApplicationsEntity.getId());
|
||||
ApplicationEvaluationEntity entity;
|
||||
|
||||
String statusType = application.getStatus();
|
||||
if (existingEntityOptional.isPresent()) {
|
||||
ApplicationEvaluationEntity existingEntity = existingEntityOptional.get();
|
||||
if (Boolean.TRUE.equals(
|
||||
application.getStatus().equals(ApplicationStatusTypeEnum.APPROVED.getValue()) ||
|
||||
application.getStatus().equals(ApplicationStatusTypeEnum.REJECTED.getValue())
|
||||
)) {
|
||||
if (Boolean.TRUE.equals(application.getStatus().equals(ApplicationStatusTypeEnum.APPROVED.getValue()) || application.getStatus()
|
||||
.equals(ApplicationStatusTypeEnum.REJECTED.getValue()))) {
|
||||
existingEntity.setStatus(ApplicationEvaluationStatusTypeEnum.CLOSE.getValue());
|
||||
assignedApplicationsEntity.setStatus(AssignedApplicationEnum.CLOSE.getValue());
|
||||
} entity = applicationEvaluationRepository.save(existingEntity);
|
||||
assignedApplicationsEntity=assignedApplicationsRepository.save(assignedApplicationsEntity);
|
||||
|
||||
return convertToResponse(entity);}return null;
|
||||
|
||||
|
||||
}
|
||||
entity = applicationEvaluationRepository.save(existingEntity);
|
||||
assignedApplicationsRepository.save(assignedApplicationsEntity);
|
||||
ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRequestRepository.findByApplicationEvaluationIdAndIsDeletedFalse(existingEntity.getId());
|
||||
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.APPROVED.getValue())))) {
|
||||
emailNotificationDao.sendAdmissibilityNotificationEmailForApprovedApplication(amendmentRequest);
|
||||
}
|
||||
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.REJECTED.getValue())))) {
|
||||
emailNotificationDao.sendInadmissibilityEmailForRejectedApplication(amendmentRequest);
|
||||
}
|
||||
return convertToResponse(entity);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user