Resolved conflicts
This commit is contained in:
@@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -16,9 +17,11 @@ import org.springframework.stereotype.Component;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.HubEntity;
|
||||
import net.gepafin.tendermanagement.entities.SamlResponseEntity;
|
||||
import net.gepafin.tendermanagement.enums.SamlResponseStatusEnum;
|
||||
import net.gepafin.tendermanagement.repositories.SamlResponseRepository;
|
||||
import net.gepafin.tendermanagement.service.HubService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
@@ -33,12 +36,16 @@ public class SamlFailureHandler implements AuthenticationFailureHandler {
|
||||
@Autowired
|
||||
private SamlResponseRepository samlResponseRepository;
|
||||
|
||||
@Autowired
|
||||
private HubService hubService;
|
||||
|
||||
@Override
|
||||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException exception) throws IOException {
|
||||
try {
|
||||
logger.error("SAML login failed: " + exception.getMessage());
|
||||
String inResponseTo = extractInResponseTo(feBaseUrl);
|
||||
String inResponseTo = extractInResponseTo(exception.getMessage());
|
||||
|
||||
if (Boolean.FALSE.equals(StringUtils.isEmpty(inResponseTo))) {
|
||||
SamlResponseEntity samlResponseLogEntity = samlResponseRepository
|
||||
.findByInResponseToAndStatus(inResponseTo, SamlResponseStatusEnum.INITIATED.getValue())
|
||||
@@ -46,6 +53,10 @@ public class SamlFailureHandler implements AuthenticationFailureHandler {
|
||||
Translator.toLocale(GepafinConstant.INVALID_REQUEST)));
|
||||
samlResponseLogEntity.setStatus(SamlResponseStatusEnum.FAILED.getValue());
|
||||
samlResponseRepository.save(samlResponseLogEntity);
|
||||
HubEntity hub = hubService.getHubByUuid(samlResponseLogEntity.getHubUuid());
|
||||
if (Boolean.FALSE.equals(StringUtils.isEmpty(hub.getDomainName()))) {
|
||||
feBaseUrl = hub.getDomainName();
|
||||
}
|
||||
}
|
||||
response.sendRedirect(feBaseUrl + "/login");
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -257,6 +257,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
|
||||
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
||||
applicationAmendmentRequestResponse.setApplicationId(applicationId);
|
||||
applicationAmendmentRequestResponse.setCallEmail(application.getCall().getEmail());
|
||||
applicationAmendmentRequestResponse.setApplicationEvaluationId(applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getId());
|
||||
applicationAmendmentRequestResponse.setNote(applicationAmendmentRequestEntity.getNote());
|
||||
applicationAmendmentRequestResponse.setStatus(ApplicationAmendmentRequestEnum.valueOf(applicationAmendmentRequestEntity.getStatus()));
|
||||
@@ -539,13 +540,28 @@ public class ApplicationAmendmentRequestDao {
|
||||
return convertEntityToResponse(request);
|
||||
}
|
||||
|
||||
public ApplicationAmendmentRequestResponse getAmendmentByApplicationId(HttpServletRequest request, Long applicationId) {
|
||||
public List<ApplicationAmendmentRequestResponse> getAmendmentByApplicationId(HttpServletRequest request, Long applicationId,List<ApplicationAmendmentRequestEnum> statuses) {
|
||||
log.info("Fetching the Amendment data from application id {}", applicationId);
|
||||
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity=applicationAmendmentRequestRepository.findByApplicationIdAndIsDeletedFalse(application.getId());
|
||||
ApplicationAmendmentRequestResponse response=null;
|
||||
List<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntity=applicationAmendmentRequestRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
|
||||
if(statuses!=null && !statuses.isEmpty()) {
|
||||
List<String> statusStrings = statuses.stream().map(Enum::name).collect(Collectors.toList());
|
||||
applicationAmendmentRequestEntity = applicationAmendmentRequestRepository.findByApplicationIdAndStatusInAndIsDeletedFalse(application.getId(), statusStrings);
|
||||
} if(!applicationAmendmentRequestEntity.isEmpty()) {
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequest=applicationAmendmentRequestEntity.get(0);
|
||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(applicationAmendmentRequest.getApplicationEvaluationEntity().getId());
|
||||
if (entityOptional.isPresent()) {
|
||||
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||
validator.validatePreInstructor(request, entityOptional.get().getUserId());
|
||||
} else {
|
||||
validator.validateUserId(request, entityOptional.get().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||
}
|
||||
}}
|
||||
List <ApplicationAmendmentRequestResponse> response=new ArrayList<>();
|
||||
if(applicationAmendmentRequestEntity!=null) {
|
||||
response = convertEntityToResponse(applicationAmendmentRequestEntity);
|
||||
response= applicationAmendmentRequestEntity.stream()
|
||||
.map(this::convertEntityToResponse)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -21,14 +21,12 @@ import net.gepafin.tendermanagement.service.SystemEmailTemplatesService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.FieldValidator;
|
||||
import net.gepafin.tendermanagement.util.MailUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -92,9 +90,6 @@ public class ApplicationDao {
|
||||
@Autowired
|
||||
private SystemEmailTemplatesService systemEmailTemplatesService;
|
||||
|
||||
@Autowired
|
||||
private MailUtil mailUtil;
|
||||
|
||||
@Value("${default_System_Receiver_Email}")
|
||||
private String defaultSystemReceiverEmail;
|
||||
|
||||
@@ -119,6 +114,9 @@ public class ApplicationDao {
|
||||
// @Value("${aws.s3.url.folder.signed.document}")
|
||||
// private String signedDocumentS3Folder;
|
||||
|
||||
@Value("${default.hub.uuid}")
|
||||
private String defaultHubUuid;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@@ -133,6 +131,10 @@ public class ApplicationDao {
|
||||
|
||||
@Autowired
|
||||
private EmailNotificationDao emailNotificationDao;
|
||||
|
||||
@Autowired
|
||||
private FormDao formDao;
|
||||
|
||||
|
||||
@Autowired
|
||||
private EmailLogDao emailLogDao;
|
||||
@@ -208,8 +210,10 @@ public class ApplicationDao {
|
||||
ApplicationFormEntity applicationFormEntity,
|
||||
List<ApplicationFormFieldResponseBean> applicationFormFieldResponseBeans) {
|
||||
|
||||
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(
|
||||
applicationFormEntity.getForm().getContent(), ContentResponseBean.class);
|
||||
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(
|
||||
// applicationFormEntity.getForm().getContent(), ContentResponseBean.class);
|
||||
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(applicationFormEntity.getForm()).getContent();
|
||||
|
||||
for (ApplicationFormFieldEntity applicationFormFieldEntity : applicationFormFieldEntities) {
|
||||
|
||||
@@ -293,11 +297,11 @@ public class ApplicationDao {
|
||||
// return applicationResponses;
|
||||
// }
|
||||
|
||||
public List<ApplicationResponse> getAllApplications(UserEntity userEntity, Long callId, Long companyId,String status) {
|
||||
public List<ApplicationResponse> getAllApplications(UserEntity userEntity, Long callId, Long companyId,List<ApplicationStatusTypeEnum> statusList) {
|
||||
|
||||
log.info("Fetching applications for RoleType: {}", userEntity.getRoleEntity().getRoleType());
|
||||
|
||||
Specification<ApplicationEntity> spec = search(userEntity, callId, companyId,status);
|
||||
Specification<ApplicationEntity> spec = search(userEntity, callId, companyId,statusList);
|
||||
|
||||
List<ApplicationEntity> applicationEntities = applicationRepository.findAll(spec);
|
||||
|
||||
@@ -307,7 +311,7 @@ public class ApplicationDao {
|
||||
}
|
||||
|
||||
|
||||
private Specification<ApplicationEntity> search(UserEntity userEntity, Long callId, Long companyId,String status) {
|
||||
private Specification<ApplicationEntity> search(UserEntity userEntity, Long callId, Long companyId,List<ApplicationStatusTypeEnum> statusList) {
|
||||
return (root, query, builder) -> {
|
||||
Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
||||
@@ -320,8 +324,11 @@ public class ApplicationDao {
|
||||
if (companyId != null) {
|
||||
predicate = builder.and(predicate, builder.equal(root.get("company").get("id"), companyId));
|
||||
}
|
||||
if (status != null) {
|
||||
predicate = builder.and(predicate, builder.equal(root.get("status"), status));
|
||||
if (statusList != null && !statusList.isEmpty()) {
|
||||
List<String> statusNames = statusList.stream()
|
||||
.map(Enum::name)
|
||||
.collect(Collectors.toList());
|
||||
predicate = builder.and(predicate, root.get("status").in(statusNames));
|
||||
}
|
||||
predicate = builder.and(predicate, builder.equal(root.get("hubId"), userEntity.getHub().getId()));
|
||||
return predicate;
|
||||
@@ -426,7 +433,8 @@ public class ApplicationDao {
|
||||
|
||||
private List<Long> validateFileUploadDocuments(ApplicationFormFieldRequestBean applicationFormFieldRequestBean, FormEntity formEntity) {
|
||||
List<Long> documentIds=null;
|
||||
List<ContentResponseBean> contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class);
|
||||
// List<ContentResponseBean> contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class);
|
||||
List<ContentResponseBean> contentResponseBeans=formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
for (ContentResponseBean contentResponseBean:contentResponseBeans){
|
||||
if(Boolean.TRUE.equals(contentResponseBean.getName().equals("fileupload"))) {
|
||||
if (contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())) {
|
||||
@@ -511,10 +519,63 @@ public class ApplicationDao {
|
||||
}
|
||||
else {
|
||||
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(applicationEntity.getId());
|
||||
for (ApplicationFormEntity applicationFormEntity : applicationFormEntities) {
|
||||
FormEntity form = formService.validateForm(applicationFormEntity.getForm().getId());
|
||||
formEntities.add(form);
|
||||
addFormApplication(form, applicationEntity, formApplicationResponses);
|
||||
List<ApplicationFormEntity> sequencedApplicationFormEntity = new ArrayList<>();
|
||||
Long formIdMiddle = null;
|
||||
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findBySourceIdAndCallId(
|
||||
applicationEntity.getCall().getInitialForm(), applicationEntity.getCall().getId());
|
||||
|
||||
if (!flowEdgesList.isEmpty()) {
|
||||
if (flowEdgesList.size() == 1) {
|
||||
formIdMiddle = flowEdgesList.get(0).getTargetId();
|
||||
} else {
|
||||
List<Long> nextFormIds = flowEdgesList.stream()
|
||||
.map(FlowEdgesEntity::getTargetId)
|
||||
.toList();
|
||||
|
||||
FlowDataEntity flowDataEntity = flowDataRepository.findByFormIdAndCallId(
|
||||
applicationEntity.getCall().getInitialForm(), applicationEntity.getCall().getId());
|
||||
|
||||
ApplicationFormFieldEntity applicationFormFieldEntity = applicationFormFieldRepository
|
||||
.findByFieldIdAndApplicationFormFormIdAndApplicationFormApplicationId(
|
||||
flowDataEntity.getChoosenField(), applicationEntity.getCall().getInitialForm(), applicationEntity.getId())
|
||||
.orElse(null);
|
||||
|
||||
if (applicationFormFieldEntity != null) {
|
||||
formIdMiddle = flowDataRepository.findByChoosenValueAndFormIdIn(
|
||||
applicationFormFieldEntity.getFieldValue(), nextFormIds)
|
||||
.map(FlowDataEntity::getFormId)
|
||||
.orElse(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Long> applicationFormIds = new ArrayList<>();
|
||||
applicationFormIds.add(applicationEntity.getCall().getInitialForm());
|
||||
if (formIdMiddle != null && formIdMiddle > 0) {
|
||||
applicationFormIds.add(formIdMiddle);
|
||||
}
|
||||
applicationFormIds.add(applicationEntity.getCall().getFinalForm());
|
||||
if (applicationFormEntities.size() == 3) {
|
||||
for (Long applicationFormId : applicationFormIds) {
|
||||
for (ApplicationFormEntity applicationFormEntity : applicationFormEntities) {
|
||||
if (applicationFormEntity.getForm().getId().equals(applicationFormId)) {
|
||||
sequencedApplicationFormEntity.add(applicationFormEntity);
|
||||
FormEntity form = formService.validateForm(applicationFormId);
|
||||
formEntities.add(form);
|
||||
addFormApplication(form, applicationEntity, formApplicationResponses);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
ApplicationFormEntity applicationFormEntity1=applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(),applicationEntity.getCall().getInitialForm());
|
||||
sequencedApplicationFormEntity.add(applicationFormEntity1);
|
||||
FormEntity form1 = formService.validateForm(applicationFormEntity1.getForm().getId());
|
||||
formEntities.add(form1);
|
||||
addFormApplication(form1, applicationEntity, formApplicationResponses);
|
||||
ApplicationFormEntity applicationFormEntity2=applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(),applicationEntity.getCall().getFinalForm());
|
||||
sequencedApplicationFormEntity.add(applicationFormEntity2);
|
||||
FormEntity form2= formService.validateForm(applicationFormEntity2.getForm().getId());
|
||||
formEntities.add(form2);
|
||||
addFormApplication(form2, applicationEntity, formApplicationResponses);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,7 +637,8 @@ public class ApplicationDao {
|
||||
formApplicationResponse.setId(formEntity.getId());
|
||||
formApplicationResponse.setLabel(formEntity.getLabel());
|
||||
formApplicationResponse.setCallId(formEntity.getCall().getId());
|
||||
formApplicationResponse.setContent(Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class));
|
||||
// formApplicationResponse.setContent(Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class)
|
||||
formApplicationResponse.setContent(formDao.convertFormEntityToFormResponseBean(formEntity).getContent());
|
||||
return formApplicationResponse;
|
||||
}
|
||||
|
||||
@@ -645,7 +707,8 @@ public class ApplicationDao {
|
||||
}
|
||||
public void validateFormFields(ApplicationRequestBean request, FormEntity formEntity) {
|
||||
|
||||
List<ContentResponseBean> contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class);
|
||||
// List<ContentResponseBean> contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class);
|
||||
List<ContentResponseBean> contentResponseBeans=formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
|
||||
List<ApplicationFormFieldRequestBean> requestFields = request.getFormFields();
|
||||
|
||||
@@ -736,7 +799,7 @@ public class ApplicationDao {
|
||||
EmailLogRequest emailLogRequest=emailLogDao.createEmailLogRequest(SystemEmailTemplatesEntityTypeEnum.APPLICATION_SUBMISSION_TO_USER_AND_COMPANY.getValue(),RecipientTypeEnum.BENEFICIARY,userEntity.getId(),subject,body, StatusTypeEnum.SUCCESS.getValue(), null,applicationEntity.getId(),EmailTrackingEntityTypeEnum.APPLICATION,userEntity);
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email),emailLogRequest);
|
||||
List<String> recipientEmails = new ArrayList<>();
|
||||
recipientEmails.add(email);
|
||||
// recipientEmails.add(email);
|
||||
String companyEmail = company.getEmail();
|
||||
String contactEmail = company.getContactEmail();
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
@@ -12,6 +15,7 @@ import net.gepafin.tendermanagement.model.request.FieldRequest;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CallService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
@@ -24,6 +28,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
import static org.apache.commons.lang3.StringUtils.isNumeric;
|
||||
|
||||
@Component
|
||||
public class ApplicationEvaluationDao {
|
||||
@@ -42,13 +47,14 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
// @Autowired
|
||||
// private CallService callService;
|
||||
|
||||
@Autowired
|
||||
private EvaluationCriteriaRepository evaluationCriteriaRepository;
|
||||
|
||||
@Autowired
|
||||
private FormRepository formRepository;
|
||||
|
||||
@Autowired
|
||||
private CallTargetAudienceChecklistRepository callTargetAudienceChecklistRepository;
|
||||
|
||||
@@ -72,6 +78,9 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
@Autowired
|
||||
ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
|
||||
|
||||
@Autowired
|
||||
private FormDao formDao;
|
||||
|
||||
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
|
||||
|
||||
@@ -163,42 +172,48 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
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) {
|
||||
Set<String> uniqueFieldIds = new HashSet<>();
|
||||
|
||||
for (CriteriaFormFieldEntity formField : criteriaFormFields) {
|
||||
String formFieldId = formField.getFormFieldId();
|
||||
|
||||
FormEntity formEntity = applicationForm.getForm();
|
||||
if (formEntity == null || !formEntity.getId().equals(formField.getFormId())) {
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
List<ContentResponseBean> contentBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
contentBeans.stream()
|
||||
.filter(contentBean -> contentBean.getId().equals(formFieldId))
|
||||
.findFirst()
|
||||
.ifPresent(contentBean -> {
|
||||
mappedField.setFieldLabel(getLabelForField(contentBean));
|
||||
mappedField.setFieldName(contentBean.getName());
|
||||
switch (contentBean.getName()) {
|
||||
case "fileupload":
|
||||
mapFileFieldDetails(mappedField, formFieldId, applicationForm.getId(), applicationId);
|
||||
break;
|
||||
}
|
||||
case "checkboxes":
|
||||
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentBean);
|
||||
break;
|
||||
case "paragraph":
|
||||
handleParagraphField(applicationId, formField, contentBean, mappedField);
|
||||
break;
|
||||
case "table":
|
||||
handleTableField(applicationId, formField, contentBean, mappedField);
|
||||
break;
|
||||
default:
|
||||
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentBean);
|
||||
}
|
||||
}
|
||||
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);
|
||||
@@ -208,6 +223,58 @@ public class ApplicationEvaluationDao {
|
||||
return mappedFields;
|
||||
}
|
||||
|
||||
private FormEntity getFormEntity(Long formId) {
|
||||
return formRepository.findById(formId).orElse(null);
|
||||
}
|
||||
|
||||
private String getLabelForField(ContentResponseBean 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
private void mapFileFieldDetails(CriteriaMappedField mappedField, String formFieldId, Long applicationFormId, Long applicationId) {
|
||||
Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
||||
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(formFieldId, applicationFormId, applicationId);
|
||||
|
||||
if (formFieldEntityOptional.isPresent()) {
|
||||
String[] documentIds = formFieldEntityOptional.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);
|
||||
});
|
||||
}
|
||||
mappedField.setFieldValue(documentResponseBeans);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void mapNonFileFieldDetails(CriteriaMappedField mappedField, String formFieldId, Long applicationFormId, Long applicationId) {
|
||||
applicationFormFieldRepository
|
||||
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(formFieldId, applicationFormId, applicationId)
|
||||
.ifPresent(field -> mappedField.setFieldValue(field.getFieldValue()));
|
||||
}
|
||||
|
||||
|
||||
private void setChecklistResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List<CallTargetAudienceChecklistEntity> checklistEntities) {
|
||||
|
||||
List<ChecklistResponse> checklistResponsesFromEntity = entity.getChecklist() != null ?
|
||||
@@ -258,7 +325,8 @@ public class ApplicationEvaluationDao {
|
||||
applicationFormEntities.forEach(applicationForm -> {
|
||||
FormEntity formEntity = applicationForm.getForm();
|
||||
if (formEntity != null) {
|
||||
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
contentResponseBeans.forEach(contentResponseBean -> {
|
||||
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) {
|
||||
String label = null;
|
||||
@@ -394,12 +462,16 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
private List<CriteriaRequest> processCriteria(ApplicationEvaluationEntity entity, ApplicationEvaluationRequest req) {
|
||||
|
||||
List<CriteriaResponse> existingCriteriaList = entity.getCriteria() != null ? Utils.convertJsonToList(entity.getCriteria(), new TypeReference<List<CriteriaResponse>>() {
|
||||
}) : new ArrayList<>();
|
||||
List<CriteriaRequest> incomingCriteriaList = Optional.ofNullable(req.getCriteria()).orElse(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 -> {
|
||||
Map<Long, CriteriaResponse> existingCriteriaMap = existingCriteriaList.stream()
|
||||
.collect(Collectors.toMap(CriteriaResponse::getId, criteria -> criteria));
|
||||
|
||||
List<CriteriaRequest> updatedCriteriaList = incomingCriteriaList.stream().map(incoming -> {
|
||||
CriteriaRequest request = new CriteriaRequest();
|
||||
request.setId(incoming.getId());
|
||||
request.setScore(incoming.getScore());
|
||||
@@ -407,14 +479,15 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
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);
|
||||
request.setScore(incoming.getScore() != null ? incoming.getScore() : existingCriteria.getScore());
|
||||
request.setValid(incoming.getValid() != null ? incoming.getValid() : existingCriteria.getValid());
|
||||
}
|
||||
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());
|
||||
@@ -428,58 +501,65 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
private List<ChecklistRequest> processChecklist(ApplicationEvaluationEntity entity, ApplicationEvaluationRequest req) {
|
||||
|
||||
List<ChecklistRequest> incomingChecklistList = Optional.ofNullable(req.getChecklist()).orElse(new ArrayList<>());
|
||||
|
||||
List<ChecklistResponse> existingChecklistList = entity.getChecklist() != null ?
|
||||
Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {
|
||||
}) :
|
||||
Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {}) :
|
||||
new ArrayList<>();
|
||||
|
||||
Map<Long, ChecklistResponse> existingChecklistMap = existingChecklistList.stream().collect(Collectors.toMap(ChecklistResponse::getId, checklist -> checklist));
|
||||
Map<Long, ChecklistResponse> existingChecklistMap = existingChecklistList.stream()
|
||||
.collect(Collectors.toMap(ChecklistResponse::getId, checklist -> checklist));
|
||||
|
||||
List<ChecklistRequest> updatedChecklistList = req.getChecklist().stream().map(incoming -> {
|
||||
List<ChecklistRequest> updatedChecklistList = incomingChecklistList.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);
|
||||
request.setValid(existingChecklist.getValid());
|
||||
}
|
||||
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);
|
||||
request.setValid(existing.getValid());
|
||||
return request;
|
||||
}).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<>();
|
||||
List<FieldRequest> incomingFieldList = Optional.ofNullable(req.getFiles()).orElse(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 -> {
|
||||
Map<String, FieldResponse> existingFieldMap = existingFieldList.stream()
|
||||
.collect(Collectors.toMap(FieldResponse::getId, field -> field));
|
||||
|
||||
List<FieldRequest> updatedFieldList = incomingFieldList.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);
|
||||
request.setValid(incoming.getValid() != null ? incoming.getValid() : existingField.getValid());
|
||||
}
|
||||
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());
|
||||
@@ -562,57 +642,23 @@ public class ApplicationEvaluationDao {
|
||||
return response;
|
||||
}
|
||||
|
||||
private void setCriteriaResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response,
|
||||
List<EvaluationCriteriaEntity> evaluationCriterias) {
|
||||
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);
|
||||
List<CriteriaResponse> criteriaResponses = getInitialCriteriaResponses(entity, applicationId);
|
||||
|
||||
criteriaResponses.forEach(criteriaResponse -> {
|
||||
EvaluationCriteriaEntity matchingEvaluationCriteria = evaluationCriterias.stream()
|
||||
.filter(evaluationCriteria -> evaluationCriteria.getId().equals(criteriaResponse.getId())).findFirst().orElse(null);
|
||||
|
||||
List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(applicationId);
|
||||
Map<String, CriteriaMappedField> mappedFieldMap = new HashMap<>();
|
||||
EvaluationCriteriaEntity matchingEvaluationCriteria =
|
||||
findMatchingEvaluationCriteria(criteriaResponse, evaluationCriterias);
|
||||
|
||||
if (matchingEvaluationCriteria != null) {
|
||||
List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(applicationId);
|
||||
Map<String, CriteriaMappedField> mappedFieldMap = populateMappedFields(
|
||||
matchingEvaluationCriteria, applicationForms, applicationId);
|
||||
|
||||
criteriaResponse.setLabel(matchingEvaluationCriteria.getLookupData().getValue());
|
||||
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()));
|
||||
}
|
||||
});
|
||||
@@ -620,6 +666,171 @@ public class ApplicationEvaluationDao {
|
||||
response.setCriteria(criteriaResponses);
|
||||
}
|
||||
|
||||
private List<CriteriaResponse> getInitialCriteriaResponses(ApplicationEvaluationEntity entity, Long applicationId) {
|
||||
return entity.getCriteria() != null
|
||||
? Utils.convertJsonToList(entity.getCriteria(), new TypeReference<List<CriteriaResponse>>() {})
|
||||
: getCriteriaResponse(applicationId);
|
||||
}
|
||||
|
||||
private EvaluationCriteriaEntity findMatchingEvaluationCriteria(CriteriaResponse criteriaResponse,
|
||||
List<EvaluationCriteriaEntity> evaluationCriterias) {
|
||||
return evaluationCriterias.stream()
|
||||
.filter(evaluationCriteria -> evaluationCriteria.getId().equals(criteriaResponse.getId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private Map<String, CriteriaMappedField> populateMappedFields(EvaluationCriteriaEntity matchingEvaluationCriteria,
|
||||
List<ApplicationFormEntity> applicationForms,
|
||||
Long applicationId) {
|
||||
Map<String, CriteriaMappedField> mappedFieldMap = new HashMap<>();
|
||||
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();
|
||||
CriteriaMappedField mappedField = populateMappedField(formFieldId, criteriaFormField, applicationForm, applicationId);
|
||||
if(mappedField != null) {
|
||||
mappedFieldMap.put(formFieldId, mappedField);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mappedFieldMap;
|
||||
}
|
||||
|
||||
private CriteriaMappedField populateMappedField(String formFieldId,
|
||||
CriteriaFormFieldEntity criteriaFormField,
|
||||
ApplicationFormEntity applicationForm, Long applicationId) {
|
||||
CriteriaMappedField mappedField = new CriteriaMappedField();
|
||||
mappedField.setId(formFieldId);
|
||||
if(Boolean.FALSE.equals(criteriaFormField.getFormId().equals(applicationForm.getForm().getId()))) {
|
||||
return null;
|
||||
}
|
||||
formRepository.findById(criteriaFormField.getFormId()).ifPresent(formEntity -> {
|
||||
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
contentResponseBeans.stream().filter(bean -> bean.getId().equals(formFieldId)).findFirst().ifPresent(contentResponseBean -> {
|
||||
String label = getLabel(contentResponseBean);
|
||||
mappedField.setFieldName(contentResponseBean.getName());
|
||||
mappedField.setFieldLabel(label);
|
||||
switch (contentResponseBean.getName()) {
|
||||
case "fileupload":
|
||||
populateFileDetailsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId);
|
||||
break;
|
||||
|
||||
case "checkboxes":
|
||||
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentResponseBean);
|
||||
break;
|
||||
|
||||
case "paragraph":
|
||||
handleParagraphField(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||
break;
|
||||
case "table":
|
||||
handleTableField(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||
break;
|
||||
|
||||
default:
|
||||
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentResponseBean);
|
||||
}
|
||||
});
|
||||
});
|
||||
return mappedField;
|
||||
}
|
||||
|
||||
|
||||
private void populateFileDetailsAsFieldValue(CriteriaMappedField mappedField, String formFieldId,
|
||||
ApplicationFormEntity applicationForm, Long applicationId) {
|
||||
applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||
formFieldId, applicationForm.getId(), applicationId)
|
||||
.ifPresent(formField -> {
|
||||
if (formField.getFieldValue() != null) {
|
||||
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||
for (String docId : formField.getFieldValue().split(",")) {
|
||||
Long documentId = Long.valueOf(docId.trim());
|
||||
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
||||
DocumentResponseBean responseBean = createDocumentResponseBean(documentEntity);
|
||||
documentResponseBeans.add(responseBean);
|
||||
});
|
||||
}
|
||||
// Set the list of DocumentResponseBean directly
|
||||
mappedField.setFieldValue(documentResponseBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getLabel(ContentResponseBean 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
private void populateOptionFieldsAsFieldValue(CriteriaMappedField mappedField, String formFieldId, ApplicationFormEntity applicationForm, Long applicationId, ContentResponseBean contentBean) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
findFormFieldValue(applicationId, formFieldId).ifPresent(formField -> {
|
||||
Object value = formField.getFieldValue();
|
||||
List<String> labels = new ArrayList<>();
|
||||
if (value instanceof String) {
|
||||
String fieldValue = (String) value;
|
||||
if (fieldValue.contains(",")) {
|
||||
try {
|
||||
List<?> parsedValue = objectMapper.readValue(fieldValue, new TypeReference<List<?>>() {});
|
||||
parsedValue.forEach(item -> addLabelToList(labels, item, contentBean));
|
||||
} catch (JsonProcessingException e) {
|
||||
|
||||
String[] fallbackValues = fieldValue.split(",");
|
||||
for (String item : fallbackValues) {
|
||||
addLabelToList(labels, item.trim(), contentBean);
|
||||
}
|
||||
}
|
||||
mappedField.setFieldValue(!labels.isEmpty() ? labels : null);
|
||||
} else {
|
||||
|
||||
addLabelToList(labels, fieldValue.trim(), contentBean);
|
||||
mappedField.setFieldValue(!labels.isEmpty() ? labels.get(0) : null);
|
||||
}
|
||||
} else if (value instanceof List<?>) {
|
||||
|
||||
List<?> parsedValue = (List<?>) value;
|
||||
parsedValue.forEach(item -> addLabelToList(labels, item, contentBean));
|
||||
mappedField.setFieldValue(!labels.isEmpty() ? labels : null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addLabelToList(List<String> labels, Object item, ContentResponseBean contentBean) {
|
||||
if (item instanceof String) {
|
||||
Object label = PdfDao.findLabelInOptions(contentBean.getSettings(), item);
|
||||
if (label != null) {
|
||||
labels.add(label.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private DocumentResponseBean createDocumentResponseBean(DocumentEntity 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());
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
private void setChecklistResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response,
|
||||
List<CallTargetAudienceChecklistEntity> checklistEntities) {
|
||||
|
||||
@@ -653,7 +864,8 @@ public class ApplicationEvaluationDao {
|
||||
applicationFormEntities.forEach(applicationForm -> {
|
||||
FormEntity formEntity = applicationForm.getForm();
|
||||
if (formEntity != null) {
|
||||
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
contentResponseBeans.forEach(contentResponseBean -> {
|
||||
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) {
|
||||
String label = null;
|
||||
@@ -693,8 +905,6 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
fieldResponse.setFileDetail(documentResponseBeans);
|
||||
}
|
||||
|
||||
// Mark this field ID as processed to prevent duplicates
|
||||
processedFieldIds.add(fieldResponse.getId());
|
||||
}
|
||||
});
|
||||
@@ -721,65 +931,265 @@ public class ApplicationEvaluationDao {
|
||||
response.setEvaluationDate(application.getSubmissionDate() != null ? application.getSubmissionDate().plusDays(30) : null);
|
||||
|
||||
}
|
||||
private Optional<ApplicationFormFieldEntity> findFormFieldValue(Long applicationId, String formFieldId) {
|
||||
return applicationFormRepository.findByApplicationId(applicationId).stream()
|
||||
.flatMap(applicationForm -> applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||
formFieldId, applicationForm.getId(), applicationId).stream())
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
List<CriteriaResponse> getCriteriaResponse(Long applicationId) {
|
||||
CallEntity call = getCallEntityByApplicationId(applicationId);
|
||||
List<EvaluationCriteriaEntity> evaluationCriterias = getEvaluationCriterias(call);
|
||||
|
||||
CallEntity call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||
List<EvaluationCriteriaEntity> evaluationCriterias = evaluationCriteriaRepository.findByCallId(call.getId());
|
||||
return evaluationCriterias.stream()
|
||||
.map(criteria -> buildCriteriaResponse(applicationId, criteria))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
List<CriteriaResponse> criteriaResponses = evaluationCriterias.stream().map(criteria -> {
|
||||
CriteriaResponse response = new CriteriaResponse();
|
||||
response.setId(criteria.getId());
|
||||
response.setLabel(criteria.getLookupData().getValue());
|
||||
response.setScore(null);
|
||||
response.setMaxScore(criteria.getScore());
|
||||
response.setValid(null);
|
||||
private CallEntity getCallEntityByApplicationId(Long applicationId) {
|
||||
return callRepository.findCallEntityByApplicationId(applicationId);
|
||||
}
|
||||
|
||||
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository.findByEvaluationCriteriaIdAndIsDeletedFalse(criteria.getId());
|
||||
private List<EvaluationCriteriaEntity> getEvaluationCriterias(CallEntity call) {
|
||||
return evaluationCriteriaRepository.findByCallId(call.getId());
|
||||
}
|
||||
|
||||
List<CriteriaMappedField> mappedFields = new ArrayList<>();
|
||||
Set<String> processedFormFieldIds = new HashSet<>();
|
||||
private CriteriaResponse buildCriteriaResponse(Long applicationId, EvaluationCriteriaEntity criteria) {
|
||||
CriteriaResponse response = new CriteriaResponse();
|
||||
response.setId(criteria.getId());
|
||||
response.setLabel(criteria.getLookupData().getValue());
|
||||
response.setScore(null);
|
||||
response.setMaxScore(criteria.getScore());
|
||||
response.setValid(null);
|
||||
|
||||
for (CriteriaFormFieldEntity criteriaFormField : criteriaFormFields) {
|
||||
if (processedFormFieldIds.contains(criteriaFormField.getFormFieldId())) {
|
||||
continue;
|
||||
}
|
||||
List<CriteriaMappedField> mappedFields = getMappedFields(applicationId, criteria);
|
||||
response.setCriteriaMappedFields(mappedFields);
|
||||
return response;
|
||||
}
|
||||
|
||||
CriteriaMappedField mappedField = new CriteriaMappedField();
|
||||
mappedField.setId(criteriaFormField.getFormFieldId());
|
||||
private List<CriteriaMappedField> getMappedFields(Long applicationId, EvaluationCriteriaEntity criteria) {
|
||||
List<CriteriaFormFieldEntity> criteriaFormFields = getCriteriaFormFields(criteria);
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
List<CriteriaMappedField> mappedFields = new ArrayList<>();
|
||||
Set<String> processedFormFieldIds = new HashSet<>();
|
||||
|
||||
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());
|
||||
for (CriteriaFormFieldEntity criteriaFormField : criteriaFormFields) {
|
||||
if (processedFormFieldIds.contains(criteriaFormField.getFormFieldId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
response.setCriteriaMappedFields(mappedFields);
|
||||
return response;
|
||||
}).collect(Collectors.toList());
|
||||
CriteriaMappedField mappedField = mapField(applicationId, criteriaFormField);
|
||||
mappedFields.add(mappedField);
|
||||
processedFormFieldIds.add(criteriaFormField.getFormFieldId());
|
||||
}
|
||||
|
||||
return criteriaResponses;
|
||||
return mappedFields;
|
||||
}
|
||||
|
||||
private List<CriteriaFormFieldEntity> getCriteriaFormFields(EvaluationCriteriaEntity criteria) {
|
||||
return criteriaFormFieldRepository.findByEvaluationCriteriaIdAndIsDeletedFalse(criteria.getId());
|
||||
}
|
||||
|
||||
private CriteriaMappedField mapField(Long applicationId, CriteriaFormFieldEntity criteriaFormField) {
|
||||
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);
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
contentResponseBeans.stream()
|
||||
.filter(bean -> bean.getId().equals(criteriaFormField.getFormFieldId()))
|
||||
.findFirst()
|
||||
.ifPresent(contentResponseBean -> processFieldValue(applicationId, criteriaFormField, contentResponseBean, mappedField));
|
||||
}
|
||||
|
||||
return mappedField;
|
||||
}
|
||||
|
||||
private void processFieldValue(Long applicationId, CriteriaFormFieldEntity criteriaFormField, ContentResponseBean contentResponseBean, CriteriaMappedField mappedField) {
|
||||
String label = getLabelFromSettings(contentResponseBean);
|
||||
|
||||
mappedField.setFieldLabel(label);
|
||||
mappedField.setFieldName(contentResponseBean.getName());
|
||||
boolean isCheckbox = "checkboxes".equals(contentResponseBean.getName());
|
||||
boolean isFileUpload = "fileupload".equals(contentResponseBean.getName());
|
||||
boolean isParagraph = "paragraph".equals(contentResponseBean.getName());
|
||||
boolean isTable = "table".equals(contentResponseBean.getName());
|
||||
if (isFileUpload) {
|
||||
handleFileUpload(applicationId, criteriaFormField, mappedField);
|
||||
} else if (isCheckbox) {
|
||||
handleCheckbox(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||
}
|
||||
else if (isParagraph) {
|
||||
handleParagraphField(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||
} else if (isTable) {
|
||||
handleTableField(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||
}
|
||||
else {
|
||||
handleOtherFields(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||
}
|
||||
}
|
||||
private void handleTableField(Long applicationId, CriteriaFormFieldEntity criteriaFormField,
|
||||
ContentResponseBean contentResponseBean, CriteriaMappedField mappedField) {
|
||||
Map<String, String> stateFieldMap = new HashMap<>();
|
||||
Map<String, Boolean> stateFieldBoolean = new HashMap<>();
|
||||
|
||||
contentResponseBean.getSettings().stream()
|
||||
.filter(setting -> "table_columns".equals(setting.getName()))
|
||||
.map(SettingResponseBean::getValue)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(settingValue -> settingValue instanceof Map)
|
||||
.map(settingValue -> (Map<String, Object>) settingValue)
|
||||
.map(valueMap -> (List<Map<String, Object>>) valueMap.get("stateFieldData"))
|
||||
.filter(Objects::nonNull)
|
||||
.flatMap(List::stream)
|
||||
.forEach(fieldData -> {
|
||||
String fieldName = (String) fieldData.get("name");
|
||||
String fieldLabel = (String) fieldData.get("label");
|
||||
Boolean predefined = (Boolean) fieldData.getOrDefault("predefined", false);
|
||||
|
||||
if (fieldName != null) {
|
||||
stateFieldMap.put(fieldName, fieldLabel);
|
||||
stateFieldBoolean.put(fieldName, predefined);
|
||||
}
|
||||
});
|
||||
|
||||
findFormFieldValue(applicationId, criteriaFormField.getFormFieldId()).ifPresent(formField -> {
|
||||
String fieldValue1 = formField.getFieldValue();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
try {
|
||||
List<Map<String, String>> rowsData = objectMapper.readValue(fieldValue1, new TypeReference<List<Map<String, String>>>() {});
|
||||
|
||||
List<Map<String, Object>> tableData = new ArrayList<>();
|
||||
for (Map<String, String> rowData : rowsData) {
|
||||
Map<String, Object> mappedRow = new HashMap<>();
|
||||
rowData.forEach((fieldKey, fieldValue) -> {
|
||||
String columnLabel = stateFieldMap.getOrDefault(fieldKey, fieldKey);
|
||||
mappedRow.put(columnLabel, fieldValue);
|
||||
});
|
||||
tableData.add(mappedRow);
|
||||
}
|
||||
|
||||
mappedField.setFieldValue(tableData);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void handleParagraphField(Long applicationId, CriteriaFormFieldEntity criteriaFormField, ContentResponseBean contentResponseBean, CriteriaMappedField mappedField) {
|
||||
findFormFieldValue(applicationId, criteriaFormField.getFormFieldId()).ifPresent(formField -> {
|
||||
String paragraph = contentResponseBean.getSettings().stream()
|
||||
.filter(setting -> "text".equals(setting.getName()))
|
||||
.map(SettingResponseBean::getValue)
|
||||
.map(Object::toString)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (paragraph != null) {
|
||||
mappedField.setFieldValue(paragraph.trim());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private String getLabelFromSettings(ContentResponseBean 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
private void handleFileUpload(Long applicationId, CriteriaFormFieldEntity criteriaFormField, CriteriaMappedField mappedField) {
|
||||
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
|
||||
findFormFieldValue(applicationId, criteriaFormField.getFormFieldId()).ifPresent(formField -> {
|
||||
String fieldValue = formField.getFieldValue();
|
||||
if (fieldValue != null) {
|
||||
String[] fieldValues = fieldValue.split(",");
|
||||
for (String value : fieldValues) {
|
||||
Long documentId = Long.valueOf(value.trim());
|
||||
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
|
||||
DocumentResponseBean responseBean = mapDocumentEntityToResponse(documentEntity);
|
||||
documentResponseBeans.add(responseBean);
|
||||
});
|
||||
}
|
||||
}
|
||||
mappedField.setFieldValue(!documentResponseBeans.isEmpty() ? documentResponseBeans : null);
|
||||
});
|
||||
}
|
||||
|
||||
private DocumentResponseBean mapDocumentEntityToResponse(DocumentEntity 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());
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
private void handleCheckbox(Long applicationId, CriteriaFormFieldEntity criteriaFormField, ContentResponseBean contentResponseBean, CriteriaMappedField mappedField) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
findFormFieldValue(applicationId, criteriaFormField.getFormFieldId()).ifPresent(formField -> {
|
||||
Object value = formField.getFieldValue();
|
||||
List<String> labels = new ArrayList<>();
|
||||
|
||||
if (value instanceof String) {
|
||||
List<?> parsedValue = parseJsonValue((String) value, objectMapper);
|
||||
addLabelsFromParsedValues(parsedValue, contentResponseBean, labels);
|
||||
} else if (value instanceof List<?>) {
|
||||
List<?> parsedValue = (List<?>) value;
|
||||
addLabelsFromParsedValues(parsedValue, contentResponseBean, labels);
|
||||
}
|
||||
|
||||
mappedField.setFieldValue(!labels.isEmpty() ? (labels.size() == 1 ? labels.get(0) : labels) : null);
|
||||
});
|
||||
}
|
||||
|
||||
private List<?> parseJsonValue(String value, ObjectMapper objectMapper) {
|
||||
try {
|
||||
return objectMapper.readValue(value, new TypeReference<List<?>>() {});
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addLabelsFromParsedValues(List<?> parsedValue, ContentResponseBean contentResponseBean, List<String> labels) {
|
||||
for (Object item : parsedValue) {
|
||||
if (item instanceof String) {
|
||||
Object label = PdfDao.findLabelInOptions(contentResponseBean.getSettings(), item);
|
||||
if (label != null) {
|
||||
labels.add(label.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleOtherFields(Long applicationId, CriteriaFormFieldEntity criteriaFormField, ContentResponseBean contentResponseBean, CriteriaMappedField mappedField) {
|
||||
findFormFieldValue(applicationId, criteriaFormField.getFormFieldId()).ifPresent(formField -> {
|
||||
String fieldValue = formField.getFieldValue() != null ? formField.getFieldValue().trim() : null;
|
||||
Object label = PdfDao.findLabelInOptions(contentResponseBean.getSettings(), fieldValue);
|
||||
if (label != null) {
|
||||
mappedField.setFieldValue(fieldValue != null && !fieldValue.isEmpty() && !fieldValue.contains(",")
|
||||
? label.toString()
|
||||
: Arrays.asList(label.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
List<ChecklistResponse> getChecklistResponse(Long applicationId) {
|
||||
|
||||
CallEntity call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||
@@ -805,7 +1215,8 @@ public class ApplicationEvaluationDao {
|
||||
FormEntity formEntity = applicationForm.getForm();
|
||||
|
||||
if (formEntity != null) {
|
||||
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
|
||||
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
|
||||
if ("fileupload".equals(contentResponseBean.getName())) {
|
||||
@@ -852,8 +1263,6 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
fieldResponse.setFileDetail(documentResponseBeans);
|
||||
|
||||
// Now add fieldResponse to the list
|
||||
fieldResponses.add(fieldResponse);
|
||||
}
|
||||
}
|
||||
@@ -886,6 +1295,8 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
if (existingEntityOptional.isPresent()) {
|
||||
ApplicationEvaluationEntity existingEntity = existingEntityOptional.get();
|
||||
// UserEntity userEntity = userService.validateUser(application.getUserId());
|
||||
// callService.validatePublishedCall(application.getCall().getId(), userEntity.getHub().getId());
|
||||
application.setStatus(newStatus.getValue());
|
||||
application = applicationRepository.save(application);
|
||||
String statusType = application.getStatus();
|
||||
|
||||
@@ -22,7 +22,6 @@ import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.service.impl.EmailService;
|
||||
import net.gepafin.tendermanagement.service.impl.EmailServiceFactory;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.MailUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -37,9 +36,6 @@ public class EmailNotificationDao {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EmailNotificationDao.class);
|
||||
|
||||
@Autowired
|
||||
private MailUtil mailUtil;
|
||||
|
||||
@Autowired
|
||||
private SystemEmailTemplatesService systemEmailTemplatesService;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class ApplicationAmendmentRequestResponse {
|
||||
private Long id;
|
||||
private String callEmail;
|
||||
private String note;
|
||||
private Long responseDays;
|
||||
private LocalDateTime startDate;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CriteriaMappedField {
|
||||
private String id;
|
||||
private String fieldName;
|
||||
private String fieldLabel;
|
||||
private String fieldValue;
|
||||
private Object fieldValue;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,10 @@ public interface ApplicationAmendmentRequestRepository extends JpaRepository<App
|
||||
@Query(value = "SELECT amr FROM ApplicationAmendmentRequestEntity amr " + "WHERE amr.applicationEvaluationEntity.id = :id " + "AND amr.applicationEvaluationEntity.isDeleted = false")
|
||||
ApplicationAmendmentRequestEntity findByApplicationEvaluationIdAndIsDeletedFalse(Long id);
|
||||
|
||||
ApplicationAmendmentRequestEntity findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
||||
// ApplicationAmendmentRequestEntity findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
||||
|
||||
List<ApplicationAmendmentRequestEntity> findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
||||
|
||||
List<ApplicationAmendmentRequestEntity> findByApplicationIdAndStatusInAndIsDeletedFalse(Long applicationId, List<String> statuses);
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface ApplicationAmendmentRequestService {
|
||||
List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request,Long beneficiaryId);
|
||||
ApplicationAmendmentRequestResponse closeAmendmentRequest(HttpServletRequest request, Long id, CloseAmendmentRequest closeAmendmentRequest);
|
||||
ApplicationAmendmentRequestResponse extendResponseDays(HttpServletRequest request, Long id, Long addedDays);
|
||||
public ApplicationAmendmentRequestResponse getAmendmentByApplicationId(HttpServletRequest request,Long applicationId);
|
||||
public List<ApplicationAmendmentRequestResponse> getAmendmentByApplicationId(HttpServletRequest request,Long applicationId,List<ApplicationAmendmentRequestEnum> statuses);
|
||||
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(HttpServletRequest request, Long applicationAmendmentId, ApplicationAmendmentRequestEnum status);
|
||||
|
||||
void sendReminderEmail(HttpServletRequest request,Long amendmentId);
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface ApplicationService {
|
||||
|
||||
ApplicationGetResponseBean getApplicationByFormId(HttpServletRequest request, Long applicationId,Long formId);
|
||||
|
||||
List<ApplicationResponse> getAllApplications(HttpServletRequest request,Long callId, Long companyId,String status);
|
||||
List<ApplicationResponse> getAllApplications(HttpServletRequest request,Long callId, Long companyId,List<ApplicationStatusTypeEnum> statusList);
|
||||
|
||||
void deleteApplication(HttpServletRequest request, Long applicationId);
|
||||
|
||||
|
||||
@@ -129,15 +129,8 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
return applicationAmendmentRequestDao.extendResponseDays(id, addedDays);
|
||||
|
||||
}
|
||||
public ApplicationAmendmentRequestResponse getAmendmentByApplicationId(HttpServletRequest request, Long applicationId) {
|
||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
|
||||
if(amendment!=null) {
|
||||
|
||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
|
||||
if (entityOptional.isPresent()) {
|
||||
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
|
||||
}}
|
||||
return applicationAmendmentRequestDao.getAmendmentByApplicationId(request,applicationId);
|
||||
public List<ApplicationAmendmentRequestResponse> getAmendmentByApplicationId(HttpServletRequest request, Long applicationId,List<ApplicationAmendmentRequestEnum> statuses) {
|
||||
return applicationAmendmentRequestDao.getAmendmentByApplicationId(request,applicationId,statuses);
|
||||
}
|
||||
@Override
|
||||
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(HttpServletRequest request, Long applicationAmendmentId, ApplicationAmendmentRequestEnum status) {
|
||||
|
||||
@@ -86,12 +86,12 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<ApplicationResponse> getAllApplications(HttpServletRequest request, Long callId, Long companyId , String status) {
|
||||
public List<ApplicationResponse> getAllApplications(HttpServletRequest request, Long callId, Long companyId ,List<ApplicationStatusTypeEnum> statusList) {
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
if (companyId != null) {
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
}
|
||||
return applicationDao.getAllApplications(userEntity, callId, companyId , status);
|
||||
return applicationDao.getAllApplications(userEntity, callId, companyId , statusList);
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
@@ -6,7 +6,10 @@ import net.gepafin.tendermanagement.enums.StatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||
import net.gepafin.tendermanagement.service.feignClient.MailgunFeignClient;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -18,24 +21,37 @@ public class MailgunEmailService implements EmailService {
|
||||
|
||||
@Autowired
|
||||
private MailgunFeignClient mailgunFeignClient;
|
||||
|
||||
@Value("${isMailSendingEnabled}")
|
||||
private String isEmailSendingEnabled;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private EmailLogDao emailLogDao;
|
||||
|
||||
@Override
|
||||
public void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig, EmailLogRequest emailLogRequest) {
|
||||
|
||||
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
||||
return;
|
||||
}
|
||||
|
||||
String domain = emailConfig.getDomain();
|
||||
String from = emailConfig.getSender();
|
||||
String apiKey = emailConfig.getApiKey();
|
||||
String authHeader = "Basic " + Base64.getEncoder().encodeToString(("api:" + apiKey).getBytes());
|
||||
|
||||
// Send email via Mailgun API
|
||||
ResponseEntity<Void> response = mailgunFeignClient.sendEmail(domain, from, recipientEmails, subject, body, authHeader);
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
emailLogRequest.setSendStatus(StatusTypeEnum.FAILED.getValue());
|
||||
emailLogRequest.setErrorMessage(String.valueOf(response.getStatusCode()));
|
||||
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||
throw new RuntimeException("Failed to send email via Mailgun: " + response.getStatusCode());
|
||||
if (Boolean.FALSE.equals(validator.isTestProfileActivated())) {
|
||||
ResponseEntity<Void> response = mailgunFeignClient.sendEmail(domain, from, recipientEmails, subject, body, authHeader);
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
emailLogRequest.setSendStatus(StatusTypeEnum.FAILED.getValue());
|
||||
emailLogRequest.setErrorMessage(String.valueOf(response.getStatusCode()));
|
||||
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||
throw new RuntimeException("Failed to send email via Mailgun: " + response.getStatusCode());
|
||||
}
|
||||
}
|
||||
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||
import net.gepafin.tendermanagement.model.request.PecEmailRequest;
|
||||
import net.gepafin.tendermanagement.service.feignClient.PecFeignClient;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -23,12 +26,23 @@ public class PecEmailService implements EmailService {
|
||||
|
||||
this.pecFeignClient = pecFeignClient;
|
||||
}
|
||||
|
||||
@Value("${isMailSendingEnabled}")
|
||||
private String isEmailSendingEnabled;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private EmailLogDao emailLogDao;
|
||||
|
||||
@Override
|
||||
public void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig, EmailLogRequest emailLogRequest) {
|
||||
|
||||
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
||||
return;
|
||||
}
|
||||
|
||||
PecEmailRequest emailRequest = new PecEmailRequest();
|
||||
emailRequest.setSender(emailConfig.getSender());
|
||||
emailRequest.setRecipient(recipientEmails);
|
||||
@@ -38,13 +52,15 @@ public class PecEmailService implements EmailService {
|
||||
emailRequest.setPassword(emailConfig.getPassword());
|
||||
|
||||
String authToken = emailConfig.getAuthToken();
|
||||
ResponseEntity<Void> response = pecFeignClient.sendEmail("Bearer " + authToken, emailRequest);
|
||||
log.info("Mail response status: {}, headers: {}, body: {}", response.getStatusCode(), response.getHeaders(), response.getBody());
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
emailLogRequest.setSendStatus(StatusTypeEnum.FAILED.getValue());
|
||||
emailLogRequest.setErrorMessage(String.valueOf(response.getStatusCode()));
|
||||
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||
throw new RuntimeException("Failed to send email via PEC: " + response.getStatusCode());
|
||||
if (Boolean.FALSE.equals(validator.isTestProfileActivated())) {
|
||||
ResponseEntity<Void> response = pecFeignClient.sendEmail("Bearer " + authToken, emailRequest);
|
||||
log.info("Mail response status: {}, headers: {}, body: {}", response.getStatusCode(), response.getHeaders(), response.getBody());
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
emailLogRequest.setSendStatus(StatusTypeEnum.FAILED.getValue());
|
||||
emailLogRequest.setErrorMessage(String.valueOf(response.getStatusCode()));
|
||||
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||
throw new RuntimeException("Failed to send email via PEC: " + response.getStatusCode());
|
||||
}
|
||||
}
|
||||
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||
}
|
||||
|
||||
@@ -151,6 +151,11 @@ public class Validator {
|
||||
String[] activeProfiles = environment.getActiveProfiles();
|
||||
return Arrays.stream(activeProfiles).anyMatch("production"::equals);
|
||||
}
|
||||
|
||||
public Boolean isTestProfileActivated() {
|
||||
String[] activeProfiles = environment.getActiveProfiles();
|
||||
return Arrays.stream(activeProfiles).anyMatch("test"::equals);
|
||||
}
|
||||
|
||||
public UserEntity validatePreInstructor(HttpServletRequest request, Long preInstructorUserId) {
|
||||
UserEntity preInstructorUser = userService.validateUser(preInstructorUserId);
|
||||
|
||||
@@ -145,7 +145,7 @@ public interface ApplicationAmendmentRequestApi {
|
||||
ResponseEntity<Response<ApplicationAmendmentRequestResponse>> closeApplicationAmendmentRequest(HttpServletRequest request,
|
||||
@Parameter(description = "The Application Amendment id", required = true) @RequestParam("id") Long id,
|
||||
@Valid @RequestBody CloseAmendmentRequest closeAmendmentRequest);
|
||||
@Operation(summary = "Api to get amendment process by application id",
|
||||
@Operation(summary = "Api to get amendment process list by application id",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@@ -154,8 +154,10 @@ public interface ApplicationAmendmentRequestApi {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "application/{id}", produces = "application/json")
|
||||
ResponseEntity<Response<ApplicationAmendmentRequestResponse>> getAmendmentByApplicationId(HttpServletRequest request, @Parameter(description = "The Application id", required = true) @PathVariable(value = "id", required = true) Long applicationId);
|
||||
@GetMapping(value = "application/{applicationId}", produces = "application/json")
|
||||
ResponseEntity<Response<List<ApplicationAmendmentRequestResponse>>> getAmendmentByApplicationId(HttpServletRequest request, @Parameter(description = "The Application id", required = true) @PathVariable(value = "applicationId", required = true) Long applicationId,
|
||||
@Parameter(description = "List of amendment statuses") @RequestParam(value = "statuses", required = false) List<ApplicationAmendmentRequestEnum> statuses
|
||||
);
|
||||
|
||||
@Operation(summary = "Api to update application amendment status",
|
||||
responses = {
|
||||
|
||||
@@ -72,7 +72,7 @@ public interface ApplicationApi {
|
||||
ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request,
|
||||
@Parameter(description = "The call id", required = false) @RequestParam(value = "callId", required = false) Long callId,
|
||||
@Parameter(description = "The company id", required = false) @RequestParam(value = "companyId", required = false) Long companyId,
|
||||
@Parameter(description = "Application status" ,required = false) @RequestParam(value = "status",required = false)String status);
|
||||
@Parameter(description = "Application statuses" ,required = false) @RequestParam(value = "statuses",required = false) List<ApplicationStatusTypeEnum> statusList);
|
||||
|
||||
@Operation(summary = "Api to delete application",
|
||||
responses = {
|
||||
|
||||
@@ -105,8 +105,8 @@ public class ApplicationAmendmentRequestController implements ApplicationAmendme
|
||||
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.RESPONSE_DAYS_EXTENDED_SUCCESS_MSG)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<Response<ApplicationAmendmentRequestResponse>> getAmendmentByApplicationId(HttpServletRequest request, Long applicationId) {
|
||||
ApplicationAmendmentRequestResponse applicationAmendmentBean = applicationAmendmentRequestService.getAmendmentByApplicationId(request,applicationId);
|
||||
public ResponseEntity<Response<List<ApplicationAmendmentRequestResponse>>> getAmendmentByApplicationId(HttpServletRequest request, Long applicationId,List<ApplicationAmendmentRequestEnum> statuses) {
|
||||
List<ApplicationAmendmentRequestResponse> applicationAmendmentBean = applicationAmendmentRequestService.getAmendmentByApplicationId(request,applicationId,statuses);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(applicationAmendmentBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_DATA_FOR_AMENDMENT_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ public class ApplicationApiController implements ApplicationApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request, Long callId, Long companyId, String status) {
|
||||
List<ApplicationResponse> applications = applicationService.getAllApplications(request, callId, companyId,status);
|
||||
public ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request, Long callId, Long companyId, List<ApplicationStatusTypeEnum> statusList) {
|
||||
List<ApplicationResponse> applications = applicationService.getAllApplications(request, callId, companyId,statusList);
|
||||
log.info("Get All Applications");
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
||||
|
||||
@@ -21,3 +21,4 @@ gepafin_email=bandi@pec.gepafin.it
|
||||
rinaldo_email=rinaldo.bonazzo@bflows.net
|
||||
carlo_email=carlo.mancosu@bflows.net
|
||||
default.hub.uuid=p4lk3bcx1RStqTaIVVbXs
|
||||
# TEST DEPLOY Configuration
|
||||
|
||||
Reference in New Issue
Block a user