Resolved conflicts

This commit is contained in:
rajesh
2024-09-14 20:42:27 +05:30
19 changed files with 444 additions and 34 deletions

View File

@@ -13,7 +13,7 @@ import net.gepafin.tendermanagement.repositories.ApplicationFormRepository;
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
import net.gepafin.tendermanagement.service.CallService;
import net.gepafin.tendermanagement.service.FormService;
import net.gepafin.tendermanagement.service.UserService;
import net.gepafin.tendermanagement.util.DateTimeUtil;
import net.gepafin.tendermanagement.util.Utils;
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@@ -31,13 +32,9 @@ public class ApplicationDao {
private final Logger log = LoggerFactory.getLogger(ApplicationDao.class);
@Autowired
private CallService callService;
@Autowired
private UserService userService;
@Autowired
private ApplicationRepository applicationRepository;
@@ -159,7 +156,7 @@ public class ApplicationDao {
}
public ApplicationEntity getApplicationOrCreate(UserEntity userEntity, CallEntity callEntity, FormEntity formEntity) {
ApplicationEntity applicationEntity = applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(), callEntity.getId());
ApplicationEntity applicationEntity = applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(), callEntity.getId()).orElse(null);
if (applicationEntity == null) {
validateFormId(formEntity, callEntity);
applicationEntity = createApplicationEntity(userEntity, callEntity);
@@ -198,7 +195,7 @@ public class ApplicationDao {
public ApplicationFormFieldEntity validateApplicationFormField(Long applicationFormFieldId) {
Optional<ApplicationFormFieldEntity> applicationFormFieldEntity = applicationFormFieldRepository.findById(applicationFormFieldId);
if (applicationFormFieldEntity.isEmpty()) {
throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.APPLICATION_FORM_FIELD_NOT_FOUND));
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.APPLICATION_FORM_FIELD_NOT_FOUND));
}
return applicationFormFieldEntity.get();
}
@@ -230,18 +227,16 @@ public class ApplicationDao {
}
public ApplicationGetResponseBean getApplicationByFormId( Long applicationId,Long formId, UserEntity userEntity) {
ApplicationEntity applicationEntity=null;
List<FormApplicationResponse> formApplicationResponses = new ArrayList<>();
List<FormEntity> formEntities = new ArrayList<>();
Optional<ApplicationEntity> applicationEntity1 = applicationRepository.findById(applicationId);
applicationEntity=applicationEntity1.get();
if (applicationEntity == null) {
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG));
}
ApplicationEntity applicationEntity = applicationRepository.findById(applicationId)
.orElseThrow(() -> new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG)));
if (formId != null) {
FormEntity formEntity = formService.validateForm(formId);
applicationEntity = applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(), formEntity.getCall().getId());
Optional<ApplicationEntity> application = applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(),
formEntity.getCall().getId());
applicationEntity=application.get();
formEntities.add(formEntity);
processForm(formEntity, applicationEntity, formApplicationResponses);
}
@@ -301,9 +296,26 @@ public class ApplicationDao {
return applicationResponse;
}
public void checkIfApplicationExists(CallEntity call,UserEntity userEntity){
ApplicationEntity applicationEntity=applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(),call.getId());
if(applicationEntity!=null){
Optional<ApplicationEntity> applicationEntity=applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(),call.getId());
if(applicationEntity.isPresent()){
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_EXISTS));
}
}
public ApplicationEntity getApplicationByCallAndUser(CallEntity call, UserEntity userEntity) {
return applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(), call.getId())
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG)));
}
public void updateApplicationStatus(Long applicationId, ApplicationStatusTypeEnum status) {
ApplicationEntity applicationEntity = validateApplication(applicationId);
applicationEntity.setStatus(status.getValue());
if(status.equals(ApplicationStatusTypeEnum.SUBMIT)) {
applicationEntity.setSubmissionDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
}
saveApplicationEntity(applicationEntity);
}
}