Applied validation

This commit is contained in:
rajesh
2024-09-17 16:15:15 +05:30
parent 6959ac0a65
commit d2fed5e168
14 changed files with 57 additions and 10 deletions

View File

@@ -21,6 +21,7 @@ import net.gepafin.tendermanagement.repositories.FlowEdgesRepository;
import net.gepafin.tendermanagement.service.CallService;
import net.gepafin.tendermanagement.service.FormService;
import net.gepafin.tendermanagement.util.DateTimeUtil;
import net.gepafin.tendermanagement.util.FieldValidator;
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +50,9 @@ public class FlowDao {
@Autowired
private FormService formService;
@Autowired
private CallDao callDao;
public FlowResponseBean createOrUpdateFlow(FlowRequestBean flowRequestBean, Long callId) {
validateFlowRequestBean(flowRequestBean);
CallEntity call = callService.validateCall(callId);
@@ -62,12 +66,17 @@ public class FlowDao {
}
public void validateFlowRequestBean(FlowRequestBean flowRequestBean){
if (FieldValidator.isNullOrZero(flowRequestBean.getInitialForm()) || FieldValidator.isNullOrZero(flowRequestBean.getFinalForm())) {
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.INITAL_AND_FINAL_FORM_CANNOT_NULL));
}
if (flowRequestBean.getFlowEdges() == null || flowRequestBean.getFlowEdges().isEmpty()) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.FLOW_REQUEST_NOT_PROPER));
}
}
public void checkIfFlowExits(CallEntity call) {
callDao.validateUpdate(call);
List<FlowDataEntity> flowDataEntities = flowDataRepository.findByCallId(call.getId());
List<FlowEdgesEntity> flowEdgesEntities = flowEdgesRepository.findByCallId(call.getId());
if (Boolean.FALSE.equals(flowDataEntities.isEmpty()) || Boolean.FALSE.equals(flowEdgesEntities.isEmpty())) {