Added an get API for application evaluation form
This commit is contained in:
@@ -136,6 +136,9 @@ public class ApplicationEvaluationDao {
|
||||
@Autowired
|
||||
private CallDao callDao;
|
||||
|
||||
@Autowired
|
||||
private EvaluationFormRepository evaluationFormRepository;
|
||||
|
||||
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
|
||||
|
||||
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
||||
@@ -2132,5 +2135,57 @@ public class ApplicationEvaluationDao {
|
||||
response.setUpdatedDate(entity.getUpdatedDate());
|
||||
return response;
|
||||
}
|
||||
|
||||
public ApplicationEvaluationFormResponse getApplicationEvaluationForm(HttpServletRequest request, Long applicationId, Long assignedApplicationId ){
|
||||
|
||||
if (applicationId == null && assignedApplicationId == null) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.EITHER_APPLICATION_ID_OR_ASSIGNED_APPLICATION_ID_MUST_BE_PROVIDED));
|
||||
}
|
||||
|
||||
ApplicationEvaluationEntity evaluationEntity = applicationEvaluationRepository.findByApplicationIdAndAssignedApplicationId(applicationId, assignedApplicationId);
|
||||
|
||||
return (evaluationEntity != null) ? processEvaluationForm(evaluationEntity) : null;
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormResponse processEvaluationForm(ApplicationEvaluationEntity evaluationEntity){
|
||||
ApplicationEvaluationFormResponse response = new ApplicationEvaluationFormResponse();
|
||||
response.setApplicationId(evaluationEntity.getApplicationId());
|
||||
response.setNote(evaluationEntity.getNote());
|
||||
response.setStatus(evaluationEntity.getStatus());
|
||||
response.setAssignedApplicationId(evaluationEntity.getAssignedApplicationsEntity().getId());
|
||||
|
||||
EvaluationFormEntity evaluationFormEntity = evaluationFormRepository.findByCallIdAndIsDeletedFalse(evaluationEntity.getAssignedApplicationsEntity().getApplication().getCall().getId());
|
||||
|
||||
if (evaluationFormEntity != null) {
|
||||
response.setEvaluationFormId(evaluationFormEntity.getId());
|
||||
response.setApplicationEvaluationFormResponse(convertEvaluationFormToResponse(evaluationFormEntity, evaluationEntity));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormResponseBean convertEvaluationFormToResponse(EvaluationFormEntity evaluationForm, ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||
ApplicationEvaluationFormResponseBean applicationEvaluationFormResponseBean = createEvaluationFormResponse(evaluationForm);
|
||||
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = applicationEvaluationFormRepository.findByEvaluationIdAndEvaluationFormId(applicationEvaluationEntity.getId(), evaluationForm.getId());
|
||||
|
||||
if(applicationEvaluationFormEntity!=null) {
|
||||
List<ApplicationEvaluationFormFieldEntity> applicationEvaluationFormFieldEntities = applicationEvaluationFormFieldRepository.findByApplicationEvaluationFormId(applicationEvaluationFormEntity.getId());
|
||||
List<ApplicationEvaluationFormFieldReponseBean> evaluationFormFieldResponseBeans = createEvaluationFormFieldResponse(applicationEvaluationFormFieldEntities, applicationEvaluationFormEntity);
|
||||
applicationEvaluationFormResponseBean.setFormFields(evaluationFormFieldResponseBeans);
|
||||
}
|
||||
|
||||
return applicationEvaluationFormResponseBean;
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormResponseBean createEvaluationFormResponse(EvaluationFormEntity evaluationFormEntity) {
|
||||
ApplicationEvaluationFormResponseBean evaluationFormResponseBean = new ApplicationEvaluationFormResponseBean();
|
||||
evaluationFormResponseBean.setId(evaluationFormEntity.getId());
|
||||
evaluationFormResponseBean.setLabel(evaluationFormEntity.getLabel());
|
||||
evaluationFormResponseBean.setCallId(evaluationFormEntity.getCall().getId());
|
||||
evaluationFormResponseBean.setContent(evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent());
|
||||
return evaluationFormResponseBean;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,17 +21,13 @@ package net.gepafin.tendermanagement.dao;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class EvaluationFormDao {
|
||||
|
||||
@Autowired
|
||||
private EvalualtionFormRepository evaluationFormRepository;
|
||||
private EvaluationFormRepository evaluationFormRepository;
|
||||
|
||||
@Autowired
|
||||
private CallDao callDao;
|
||||
|
||||
Reference in New Issue
Block a user