updated code
This commit is contained in:
@@ -119,6 +119,9 @@ public class ApplicationDao {
|
||||
|
||||
@Value("${aws.s3.url.folder.signed.document}")
|
||||
private String signedDocumentS3Folder;
|
||||
|
||||
@Value("${default.hub.uuid}")
|
||||
private String defaultHubUuid;
|
||||
|
||||
|
||||
public ApplicationResponseBean createApplication(ApplicationRequestBean applicationRequestBean, UserEntity userEntity, Long formId, Long applicationId) {
|
||||
@@ -602,8 +605,7 @@ public class ApplicationDao {
|
||||
if (totalSteps.intValue() != completedSteps) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
|
||||
}
|
||||
Long maxProtocolNumber=protocolRepository.findMaxProtocolNumber();
|
||||
Long protocolNumber = (maxProtocolNumber != null) ? maxProtocolNumber + 1 : 1;
|
||||
Long protocolNumber = getProtocolNumber(userEntity.getHub());
|
||||
ProtocolEntity protocolEntity=createProtocolEntity(applicationEntity,protocolNumber);
|
||||
applicationEntity.setProtocol(protocolEntity);
|
||||
applicationEntity.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue());
|
||||
@@ -618,6 +620,14 @@ public class ApplicationDao {
|
||||
return getApplicationResponse(applicationEntity);
|
||||
}
|
||||
|
||||
private Long getProtocolNumber(HubEntity hubEntity) {
|
||||
Long maxProtocolNumber = protocolRepository.findMaxProtocolNumberAndHubId(hubEntity.getId());
|
||||
Long startNumber = 10000001L;
|
||||
if(Boolean.FALSE.equals(defaultHubUuid.equals(hubEntity.getUniqueUuid()))) {
|
||||
startNumber = 20000001L;
|
||||
}
|
||||
return (maxProtocolNumber != null) ? maxProtocolNumber + 1 : startNumber;
|
||||
}
|
||||
public Integer calculateProgress(Long totalSteps, Long completedSteps) {
|
||||
if (FieldValidator.isNullOrZero(totalSteps)) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.TOTAL_STEPS_NOT_BE_ZERO));
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Component
|
||||
@@ -89,4 +88,9 @@ public class HubDao {
|
||||
responseBean.setUpdatedDate(hubEntity.getUpdatedDate());
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
public HubEntity getHubByUuid(String hubUuid) {
|
||||
return hubRepository.findByUniqueUuid(hubUuid).orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.HUB_NOT_FOUND)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class UserDao {
|
||||
Translator.toLocale(GepafinConstant.VALIDATE_EMAIL));
|
||||
}
|
||||
log.info("Creating user with email: {}", userReq.getEmail());
|
||||
if (userRepository.existsByEmailIgnoreCaseAndhubUniqueUuid(userReq.getEmail(), userReq.getHubUuid())) {
|
||||
if (userRepository.existsByEmailIgnoreCaseAndHubUniqueUuid(userReq.getEmail(), userReq.getHubUuid())) {
|
||||
log.error("User creation failed: Email {} already exists", userReq.getEmail());
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.EMAIL_ALREADY_EXISTS));
|
||||
@@ -301,7 +301,7 @@ public class UserDao {
|
||||
|
||||
public String initiatePasswordReset(InitiatePasswordResetReq resetReq) {
|
||||
UserEntity user = userRepository
|
||||
.findByEmailIgnoreCaseAndhubUniqueUuid(resetReq.getEmail(), resetReq.getHubUuid())
|
||||
.findByEmailIgnoreCaseAndHubUniqueUuid(resetReq.getEmail(), resetReq.getHubUuid())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
|
||||
|
||||
@@ -314,7 +314,7 @@ public class UserDao {
|
||||
|
||||
public Boolean resetPassword(ResetPasswordReq resetPasswordReq) {
|
||||
UserEntity user = userRepository
|
||||
.findByEmailIgnoreCaseAndhubUniqueUuid(resetPasswordReq.getEmail(), resetPasswordReq.getHubUuid())
|
||||
.findByEmailIgnoreCaseAndHubUniqueUuid(resetPasswordReq.getEmail(), resetPasswordReq.getHubUuid())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
|
||||
|
||||
@@ -338,7 +338,7 @@ public class UserDao {
|
||||
|
||||
public Boolean changePassword(UserEntity userEntity, ChangePasswordRequest request) {
|
||||
UserEntity user = userRepository
|
||||
.findByEmailIgnoreCaseAndhubUniqueUuid(request.getEmail(), userEntity.getHub().getUniqueUuid())
|
||||
.findByEmailIgnoreCaseAndHubUniqueUuid(request.getEmail(), userEntity.getHub().getUniqueUuid())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user