remove null checks for call and put some other validation
This commit is contained in:
@@ -83,5 +83,6 @@ public class GepafinConstant {
|
|||||||
public static final String INVALID_STATUS_CHANGE_FROM_DRAFT = "invalid.status.change.from.draft";
|
public static final String INVALID_STATUS_CHANGE_FROM_DRAFT = "invalid.status.change.from.draft";
|
||||||
public static final String STATUS_CANNOT_BE_CHANGED = "status.cannot.be.changed";
|
public static final String STATUS_CANNOT_BE_CHANGED = "status.cannot.be.changed";
|
||||||
public static final String INVALID_STATUS_TRANSITION = "invalid.status.transition";
|
public static final String INVALID_STATUS_TRANSITION = "invalid.status.transition";
|
||||||
|
public static final String PUBLISHED_CALL_NOT_UPDATE = "published.call.not.update";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -8,7 +7,6 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
|
||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -78,8 +76,10 @@ public class CallDao {
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, Long userId) {
|
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, Long userId) {
|
||||||
|
UserEntity userEntity = userService.validateUser(userId);
|
||||||
|
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
|
||||||
CallEntity callEntity = convertToCallEntity(createCallRequest);
|
CallEntity callEntity = convertToCallEntity(createCallRequest);
|
||||||
convertToFaqEntities(createCallRequest.getFaq(), callEntity, userId);
|
convertToFaqEntities(createCallRequest.getFaq(), callEntity, userEntity);
|
||||||
convertLookUpDataEntities(createCallRequest.getAimedTo(), callEntity,
|
convertLookUpDataEntities(createCallRequest.getAimedTo(), callEntity,
|
||||||
LookUpDataTypeEnum.AIMED_TO);
|
LookUpDataTypeEnum.AIMED_TO);
|
||||||
// createCallResponseBean = assembleCreateCallResponseBean(callEntity, Collections.emptyList(),
|
// createCallResponseBean = assembleCreateCallResponseBean(callEntity, Collections.emptyList(),
|
||||||
@@ -94,7 +94,7 @@ public class CallDao {
|
|||||||
|
|
||||||
public CallEntity convertToCallEntity(CreateCallRequestStep1 createCallRequest) {
|
public CallEntity convertToCallEntity(CreateCallRequestStep1 createCallRequest) {
|
||||||
CallEntity callEntity = new CallEntity();
|
CallEntity callEntity = new CallEntity();
|
||||||
validateCallEntity(createCallRequest);
|
// validateCallEntity(createCallRequest);
|
||||||
RegionEntity region = regionRepository.findById(createCallRequest.getRegionId())
|
RegionEntity region = regionRepository.findById(createCallRequest.getRegionId())
|
||||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.REGION_NOT_FOUND)));
|
Translator.toLocale(GepafinConstant.REGION_NOT_FOUND)));
|
||||||
@@ -102,8 +102,13 @@ public class CallDao {
|
|||||||
callEntity.setName(createCallRequest.getName());
|
callEntity.setName(createCallRequest.getName());
|
||||||
callEntity.setDescriptionShort(createCallRequest.getDescriptionShort());
|
callEntity.setDescriptionShort(createCallRequest.getDescriptionShort());
|
||||||
callEntity.setDescriptionLong(createCallRequest.getDescriptionLong());
|
callEntity.setDescriptionLong(createCallRequest.getDescriptionLong());
|
||||||
callEntity.setStartDate(createCallRequest.getStartDate());
|
List<LocalDateTime> dates = createCallRequest.getDates();
|
||||||
callEntity.setEndDate(createCallRequest.getEndDate());
|
if(dates!=null) {
|
||||||
|
if(dates.size()>1) {
|
||||||
|
callEntity.setStartDate(dates.get(0));
|
||||||
|
callEntity.setEndDate(dates.get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
callEntity.setStatus(CallStatusEnum.DRAFT.getValue());
|
callEntity.setStatus(CallStatusEnum.DRAFT.getValue());
|
||||||
callEntity.setAmountMax(createCallRequest.getAmountMax());
|
callEntity.setAmountMax(createCallRequest.getAmountMax());
|
||||||
callEntity.setAmount(createCallRequest.getAmountMax());
|
callEntity.setAmount(createCallRequest.getAmountMax());
|
||||||
@@ -194,20 +199,19 @@ public class CallDao {
|
|||||||
return documentEntity;
|
return documentEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FaqEntity> convertToFaqEntities(List<FaqReq> faqReqList, CallEntity callEntity, Long userId) {
|
public List<FaqEntity> convertToFaqEntities(List<FaqReq> faqReqList, CallEntity callEntity, UserEntity userEntity) {
|
||||||
if (faqReqList == null) {
|
if (faqReqList == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<FaqEntity> faqEntities = faqReqList.stream().map(req -> convertToFaqEntity(req, callEntity, userId))
|
List<FaqEntity> faqEntities = faqReqList.stream().map(req -> convertToFaqEntity(req, callEntity, userEntity))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
faqRepository.saveAll(faqEntities);
|
faqRepository.saveAll(faqEntities);
|
||||||
return faqEntities;
|
return faqEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FaqEntity convertToFaqEntity(FaqReq faqReq, CallEntity callEntity, Long userId) {
|
public FaqEntity convertToFaqEntity(FaqReq faqReq, CallEntity callEntity, UserEntity userEntity) {
|
||||||
FaqEntity faqEntity = new FaqEntity();
|
FaqEntity faqEntity = new FaqEntity();
|
||||||
validateFaqEntity(faqReq.getQuestion());
|
validateFaqEntity(faqReq.getQuestion());
|
||||||
UserEntity userEntity = userService.validateUser(userId);
|
|
||||||
faqEntity.setUser(userEntity);
|
faqEntity.setUser(userEntity);
|
||||||
faqEntity.setIsVisible(true);
|
faqEntity.setIsVisible(true);
|
||||||
if (faqReq.getIsVisible() != null) {
|
if (faqReq.getIsVisible() != null) {
|
||||||
@@ -246,32 +250,38 @@ public class CallDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validateCallEntity(CreateCallRequestStep1 createCallRequest) {
|
// public void validateCallEntity(CreateCallRequestStep1 createCallRequest) {
|
||||||
if (createCallRequest.getRegionId() == null) {
|
// if (createCallRequest.getRegionId() == null) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
// throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.REGION_NOT_FOUND_MSG));
|
// Translator.toLocale(GepafinConstant.REGION_NOT_FOUND_MSG));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (createCallRequest.getAmount().compareTo(BigDecimal.ZERO) <= 0
|
// if (createCallRequest.getAmount().compareTo(BigDecimal.ZERO) <= 0
|
||||||
|| createCallRequest.getAmountMax().compareTo(BigDecimal.ZERO) <= 0) {
|
// || createCallRequest.getAmountMax().compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
// throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
// Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
||||||
}
|
// }
|
||||||
if (createCallRequest.getStartDate().toLocalDate().isBefore(LocalDate.now())
|
// if (createCallRequest.getStartDate().toLocalDate().isBefore(LocalDate.now())
|
||||||
|| createCallRequest.getEndDate().toLocalDate().isBefore(LocalDate.now()) || createCallRequest
|
// || createCallRequest.getEndDate().toLocalDate().isBefore(LocalDate.now()) || createCallRequest
|
||||||
.getStartDate().toLocalDate().isAfter(createCallRequest.getEndDate().toLocalDate())) {
|
// .getStartDate().toLocalDate().isAfter(createCallRequest.getEndDate().toLocalDate())) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
// throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
// Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
public CallResponse convertToCallResponseBean(CallEntity callEntity) {
|
public CallResponse convertToCallResponseBean(CallEntity callEntity) {
|
||||||
CallResponse createCallResponseBean = new CallResponse();
|
CallResponse createCallResponseBean = new CallResponse();
|
||||||
createCallResponseBean.setId(callEntity.getId());
|
createCallResponseBean.setId(callEntity.getId());
|
||||||
createCallResponseBean.setName(callEntity.getName());
|
createCallResponseBean.setName(callEntity.getName());
|
||||||
createCallResponseBean.setStartDate(callEntity.getStartDate());
|
List<LocalDateTime> dates = new ArrayList<>();
|
||||||
createCallResponseBean.setEndDate(callEntity.getEndDate());
|
if(callEntity.getStartDate() != null) {
|
||||||
|
dates.add(callEntity.getStartDate());
|
||||||
|
}
|
||||||
|
if(callEntity.getStartDate() != null) {
|
||||||
|
dates.add(callEntity.getEndDate());
|
||||||
|
}
|
||||||
|
createCallResponseBean.setDates(dates);
|
||||||
createCallResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
createCallResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
||||||
createCallResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
createCallResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
||||||
createCallResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
createCallResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
||||||
@@ -353,6 +363,9 @@ public class CallDao {
|
|||||||
|
|
||||||
public List<LookUpDataResponse> convertLookUpDataEntities(List<LookUpDataReq> lookUpData, CallEntity callEntity,
|
public List<LookUpDataResponse> convertLookUpDataEntities(List<LookUpDataReq> lookUpData, CallEntity callEntity,
|
||||||
LookUpDataEntity.LookUpDataTypeEnum type) {
|
LookUpDataEntity.LookUpDataTypeEnum type) {
|
||||||
|
if(lookUpData == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
List<LookUpDataEntity> lookUpDataEntities = lookUpData.stream()
|
List<LookUpDataEntity> lookUpDataEntities = lookUpData.stream()
|
||||||
.map(req -> convertLookUpDataRequestIntoLookUpDataEntity(req, type)).collect(Collectors.toList());
|
.map(req -> convertLookUpDataRequestIntoLookUpDataEntity(req, type)).collect(Collectors.toList());
|
||||||
|
|
||||||
@@ -418,7 +431,7 @@ public class CallDao {
|
|||||||
CallEntity callEntity = callRepository.findById(callId)
|
CallEntity callEntity = callRepository.findById(callId)
|
||||||
.orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
|
.orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||||
|
validateUpdate(callEntity);
|
||||||
setIfUpdated(callEntity::getThreshold, callEntity::setThreshold, createCallRequest.getThreshold());
|
setIfUpdated(callEntity::getThreshold, callEntity::setThreshold, createCallRequest.getThreshold());
|
||||||
callRepository.save(callEntity);
|
callRepository.save(callEntity);
|
||||||
convertToEvaluationCriteriaEntities(createCallRequest.getCriteria(), callEntity, LookUpDataTypeEnum.EVALUATION_CRITERIA);
|
convertToEvaluationCriteriaEntities(createCallRequest.getCriteria(), callEntity, LookUpDataTypeEnum.EVALUATION_CRITERIA);
|
||||||
@@ -442,11 +455,24 @@ public class CallDao {
|
|||||||
return createCallResponseBean;
|
return createCallResponseBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateUpdate(CallEntity callEntity) {
|
||||||
|
if(callEntity.getStatus().equals(CallStatusEnum.PUBLISH.getValue())) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.PUBLISHED_CALL_NOT_UPDATE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void isValidDateRange(UpdateCallRequestStep1 updateCallRequest, CallEntity callEntity) {
|
public void isValidDateRange(UpdateCallRequestStep1 updateCallRequest, CallEntity callEntity) {
|
||||||
LocalDate startDate = updateCallRequest.getStartDate() != null ? updateCallRequest.getStartDate().toLocalDate()
|
List<LocalDateTime> dates = updateCallRequest.getDates();
|
||||||
: null;
|
|
||||||
LocalDate endDate = updateCallRequest.getEndDate() != null ? updateCallRequest.getEndDate().toLocalDate()
|
LocalDate startDate = (dates != null && dates.size() > 0 && dates.get(0) != null)
|
||||||
: null;
|
? dates.get(0).toLocalDate()
|
||||||
|
: null;
|
||||||
|
|
||||||
|
LocalDate endDate = (dates != null && dates.size() > 1 && dates.get(1) != null)
|
||||||
|
? dates.get(1).toLocalDate()
|
||||||
|
: null;
|
||||||
|
|
||||||
Boolean isValid = true;
|
Boolean isValid = true;
|
||||||
if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
|
if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
@@ -473,8 +499,18 @@ public class CallDao {
|
|||||||
updateCallRequest.getDescriptionShort());
|
updateCallRequest.getDescriptionShort());
|
||||||
setIfUpdated(callEntity::getDescriptionLong, callEntity::setDescriptionLong,
|
setIfUpdated(callEntity::getDescriptionLong, callEntity::setDescriptionLong,
|
||||||
updateCallRequest.getDescriptionLong());
|
updateCallRequest.getDescriptionLong());
|
||||||
setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, updateCallRequest.getStartDate());
|
List<LocalDateTime> dates=updateCallRequest.getDates();
|
||||||
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, updateCallRequest.getEndDate());
|
|
||||||
|
if (dates != null && dates.size()>1) {
|
||||||
|
if (dates.size() > 0) {
|
||||||
|
setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, dates.get(0));
|
||||||
|
}
|
||||||
|
if (dates.size() > 1) {
|
||||||
|
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, updateCallRequest.getStartDate());
|
||||||
|
// setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, updateCallRequest.getEndDate());
|
||||||
setIfUpdated(callEntity::getAmount, callEntity::setAmount, updateCallRequest.getAmount());
|
setIfUpdated(callEntity::getAmount, callEntity::setAmount, updateCallRequest.getAmount());
|
||||||
setIfUpdated(callEntity::getAmountMax, callEntity::setAmountMax, updateCallRequest.getAmountMax());
|
setIfUpdated(callEntity::getAmountMax, callEntity::setAmountMax, updateCallRequest.getAmountMax());
|
||||||
setIfUpdated(callEntity::getDocumentationRequested, callEntity::setDocumentationRequested,
|
setIfUpdated(callEntity::getDocumentationRequested, callEntity::setDocumentationRequested,
|
||||||
@@ -657,7 +693,7 @@ public class CallDao {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PUBLISH:
|
case PUBLISH:
|
||||||
case EXPIRE:
|
case EXPIRED:
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.STATUS_CANNOT_BE_CHANGED));
|
Translator.toLocale(GepafinConstant.STATUS_CANNOT_BE_CHANGED));
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import net.gepafin.tendermanagement.model.request.FaqReq;
|
|||||||
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
|
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
|
||||||
import net.gepafin.tendermanagement.repositories.CallRepository;
|
import net.gepafin.tendermanagement.repositories.CallRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.FaqRepository;
|
import net.gepafin.tendermanagement.repositories.FaqRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
@@ -25,7 +25,7 @@ public class FaqDao {
|
|||||||
private FaqRepository faqRepository;
|
private FaqRepository faqRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserRepository userRepository;
|
private UserService userService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CallDao callDao;
|
private CallDao callDao;
|
||||||
@@ -38,7 +38,8 @@ public class FaqDao {
|
|||||||
CallEntity callEntity = callRepository.findById(callId)
|
CallEntity callEntity = callRepository.findById(callId)
|
||||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||||
entity = callDao.convertToFaqEntity(faqRequest, callEntity, userId);
|
UserEntity userEntity = userService.validateUser(userId);
|
||||||
|
entity = callDao.convertToFaqEntity(faqRequest, callEntity, userEntity);
|
||||||
faqRepository.save(entity);
|
faqRepository.save(entity);
|
||||||
return convertFaqEntityToResponseBean(entity);
|
return convertFaqEntityToResponseBean(entity);
|
||||||
}
|
}
|
||||||
@@ -81,9 +82,7 @@ public class FaqDao {
|
|||||||
|
|
||||||
private void updateFaqEntity(FaqEntity faqEntity, FaqReq faqReq, Long userId, CallEntity callEntity) {
|
private void updateFaqEntity(FaqEntity faqEntity, FaqReq faqReq, Long userId, CallEntity callEntity) {
|
||||||
faqEntity.setQuestion(faqReq.getQuestion());
|
faqEntity.setQuestion(faqReq.getQuestion());
|
||||||
UserEntity userEntity = userRepository.findById(userId)
|
UserEntity userEntity = userService.validateUser(userId);
|
||||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
|
||||||
Translator.toLocale(GepafinConstant.LOOK_UP_DATA_NOT_VALID_MSG)));
|
|
||||||
faqEntity.setUser(userEntity);
|
faqEntity.setUser(userEntity);
|
||||||
faqEntity.setIsVisible(true);
|
faqEntity.setIsVisible(true);
|
||||||
if (faqReq.getIsVisible() != null) {
|
if (faqReq.getIsVisible() != null) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.time.LocalDateTime;
|
|||||||
@Builder
|
@Builder
|
||||||
public class CallEntity extends BaseEntity {
|
public class CallEntity extends BaseEntity {
|
||||||
|
|
||||||
@Column(name = "NAME", nullable = false, length = 255)
|
@Column(name = "NAME", length = 255)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Column(name = "DESCRIPTION_SHORT", columnDefinition = "TEXT")
|
@Column(name = "DESCRIPTION_SHORT", columnDefinition = "TEXT")
|
||||||
@@ -26,23 +26,23 @@ public class CallEntity extends BaseEntity {
|
|||||||
@Column(name = "DESCRIPTION_LONG", columnDefinition = "TEXT")
|
@Column(name = "DESCRIPTION_LONG", columnDefinition = "TEXT")
|
||||||
private String descriptionLong;
|
private String descriptionLong;
|
||||||
|
|
||||||
@Column(name = "START_DATE", nullable = false)
|
@Column(name = "START_DATE")
|
||||||
private LocalDateTime startDate;
|
private LocalDateTime startDate;
|
||||||
|
|
||||||
@Column(name = "END_DATE", nullable = false)
|
@Column(name = "END_DATE")
|
||||||
private LocalDateTime endDate;
|
private LocalDateTime endDate;
|
||||||
|
|
||||||
@Column(name = "STATUS", nullable = false, length = 255)
|
@Column(name = "STATUS", length = 255)
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "REGION_ID", nullable = false, foreignKey = @ForeignKey(name = "fk_region_call"))
|
@JoinColumn(name = "REGION_ID", foreignKey = @ForeignKey(name = "fk_region_call"))
|
||||||
private RegionEntity region;
|
private RegionEntity region;
|
||||||
|
|
||||||
@Column(name = "AMOUNT", nullable = false)
|
@Column(name = "AMOUNT")
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
|
|
||||||
@Column(name = "AMOUNT_MAX", nullable = false)
|
@Column(name = "AMOUNT_MAX")
|
||||||
private BigDecimal amountMax;
|
private BigDecimal amountMax;
|
||||||
|
|
||||||
@Column(name = "CONTACT_INFO", columnDefinition = "TEXT")
|
@Column(name = "CONTACT_INFO", columnDefinition = "TEXT")
|
||||||
@@ -51,7 +51,7 @@ public class CallEntity extends BaseEntity {
|
|||||||
@Column(name = "SUBMISSION_METHOD", columnDefinition = "TEXT")
|
@Column(name = "SUBMISSION_METHOD", columnDefinition = "TEXT")
|
||||||
private String submissionMethod;
|
private String submissionMethod;
|
||||||
|
|
||||||
@Column(name = "THRESHOLD", nullable = false)
|
@Column(name = "THRESHOLD")
|
||||||
private Long threshold;
|
private Long threshold;
|
||||||
|
|
||||||
@Column(name="DOCUMENTATION_REQUESTED",columnDefinition = "TEXT")
|
@Column(name="DOCUMENTATION_REQUESTED",columnDefinition = "TEXT")
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ public enum CallStatusEnum {
|
|||||||
|
|
||||||
DRAFT("DRAFT"),
|
DRAFT("DRAFT"),
|
||||||
PUBLISH("PUBLISH"),
|
PUBLISH("PUBLISH"),
|
||||||
EXPIRE("EXPIRED"),
|
EXPIRED("EXPIRED"),
|
||||||
READY_TO_PUBLISH("READY_TO_PUBLISH");
|
READY_TO_PUBLISH("READY_TO_PUBLISH");
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|||||||
@@ -3,42 +3,27 @@ package net.gepafin.tendermanagement.model.request;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class CreateCallRequestStep1 {
|
public class CreateCallRequestStep1 {
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
private String descriptionShort;
|
private String descriptionShort;
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
private String descriptionLong;
|
private String descriptionLong;
|
||||||
|
|
||||||
@NotNull
|
private List<LocalDateTime> dates;
|
||||||
private LocalDateTime startDate;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private LocalDateTime endDate;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private Long regionId;
|
private Long regionId;
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private BigDecimal amountMax;
|
private BigDecimal amountMax;
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private List<LookUpDataReq> aimedTo;
|
private List<LookUpDataReq> aimedTo;
|
||||||
|
|
||||||
@NotEmpty
|
|
||||||
private String documentationRequested;
|
private String documentationRequested;
|
||||||
|
|
||||||
private Boolean confidi;
|
private Boolean confidi;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.gepafin.tendermanagement.model.request;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -10,10 +9,8 @@ public class CreateCallRequestStep2 {
|
|||||||
|
|
||||||
private Long threshold;
|
private Long threshold;
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private List<EvaluationCriteriaReq> criteria;
|
private List<EvaluationCriteriaReq> criteria;
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private List<LookUpDataReq> checkList;
|
private List<LookUpDataReq> checkList;
|
||||||
|
|
||||||
private List<DocumentReq> docs;
|
private List<DocumentReq> docs;
|
||||||
|
|||||||
@@ -9,35 +9,24 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class UpdateCallRequestStep1 {
|
public class UpdateCallRequestStep1 {
|
||||||
|
|
||||||
|
private String name;
|
||||||
private String name;
|
|
||||||
|
|
||||||
|
private String descriptionShort;
|
||||||
private String descriptionShort;
|
|
||||||
|
|
||||||
|
private String descriptionLong;
|
||||||
private String descriptionLong;
|
|
||||||
|
|
||||||
|
private List<LocalDateTime> dates;
|
||||||
private LocalDateTime startDate;
|
|
||||||
|
|
||||||
|
private BigDecimal amount;
|
||||||
private LocalDateTime endDate;
|
|
||||||
|
|
||||||
|
private BigDecimal amountMax;
|
||||||
private BigDecimal amount;
|
|
||||||
|
|
||||||
|
private List<LookUpDataReq> aimedTo;
|
||||||
private BigDecimal amountMax;
|
|
||||||
|
|
||||||
|
private String documentationRequested;
|
||||||
private List<LookUpDataReq> aimedTo;
|
|
||||||
|
|
||||||
|
private Boolean confidi;
|
||||||
private String documentationRequested;
|
|
||||||
|
|
||||||
private Boolean confidi;
|
private List<FaqReq> faq;
|
||||||
|
|
||||||
private List<FaqReq> faq;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ public class CallResponse {
|
|||||||
|
|
||||||
private String descriptionLong;
|
private String descriptionLong;
|
||||||
|
|
||||||
private LocalDateTime startDate;
|
private List<LocalDateTime> dates;
|
||||||
|
|
||||||
private LocalDateTime endDate;
|
|
||||||
|
|
||||||
private CallStatusEnum status;
|
private CallStatusEnum status;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package net.gepafin.tendermanagement.service.impl;
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.model.response.CallResponse;
|
import net.gepafin.tendermanagement.model.response.CallResponse;
|
||||||
import net.gepafin.tendermanagement.util.FieldValidator;
|
import net.gepafin.tendermanagement.util.FieldValidator;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
|
||||||
public class CallValidatorServiceImpl {
|
public class CallValidatorServiceImpl {
|
||||||
|
|
||||||
@@ -11,8 +17,8 @@ public class CallValidatorServiceImpl {
|
|||||||
.notNull(response.getName(), "name")
|
.notNull(response.getName(), "name")
|
||||||
.notNull(response.getDescriptionShort(), "descriptionShort")
|
.notNull(response.getDescriptionShort(), "descriptionShort")
|
||||||
.notNull(response.getDescriptionLong(), "descriptionLong")
|
.notNull(response.getDescriptionLong(), "descriptionLong")
|
||||||
.notNull(response.getStartDate(), "startDate")
|
.notNull(response.getDates().get(0), "startDate")
|
||||||
.notNull(response.getEndDate(), "endDate")
|
.notNull(response.getDates().get(1), "endDate")
|
||||||
.notNull(response.getStatus(), "status")
|
.notNull(response.getStatus(), "status")
|
||||||
.notNull(response.getRegionId(), "regionId")
|
.notNull(response.getRegionId(), "regionId")
|
||||||
.notNull(response.getAmount(), "amount")
|
.notNull(response.getAmount(), "amount")
|
||||||
@@ -26,6 +32,13 @@ public class CallValidatorServiceImpl {
|
|||||||
.notEmpty(response.getImages(), "images")
|
.notEmpty(response.getImages(), "images")
|
||||||
.notEmpty(response.getCheckList(), "checkList")
|
.notEmpty(response.getCheckList(), "checkList")
|
||||||
.validate();
|
.validate();
|
||||||
|
|
||||||
|
if (response.getDates().get(0).toLocalDate().isBefore(LocalDate.now())
|
||||||
|
|| response.getDates().get(1).toLocalDate().isBefore(LocalDate.now()) ||
|
||||||
|
response.getDates().get(0).toLocalDate().isAfter(response.getDates().get(1).toLocalDate())) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package net.gepafin.tendermanagement.web.rest.api;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
|
||||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -46,7 +44,7 @@ public interface CallApi {
|
|||||||
@Parameter(description = "Call request object", required = true)
|
@Parameter(description = "Call request object", required = true)
|
||||||
@Valid @RequestBody CreateCallRequestStep1 createCallRequest);
|
@Valid @RequestBody CreateCallRequestStep1 createCallRequest);
|
||||||
|
|
||||||
@Operation(summary = "Api to create call step 2",
|
@Operation(summary = "Api to update call step 2",
|
||||||
responses = {
|
responses = {
|
||||||
@ApiResponse(responseCode = "200", description = "OK"),
|
@ApiResponse(responseCode = "200", description = "OK"),
|
||||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package net.gepafin.tendermanagement.web.rest.api.impl;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
|
||||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|||||||
@@ -441,5 +441,16 @@
|
|||||||
</column>
|
</column>
|
||||||
</addColumn>
|
</addColumn>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
|
||||||
|
<changeSet id="27-08-2024_3" author="Rajesh Khore">
|
||||||
|
<dropNotNullConstraint tableName="call" columnName="name"/>
|
||||||
|
<dropNotNullConstraint tableName="call" columnName="start_date"/>
|
||||||
|
<dropNotNullConstraint tableName="call" columnName="end_date"/>
|
||||||
|
<dropNotNullConstraint tableName="call" columnName="status"/>
|
||||||
|
<dropNotNullConstraint tableName="call" columnName="region_id"/>
|
||||||
|
<dropNotNullConstraint tableName="call" columnName="amount"/>
|
||||||
|
<dropNotNullConstraint tableName="call" columnName="amount_max"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ status.same.error=Status is already set.
|
|||||||
invalid.status.change.from.draft=Status cannot be changed to READY_TO_PUBLISH or PUBLISH from DRAFT.
|
invalid.status.change.from.draft=Status cannot be changed to READY_TO_PUBLISH or PUBLISH from DRAFT.
|
||||||
status.cannot.be.changed=Status cannot be changed.
|
status.cannot.be.changed=Status cannot be changed.
|
||||||
invalid.status.transition=Invalid status transition.
|
invalid.status.transition=Invalid status transition.
|
||||||
|
published.call.not.update=Published call cannot be updated.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Login-related messages
|
# Login-related messages
|
||||||
login.successfully=Login successfully.
|
login.successfully=Login successfully.
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ status.same.error=Lo stato
|
|||||||
invalid.status.change.from.draft=Lo stato non può essere cambiato in READY_TO_PUBLISH o PUBLISH da DRAFT.
|
invalid.status.change.from.draft=Lo stato non può essere cambiato in READY_TO_PUBLISH o PUBLISH da DRAFT.
|
||||||
status.cannot.be.changed=Lo stato non può essere cambiato.
|
status.cannot.be.changed=Lo stato non può essere cambiato.
|
||||||
invalid.status.transition=Transizione di stato non valida.
|
invalid.status.transition=Transizione di stato non valida.
|
||||||
|
published.call.not.update=Il bando pubblicato non può essere aggiornato.
|
||||||
|
|
||||||
|
|
||||||
# Login-related messages
|
# Login-related messages
|
||||||
login.successfully=Accesso effettuato con successo.
|
login.successfully=Accesso effettuato con successo.
|
||||||
|
|||||||
Reference in New Issue
Block a user