Fixed form issue
This commit is contained in:
@@ -92,17 +92,20 @@ public class FormDao {
|
|||||||
}
|
}
|
||||||
public FormResponseBean updateForm(Long formId, FormRequest formRequest,Boolean forceDeleteFlow){
|
public FormResponseBean updateForm(Long formId, FormRequest formRequest,Boolean forceDeleteFlow){
|
||||||
ContentRequestBean contentRequestBean2=null;
|
ContentRequestBean contentRequestBean2=null;
|
||||||
|
String choosenField=null;
|
||||||
FormEntity formEntity = validateForm(formId);
|
FormEntity formEntity = validateForm(formId);
|
||||||
callDao.validateUpdate(formEntity.getCall());
|
callDao.validateUpdate(formEntity.getCall());
|
||||||
FlowDataEntity flowDataEntity=flowDataRepository.findByFormIdAndCallId(formEntity.getId(),formEntity.getCall().getId());
|
List<ContentRequestBean> contentRequestBean = Utils.convertJsonStringToList(formEntity.getContent(), ContentRequestBean.class);
|
||||||
String choosenField=flowDataEntity.getChoosenField();
|
for (ContentRequestBean contentRequestBean1 : contentRequestBean) {
|
||||||
List<ContentRequestBean> contentRequestBean=Utils.convertJsonStringToList(formEntity.getContent(),ContentRequestBean.class);
|
FlowDataEntity flowDataEntity = flowDataRepository.findByFormIdAndChoosenField(formEntity.getId(), contentRequestBean1.getId());
|
||||||
for (ContentRequestBean contentRequestBean1:contentRequestBean){
|
if (flowDataEntity != null) {
|
||||||
if(Boolean.TRUE.equals(contentRequestBean1.getId().equals(choosenField))){
|
choosenField = flowDataEntity.getChoosenField();
|
||||||
contentRequestBean2=contentRequestBean1;
|
if (Boolean.TRUE.equals(contentRequestBean1.getId().equals(choosenField))) {
|
||||||
|
contentRequestBean2 = contentRequestBean1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (contentRequestBean2 != null) {
|
if (contentRequestBean2 != null) {
|
||||||
List<SettingRequestBean> settingRequestBeansDB = contentRequestBean2.getSettings();
|
List<SettingRequestBean> settingRequestBeansDB = contentRequestBean2.getSettings();
|
||||||
for (ContentRequestBean contentRequestBeanRequest : formRequest.getContent()) {
|
for (ContentRequestBean contentRequestBeanRequest : formRequest.getContent()) {
|
||||||
@@ -111,21 +114,21 @@ public class FormDao {
|
|||||||
for (SettingRequestBean settingRequestBeanDB : settingRequestBeansDB) {
|
for (SettingRequestBean settingRequestBeanDB : settingRequestBeansDB) {
|
||||||
if (settingRequestBeanRequest.getName().equals(settingRequestBeanDB.getName())) {
|
if (settingRequestBeanRequest.getName().equals(settingRequestBeanDB.getName())) {
|
||||||
if (!settingRequestBeanRequest.getValue().equals(settingRequestBeanDB.getValue())) {
|
if (!settingRequestBeanRequest.getValue().equals(settingRequestBeanDB.getValue())) {
|
||||||
if(Boolean.TRUE.equals(forceDeleteFlow)) {
|
if (Boolean.TRUE.equals(forceDeleteFlow)) {
|
||||||
Utils.setIfUpdated(formEntity::getLabel,formEntity::setLabel,formRequest.getLabel());
|
Utils.setIfUpdated(formEntity::getLabel, formEntity::setLabel, formRequest.getLabel());
|
||||||
Utils.setIfUpdated(formEntity::getContent,formEntity::setContent,setContentResponseBean(formRequest.getContent()));
|
Utils.setIfUpdated(formEntity::getContent, formEntity::setContent, setContentResponseBean(formRequest.getContent()));
|
||||||
formEntity.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
formEntity.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
formEntity=saveFormEntity(formEntity);
|
formEntity = saveFormEntity(formEntity);
|
||||||
List<FlowDataEntity> flowDataEntities=flowDataRepository.findByCallId(formEntity.getCall().getId());
|
List<FlowDataEntity> flowDataEntities = flowDataRepository.findByCallId(formEntity.getCall().getId());
|
||||||
List<FlowEdgesEntity> flowEdgesEntities=flowEdgesRepository.findByCallId(formEntity.getCall().getId());
|
List<FlowEdgesEntity> flowEdgesEntities = flowEdgesRepository.findByCallId(formEntity.getCall().getId());
|
||||||
flowDataRepository.deleteAll(flowDataEntities);
|
flowDataRepository.deleteAll(flowDataEntities);
|
||||||
flowEdgesRepository.deleteAll(flowEdgesEntities);
|
flowEdgesRepository.deleteAll(flowEdgesEntities);
|
||||||
CallEntity callEntity=formEntity.getCall();
|
CallEntity callEntity = formEntity.getCall();
|
||||||
callEntity.setInitialForm(null);
|
callEntity.setInitialForm(null);
|
||||||
callEntity.setFinalForm(null);
|
callEntity.setFinalForm(null);
|
||||||
callRepository.save(callEntity);
|
callRepository.save(callEntity);
|
||||||
return convertFormEntityToFormResponseBean(formEntity);
|
return convertFormEntityToFormResponseBean(formEntity);
|
||||||
}else {
|
} else {
|
||||||
throw new CustomValidationException(
|
throw new CustomValidationException(
|
||||||
Status.BAD_REQUEST,
|
Status.BAD_REQUEST,
|
||||||
Translator.toLocale(GepafinConstant.UPDATING_FORM_VALUE_IMPACT_ON_FLOW, choosenField)
|
Translator.toLocale(GepafinConstant.UPDATING_FORM_VALUE_IMPACT_ON_FLOW, choosenField)
|
||||||
@@ -138,6 +141,13 @@ public class FormDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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 null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,4 +17,7 @@ public interface FlowDataRepository extends JpaRepository<FlowDataEntity,Long> {
|
|||||||
public Optional<FlowDataEntity> findByChoosenValueAndFormIdIn(String fieldValue, List<Long> nextFormIds);
|
public Optional<FlowDataEntity> findByChoosenValueAndFormIdIn(String fieldValue, List<Long> nextFormIds);
|
||||||
|
|
||||||
public List<FlowDataEntity> findByFormIdInAndCallId(List<Long> previousFormIds, Long callId);
|
public List<FlowDataEntity> findByFormIdInAndCallId(List<Long> previousFormIds, Long callId);
|
||||||
|
|
||||||
|
public FlowDataEntity findByFormIdAndChoosenField(Long formId, String choosenField);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user