Done ticket BE-24,25
This commit is contained in:
@@ -226,31 +226,53 @@ public class FlowFormDao {
|
||||
public NextOrPreviousFormResponse getnextOrPreviousForm(ApplicationEntity applicationEntity, Long formId,
|
||||
FormActionEnum action) {
|
||||
Long calculatedFormId = null;
|
||||
FormEntity fromEntity = null;
|
||||
FormEntity formEntity = null;
|
||||
if (formId == null) {
|
||||
calculatedFormId = getDefaultForm(applicationEntity);
|
||||
} else {
|
||||
fromEntity = Optional
|
||||
if(action==null) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.ACTION_REQUIRED));
|
||||
}
|
||||
formEntity = Optional
|
||||
.of(applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(), formId))
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.FORM_NOT_FOUND)))
|
||||
.getForm();
|
||||
|
||||
if (action.equals(FormActionEnum.NEXT)) {
|
||||
calculatedFormId = getNextForm(fromEntity, applicationEntity);
|
||||
calculatedFormId = getNextForm(formEntity, applicationEntity);
|
||||
} else {
|
||||
calculatedFormId = getPreviousForm(fromEntity, applicationEntity);
|
||||
calculatedFormId = getPreviousForm(formEntity, applicationEntity);
|
||||
}
|
||||
}
|
||||
NextOrPreviousFormResponse nextOrPreviousFormResponse = new NextOrPreviousFormResponse();
|
||||
NextOrPreviousFormResponse nextOrPreviousFormResponse = null;
|
||||
if (calculatedFormId != null) {
|
||||
nextOrPreviousFormResponse.setFormId(calculatedFormId);
|
||||
nextOrPreviousFormResponse.setApplicationFormResponse(
|
||||
applicationDao.processForm(formService.validateForm(calculatedFormId), applicationEntity));
|
||||
nextOrPreviousFormResponse = setNextOrPreviousResponse(calculatedFormId, applicationEntity);
|
||||
}
|
||||
return nextOrPreviousFormResponse;
|
||||
}
|
||||
|
||||
private NextOrPreviousFormResponse setNextOrPreviousResponse(Long calculatedFormId, ApplicationEntity applicationEntity) {
|
||||
NextOrPreviousFormResponse nextOrPreviousFormResponse = new NextOrPreviousFormResponse();
|
||||
FormEntity formEntity = formService.validateForm(calculatedFormId);
|
||||
nextOrPreviousFormResponse.setFormId(calculatedFormId);
|
||||
nextOrPreviousFormResponse.setApplicationFormResponse(
|
||||
applicationDao.processForm(formEntity, applicationEntity));
|
||||
nextOrPreviousFormResponse.setCallId(applicationEntity.getCall().getId());
|
||||
nextOrPreviousFormResponse.setCallTitle(applicationEntity.getCall().getDescriptionShort());
|
||||
|
||||
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
|
||||
Long totalFormSteps = 3l;
|
||||
if (flowEdgesList.size() == 1) {
|
||||
totalFormSteps = 2l;
|
||||
}
|
||||
List<ApplicationFormEntity> applicationFormList = applicationFormRepository.findByApplicationId(applicationEntity.getId());
|
||||
nextOrPreviousFormResponse.setTotalFormSteps(totalFormSteps);
|
||||
nextOrPreviousFormResponse.setCompletedSteps(Long.valueOf(applicationFormList.size()));
|
||||
return nextOrPreviousFormResponse;
|
||||
}
|
||||
|
||||
private Long getDefaultForm(ApplicationEntity applicationEntity) {
|
||||
List<ApplicationFormEntity> applicationFormList = applicationFormRepository.findByApplicationIdOrderByCreatedDateAsc(applicationEntity.getId());
|
||||
if(applicationFormList.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user