resolved conflicts

This commit is contained in:
rajesh
2024-08-28 02:14:04 +05:30
23 changed files with 234 additions and 69 deletions

View File

@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import net.gepafin.tendermanagement.model.response.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@@ -32,11 +33,6 @@ import net.gepafin.tendermanagement.model.request.EvaluationCriteriaReq;
import net.gepafin.tendermanagement.model.request.FaqReq;
import net.gepafin.tendermanagement.model.request.LookUpDataReq;
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
import net.gepafin.tendermanagement.model.response.CreateCallResponseBean;
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
import net.gepafin.tendermanagement.model.response.EvaluationCriteriaResponseBean;
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
import net.gepafin.tendermanagement.model.response.LookUpDataResponse;
import net.gepafin.tendermanagement.repositories.CallRepository;
import net.gepafin.tendermanagement.repositories.CallTargetAudienceChecklistRepository;
import net.gepafin.tendermanagement.repositories.DocumentRepository;
@@ -273,7 +269,8 @@ public class CallDao {
CreateCallResponseBean createCallResponseBean = new CreateCallResponseBean();
createCallResponseBean.setId(callEntity.getId());
createCallResponseBean.setName(callEntity.getName());
createCallResponseBean.setDates(List.of(callEntity.getStartDate(), callEntity.getEndDate()));
createCallResponseBean.setStartDate(callEntity.getStartDate());
createCallResponseBean.setEndDate(callEntity.getEndDate());
createCallResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
createCallResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
createCallResponseBean.setStatus(CallTypeEnum.valueOf(callEntity.getStatus()));
@@ -403,13 +400,19 @@ public class CallDao {
return lookUpDataResponse;
}
private CallEntity getCallById(Long callId) {
public CallEntity validateCall(Long callId) {
return callRepository.findById(callId).orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
}
public CreateCallResponseBean getCallById(Long callId) {
CallEntity callEntity = callRepository.findById(callId)
.orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
return getCallResponseBean(callEntity);
}
public CreateCallResponseBean createCallStep2(CreateCallRequestStep2 createCallRequest, Long userId) {
CallEntity callEntity = callRepository.findById(createCallRequest.getCallId())
public CreateCallResponseBean createCallStep2(Long callId, CreateCallRequestStep2 createCallRequest, Long userId) {
CallEntity callEntity = callRepository.findById(callId)
.orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
@@ -459,7 +462,7 @@ public class CallDao {
}
public CreateCallResponseBean updateCallStep1(Long callId, UpdateCallRequestStep1 updateCallRequest, Long userId) {
CallEntity callEntity = getCallById(callId);
CallEntity callEntity = validateCall(callId);
UserEntity userEntity = userService.validateUser(userId);
isValidDateRange(updateCallRequest, callEntity);
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
@@ -567,6 +570,26 @@ public class CallDao {
callTargetAudienceChecklistRepository.save(callTargetAudienceChecklistEntity);
}
public CallDetailsResponseBean convertToCallDetailsResponseBean(CallEntity callEntity) {
CallDetailsResponseBean callDetailsResponseBean = new CallDetailsResponseBean();
callDetailsResponseBean.setId(callEntity.getId());
callDetailsResponseBean.setName(callEntity.getName());
callDetailsResponseBean.setDates(List.of(callEntity.getStartDate(), callEntity.getEndDate()));
callDetailsResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
callDetailsResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
callDetailsResponseBean.setStatus(CallTypeEnum.valueOf(callEntity.getStatus()));
callDetailsResponseBean.setRegionId(callEntity.getRegion().getId());
callDetailsResponseBean.setAmount(callEntity.getAmount());
callDetailsResponseBean.setAmountMax(callEntity.getAmountMax());
callDetailsResponseBean.setContactInfo(callEntity.getContactInfo());
callDetailsResponseBean.setSubmissionMethod(callEntity.getSubmissionMethod());
callDetailsResponseBean.setThreshold(callEntity.getThreshold());
callDetailsResponseBean.setDocumentationReqested(callEntity.getDocumentationRequested());
callDetailsResponseBean.setPriorityArea(callEntity.getPriorityArea());
callDetailsResponseBean.setCreatedDate(callEntity.getCreatedDate());
callDetailsResponseBean.setUpdatedDate(callEntity.getUpdatedDate());
return callDetailsResponseBean;
}
private CreateCallResponseBean getCallResponseBean(CallEntity callEntity) {
List<DocumentEntity> documentEntities = documentRepository.findByCallIdAndTypeAndIsDeletedFalse(callEntity.getId(),
DocumentTypeEnum.DOCUMENT.getValue());
@@ -589,4 +612,10 @@ public class CallDao {
createCallResponseBean.setCheckList(checkList);
return createCallResponseBean;
}
public List<CallDetailsResponseBean> getAllCalls() {
return callRepository.findAll()
.stream()
.map(this::convertToCallDetailsResponseBean)
.collect(Collectors.toList());
}
}