Resolved conflicts
This commit is contained in:
@@ -155,4 +155,5 @@ public class GepafinConstant {
|
||||
public static final String IS_CODICE_FISCALE="isCodiceFiscale";
|
||||
public static final String IS_PIVA="isPIVA";
|
||||
|
||||
public static final String FAILED_RETAIN_FIELD="failed.retain.field";
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@ package net.gepafin.tendermanagement.dao;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.service.*;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -424,8 +426,14 @@ public class CallDao {
|
||||
|
||||
public CallResponse updateCallStep1(Long callId, UpdateCallRequestStep1 updateCallRequest, Long userId) {
|
||||
CallEntity callEntity = validateCall(callId);
|
||||
validateUpdate(callEntity);
|
||||
UserEntity userEntity = userService.validateUser(userId);
|
||||
if(Boolean.TRUE.equals(callEntity.getStatus().equals(CallStatusEnum.PUBLISH.getValue()))) {
|
||||
try {
|
||||
Utils.retainOnlySpecificFields(updateCallRequest, Collections.singletonList("faq"));
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.FAILED_RETAIN_FIELD));
|
||||
}
|
||||
}
|
||||
UserEntity userEntity = userService.validateUser(userId);
|
||||
isValidDateRange(updateCallRequest, callEntity);
|
||||
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
|
||||
setIfUpdated(callEntity::getDescriptionShort, callEntity::setDescriptionShort,
|
||||
|
||||
@@ -95,55 +95,65 @@ public class FormDao {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.REQUIRED_PARAMETER_NOT_FOUND_FOR_FORM));
|
||||
}
|
||||
}
|
||||
public FormResponseBean updateForm(Long formId, FormRequest formRequest,Boolean forceDeleteFlow){
|
||||
public FormResponseBean updateForm(Long formId, FormRequest formRequest,Boolean forceDeleteFlow){
|
||||
ContentRequestBean contentRequestBean2=null;
|
||||
String choosenField=null;
|
||||
FormEntity formEntity = validateForm(formId);
|
||||
callDao.validateUpdate(formEntity.getCall());
|
||||
FlowDataEntity flowDataEntity=flowDataRepository.findByFormIdAndCallId(formEntity.getId(),formEntity.getCall().getId());
|
||||
String choosenField=flowDataEntity.getChoosenField();
|
||||
List<ContentRequestBean> contentRequestBean=Utils.convertJsonStringToList(formEntity.getContent(),ContentRequestBean.class);
|
||||
for (ContentRequestBean contentRequestBean1:contentRequestBean){
|
||||
if(Boolean.TRUE.equals(contentRequestBean1.getId().equals(choosenField))){
|
||||
contentRequestBean2=contentRequestBean1;
|
||||
break;
|
||||
callDao.validateUpdate(formEntity.getCall());
|
||||
List<ContentRequestBean> contentRequestBean = Utils.convertJsonStringToList(formEntity.getContent(), ContentRequestBean.class);
|
||||
for (ContentRequestBean contentRequestBean1 : contentRequestBean) {
|
||||
FlowDataEntity flowDataEntity = flowDataRepository.findByFormIdAndChoosenField(formEntity.getId(), contentRequestBean1.getId());
|
||||
if (flowDataEntity != null) {
|
||||
choosenField = flowDataEntity.getChoosenField();
|
||||
if (Boolean.TRUE.equals(contentRequestBean1.getId().equals(choosenField))) {
|
||||
contentRequestBean2 = contentRequestBean1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (contentRequestBean2 != null) {
|
||||
List<SettingRequestBean> settingRequestBeansDB = contentRequestBean2.getSettings();
|
||||
for (ContentRequestBean contentRequestBeanRequest : formRequest.getContent()) {
|
||||
if (contentRequestBeanRequest.getId().equals(contentRequestBean2.getId())) {
|
||||
for (SettingRequestBean settingRequestBeanRequest : contentRequestBeanRequest.getSettings()) {
|
||||
for (SettingRequestBean settingRequestBeanDB : settingRequestBeansDB) {
|
||||
if (settingRequestBeanRequest.getName().equals(settingRequestBeanDB.getName())) {
|
||||
if (!settingRequestBeanRequest.getValue().equals(settingRequestBeanDB.getValue())) {
|
||||
if(Boolean.TRUE.equals(forceDeleteFlow)) {
|
||||
Utils.setIfUpdated(formEntity::getLabel,formEntity::setLabel,formRequest.getLabel());
|
||||
Utils.setIfUpdated(formEntity::getContent,formEntity::setContent,setContentResponseBean(formRequest.getContent()));
|
||||
formEntity.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
formEntity=saveFormEntity(formEntity);
|
||||
List<FlowDataEntity> flowDataEntities=flowDataRepository.findByCallId(formEntity.getCall().getId());
|
||||
List<FlowEdgesEntity> flowEdgesEntities=flowEdgesRepository.findByCallId(formEntity.getCall().getId());
|
||||
flowDataRepository.deleteAll(flowDataEntities);
|
||||
flowEdgesRepository.deleteAll(flowEdgesEntities);
|
||||
CallEntity callEntity=formEntity.getCall();
|
||||
callEntity.setInitialForm(null);
|
||||
callEntity.setFinalForm(null);
|
||||
callRepository.save(callEntity);
|
||||
return convertFormEntityToFormResponseBean(formEntity);
|
||||
}else {
|
||||
throw new CustomValidationException(
|
||||
Status.BAD_REQUEST,
|
||||
Translator.toLocale(GepafinConstant.UPDATING_FORM_VALUE_IMPACT_ON_FLOW, choosenField)
|
||||
);
|
||||
}
|
||||
if (contentRequestBean2 != null) {
|
||||
List<SettingRequestBean> settingRequestBeansDB = contentRequestBean2.getSettings();
|
||||
for (ContentRequestBean contentRequestBeanRequest : formRequest.getContent()) {
|
||||
if (contentRequestBeanRequest.getId().equals(contentRequestBean2.getId())) {
|
||||
for (SettingRequestBean settingRequestBeanRequest : contentRequestBeanRequest.getSettings()) {
|
||||
for (SettingRequestBean settingRequestBeanDB : settingRequestBeansDB) {
|
||||
if (settingRequestBeanRequest.getName().equals(settingRequestBeanDB.getName())) {
|
||||
if (!settingRequestBeanRequest.getValue().equals(settingRequestBeanDB.getValue())) {
|
||||
if (Boolean.TRUE.equals(forceDeleteFlow)) {
|
||||
Utils.setIfUpdated(formEntity::getLabel, formEntity::setLabel, formRequest.getLabel());
|
||||
Utils.setIfUpdated(formEntity::getContent, formEntity::setContent, setContentResponseBean(formRequest.getContent()));
|
||||
formEntity.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
formEntity = saveFormEntity(formEntity);
|
||||
List<FlowDataEntity> flowDataEntities = flowDataRepository.findByCallId(formEntity.getCall().getId());
|
||||
List<FlowEdgesEntity> flowEdgesEntities = flowEdgesRepository.findByCallId(formEntity.getCall().getId());
|
||||
flowDataRepository.deleteAll(flowDataEntities);
|
||||
flowEdgesRepository.deleteAll(flowEdgesEntities);
|
||||
CallEntity callEntity = formEntity.getCall();
|
||||
callEntity.setInitialForm(null);
|
||||
callEntity.setFinalForm(null);
|
||||
callRepository.save(callEntity);
|
||||
return convertFormEntityToFormResponseBean(formEntity);
|
||||
} else {
|
||||
throw new CustomValidationException(
|
||||
Status.BAD_REQUEST,
|
||||
Translator.toLocale(GepafinConstant.UPDATING_FORM_VALUE_IMPACT_ON_FLOW, choosenField)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Utils.setIfUpdated(formEntity::getLabel, formEntity::setLabel, formRequest.getLabel());
|
||||
Utils.setIfUpdated(formEntity::getContent, formEntity::setContent, setContentResponseBean(formRequest.getContent()));
|
||||
formEntity.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
formEntity = saveFormEntity(formEntity);
|
||||
return convertFormEntityToFormResponseBean(formEntity);
|
||||
}
|
||||
return null;
|
||||
return convertFormEntityToFormResponseBean(formEntity);
|
||||
}
|
||||
|
||||
public FormEntity validateForm(Long formId) {
|
||||
|
||||
@@ -17,4 +17,7 @@ public interface FlowDataRepository extends JpaRepository<FlowDataEntity,Long> {
|
||||
public Optional<FlowDataEntity> findByChoosenValueAndFormIdIn(String fieldValue, List<Long> nextFormIds);
|
||||
|
||||
public List<FlowDataEntity> findByFormIdInAndCallId(List<Long> previousFormIds, Long callId);
|
||||
|
||||
public FlowDataEntity findByFormIdAndChoosenField(Long formId, String choosenField);
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.apache.commons.collections4.MapUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
@@ -147,4 +148,17 @@ public class Utils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static <T> void retainOnlySpecificFields(T requestObject, List<T> retainFields) throws IllegalAccessException {
|
||||
// Get all declared fields of the request object's class
|
||||
Field[] fields = requestObject.getClass().getDeclaredFields();
|
||||
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true); // To allow access to private fields
|
||||
|
||||
// Check if the field is in the retainFields list
|
||||
if (!retainFields.contains(field.getName())) {
|
||||
field.set(requestObject, null); // Set the field to null if not in the retain list
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,4 +181,5 @@ validation.piva=The VAT number for {0} must be up to 11 digits.
|
||||
valid.vat.number=The VAT number is not valid for field {0}.
|
||||
|
||||
|
||||
failed.retain.field=Failed to retain specific fields.
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ application.not.found=Applicazione non trovata con l'ID fornito.
|
||||
application.form.field.not.found=Campo del modulo di domanda non trovato.
|
||||
Form.not.matches.to.call.initial.form=L'ID del modulo non corrisponde all'ID del modulo iniziale della chiamata.
|
||||
application.already.exists=L'applicazione esiste gi<67> per questa chiamata.
|
||||
application.already.submitted=La domanda è già stata inviata.
|
||||
application.already.submitted=La domanda <EFBFBD> gi<EFBFBD> stata inviata.
|
||||
|
||||
#Validation related messages
|
||||
validation.field.required=Il campo {0} <20> obbligatorio.
|
||||
@@ -159,10 +159,10 @@ current.form.incomplete=il modulo corrente non <20> compilato
|
||||
flow.not.found=Flow not found.
|
||||
validation.message=Messaggi di convalida.
|
||||
action.required=Campo azione obbligatorio.
|
||||
call.not.published=La chiamata non è stata pubblicata.
|
||||
call.not.published=La chiamata non <EFBFBD> stata pubblicata.
|
||||
application.form.not.found=Modulo di domanda non trovato.
|
||||
|
||||
updating.form.value.impact.on.flow=L'aggiornamento di questo valore del modulo {0} può avere un impatto sul flusso.
|
||||
updating.form.value.impact.on.flow=L'aggiornamento di questo valore del modulo {0} pu<EFBFBD> avere un impatto sul flusso.
|
||||
validation.field.custom=Il valore per il campo {0} non soddisfa la regola di convalida personalizzata.
|
||||
|
||||
validation.codice.fiscale=Il campo {0} deve essere un Codice Fiscale valido con esattamente 16 caratteri: 6 lettere, 2 cifre, 1 lettera, 2 cifre, 1 lettera, 3 cifre e 1 lettera.
|
||||
@@ -173,4 +173,5 @@ validation.email.pec=Il campo {0} deve essere un indirizzo email PEC valido.
|
||||
validation.url=Il campo {0} deve essere un URL valido.
|
||||
validation.marca.da.bollo=Il campo {0} deve essere una Marca Da Bollo valida con esattamente 14 cifre.
|
||||
validation.piva=Il numero di partita IVA per {0} deve essere lungo fino a 11 cifre.
|
||||
valid.vat.number=Il numero di partita IVA non è valido per il campo {0}.
|
||||
valid.vat.number=Il numero di partita IVA non <EFBFBD> valido per il campo {0}.
|
||||
failed.retain.field=Impossibile conservare campi specifici.
|
||||
|
||||
Reference in New Issue
Block a user