From 4d1a1a9352e73ed3fd9795c0738edcba2e2776df Mon Sep 17 00:00:00 2001 From: rajesh Date: Fri, 8 Nov 2024 20:30:09 +0530 Subject: [PATCH] fixed evaluation criteria issue --- .../tendermanagement/dao/ApplicationDao.java | 18 +++-- .../dao/ApplicationEvaluationDao.java | 71 +++++++++++-------- 2 files changed, 53 insertions(+), 36 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index 1eb8017f..cb1e14c3 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -137,6 +137,9 @@ public class ApplicationDao { @Autowired private EmailNotificationDao emailNotificationDao; + + @Autowired + private FormDao formDao; public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) { FormEntity formEntity = formService.validateForm(formId); @@ -209,8 +212,10 @@ public class ApplicationDao { ApplicationFormEntity applicationFormEntity, List applicationFormFieldResponseBeans) { - List contentResponseBeans = Utils.convertJsonStringToList( - applicationFormEntity.getForm().getContent(), ContentResponseBean.class); +// List contentResponseBeans = Utils.convertJsonStringToList( +// applicationFormEntity.getForm().getContent(), ContentResponseBean.class); + + List contentResponseBeans = formDao.convertFormEntityToFormResponseBean(applicationFormEntity.getForm()).getContent(); for (ApplicationFormFieldEntity applicationFormFieldEntity : applicationFormFieldEntities) { @@ -430,7 +435,8 @@ public class ApplicationDao { private List validateFileUploadDocuments(ApplicationFormFieldRequestBean applicationFormFieldRequestBean, FormEntity formEntity) { List documentIds=null; - List contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class); +// List contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class); + List contentResponseBeans=formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); for (ContentResponseBean contentResponseBean:contentResponseBeans){ if(Boolean.TRUE.equals(contentResponseBean.getName().equals("fileupload"))) { if (contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())) { @@ -580,7 +586,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; } @@ -649,7 +656,8 @@ public class ApplicationDao { } public void validateFormFields(ApplicationRequestBean request, FormEntity formEntity) { - List contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class); +// List contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class); + List contentResponseBeans=formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); List requestFields = request.getFormFields(); diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java index 609eb0db..7eca5cf9 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java @@ -75,6 +75,9 @@ public class ApplicationEvaluationDao { @Autowired ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository; + + @Autowired + private FormDao formDao; private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) { @@ -168,41 +171,42 @@ public class ApplicationEvaluationDao { private List getMappedFieldsForCriteria(Long evaluationCriteriaId, Long applicationId) { List criteriaFormFields = criteriaFormFieldRepository.findByEvaluationCriteriaIdAndIsDeletedFalse(evaluationCriteriaId); List mappedFields = new ArrayList<>(); - Set uniqueFieldIds = new HashSet<>(); - List applicationForms = applicationFormRepository.findByApplicationId(applicationId); + for (ApplicationFormEntity applicationForm : applicationForms) { + Set 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 = getFormEntity(formField.getFormId()); - if (formEntity != null) { - List contentBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); - contentBeans.stream() - .filter(contentBean -> contentBean.getId().equals(formFieldId)) - .findFirst() - .ifPresent(contentBean -> { - mappedField.setFieldLabel(getLabelForField(contentBean)); - 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; - default: - populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentBean); - } - }); - } + List contentBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); + contentBeans.stream() + .filter(contentBean -> contentBean.getId().equals(formFieldId)) + .findFirst() + .ifPresent(contentBean -> { + mappedField.setFieldLabel(getLabelForField(contentBean)); + 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; + default: + populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentBean); + } + }); mappedFields.add(mappedField); uniqueFieldIds.add(formFieldId); @@ -314,7 +318,8 @@ public class ApplicationEvaluationDao { applicationFormEntities.forEach(applicationForm -> { FormEntity formEntity = applicationForm.getForm(); if (formEntity != null) { - List contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); +// List contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); + List contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); contentResponseBeans.forEach(contentResponseBean -> { if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) { String label = null; @@ -682,7 +687,8 @@ public class ApplicationEvaluationDao { ApplicationFormEntity applicationForm, Long applicationId) { mappedField.setId(formFieldId); formRepository.findById(criteriaFormField.getFormId()).ifPresent(formEntity -> { - List contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); +// List contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); + List contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); contentResponseBeans.stream().filter(bean -> bean.getId().equals(formFieldId)).findFirst().ifPresent(contentResponseBean -> { String label = getLabel(contentResponseBean); mappedField.setFieldLabel(label); @@ -828,7 +834,8 @@ public class ApplicationEvaluationDao { applicationFormEntities.forEach(applicationForm -> { FormEntity formEntity = applicationForm.getForm(); if (formEntity != null) { - List contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); +// List contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); + List contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); contentResponseBeans.forEach(contentResponseBean -> { if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) { String label = null; @@ -960,7 +967,8 @@ public class ApplicationEvaluationDao { FormEntity formEntity = formRepository.findById(criteriaFormField.getFormId()).orElse(null); if (formEntity != null) { - List contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); +// List contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); + List contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); contentResponseBeans.stream() .filter(bean -> bean.getId().equals(criteriaFormField.getFormFieldId())) .findFirst() @@ -1125,7 +1133,8 @@ public class ApplicationEvaluationDao { FormEntity formEntity = applicationForm.getForm(); if (formEntity != null) { - List contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); +// List contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); + List contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); for (ContentResponseBean contentResponseBean : contentResponseBeans) { if ("fileupload".equals(contentResponseBean.getName())) {