Updated response
This commit is contained in:
@@ -5,7 +5,6 @@ import net.gepafin.tendermanagement.config.Translator;
|
|||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.entities.*;
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
|
||||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||||
@@ -22,7 +21,6 @@ import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -53,7 +51,11 @@ public class ApplicationEvaluationDao {
|
|||||||
private ApplicationFormRepository applicationFormRepository;
|
private ApplicationFormRepository applicationFormRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationFormFieldRepository applicationFormFieldRepository;
|
private ApplicationFormFieldRepository applicationFormFieldRepository;
|
||||||
@Autowired AssignedApplicationsRepository assignedApplicationsRepository;
|
@Autowired
|
||||||
|
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||||
|
@Autowired
|
||||||
|
private CriteriaFormFieldRepository criteriaFormFieldRepository;
|
||||||
|
|
||||||
|
|
||||||
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req,Long applicationId) {
|
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req,Long applicationId) {
|
||||||
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
||||||
@@ -67,7 +69,7 @@ public class ApplicationEvaluationDao {
|
|||||||
entity.setFile(Utils.convertObjectToJson(req.getField()));
|
entity.setFile(Utils.convertObjectToJson(req.getField()));
|
||||||
entity.setNote(req.getNote());
|
entity.setNote(req.getNote());
|
||||||
entity.setIsDeleted(false);
|
entity.setIsDeleted(false);
|
||||||
entity.setStatus(ApplicationEvaluationStatusTypeEnum.DRAFT.getValue());
|
entity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +108,7 @@ public class ApplicationEvaluationDao {
|
|||||||
: new ArrayList<>();
|
: new ArrayList<>();
|
||||||
|
|
||||||
List<CriteriaResponse> criteriaResponsesFromDB = getCriteriaResponse(entity.getApplicationId());
|
List<CriteriaResponse> criteriaResponsesFromDB = getCriteriaResponse(entity.getApplicationId());
|
||||||
addMissingCriteriaResponses(criteriaResponsesFromEntity, criteriaResponsesFromDB);
|
addMissingCriteriaResponses(criteriaResponsesFromEntity, criteriaResponsesFromDB,entity.getApplicationId());
|
||||||
|
|
||||||
criteriaResponsesFromEntity.forEach(criteriaResponse -> {
|
criteriaResponsesFromEntity.forEach(criteriaResponse -> {
|
||||||
EvaluationCriteriaEntity matchingEvaluationCriteria = evaluationCriterias.stream()
|
EvaluationCriteriaEntity matchingEvaluationCriteria = evaluationCriterias.stream()
|
||||||
.filter(evaluationCriteria -> evaluationCriteria.getId().equals(criteriaResponse.getId()))
|
.filter(evaluationCriteria -> evaluationCriteria.getId().equals(criteriaResponse.getId()))
|
||||||
@@ -117,23 +118,75 @@ public class ApplicationEvaluationDao {
|
|||||||
if (matchingEvaluationCriteria != null) {
|
if (matchingEvaluationCriteria != null) {
|
||||||
criteriaResponse.setLabel(matchingEvaluationCriteria.getLookupData().getValue());
|
criteriaResponse.setLabel(matchingEvaluationCriteria.getLookupData().getValue());
|
||||||
criteriaResponse.setMaxScore(matchingEvaluationCriteria.getScore());
|
criteriaResponse.setMaxScore(matchingEvaluationCriteria.getScore());
|
||||||
|
|
||||||
|
List<CriteriaMappedField> mappedFields = getMappedFieldsForCriteria(matchingEvaluationCriteria.getId(), entity.getApplicationId());
|
||||||
|
criteriaResponse.setCriteriaMappedFields(mappedFields);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
response.setCriteria(criteriaResponsesFromEntity);
|
response.setCriteria(criteriaResponsesFromEntity);
|
||||||
}
|
}
|
||||||
|
private void addMissingCriteriaResponses(List<CriteriaResponse> criteriaResponsesFromEntity, List<CriteriaResponse> criteriaResponsesFromDB,Long applicationId) {
|
||||||
private void addMissingCriteriaResponses(List<CriteriaResponse> criteriaResponsesFromEntity, List<CriteriaResponse> criteriaResponsesFromDB) {
|
|
||||||
Set<Long> existingCriteriaIds = criteriaResponsesFromEntity.stream()
|
Set<Long> existingCriteriaIds = criteriaResponsesFromEntity.stream()
|
||||||
.map(CriteriaResponse::getId)
|
.map(CriteriaResponse::getId)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
for (CriteriaResponse dbResponse : criteriaResponsesFromDB) {
|
for (CriteriaResponse dbResponse : criteriaResponsesFromDB) {
|
||||||
if (!existingCriteriaIds.contains(dbResponse.getId())) {
|
if (!existingCriteriaIds.contains(dbResponse.getId())) {
|
||||||
|
List<CriteriaMappedField> mappedFields = getMappedFieldsForCriteria(dbResponse.getId(), applicationId);
|
||||||
|
dbResponse.setCriteriaMappedFields(mappedFields);
|
||||||
criteriaResponsesFromEntity.add(dbResponse);
|
criteriaResponsesFromEntity.add(dbResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private List<CriteriaMappedField> getMappedFieldsForCriteria(Long evaluationCriteriaId, Long applicationId) {
|
||||||
|
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository
|
||||||
|
.findByEvaluationCriteriaIdAndIsDeletedFalse(evaluationCriteriaId);
|
||||||
|
List<CriteriaMappedField> mappedFields = new ArrayList<>();
|
||||||
|
|
||||||
|
Set<String> uniqueFieldIds = new HashSet<>();
|
||||||
|
|
||||||
|
List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(applicationId);
|
||||||
|
for (ApplicationFormEntity applicationForm : applicationForms) {
|
||||||
|
for (CriteriaFormFieldEntity formField : criteriaFormFields) {
|
||||||
|
String formFieldId = formField.getFormFieldId();
|
||||||
|
|
||||||
|
if (!uniqueFieldIds.contains(formFieldId)) {
|
||||||
|
CriteriaMappedField mappedField = new CriteriaMappedField();
|
||||||
|
mappedField.setId(formFieldId);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mappedField.setFieldLabel(label);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
||||||
|
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(formFieldId, applicationForm.getId(), applicationId);
|
||||||
|
|
||||||
|
formFieldEntityOptional.ifPresent(field -> mappedField.setFieldValue(field.getFieldValue()));
|
||||||
|
|
||||||
|
mappedFields.add(mappedField);
|
||||||
|
uniqueFieldIds.add(formFieldId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mappedFields;
|
||||||
|
}
|
||||||
|
|
||||||
private void setChecklistResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List<CallTargetAudienceChecklistEntity> checklistEntities) {
|
private void setChecklistResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List<CallTargetAudienceChecklistEntity> checklistEntities) {
|
||||||
List<ChecklistResponse> checklistResponsesFromEntity = entity.getChecklist() != null
|
List<ChecklistResponse> checklistResponsesFromEntity = entity.getChecklist() != null
|
||||||
@@ -173,24 +226,69 @@ public class ApplicationEvaluationDao {
|
|||||||
List<FieldResponse> fieldResponsesFromEntity = entity.getFile() != null
|
List<FieldResponse> fieldResponsesFromEntity = entity.getFile() != null
|
||||||
? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {})
|
? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {})
|
||||||
: new ArrayList<>();
|
: new ArrayList<>();
|
||||||
|
|
||||||
List<FieldResponse> fieldResponsesFromDB = getFieldResponses(entity.getApplicationId());
|
List<FieldResponse> fieldResponsesFromDB = getFieldResponses(entity.getApplicationId());
|
||||||
addMissingFieldResponses(fieldResponsesFromEntity, fieldResponsesFromDB);
|
addMissingFieldResponses(fieldResponsesFromEntity, fieldResponsesFromDB);
|
||||||
|
|
||||||
|
Set<String> processedFieldIds = new HashSet<>();
|
||||||
|
|
||||||
fieldResponsesFromEntity.forEach(fieldResponse -> {
|
fieldResponsesFromEntity.forEach(fieldResponse -> {
|
||||||
|
if (processedFieldIds.contains(fieldResponse.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
applicationFormEntities.forEach(applicationForm -> {
|
applicationFormEntities.forEach(applicationForm -> {
|
||||||
FormEntity formEntity = applicationForm.getForm();
|
FormEntity formEntity = applicationForm.getForm();
|
||||||
if (formEntity != null) {
|
if (formEntity != null) {
|
||||||
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||||
contentResponseBeans.forEach(contentResponseBean -> {
|
contentResponseBeans.forEach(contentResponseBean -> {
|
||||||
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) {
|
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) {
|
||||||
fieldResponse.setLabel(contentResponseBean.getLabel());
|
String label = null;
|
||||||
|
if (contentResponseBean.getSettings() != null) {
|
||||||
|
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||||
|
if ("label".equals(setting.getName())) {
|
||||||
|
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldResponse.setLabel(label);
|
||||||
|
|
||||||
|
Optional<ApplicationFormFieldEntity> optionalFormField = applicationFormFieldRepository
|
||||||
|
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||||
|
fieldResponse.getId(), applicationForm.getId(), entity.getApplicationId()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (optionalFormField.isPresent()) {
|
||||||
|
ApplicationFormFieldEntity formField = optionalFormField.get();
|
||||||
|
if (formField.getFieldValue() != null) {
|
||||||
|
String[] documentIds = formField.getFieldValue().split(",");
|
||||||
|
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String docId : documentIds) {
|
||||||
|
Long documentId = Long.valueOf(docId.trim());
|
||||||
|
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
||||||
|
DocumentResponseBean responseBean = new DocumentResponseBean();
|
||||||
|
responseBean.setId(documentEntity.getId());
|
||||||
|
responseBean.setName(documentEntity.getFileName());
|
||||||
|
responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType()));
|
||||||
|
responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource()));
|
||||||
|
responseBean.setSourceId(documentEntity.getSourceId());
|
||||||
|
responseBean.setFilePath(documentEntity.getFilePath());
|
||||||
|
responseBean.setCreatedDate(documentEntity.getCreatedDate());
|
||||||
|
responseBean.setUpdatedDate(documentEntity.getUpdatedDate());
|
||||||
|
documentResponseBeans.add(responseBean);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldResponse.setFileDetail(documentResponseBeans);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
processedFieldIds.add(fieldResponse.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
response.setFiles(fieldResponsesFromEntity);
|
response.setFiles(fieldResponsesFromEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,22 +307,25 @@ public class ApplicationEvaluationDao {
|
|||||||
private void setApplicationDetails(ApplicationEvaluationResponse response, ApplicationEvaluationEntity entity) {
|
private void setApplicationDetails(ApplicationEvaluationResponse response, ApplicationEvaluationEntity entity) {
|
||||||
ApplicationEntity application = applicationService.validateApplication(entity.getApplicationId() != null ? entity.getApplicationId(): null);
|
ApplicationEntity application = applicationService.validateApplication(entity.getApplicationId() != null ? entity.getApplicationId(): null);
|
||||||
UserEntity user = userService.validateUser(application.getUserId());
|
UserEntity user = userService.validateUser(application.getUserId());
|
||||||
|
|
||||||
|
CallEntity call = callRepository.findCallEntityByApplicationId(entity.getApplicationId());
|
||||||
|
|
||||||
String firstName = user.getFirstName() != null ? user.getFirstName() : "";
|
String firstName = user.getFirstName() != null ? user.getFirstName() : "";
|
||||||
String lastName = user.getLastName() != null ? user.getLastName() : "";
|
String lastName = user.getLastName() != null ? user.getLastName() : "";
|
||||||
|
|
||||||
String beneficiary = String.join(" ", firstName, lastName).trim();
|
String beneficiary = String.join(" ", firstName, lastName).trim();
|
||||||
response.setBeneficiary(beneficiary);
|
response.setBeneficiary(beneficiary);
|
||||||
|
response.setMinScore(call.getThreshold());
|
||||||
response.setCallName(application.getCall().getName());
|
response.setCallName(application.getCall().getName());
|
||||||
response.setProtocolNumber(application.getProtocol() != null ? application.getProtocol().getProtocolNumber() : null);
|
response.setProtocolNumber(application.getProtocol() != null ? application.getProtocol().getProtocolNumber() : null);
|
||||||
response.setSubmissionDate(application.getSubmissionDate());
|
response.setSubmissionDate(application.getSubmissionDate()!= null ? application.getSubmissionDate(): null);
|
||||||
response.setEvaluationDate(application.getSubmissionDate().plusDays(30));
|
response.setEvaluationDate(application.getSubmissionDate()!= null ? application.getSubmissionDate().plusDays(30):null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(UserEntity user, ApplicationEvaluationRequest req,Long applicationId) {
|
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(UserEntity user, ApplicationEvaluationRequest req,Long applicationId) {
|
||||||
Optional<ApplicationEvaluationEntity> existingEntityOptional = applicationEvaluationRepository.findByApplicationId(applicationId);
|
Optional<ApplicationEvaluationEntity> existingEntityOptional = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
|
||||||
ApplicationEvaluationEntity entity;
|
ApplicationEvaluationEntity entity;
|
||||||
|
|
||||||
if (existingEntityOptional.isPresent()) {
|
if (existingEntityOptional.isPresent()) {
|
||||||
@@ -368,26 +469,51 @@ public class ApplicationEvaluationDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(UserEntity user, Long applicationId) {
|
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(UserEntity user, Long applicationId, Long assignedApplicationId) {
|
||||||
applicationService.validateApplication(applicationId);
|
|
||||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByApplicationId(applicationId);
|
|
||||||
return entityOptional.map(this::convertToResponse).orElseGet(() -> getEvaluationResponseByApplicationid(user, applicationId));
|
|
||||||
|
|
||||||
|
applicationService.validateApplication(applicationId);
|
||||||
|
|
||||||
|
Optional<ApplicationEvaluationEntity> entityOptional;
|
||||||
|
|
||||||
|
if (applicationId != null && assignedApplicationId != null) {
|
||||||
|
entityOptional = applicationEvaluationRepository.findByApplicationIdAndAssignedApplicationsEntity_IdAndIsDeletedFalse(applicationId, assignedApplicationId);
|
||||||
|
} else if (applicationId != null) {
|
||||||
|
entityOptional = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
|
||||||
|
} else if (assignedApplicationId != null) {
|
||||||
|
entityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId);
|
||||||
|
} else {
|
||||||
|
entityOptional = applicationEvaluationRepository.findFirstByIsDeletedFalseOrderByCreatedDateDesc();
|
||||||
|
}
|
||||||
|
return entityOptional.map(this::convertToResponse)
|
||||||
|
.orElseGet(() -> {
|
||||||
|
return getEvaluationResponseByApplicationid(user, applicationId, assignedApplicationId);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
public ApplicationEvaluationResponse getEvaluationResponseByApplicationid(UserEntity user, Long applicationId) {
|
|
||||||
|
public ApplicationEvaluationResponse getEvaluationResponseByApplicationid(UserEntity user, Long applicationId,Long assignedApplicationId) {
|
||||||
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
||||||
ApplicationEvaluationResponse response = new ApplicationEvaluationResponse();
|
ApplicationEvaluationResponse response = new ApplicationEvaluationResponse();
|
||||||
|
CallEntity call=null;
|
||||||
CallEntity call = callRepository.findCallEntityByApplicationId(applicationId);
|
AssignedApplicationsEntity assignedApplications=null;
|
||||||
|
if (applicationId != null) {
|
||||||
|
call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||||
|
assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId).orElse(null);
|
||||||
|
} else if (assignedApplicationId != null) {
|
||||||
|
call = callRepository.findCallEntityByApplicationId(assignedApplicationId);
|
||||||
|
assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationId).orElseThrow(()->
|
||||||
|
new ResourceNotFoundException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_MSG)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||||
|
assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId).orElse(null);}
|
||||||
List<EvaluationCriteriaEntity> evaluationCriterias = evaluationCriteriaRepository.findByCallId(call.getId());
|
List<EvaluationCriteriaEntity> evaluationCriterias = evaluationCriteriaRepository.findByCallId(call.getId());
|
||||||
List<CallTargetAudienceChecklistEntity> checklistEntities = callTargetAudienceChecklistRepository.findByCallId(call.getId());
|
List<CallTargetAudienceChecklistEntity> checklistEntities = callTargetAudienceChecklistRepository.findByCallId(call.getId());
|
||||||
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(applicationId);
|
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(applicationId);
|
||||||
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId).orElse(null);
|
|
||||||
response.setApplicationId(applicationId);
|
response.setApplicationId(applicationId);
|
||||||
response.setAssignedApplicationId(assignedApplications.getId());
|
response.setAssignedApplicationId(assignedApplications.getId());
|
||||||
response.setNote(null);
|
response.setNote(null);
|
||||||
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(ApplicationEvaluationStatusTypeEnum.DRAFT.getValue()));
|
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(ApplicationEvaluationStatusTypeEnum.OPEN.getValue()));
|
||||||
|
response.setMinScore(call.getThreshold());
|
||||||
setCriteriaResponses(entity, applicationId, response, evaluationCriterias);
|
setCriteriaResponses(entity, applicationId, response, evaluationCriterias);
|
||||||
setChecklistResponses(entity, applicationId, response, checklistEntities);
|
setChecklistResponses(entity, applicationId, response, checklistEntities);
|
||||||
setFileResponses(entity, applicationId, response, applicationFormEntities);
|
setFileResponses(entity, applicationId, response, applicationFormEntities);
|
||||||
@@ -408,9 +534,51 @@ public class ApplicationEvaluationDao {
|
|||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
|
List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(applicationId);
|
||||||
|
Map<String, CriteriaMappedField> mappedFieldMap = new HashMap<>();
|
||||||
|
|
||||||
if (matchingEvaluationCriteria != null) {
|
if (matchingEvaluationCriteria != null) {
|
||||||
criteriaResponse.setLabel(matchingEvaluationCriteria.getLookupData().getValue());
|
criteriaResponse.setLabel(matchingEvaluationCriteria.getLookupData().getValue());
|
||||||
criteriaResponse.setMaxScore(matchingEvaluationCriteria.getScore());
|
criteriaResponse.setMaxScore(matchingEvaluationCriteria.getScore());
|
||||||
|
|
||||||
|
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository
|
||||||
|
.findByEvaluationCriteriaIdAndIsDeletedFalse(matchingEvaluationCriteria.getId());
|
||||||
|
|
||||||
|
for (ApplicationFormEntity applicationForm : applicationForms) {
|
||||||
|
for (CriteriaFormFieldEntity criteriaFormField : criteriaFormFields) {
|
||||||
|
String formFieldId = criteriaFormField.getFormFieldId();
|
||||||
|
if (!mappedFieldMap.containsKey(formFieldId)) {
|
||||||
|
CriteriaMappedField mappedField = new CriteriaMappedField();
|
||||||
|
mappedField.setId(formFieldId);
|
||||||
|
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(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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
||||||
|
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(formFieldId, applicationForm.getId(), applicationId);
|
||||||
|
|
||||||
|
formFieldEntityOptional.ifPresent(formField -> mappedField.setFieldValue(formField.getFieldValue()));
|
||||||
|
mappedFieldMap.put(formFieldId, mappedField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
criteriaResponse.setCriteriaMappedFields(new ArrayList<>(mappedFieldMap.values()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -435,20 +603,62 @@ public class ApplicationEvaluationDao {
|
|||||||
|
|
||||||
response.setChecklist(checklistResponses);
|
response.setChecklist(checklistResponses);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFileResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response, List<ApplicationFormEntity> applicationFormEntities) {
|
private void setFileResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response, List<ApplicationFormEntity> applicationFormEntities) {
|
||||||
List<FieldResponse> fieldResponses = entity.getFile() != null
|
List<FieldResponse> fieldResponses = entity.getFile() != null
|
||||||
? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {})
|
? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {})
|
||||||
: getFieldResponses(applicationId);
|
: getFieldResponses(applicationId);
|
||||||
|
Set<String> processedFieldIds = new HashSet<>();
|
||||||
|
|
||||||
fieldResponses.forEach(fieldResponse -> {
|
fieldResponses.forEach(fieldResponse -> {
|
||||||
|
if (processedFieldIds.contains(fieldResponse.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
applicationFormEntities.forEach(applicationForm -> {
|
applicationFormEntities.forEach(applicationForm -> {
|
||||||
FormEntity formEntity = applicationForm.getForm();
|
FormEntity formEntity = applicationForm.getForm();
|
||||||
if (formEntity != null) {
|
if (formEntity != null) {
|
||||||
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||||
contentResponseBeans.forEach(contentResponseBean -> {
|
contentResponseBeans.forEach(contentResponseBean -> {
|
||||||
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) {
|
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) {
|
||||||
fieldResponse.setLabel(contentResponseBean.getLabel());
|
String label = null;
|
||||||
|
if (contentResponseBean.getSettings() != null) {
|
||||||
|
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||||
|
if ("label".equals(setting.getName())) {
|
||||||
|
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldResponse.setLabel(label);
|
||||||
|
|
||||||
|
Optional<ApplicationFormFieldEntity> optionalFormField = applicationFormFieldRepository
|
||||||
|
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(fieldResponse.getId(), applicationForm.getId(), applicationId);
|
||||||
|
|
||||||
|
if (optionalFormField.isPresent() && optionalFormField.get().getFieldValue() != null) {
|
||||||
|
String[] documentIds = optionalFormField.get().getFieldValue().split(",");
|
||||||
|
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String docId : documentIds) {
|
||||||
|
Long documentId = Long.valueOf(docId.trim());
|
||||||
|
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
||||||
|
DocumentResponseBean responseBean = new DocumentResponseBean();
|
||||||
|
responseBean.setId(documentEntity.getId());
|
||||||
|
responseBean.setName(documentEntity.getFileName());
|
||||||
|
responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType()));
|
||||||
|
responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource()));
|
||||||
|
responseBean.setSourceId(documentEntity.getSourceId());
|
||||||
|
responseBean.setFilePath(documentEntity.getFilePath());
|
||||||
|
responseBean.setCreatedDate(documentEntity.getCreatedDate());
|
||||||
|
responseBean.setUpdatedDate(documentEntity.getUpdatedDate());
|
||||||
|
documentResponseBeans.add(responseBean);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldResponse.setFileDetail(documentResponseBeans);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark this field ID as processed to prevent duplicates
|
||||||
|
processedFieldIds.add(fieldResponse.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -458,6 +668,7 @@ public class ApplicationEvaluationDao {
|
|||||||
response.setFiles(fieldResponses);
|
response.setFiles(fieldResponses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setApplicationDetails(ApplicationEvaluationResponse response, Long applicationId, UserEntity user) {
|
private void setApplicationDetails(ApplicationEvaluationResponse response, Long applicationId, UserEntity user) {
|
||||||
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
||||||
userService.validateUser(application.getUserId());
|
userService.validateUser(application.getUserId());
|
||||||
@@ -469,13 +680,15 @@ public class ApplicationEvaluationDao {
|
|||||||
|
|
||||||
response.setCallName(application.getCall().getName());
|
response.setCallName(application.getCall().getName());
|
||||||
response.setProtocolNumber(application.getProtocol() != null ? application.getProtocol().getProtocolNumber() : null);
|
response.setProtocolNumber(application.getProtocol() != null ? application.getProtocol().getProtocolNumber() : null);
|
||||||
response.setSubmissionDate(application.getSubmissionDate());
|
response.setSubmissionDate(application.getSubmissionDate()!= null ? application.getSubmissionDate(): null);
|
||||||
response.setEvaluationDate(application.getSubmissionDate().plusDays(30));
|
response.setEvaluationDate(application.getSubmissionDate()!= null ? application.getSubmissionDate().plusDays(30):null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CriteriaResponse> getCriteriaResponse(Long applicationId){ CallEntity call = callRepository.findCallEntityByApplicationId(applicationId);
|
List<CriteriaResponse> getCriteriaResponse(Long applicationId) {
|
||||||
|
CallEntity call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||||
List<EvaluationCriteriaEntity> evaluationCriterias = evaluationCriteriaRepository.findByCallId(call.getId());
|
List<EvaluationCriteriaEntity> evaluationCriterias = evaluationCriteriaRepository.findByCallId(call.getId());
|
||||||
|
|
||||||
List<CriteriaResponse> criteriaResponses = evaluationCriterias.stream().map(criteria -> {
|
List<CriteriaResponse> criteriaResponses = evaluationCriterias.stream().map(criteria -> {
|
||||||
CriteriaResponse response = new CriteriaResponse();
|
CriteriaResponse response = new CriteriaResponse();
|
||||||
response.setId(criteria.getId());
|
response.setId(criteria.getId());
|
||||||
@@ -484,6 +697,54 @@ public class ApplicationEvaluationDao {
|
|||||||
response.setMaxScore(criteria.getScore());
|
response.setMaxScore(criteria.getScore());
|
||||||
response.setValid(null);
|
response.setValid(null);
|
||||||
|
|
||||||
|
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository
|
||||||
|
.findByEvaluationCriteriaIdAndIsDeletedFalse(criteria.getId());
|
||||||
|
|
||||||
|
List<CriteriaMappedField> mappedFields = new ArrayList<>();
|
||||||
|
Set<String> processedFormFieldIds = new HashSet<>();
|
||||||
|
|
||||||
|
for (CriteriaFormFieldEntity criteriaFormField : criteriaFormFields) {
|
||||||
|
if (processedFormFieldIds.contains(criteriaFormField.getFormFieldId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CriteriaMappedField mappedField = new CriteriaMappedField();
|
||||||
|
mappedField.setId(criteriaFormField.getFormFieldId());
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mappedField.setFieldLabel(label);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
response.setCriteriaMappedFields(mappedFields);
|
||||||
return response;
|
return response;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
@@ -503,7 +764,6 @@ public class ApplicationEvaluationDao {
|
|||||||
|
|
||||||
return checklistResponses;
|
return checklistResponses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FieldResponse> getFieldResponses(Long applicationId) {
|
public List<FieldResponse> getFieldResponses(Long applicationId) {
|
||||||
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(applicationId);
|
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(applicationId);
|
||||||
List<FieldResponse> fieldResponses = new ArrayList<>();
|
List<FieldResponse> fieldResponses = new ArrayList<>();
|
||||||
@@ -517,10 +777,10 @@ public class ApplicationEvaluationDao {
|
|||||||
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
|
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
|
||||||
if ("fileupload".equals(contentResponseBean.getName())) {
|
if ("fileupload".equals(contentResponseBean.getName())) {
|
||||||
String fieldId = contentResponseBean.getId();
|
String fieldId = contentResponseBean.getId();
|
||||||
Long formId = applicationForm.getId();
|
Long applicationFormId = applicationForm.getId();
|
||||||
|
|
||||||
Optional<ApplicationFormFieldEntity> optionalFormField = applicationFormFieldRepository
|
Optional<ApplicationFormFieldEntity> optionalFormField = applicationFormFieldRepository
|
||||||
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(fieldId, formId, applicationId);
|
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(fieldId, applicationFormId, applicationId);
|
||||||
|
|
||||||
if (optionalFormField.isPresent()) {
|
if (optionalFormField.isPresent()) {
|
||||||
ApplicationFormFieldEntity formField = optionalFormField.get();
|
ApplicationFormFieldEntity formField = optionalFormField.get();
|
||||||
@@ -528,8 +788,39 @@ public class ApplicationEvaluationDao {
|
|||||||
if (formField.getFieldValue() != null) {
|
if (formField.getFieldValue() != null) {
|
||||||
FieldResponse fieldResponse = new FieldResponse();
|
FieldResponse fieldResponse = new FieldResponse();
|
||||||
fieldResponse.setId(fieldId);
|
fieldResponse.setId(fieldId);
|
||||||
fieldResponse.setLabel(contentResponseBean.getLabel());
|
String label = null;
|
||||||
|
if (contentResponseBean.getSettings() != null) {
|
||||||
|
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||||
|
if ("label".equals(setting.getName())) {
|
||||||
|
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldResponse.setLabel(label);
|
||||||
fieldResponse.setValid(null);
|
fieldResponse.setValid(null);
|
||||||
|
String[] documentIds = formField.getFieldValue().split(",");
|
||||||
|
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String docId : documentIds) {
|
||||||
|
Long documentId = Long.valueOf(docId.trim());
|
||||||
|
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
||||||
|
DocumentResponseBean responseBean = new DocumentResponseBean();
|
||||||
|
responseBean.setId(documentEntity.getId());
|
||||||
|
responseBean.setName(documentEntity.getFileName());
|
||||||
|
responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType()));
|
||||||
|
responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource()));
|
||||||
|
responseBean.setSourceId(documentEntity.getSourceId());
|
||||||
|
responseBean.setFilePath(documentEntity.getFilePath());
|
||||||
|
responseBean.setCreatedDate(documentEntity.getCreatedDate());
|
||||||
|
responseBean.setUpdatedDate(documentEntity.getUpdatedDate());
|
||||||
|
documentResponseBeans.add(responseBean);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldResponse.setFileDetail(documentResponseBeans);
|
||||||
|
|
||||||
|
// Now add fieldResponse to the list
|
||||||
fieldResponses.add(fieldResponse);
|
fieldResponses.add(fieldResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -537,7 +828,6 @@ public class ApplicationEvaluationDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fieldResponses;
|
return fieldResponses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package net.gepafin.tendermanagement.enums;
|
|||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
public enum ApplicationEvaluationStatusTypeEnum {
|
public enum ApplicationEvaluationStatusTypeEnum {
|
||||||
DRAFT("DRAFT"),
|
OPEN ("OPEN"),
|
||||||
APPROVED("APPROVED"),
|
SOCCORSO("SOCCORSO"),
|
||||||
REJECTED("REJECTED");
|
CLOSE("CLOSE");
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class ApplicationEvaluationResponse {
|
|||||||
private Long assignedApplicationId;
|
private Long assignedApplicationId;
|
||||||
private String note;
|
private String note;
|
||||||
private ApplicationEvaluationStatusTypeEnum status;
|
private ApplicationEvaluationStatusTypeEnum status;
|
||||||
|
private Long minScore;
|
||||||
private List<CriteriaResponse> criteria;
|
private List<CriteriaResponse> criteria;
|
||||||
private List<ChecklistResponse> checklist;
|
private List<ChecklistResponse> checklist;
|
||||||
private List<FieldResponse> files;
|
private List<FieldResponse> files;
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CriteriaMappedField {
|
||||||
|
private String id;
|
||||||
|
private String fieldLabel;
|
||||||
|
private String fieldValue;
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package net.gepafin.tendermanagement.model.response;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class CriteriaResponse {
|
public class CriteriaResponse {
|
||||||
@@ -10,5 +10,6 @@ public class CriteriaResponse {
|
|||||||
private String label;
|
private String label;
|
||||||
private Long score;
|
private Long score;
|
||||||
private Long maxScore;
|
private Long maxScore;
|
||||||
|
private List<CriteriaMappedField> criteriaMappedFields;
|
||||||
private Boolean valid;
|
private Boolean valid;
|
||||||
}
|
}
|
||||||
@@ -3,9 +3,13 @@ package net.gepafin.tendermanagement.model.response;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class FieldResponse {
|
public class FieldResponse {
|
||||||
private String id;
|
private String id;
|
||||||
private String label;
|
private String label;
|
||||||
private Boolean valid;
|
private Boolean valid;
|
||||||
|
private List<DocumentResponseBean> fileDetail ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,21 @@ package net.gepafin.tendermanagement.repositories;
|
|||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ApplicationEvaluationRepository extends JpaRepository<ApplicationEvaluationEntity, Long> {
|
public interface ApplicationEvaluationRepository extends JpaRepository<ApplicationEvaluationEntity, Long> {
|
||||||
Optional<ApplicationEvaluationEntity> findByApplicationId(Long applicationId);
|
|
||||||
|
Optional<ApplicationEvaluationEntity> findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
||||||
|
|
||||||
|
Optional<ApplicationEvaluationEntity> findByAssignedApplicationsEntity_IdAndIsDeletedFalse(Long assignedApplicationId);
|
||||||
|
|
||||||
|
Optional<ApplicationEvaluationEntity> findByApplicationIdAndAssignedApplicationsEntity_IdAndIsDeletedFalse(Long applicationId, Long assignedApplicationId);
|
||||||
|
|
||||||
|
Optional<ApplicationEvaluationEntity> findFirstByIsDeletedFalseOrderByCreatedDateDesc();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package net.gepafin.tendermanagement.repositories;
|
|||||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -9,5 +11,11 @@ import java.util.Optional;
|
|||||||
public interface AssignedApplicationsRepository extends JpaRepository<AssignedApplicationsEntity,Long>, JpaSpecificationExecutor<AssignedApplicationsEntity>{
|
public interface AssignedApplicationsRepository extends JpaRepository<AssignedApplicationsEntity,Long>, JpaSpecificationExecutor<AssignedApplicationsEntity>{
|
||||||
Optional<AssignedApplicationsEntity> findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
Optional<AssignedApplicationsEntity> findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
||||||
Optional<AssignedApplicationsEntity> findByIdAndIsDeletedFalse(Long id);
|
Optional<AssignedApplicationsEntity> findByIdAndIsDeletedFalse(Long id);
|
||||||
|
@Query("SELECT aa FROM AssignedApplicationsEntity aa WHERE aa.isDeleted = false " +
|
||||||
|
"AND (:applicationId IS NULL OR aa.application.id = :applicationId) " +
|
||||||
|
"AND (:id IS NULL OR aa.id = :id)")
|
||||||
|
Optional<AssignedApplicationsEntity> findByApplicationIdOrId(@Param("applicationId") Long applicationId,
|
||||||
|
@Param("id") Long id);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ import org.springframework.stereotype.Repository;
|
|||||||
public interface DocumentRepository extends JpaRepository<DocumentEntity, Long> {
|
public interface DocumentRepository extends JpaRepository<DocumentEntity, Long> {
|
||||||
|
|
||||||
@Query("SELECT d FROM DocumentEntity d WHERE d.id = :id AND d.isDeleted = false")
|
@Query("SELECT d FROM DocumentEntity d WHERE d.id = :id AND d.isDeleted = false")
|
||||||
Optional<DocumentEntity> findById(@Param("id") Long id);
|
Optional<DocumentEntity> findByIdAndNotDeleted(@Param("id") Long id);
|
||||||
|
|
||||||
// List<DocumentEntity> findBySourceIdAndTypeAndIsDeletedFalse(Long sourceId, String type);
|
// List<DocumentEntity> findBySourceIdAndTypeAndIsDeletedFalse(Long sourceId, String type);
|
||||||
|
|
||||||
// Optional<DocumentEntity> findByIdAndSourceIdAndIsDeletedFalse(Long id, Long sourceId);
|
// Optional<DocumentEntity> findByIdAndSourceIdAndIsDeletedFalse(Long id, Long sourceId);
|
||||||
|
|
||||||
List<DocumentEntity> findBySource(String source);
|
List<DocumentEntity> findBySource(String source);
|
||||||
|
|
||||||
List<DocumentEntity> findBySourceIdAndSourceAndTypeAndIsDeletedFalse(Long sourceId, String source, String type);
|
List<DocumentEntity> findBySourceIdAndSourceAndTypeAndIsDeletedFalse(Long sourceId, String source, String type);
|
||||||
|
|
||||||
Optional<DocumentEntity> findByIdAndSourceIdAndSourceAndIsDeletedFalse(Long id, Long sourceId, String source);
|
Optional<DocumentEntity> findByIdAndSourceIdAndSourceAndIsDeletedFalse(Long id, Long sourceId, String source);
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ public interface ApplicationEvaluationService {
|
|||||||
ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationRequest applicationEvaluationRequest,Long assignedApplicationsId);
|
ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationRequest applicationEvaluationRequest,Long assignedApplicationsId);
|
||||||
void deleteApplicationEvaluation(HttpServletRequest request,Long id);
|
void deleteApplicationEvaluation(HttpServletRequest request,Long id);
|
||||||
|
|
||||||
ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId);
|
ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId,Long assignedApplicationId);
|
||||||
|
|
||||||
ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long applicationEvaluationId, ApplicationEvaluationStatusTypeEnum status);
|
ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long applicationEvaluationId, ApplicationEvaluationStatusTypeEnum status);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,14 +47,23 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId) {
|
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(
|
||||||
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId).orElse(null);
|
HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
|
||||||
if(assignedApplications==null){
|
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG));
|
|
||||||
}
|
|
||||||
UserEntity user = validator.validatePreInstructor(request, assignedApplications.getUserId());
|
|
||||||
return applicationEvaluationDao.getApplicationEvaluationByApplicationId(user, assignedApplications.getUserId());
|
|
||||||
|
|
||||||
|
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
|
||||||
|
assignedApplicationsRepository.findByApplicationIdOrId(applicationId, assignedApplicationId);
|
||||||
|
|
||||||
|
AssignedApplicationsEntity assignedApplications = assignedApplicationsOptional
|
||||||
|
.orElseThrow(() -> new CustomValidationException(
|
||||||
|
Status.BAD_REQUEST,
|
||||||
|
Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG)
|
||||||
|
));
|
||||||
|
UserEntity user = validator.validatePreInstructor(request, assignedApplications.getUserId());
|
||||||
|
return applicationEvaluationDao.getApplicationEvaluationByApplicationId(
|
||||||
|
user,
|
||||||
|
assignedApplications.getApplication().getId(),
|
||||||
|
assignedApplications.getId()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -44,9 +44,12 @@ public interface ApplicationEvaluationApi {
|
|||||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) }))
|
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) }))
|
||||||
})
|
})
|
||||||
@GetMapping(value = "/application/{applicationId}", produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(value = "/application", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
ResponseEntity<Response<ApplicationEvaluationResponse>> getApplicationEvaluationByApplicationId(HttpServletRequest request,
|
ResponseEntity<Response<ApplicationEvaluationResponse>> getApplicationEvaluationByApplicationId(
|
||||||
@Parameter(required = true) @PathVariable("applicationId") Long applicationId);
|
HttpServletRequest request,
|
||||||
|
@Parameter(description = "Application ID", required = false) @RequestParam(value = "applicationId", required = false) Long applicationId,
|
||||||
|
@Parameter(description = "Assigned Application ID", required = false) @RequestParam(value = "assignedApplicationId", required = false) Long assignedApplicationId);
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "API to delete ApplicationEvaluation",
|
@Operation(summary = "API to delete ApplicationEvaluation",
|
||||||
responses = {
|
responses = {
|
||||||
@@ -67,9 +70,9 @@ public interface ApplicationEvaluationApi {
|
|||||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
@PutMapping(value = "/{id}/status", produces = MediaType.APPLICATION_JSON_VALUE)
|
@PutMapping(value = "/{applicationId}/status", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
ResponseEntity<Response<ApplicationEvaluationResponse>> updateApplicationEvaluationStatus(HttpServletRequest request,
|
ResponseEntity<Response<ApplicationEvaluationResponse>> updateApplicationEvaluationStatus(HttpServletRequest request,
|
||||||
@Parameter( required = true) @PathVariable("id") Long id,
|
@Parameter( required = true) @PathVariable("applicationId") Long applicationId,
|
||||||
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) ApplicationEvaluationStatusTypeEnum status);
|
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) ApplicationEvaluationStatusTypeEnum status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,9 +37,11 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<ApplicationEvaluationResponse>> getApplicationEvaluationByApplicationId(HttpServletRequest request,
|
public ResponseEntity<Response<ApplicationEvaluationResponse>> getApplicationEvaluationByApplicationId(
|
||||||
Long applicationId) {
|
HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
|
||||||
ApplicationEvaluationResponse response = applicationEvaluationService.getApplicationEvaluationByApplicationId(request,applicationId);
|
|
||||||
|
ApplicationEvaluationResponse response = null;
|
||||||
|
response = applicationEvaluationService.getApplicationEvaluationByApplicationId(request, applicationId,assignedApplicationId);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_FETCHED_SUCCESSFULLY)));
|
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_FETCHED_SUCCESSFULLY)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1518,7 +1518,7 @@
|
|||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/>
|
<constraints nullable="true"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|||||||
Reference in New Issue
Block a user