Implemnted new flow for application form data
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -46,7 +44,9 @@ public class FlowFormDao {
|
||||
@Autowired
|
||||
private FormService formService;
|
||||
@Autowired
|
||||
private FormRepository formRepository;
|
||||
private FormDao formDao;
|
||||
|
||||
|
||||
|
||||
// Long getNextForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) {
|
||||
// // vlaidation if next form findout and cuuent from is not fill the give error
|
||||
@@ -274,16 +274,24 @@ public class FlowFormDao {
|
||||
}
|
||||
}
|
||||
NextOrPreviousFormResponse nextOrPreviousFormResponse = null;
|
||||
if (calculatedFormId != null) {
|
||||
nextOrPreviousFormResponse = setNextOrPreviousResponse(calculatedFormId, applicationEntity);
|
||||
if (calculatedFormId == null && formId == null) {
|
||||
FormEntity form=formService.validateForm(applicationEntity.getCall().getInitialForm());
|
||||
calculatedFormId=form.getId();
|
||||
}
|
||||
if (calculatedFormId == null) {
|
||||
calculatedFormId=formId;
|
||||
}
|
||||
nextOrPreviousFormResponse = setNextOrPreviousResponse(calculatedFormId, applicationEntity);
|
||||
|
||||
return nextOrPreviousFormResponse;
|
||||
}
|
||||
|
||||
private NextOrPreviousFormResponse setNextOrPreviousResponse(Long calculatedFormId, ApplicationEntity applicationEntity) {
|
||||
NextOrPreviousFormResponse nextOrPreviousFormResponse = new NextOrPreviousFormResponse();
|
||||
Integer completedSteps=0;
|
||||
FormEntity formEntity = formService.validateForm(calculatedFormId);
|
||||
nextOrPreviousFormResponse.setFormId(calculatedFormId);
|
||||
nextOrPreviousFormResponse.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(applicationEntity.getStatus()));
|
||||
nextOrPreviousFormResponse.setApplicationFormResponse(
|
||||
applicationDao.processForm(formEntity, applicationEntity));
|
||||
nextOrPreviousFormResponse.setCallId(applicationEntity.getCall().getId());
|
||||
@@ -292,13 +300,27 @@ public class FlowFormDao {
|
||||
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
|
||||
Long totalFormSteps = calculateTotalSteps(flowEdgesList);
|
||||
Long currentStep = calculateCurrentStep(formEntity);
|
||||
List<ApplicationFormEntity> applicationFormList = applicationFormRepository.findByApplicationId(applicationEntity.getId());
|
||||
nextOrPreviousFormResponse.setTotalFormSteps(totalFormSteps);
|
||||
nextOrPreviousFormResponse.setCompletedSteps(Long.valueOf(applicationFormList.size()));
|
||||
completedSteps = getCompletedSteps(applicationEntity);
|
||||
nextOrPreviousFormResponse.setCompletedSteps(Long.valueOf(completedSteps));
|
||||
nextOrPreviousFormResponse.setCurrentStep(currentStep);
|
||||
return nextOrPreviousFormResponse;
|
||||
}
|
||||
|
||||
public Integer getCompletedSteps(ApplicationEntity applicationEntity) {
|
||||
Integer completedSteps=0;
|
||||
List<ApplicationFormEntity> applicationFormList = applicationFormRepository.findByApplicationId(applicationEntity.getId());
|
||||
List<ApplicationFormFieldEntity> applicationFormFieldEntities=new ArrayList<>();
|
||||
for (ApplicationFormEntity applicationFormEntity:applicationFormList){
|
||||
applicationFormFieldEntities=applicationFormFieldRepository.findByApplicationFormId(applicationFormEntity.getId());
|
||||
Boolean isCompleted=formDao.validateCompletedSteps(applicationFormFieldEntities, applicationEntity, applicationFormEntity.getForm());
|
||||
if(Boolean.TRUE.equals(isCompleted)){
|
||||
completedSteps++;
|
||||
}
|
||||
}
|
||||
return completedSteps;
|
||||
}
|
||||
|
||||
public Long calculateCurrentStep(FormEntity formEntity) {
|
||||
Long currentStep = 2l;
|
||||
if (formEntity.getId().equals(formEntity.getCall().getInitialForm())) {
|
||||
|
||||
Reference in New Issue
Block a user