From b28f5b71fcb2851dcc07783f0cb2967752459c6f Mon Sep 17 00:00:00 2001 From: harish Date: Mon, 23 Sep 2024 18:19:14 +0530 Subject: [PATCH 1/8] Add trigger and function for updated_date and created_date column in gepafin_schema --- .../db/changelog/db.changelog-1.0.0.xml | 33 +++++++++++- .../db/changelog/db.changelog-master.xml | 1 + .../db/changelog/dynamic-triggers.xml | 51 +++++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/db/changelog/dynamic-triggers.xml diff --git a/src/main/resources/db/changelog/db.changelog-1.0.0.xml b/src/main/resources/db/changelog/db.changelog-1.0.0.xml index f4a78969..c1a48adb 100644 --- a/src/main/resources/db/changelog/db.changelog-1.0.0.xml +++ b/src/main/resources/db/changelog/db.changelog-1.0.0.xml @@ -539,7 +539,7 @@ - + TRUNCATE TABLE FORM_FIELD RESTART IDENTITY; @@ -696,7 +696,7 @@ path="classpath:db/dump/inserted_form_field_data_13_09_2024.sql" /> - + @@ -710,4 +710,33 @@ + + + + CREATE OR REPLACE FUNCTION gepafin_schema.clock_timestamp_updated_date_column() + RETURNS TRIGGER + LANGUAGE plpgsql + AS $$ + BEGIN + NEW.updated_date = clock_timestamp(); + RETURN NEW; + END; + $$; + + + + + CREATE OR REPLACE FUNCTION gepafin_schema.clock_timestamp_created_date_column() + RETURNS TRIGGER + LANGUAGE plpgsql + AS $$ + BEGIN + IF NEW.created_date IS NULL THEN + NEW.created_date = clock_timestamp(); + END IF; + RETURN NEW; + END; + $$; + + diff --git a/src/main/resources/db/changelog/db.changelog-master.xml b/src/main/resources/db/changelog/db.changelog-master.xml index f44695c7..bf4c4536 100644 --- a/src/main/resources/db/changelog/db.changelog-master.xml +++ b/src/main/resources/db/changelog/db.changelog-master.xml @@ -5,4 +5,5 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.23.xsd"> + diff --git a/src/main/resources/db/changelog/dynamic-triggers.xml b/src/main/resources/db/changelog/dynamic-triggers.xml new file mode 100644 index 00000000..23f1101e --- /dev/null +++ b/src/main/resources/db/changelog/dynamic-triggers.xml @@ -0,0 +1,51 @@ + + + + + DO $$ + DECLARE + r RECORD; + BEGIN + -- Loop through all tables in the schema that have the 'updated_date' column + FOR r IN ( + SELECT table_name + FROM information_schema.columns + WHERE column_name = 'updated_date' + AND table_schema = 'gepafin_schema' + ) + LOOP + EXECUTE format( + 'CREATE OR REPLACE TRIGGER tg_gepafin_schema_updated_at_%I + BEFORE UPDATE ON gepafin_schema.%I + FOR EACH ROW + EXECUTE FUNCTION gepafin_schema.clock_timestamp_updated_date_column()', + r.table_name, r.table_name + ); + END LOOP; + + -- Loop through all tables in the schema that have the 'created_date' column + FOR r IN ( + SELECT table_name + FROM information_schema.columns + WHERE column_name = 'created_date' + AND table_schema = 'gepafin_schema' + ) + LOOP + EXECUTE format( + 'CREATE OR REPLACE TRIGGER tg_gepafin_schema_created_at_%I + BEFORE INSERT ON gepafin_schema.%I + FOR EACH ROW + EXECUTE FUNCTION gepafin_schema.clock_timestamp_created_date_column()', + r.table_name, r.table_name + ); + END LOOP; + END; + $$ LANGUAGE plpgsql; + + + From 241b6cd8e29edca06e098d6408d2929b6012a0eb Mon Sep 17 00:00:00 2001 From: harish Date: Thu, 3 Oct 2024 16:10:16 +0530 Subject: [PATCH 2/8] Updated code --- src/main/resources/db/changelog/db.changelog-1.0.0.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/db/changelog/db.changelog-1.0.0.xml b/src/main/resources/db/changelog/db.changelog-1.0.0.xml index c1a48adb..86f35aa4 100644 --- a/src/main/resources/db/changelog/db.changelog-1.0.0.xml +++ b/src/main/resources/db/changelog/db.changelog-1.0.0.xml @@ -710,7 +710,7 @@ - + CREATE OR REPLACE FUNCTION gepafin_schema.clock_timestamp_updated_date_column() @@ -724,7 +724,6 @@ $$; - CREATE OR REPLACE FUNCTION gepafin_schema.clock_timestamp_created_date_column() RETURNS TRIGGER @@ -734,6 +733,7 @@ IF NEW.created_date IS NULL THEN NEW.created_date = clock_timestamp(); END IF; + NEW.updated_date = NEW.created_date; RETURN NEW; END; $$; From 2bae3675f8da306a01018d4ba07737fdda20bcad Mon Sep 17 00:00:00 2001 From: nisha Date: Thu, 3 Oct 2024 19:05:08 +0530 Subject: [PATCH 3/8] Updated form field element --- .../db/changelog/db.changelog-1.0.0.xml | 9 ++ .../updated_form_field_data_03-10-2024_1.sql | 101 ++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 src/main/resources/db/dump/updated_form_field_data_03-10-2024_1.sql diff --git a/src/main/resources/db/changelog/db.changelog-1.0.0.xml b/src/main/resources/db/changelog/db.changelog-1.0.0.xml index bc49068c..d067df71 100644 --- a/src/main/resources/db/changelog/db.changelog-1.0.0.xml +++ b/src/main/resources/db/changelog/db.changelog-1.0.0.xml @@ -871,4 +871,13 @@ path="classpath:db/dump/updated_form_field_data_03-10-2024.sql" /> + + + TRUNCATE TABLE FORM_FIELD RESTART IDENTITY; + + + + + diff --git a/src/main/resources/db/dump/updated_form_field_data_03-10-2024_1.sql b/src/main/resources/db/dump/updated_form_field_data_03-10-2024_1.sql new file mode 100644 index 00000000..697903cc --- /dev/null +++ b/src/main/resources/db/dump/updated_form_field_data_03-10-2024_1.sql @@ -0,0 +1,101 @@ +INSERT INTO FORM_FIELD (SORT_ORDER, NAME, LABEL, DESCRIPTION, SETTINGS, VALIDATORS, CREATED_DATE, UPDATED_DATE) +VALUES +(1, 'textinput', 'Testo Breve', 'Per risposte concise (nomi, titoli, brevi descrizioni)', + '[{"name": "label", "value": "Testo Breve"}, {"name": "placeholder", "value": ""}]', + '{"isRequired": false, "minLength": null, "maxLength": null, "pattern": null, "custom": null}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(2, 'textarea', 'Testo Lungo', 'Campo di testo esteso per paragrafi, descrizioni, proposte', + '[{"name": "label", "value": "Testo Lungo"}, {"name": "placeholder", "value": ""}]', + '{"isRequired": false, "minLength": null, "maxLength": null, "pattern": null, "custom": null}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(3, 'wysiwyg', 'Campo di Testo Formattato', 'Editor avanzato per testo con formattazione', + '[{"name": "label", "value": "Testo Formattato"}, {"name": "placeholder", "value": ""}]', + '{"isRequired": false, "minLength": null, "maxLength": null, "pattern": null, "custom": null}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(4, 'numberinput', 'Campo Numerico', 'Per l''inserimento di valori numerici (quantità, importi, percentuali)', + '[{"name": "label", "value": "Numero"}, {"name": "placeholder", "value": "0"}, {"name": "step", "value": "0"}]', + '{"isRequired": false, "min": null, "max": null, "pattern": null, "custom": null}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(5, 'radio', 'Scelta Singola', 'Gruppo di opzioni per selezione singola', + '[{"name": "label", "value": "Scelta Singola"}, {"name": "options", "value": []}]', + '{"isRequired": false, "custom": null}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(6, 'select', 'Menu a Tendina', 'Selezione da opzioni predefinite', + '[{"name": "label", "value": "Menu a Tendina"}, {"name": "options", "value": []}]', + '{"isRequired": false, "custom": null}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(7, 'checkboxes', 'Scelta Multipla', 'Gruppo di opzioni per selezione singola o multipla', + '[{"name": "label", "value": "Scelta Multipla"}, {"name": "options", "value": []}]', + '{"isRequired": false, "min": null, "max": null, "custom": null}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(8, 'switch', 'Casella di Spunta', 'Per selezioni binarie, accettazioni, conferme', + '[{"name": "label", "value": "Casella di Spunta"}]', + '{"isRequired": false}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(9, 'datepicker', 'Data', 'Selezione di data', + '[{"name": "label", "value": "Data"}]', + '{"isRequired": false}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(10, 'fileupload', 'Caricamento File', 'Per l''upload di documenti o immagini', + '[{"name": "label", "value": "Caricamento File"}, {"name": "mime", "value": []}]', + '{"isRequired": false, "maxSize": 100000}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(11, 'textinput', 'Campo Partita IVA', 'Specifico per l''inserimento del numero di Partita IVA', + '[{"name": "label", "value": "Partita IVA"}, {"name": "placeholder", "value": ""}]', + '{"isRequired": true, "custom": "isPIVA"}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(12, 'textinput', 'Campo Codice Fiscale','Specifico per l''inserimento del Codice Fiscale italiano per persone fisiche e giuridiche', + '[{"name": "label", "value": "Codice Fiscale"}, {"name": "placeholder", "value": ""}]', + '{"isRequired": true, "custom": "isCodiceFiscale"}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(13, 'textinput', 'Campo CAP','Per l''inserimento del Codice di Avviamento Postale', + '[{"name": "label", "value": "CAP"}, {"name": "placeholder", "value": ""}]', + '{"isRequired": true, "custom": "isCAP"}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(14, 'textinput', 'Campo IBAN', 'Per l''inserimento del codice IBAN', + '[{"name": "label", "value": "IBAN"}, {"name": "placeholder", "value": ""}]', + '{"isRequired": true, "custom": "isIBAN"}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(15, 'textinput', 'Campo Email', 'Per l''inserimento di indirizzi email standard (non PEC)', + '[{"name": "label", "value": "Campo Email"}, {"name": "placeholder", "value": "nome@esempio.it"}]', + '{"isRequired": false, "custom": "isEmail"}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(16, 'textinput', 'Campo PEC', 'Specifico per l''inserimento di un indirizzo di Posta Elettronica Certificata', + '[{"name": "label", "value": "Campo PEC"}, {"name": "placeholder", "value": "nome@pec.it"}]', + '{"isRequired": false, "custom": "isEmailPEC"}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(17, 'textinput', 'Campo URL', 'Per l''inserimento di indirizzi web', + '[{"name": "label", "value": "Indirizzo URL"}, {"name": "placeholder", "value": ""}]', + '{"isRequired": false, "custom": "isUrl"}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(18, 'textinput', 'Marca da bollo', 'Per inserire codice di marca da bollo', + '[{"name": "label", "value": "Marca da bollo"}, {"name": "placeholder", "value": "Numero identificativo"}]', + '{"isRequired": false, "custom": "isMarcaDaBollo"}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(19, 'paragraph', 'Paragrafo', 'Semplice testo formattato', + '[{"name": "text", "value": ""}]', + '{}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), + +(20, 'table', 'Tabella', 'Tabella', + '[{"name": "label", "value": "Tabella"}, {"name": "table_columns", "value": []}]', + '{}', + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); From f838da73ef3d074208c8654cee3e88c15a6d2e2c Mon Sep 17 00:00:00 2001 From: harish Date: Fri, 4 Oct 2024 19:03:33 +0530 Subject: [PATCH 4/8] Fixed next pervious issue --- .../tendermanagement/dao/FlowFormDao.java | 31 +++++++++++++------ .../service/impl/ApplicationServiceImpl.java | 2 +- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java b/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java index b99ba6c2..013f018c 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java @@ -240,15 +240,17 @@ public class FlowFormDao { List previousFormIds = flowEdgesList.stream() .map(FlowEdgesEntity::getSourceId) .toList(); + if (previousFormIds.size() == 1) { + return previousFormIds.get(0); + } List applicationFormEntities=applicationFormRepository.findByFormIdInAndApplicationId(previousFormIds,applicationEntity.getId()); - applicationFormEntities.sort(Comparator.comparing(ApplicationFormEntity::getCreatedDate).reversed()); return applicationFormEntities.isEmpty() ? null : applicationFormEntities.get(0).getForm().getId(); } - public NextOrPreviousFormResponse getnextOrPreviousForm(ApplicationEntity applicationEntity, Long formId, - FormActionEnum action) { + public NextOrPreviousFormResponse getNextOrPreviousForm(ApplicationEntity applicationEntity, Long formId, + FormActionEnum action) { Long calculatedFormId = null; FormEntity formEntity = null; if (formId == null) { @@ -299,7 +301,7 @@ public class FlowFormDao { List flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId()); Long totalFormSteps = calculateTotalSteps(flowEdgesList); - Long currentStep = calculateCurrentStep(formEntity); + Long currentStep = calculateCurrentStep(flowEdgesList, formEntity); nextOrPreviousFormResponse.setTotalFormSteps(totalFormSteps); completedSteps = getCompletedSteps(applicationEntity); nextOrPreviousFormResponse.setCompletedSteps(Long.valueOf(completedSteps)); @@ -321,11 +323,11 @@ public class FlowFormDao { return completedSteps; } - public Long calculateCurrentStep(FormEntity formEntity) { + public Long calculateCurrentStep(List flowEdgesList, FormEntity formEntity) { Long currentStep = 2l; if (formEntity.getId().equals(formEntity.getCall().getInitialForm())) { currentStep = 1l; - } else if (formEntity.getId().equals(formEntity.getCall().getFinalForm())) { + } else if (flowEdgesList.size()>1 && formEntity.getId().equals(formEntity.getCall().getFinalForm())) { currentStep = 3l; } return currentStep; @@ -341,13 +343,22 @@ public class FlowFormDao { private Long getDefaultForm(ApplicationEntity applicationEntity) { List applicationFormList = applicationFormRepository.findByApplicationIdOrderByCreatedDateAsc(applicationEntity.getId()); - if(applicationFormList.isEmpty()) { + if (applicationFormList.isEmpty()) { return applicationEntity.getCall().getInitialForm(); } - if(applicationFormList.get(applicationFormList.size()-1).getForm().getId().equals(applicationEntity.getCall().getFinalForm())) { - return applicationEntity.getCall().getInitialForm(); + if (applicationFormList.get(applicationFormList.size() - 1).getForm().getId().equals(applicationEntity.getCall().getFinalForm())) { + return applicationEntity.getCall().getInitialForm(); } - return getNextForm(applicationFormList.get(applicationFormList.size()-1).getForm(), applicationEntity); + FormEntity currentFormEntity = applicationFormList.get(applicationFormList.size() - 1).getForm(); + + for (ApplicationFormEntity applicationFormEntity : applicationFormList) { + Boolean isCompleted = formDao.validateCompletedSteps(applicationFormFieldRepository.findByApplicationFormId(applicationFormEntity.getId()), applicationEntity, applicationFormEntity.getForm()); + if (Boolean.FALSE.equals(isCompleted)) { + currentFormEntity = applicationFormEntity.getForm(); + break; + } + } + return getNextForm(currentFormEntity, applicationEntity); } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java index a64afadf..c69354b2 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java @@ -72,7 +72,7 @@ public class ApplicationServiceImpl implements ApplicationService { public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId, FormActionEnum action) { ApplicationEntity applicationEntity = validateApplication(applicationId); - return flowFormDao.getnextOrPreviousForm(applicationEntity, formId, action); + return flowFormDao.getNextOrPreviousForm(applicationEntity, formId, action); } @Override From fa4634972075c1989da9b7e827399760c9e01a74 Mon Sep 17 00:00:00 2001 From: nishainnogent Date: Fri, 4 Oct 2024 19:28:41 +0530 Subject: [PATCH 5/8] updated code --- .../tendermanagement/dao/FlowFormDao.java | 132 +++++++++--------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java b/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java index 013f018c..1ffb9059 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java @@ -1,6 +1,7 @@ package net.gepafin.tendermanagement.dao; import java.util.*; +import java.util.stream.Collectors; import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum; import net.gepafin.tendermanagement.repositories.*; @@ -174,81 +175,81 @@ public class FlowFormDao { .orElse(null); } -// public Long getPreviousForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) { -// // Retrieve the flow edges for the previous forms -// List flowEdgesList = flowEdgesRepository.findByTargetIdAndCallId( -// currentFormEntity.getId(), applicationEntity.getCall().getId()); -// -// if (flowEdgesList.isEmpty()) { -// return null; -//// throw new ResourceNotFoundException(Status.NOT_FOUND, -//// Translator.toLocale(GepafinConstant.PREVIOUS_FORM_NOT_FOUND)); -// } -// -// // If only one edge exists, return the source form ID -// if (flowEdgesList.size() == 1) { -// return flowEdgesList.get(0).getSourceId(); -// } -// -// // For multiple edges, find the previous form based on the chosen value -// List previousFormIds = flowEdgesList.stream() -// .map(FlowEdgesEntity::getSourceId) -// .toList(); -// -// // Fetch the flow data based on previous form IDs -// List flowDataList = flowDataRepository.findByFormIdInAndCallId( -// previousFormIds, applicationEntity.getCall().getId()); -// -// List chosenValues = flowDataList.stream() -// .map(FlowDataEntity::getChoosenValue) -// .toList(); -// -// // Fetch the previous forms based on the chosen field values -// Set formList = applicationFormFieldRepository -// .findByFieldValueInAndApplicationFormApplicationId(chosenValues, applicationEntity.getId()).stream() -// .map(fieldEntity -> fieldEntity.getApplicationForm().getForm()) -// .collect(Collectors.toSet()); -// -// // Find next form IDs recursively for all forms in the formList -// List fieldIds = formList.stream() -// .map(formEntity -> getNextForm(formEntity, applicationEntity)) -// .toList(); -// -// // Return the first matching previous form ID that corresponds to a next form -// return previousFormIds.stream() -// .filter(fieldIds::contains) -// .findFirst().orElse(null); -// } - public Long getPreviousForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) { + // Retrieve the flow edges for the previous forms + List flowEdgesList = flowEdgesRepository.findByTargetIdAndCallId( + currentFormEntity.getId(), applicationEntity.getCall().getId()); - List flowEdgesList = flowEdgesRepository.findByTargetIdAndCallId( - currentFormEntity.getId(), applicationEntity.getCall().getId()); - - if (flowEdgesList.isEmpty()) { - return null; + if (flowEdgesList.isEmpty()) { + return null; // throw new ResourceNotFoundException(Status.NOT_FOUND, // Translator.toLocale(GepafinConstant.PREVIOUS_FORM_NOT_FOUND)); } - // // If only one edge exists, return the source form ID - // if (flowEdgesList.size() == 1) { - // return flowEdgesList.get(0).getSourceId(); - // } + // If only one edge exists, return the source form ID + if (flowEdgesList.size() == 1) { + return flowEdgesList.get(0).getSourceId(); + } // For multiple edges, find the previous form based on the chosen value - List previousFormIds = flowEdgesList.stream() - .map(FlowEdgesEntity::getSourceId) - .toList(); - if (previousFormIds.size() == 1) { - return previousFormIds.get(0); - } + List previousFormIds = flowEdgesList.stream() + .map(FlowEdgesEntity::getSourceId) + .toList(); - List applicationFormEntities=applicationFormRepository.findByFormIdInAndApplicationId(previousFormIds,applicationEntity.getId()); - applicationFormEntities.sort(Comparator.comparing(ApplicationFormEntity::getCreatedDate).reversed()); + // Fetch the flow data based on previous form IDs + List flowDataList = flowDataRepository.findByFormIdInAndCallId( + previousFormIds, applicationEntity.getCall().getId()); - return applicationFormEntities.isEmpty() ? null : applicationFormEntities.get(0).getForm().getId(); + List chosenValues = flowDataList.stream() + .map(FlowDataEntity::getChoosenValue) + .toList(); + + // Fetch the previous forms based on the chosen field values + Set formList = applicationFormFieldRepository + .findByFieldValueInAndApplicationFormApplicationId(chosenValues, applicationEntity.getId()).stream() + .map(fieldEntity -> fieldEntity.getApplicationForm().getForm()) + .collect(Collectors.toSet()); + + // Find next form IDs recursively for all forms in the formList + List fieldIds = formList.stream() + .map(formEntity -> getNextForm(formEntity, applicationEntity)) + .toList(); + + // Return the first matching previous form ID that corresponds to a next form + return previousFormIds.stream() + .filter(fieldIds::contains) + .findFirst().orElse(null); } + +// public Long getPreviousForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) { +// +// List flowEdgesList = flowEdgesRepository.findByTargetIdAndCallId( +// currentFormEntity.getId(), applicationEntity.getCall().getId()); +// +// if (flowEdgesList.isEmpty()) { +// return null; +//// throw new ResourceNotFoundException(Status.NOT_FOUND, +//// Translator.toLocale(GepafinConstant.PREVIOUS_FORM_NOT_FOUND)); +// } +// +// // // If only one edge exists, return the source form ID +// // if (flowEdgesList.size() == 1) { +// // return flowEdgesList.get(0).getSourceId(); +// // } +// +// // For multiple edges, find the previous form based on the chosen value +// List previousFormIds = flowEdgesList.stream() +// .map(FlowEdgesEntity::getSourceId) +// .toList(); +// if (previousFormIds.size() == 1) { +// return previousFormIds.get(0); +// } +// +// List applicationFormEntities=applicationFormRepository.findByFormIdInAndApplicationId(previousFormIds,applicationEntity.getId()); +// applicationFormEntities.sort(Comparator.comparing(ApplicationFormEntity::getCreatedDate).reversed()); +// +// return applicationFormEntities.isEmpty() ? null : applicationFormEntities.get(0).getForm().getId(); +// } public NextOrPreviousFormResponse getNextOrPreviousForm(ApplicationEntity applicationEntity, Long formId, FormActionEnum action) { Long calculatedFormId = null; @@ -354,8 +355,7 @@ public class FlowFormDao { for (ApplicationFormEntity applicationFormEntity : applicationFormList) { Boolean isCompleted = formDao.validateCompletedSteps(applicationFormFieldRepository.findByApplicationFormId(applicationFormEntity.getId()), applicationEntity, applicationFormEntity.getForm()); if (Boolean.FALSE.equals(isCompleted)) { - currentFormEntity = applicationFormEntity.getForm(); - break; + return applicationFormEntity.getForm().getId(); } } return getNextForm(currentFormEntity, applicationEntity); From 9477c8fe14efaf335ec8ac18190f74602e3fae02 Mon Sep 17 00:00:00 2001 From: harish Date: Mon, 7 Oct 2024 12:45:34 +0530 Subject: [PATCH 6/8] Updated application status api response --- .../gepafin/tendermanagement/constants/GepafinConstant.java | 2 ++ .../net/gepafin/tendermanagement/dao/ApplicationDao.java | 6 ++++-- .../tendermanagement/service/ApplicationService.java | 2 +- .../service/impl/ApplicationServiceImpl.java | 4 ++-- .../tendermanagement/web/rest/api/ApplicationApi.java | 2 +- .../web/rest/api/impl/ApplicationApiController.java | 6 +++--- src/main/resources/message_en.properties | 1 + src/main/resources/message_it.properties | 1 + 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index 3ebf7e5f..cffcc815 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -179,4 +179,6 @@ public class GepafinConstant { public static final String UNAUTHORIZED = "UNAUTHORIZED"; public static final String COMPANY_ID_MANDATORY = "company.id.mandatory"; public static final String USER_ALREADY_CONNECTED_TO_COMPANY = "user.already.connected.to.company"; + public static final String STATUS_UPDATED_SUCCESSFULLY = "status.updated.successfully"; + } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index a76b9de3..50ed07b1 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -492,7 +492,7 @@ public class ApplicationDao { } } - public void updateApplicationStatus(Long applicationId, ApplicationStatusTypeEnum status) { + public ApplicationResponse updateApplicationStatus(Long applicationId, ApplicationStatusTypeEnum status) { ApplicationEntity applicationEntity = validateApplication(applicationId); if (status.equals(ApplicationStatusTypeEnum.SUBMIT)) { @@ -518,7 +518,9 @@ public class ApplicationDao { } else { applicationEntity.setStatus(status.getValue()); } - saveApplicationEntity(applicationEntity); + applicationEntity = saveApplicationEntity(applicationEntity); + + return getApplicationResponse(applicationEntity); } public Integer calculateProgress(Long totalSteps, Long completedSteps) { diff --git a/src/main/java/net/gepafin/tendermanagement/service/ApplicationService.java b/src/main/java/net/gepafin/tendermanagement/service/ApplicationService.java index a8f6ad53..edb62c93 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/ApplicationService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/ApplicationService.java @@ -29,6 +29,6 @@ public interface ApplicationService { public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId, FormActionEnum action); - public void updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status); + public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status); } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java index c69354b2..142d4b01 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java @@ -76,8 +76,8 @@ public class ApplicationServiceImpl implements ApplicationService { } @Override - public void updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) { - applicationDao.updateApplicationStatus(applicationId, status); + public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) { + return applicationDao.updateApplicationStatus(applicationId, status); } diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java index c56680ef..1869655c 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java @@ -127,7 +127,7 @@ public interface ApplicationApi { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @PutMapping(value = "/{applicationId}/status", produces = { "application/json" }) - ResponseEntity> updateApplicationStatus(HttpServletRequest request, + ResponseEntity> updateApplicationStatus(HttpServletRequest request, @Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId, @Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) ApplicationStatusTypeEnum status); diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java index 69f28492..6de3f812 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java @@ -83,10 +83,10 @@ public class ApplicationApiController implements ApplicationApi { } @Override - public ResponseEntity> updateApplicationStatus(HttpServletRequest request, Long applicationId, + public ResponseEntity> updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) { - applicationService.updateApplicationStatus(request, applicationId, status); + ApplicationResponse applicationResponse = applicationService.updateApplicationStatus(request, applicationId, status); return ResponseEntity.status(HttpStatus.OK) - .body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG))); + .body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.STATUS_UPDATED_SUCCESSFULLY))); } } diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index d70c97f4..b921d880 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -206,3 +206,4 @@ vatnumber.already.exists=VatNumber already exists. invalid.email=Invalid email. company.id.mandatory=Company id is mandatory. user.already.connected.to.company=The user is already connected to this company. +status.updated.successfully=Status updated successfully. diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index 00e8dcfc..c81ee2df 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -199,3 +199,4 @@ vatnumber.already.exists=Il numero di partita IVA esiste gi invalid.email=Email non valida. company.id.mandatory=L'ID dell'azienda è obbligatorio. user.already.connected.to.company=L'utente è già collegato a questa azienda. +status.updated.successfully=Stato aggiornato con successo. From 32f075a03dd8163b183234ad88fa9404a90eada7 Mon Sep 17 00:00:00 2001 From: harish Date: Mon, 7 Oct 2024 15:09:16 +0530 Subject: [PATCH 7/8] Added DateOfBirth in UserSamlResponse --- .../tendermanagement/model/response/UserSamlResponse.java | 4 ++++ .../service/impl/AuthenticationService.java | 8 ++++++++ src/main/resources/application-production.properties | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/model/response/UserSamlResponse.java b/src/main/java/net/gepafin/tendermanagement/model/response/UserSamlResponse.java index da732bd4..8fdcbdea 100644 --- a/src/main/java/net/gepafin/tendermanagement/model/response/UserSamlResponse.java +++ b/src/main/java/net/gepafin/tendermanagement/model/response/UserSamlResponse.java @@ -2,6 +2,8 @@ package net.gepafin.tendermanagement.model.response; import lombok.Data; +import java.time.LocalDateTime; + @Data public class UserSamlResponse { @@ -10,4 +12,6 @@ public class UserSamlResponse { private String firstName; private String lastName; + + private LocalDateTime dateOfBirth; } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/AuthenticationService.java b/src/main/java/net/gepafin/tendermanagement/service/impl/AuthenticationService.java index a84b325c..03ce8b1c 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/AuthenticationService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/AuthenticationService.java @@ -33,6 +33,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; import org.springframework.stereotype.Service; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; import java.util.Map; @@ -182,6 +183,13 @@ public class AuthenticationService { && !userAttributes.get("cognome").isEmpty()) { userSamlResponse.setLastName(userAttributes.get("cognome").get(0).toString()); } + if (userAttributes.containsKey("dataNascita") && userAttributes.get("dataNascita") != null + && !userAttributes.get("dataNascita").isEmpty()) { + String dateString =userAttributes.get("dataNascita").get(0).toString(); + LocalDate dateOfBirth = LocalDate.parse(dateString); + LocalDateTime dateOfBirthWithTime = dateOfBirth.atStartOfDay(); + userSamlResponse.setDateOfBirth(dateOfBirthWithTime); + } userSamlResponse.setCodiceFiscale(cf); return userSamlResponse; } diff --git a/src/main/resources/application-production.properties b/src/main/resources/application-production.properties index f4ea18fa..968d5ac5 100644 --- a/src/main/resources/application-production.properties +++ b/src/main/resources/application-production.properties @@ -9,8 +9,8 @@ spring.h2.console.enabled=true base-url=http://bandi-api.gepafin.it isVatCheckGloballyDisabled = false -fe.base.url=http://gepafin-production-fe.s3-website.eu-central-1.amazonaws.com - +#fe.base.url=http://gepafin-production-fe.s3-website.eu-central-1.amazonaws.com +fe.base.url=http://bandi.gepafin.it #SPID configuration spid.ipd.base.url=https://login.regione.umbria.it active.profile.folder=production \ No newline at end of file From 65169e54c3d07b7d89e703da06289b256258cd77 Mon Sep 17 00:00:00 2001 From: harish Date: Mon, 7 Oct 2024 15:17:03 +0530 Subject: [PATCH 8/8] Updated message for application status api response --- .../net/gepafin/tendermanagement/constants/GepafinConstant.java | 2 +- .../web/rest/api/impl/ApplicationApiController.java | 2 +- src/main/resources/message_en.properties | 1 + src/main/resources/message_it.properties | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index cffcc815..89c1e475 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -179,6 +179,6 @@ public class GepafinConstant { public static final String UNAUTHORIZED = "UNAUTHORIZED"; public static final String COMPANY_ID_MANDATORY = "company.id.mandatory"; public static final String USER_ALREADY_CONNECTED_TO_COMPANY = "user.already.connected.to.company"; - public static final String STATUS_UPDATED_SUCCESSFULLY = "status.updated.successfully"; + public static final String APPLICATION_STATUS_UPDATED_SUCCESSFULLY = "application.status.updated.successfully"; } diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java index 6de3f812..bcbf8e80 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java @@ -87,6 +87,6 @@ public class ApplicationApiController implements ApplicationApi { ApplicationStatusTypeEnum status) { ApplicationResponse applicationResponse = applicationService.updateApplicationStatus(request, applicationId, status); return ResponseEntity.status(HttpStatus.OK) - .body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.STATUS_UPDATED_SUCCESSFULLY))); + .body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_STATUS_UPDATED_SUCCESSFULLY))); } } diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index b921d880..3b11067b 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -207,3 +207,4 @@ invalid.email=Invalid email. company.id.mandatory=Company id is mandatory. user.already.connected.to.company=The user is already connected to this company. status.updated.successfully=Status updated successfully. +application.status.updated.successfully = Application status updated successfully. diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index c81ee2df..27ebd36d 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -200,3 +200,4 @@ invalid.email=Email non valida. company.id.mandatory=L'ID dell'azienda è obbligatorio. user.already.connected.to.company=L'utente è già collegato a questa azienda. status.updated.successfully=Stato aggiornato con successo. +application.status.updated.successfully = Stato dell'applicazione aggiornato con successo.