diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java index 5a3bd199..cf29392d 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java @@ -13,6 +13,7 @@ import net.gepafin.tendermanagement.model.response.AmendmentFormFieldResponse; import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse; import net.gepafin.tendermanagement.model.response.CommunicationResponseBean; import net.gepafin.tendermanagement.repositories.*; +import net.gepafin.tendermanagement.service.ApplicationEvaluationService; import net.gepafin.tendermanagement.service.ApplicationService; import net.gepafin.tendermanagement.service.UserService; import net.gepafin.tendermanagement.util.DateTimeUtil; @@ -33,9 +34,6 @@ public class ApplicationAmendmentRequestDao { @Autowired private ApplicationService applicationService; - @Autowired - private FormRepository formRepository; - @Autowired private UserService userService; @@ -52,13 +50,22 @@ public class ApplicationAmendmentRequestDao { private DocumentRepository documentRepository; @Autowired - CommunicationRepository communicationRepository; + private CommunicationRepository communicationRepository; @Autowired - CommunicationDao communicationDao; + private CommunicationDao communicationDao; - public List getApplicationDataForAmendment(HttpServletRequest request,Long applicationId){ - log.info("Fetching the application data for the Amendment process {}", applicationId); + @Autowired + private ApplicationEvaluationService applicationEvaluationService; + + @Autowired + private ProtocolDao protocolDao; + + + public List getApplicationDataForAmendment(HttpServletRequest request,Long applicationEvaluationId){ + log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId); + ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId); + Long applicationId = applicationEvaluationEntity.getApplicationId(); ApplicationEntity application = applicationService.validateApplication(applicationId); String callName = application.getCall().getName(); Long protocolNumber = (application.getProtocol() != null && application.getProtocol().getProtocolNumber() != null) @@ -84,7 +91,7 @@ public class ApplicationAmendmentRequestDao { ApplicationAmendmentRequestResponse response = convertEntityToResponse( protocolNumber, callName, formFields, beneficiaryName); - List communicationList = communicationRepository.findCommentsById(response.getId()); + List communicationList = communicationRepository.findCommentsByApplicationAmendmentRequestId(response.getId()); response.setCommentsList(communicationList); responses.add(response); } @@ -157,23 +164,26 @@ public class ApplicationAmendmentRequestDao { return filteredList; } - public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(Long applicationId, ApplicationAmendmentRequest applicationAmendmentRequest){ - log.info("Submiting application data for amendment Process with details: {}", applicationId); + public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(Long applicationEvaluationId, ApplicationAmendmentRequest applicationAmendmentRequest){ + log.info("Submiting application data for amendment Process with details: {}", applicationEvaluationId); - ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId); - ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = createApplicationAmendmentRequestEntity(applicationAmendmentRequest); + ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = createApplicationAmendmentRequestEntity(applicationAmendmentRequest, applicationEvaluationId); ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = convertEntityToResponse(applicationAmendmentRequestEntity); log.info("Application submitted successfully for amendment", applicationAmendmentRequestResponse); - if(!applicationAmendmentRequestResponse.isSendEmail()){ - communicationDao.sendMailToNotifyBeneficiaryRegardingNewAmendment(applicationEntity); + if(Boolean.TRUE.equals(applicationAmendmentRequestResponse.isSendEmail())){ + communicationDao.sendMailToNotifyBeneficiaryRegardingNewAmendment(applicationAmendmentRequestEntity); } return applicationAmendmentRequestResponse; } - public ApplicationAmendmentRequestEntity createApplicationAmendmentRequestEntity(ApplicationAmendmentRequest applicationAmendmentRequest){ + public ApplicationAmendmentRequestEntity createApplicationAmendmentRequestEntity(ApplicationAmendmentRequest applicationAmendmentRequest,Long applicationEvaluationId){ ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = new ApplicationAmendmentRequestEntity(); applicationAmendmentRequestEntity.setNote(applicationAmendmentRequest.getNote()); applicationAmendmentRequestEntity.setResponseDays(applicationAmendmentRequest.getResponseDays()); + ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId); + + applicationAmendmentRequestEntity.setApplicationEvaluationEntity(applicationEvaluationEntity); + applicationAmendmentRequestEntity.setApplicationId(applicationEvaluationEntity.getApplicationId()); if (applicationAmendmentRequest.getFormFields() != null) { String fieldIdsString = applicationAmendmentRequest.getFormFields().stream() @@ -182,7 +192,12 @@ public class ApplicationAmendmentRequestDao { .collect(Collectors.joining(",")); applicationAmendmentRequestEntity.setFormFields(fieldIdsString); } - + UserEntity userEntity = userService.validateUser(applicationEvaluationId); + Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub()); + ProtocolEntity protocolEntity = protocolDao.createProtocolEntity( + applicationEvaluationEntity.getAssignedApplicationsEntity().getApplication(), protocolNumber, + userEntity.getHub().getId()); + applicationAmendmentRequestEntity.setProtocol(protocolEntity); applicationAmendmentRequestEntity.setIsEmail(false); applicationAmendmentRequestEntity.setIsNotification(false); ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity); @@ -197,16 +212,19 @@ public class ApplicationAmendmentRequestDao { public ApplicationAmendmentRequestResponse convertEntityToResponse(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity){ ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = new ApplicationAmendmentRequestResponse(); applicationAmendmentRequestResponse.setId(applicationAmendmentRequestEntity.getId()); - Long applicationId = 20L; + Long applicationId= applicationAmendmentRequestEntity.getApplicationId(); + ApplicationEntity application = applicationService.validateApplication(applicationId); + applicationAmendmentRequestResponse.setApplicationId(applicationId); + applicationAmendmentRequestResponse.setApplicationEvaluationId(applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getId()); applicationAmendmentRequestResponse.setNote(applicationAmendmentRequestEntity.getNote()); applicationAmendmentRequestResponse.setResponseDays(applicationAmendmentRequestEntity.getResponseDays()); applicationAmendmentRequestResponse.setStartDate(applicationAmendmentRequestEntity.getCreatedDate()); applicationAmendmentRequestResponse.setSendEmail(applicationAmendmentRequestEntity.getIsEmail()); applicationAmendmentRequestResponse.setSendNotification(applicationAmendmentRequestEntity.getIsNotification()); String callName = application.getCall().getName(); - Long protocolNumber = (application.getProtocol() != null && application.getProtocol().getProtocolNumber() != null) - ? application.getProtocol().getProtocolNumber() + Long protocolNumber = (applicationAmendmentRequestEntity.getProtocol() != null && applicationAmendmentRequestEntity.getProtocol().getProtocolNumber() != null) + ? applicationAmendmentRequestEntity.getProtocol().getProtocolNumber() : null; UserEntity userEntity = userService.validateUser(application.getUserId()); String firstName = userEntity.getBeneficiary() != null ? userEntity.getBeneficiary().getFirstName() : ""; @@ -256,6 +274,7 @@ public class ApplicationAmendmentRequestDao { } return applicationAmendmentRequestEntity; } + public void deleteById(Long id) { log.info("Deleting assigned application with ID: {}", id); ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity= validateApplicationAmendmentRequest(id); diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index 2332a194..e1cf0820 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -44,7 +44,6 @@ import jakarta.servlet.http.HttpServletRequest; import java.text.MessageFormat; import java.time.LocalDateTime; -import java.time.LocalTime; import java.util.*; import java.util.stream.Collectors; @@ -91,9 +90,6 @@ public class ApplicationDao { @Autowired private CompanyService companyService; - - @Autowired - private ProtocolRepository protocolRepository; @Autowired private SystemEmailTemplatesService systemEmailTemplatesService; @@ -122,14 +118,14 @@ public class ApplicationDao { @Value("${aws.s3.url.folder.signed.document}") private String signedDocumentS3Folder; - @Value("${default.hub.uuid}") - private String defaultHubUuid; - @Autowired private UserService userService; @Autowired - S3PathConfig s3ConfigBean; + private S3PathConfig s3ConfigBean; + + @Autowired + private ProtocolDao protocolDao; public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) { @@ -606,8 +602,8 @@ public class ApplicationDao { } if (status.equals(ApplicationStatusTypeEnum.SUBMIT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.READY.getValue()))) { callService.validatePublishedCall(applicationEntity.getCall().getId(), userEntity.getHub().getId()); - Long protocolNumber = getProtocolNumber(userEntity.getHub()); - ProtocolEntity protocolEntity = createProtocolEntity(applicationEntity,protocolNumber, userEntity.getHub().getId()); + Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub()); + ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(applicationEntity,protocolNumber, userEntity.getHub().getId()); applicationEntity.setProtocol(protocolEntity); applicationEntity.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue()); applicationEntity.setSubmissionDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now())); @@ -622,14 +618,7 @@ 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)); @@ -703,18 +692,6 @@ public class ApplicationDao { } } - public ProtocolEntity createProtocolEntity(ApplicationEntity applicationEntity,Long protocolNumber, Long hubId){ - ProtocolEntity protocolEntity=new ProtocolEntity(); - protocolEntity.setCall(applicationEntity.getCall().getId()); - LocalDateTime utcDateTime = DateTimeUtil.DateServerToUTC(LocalDateTime.now()); - protocolEntity.setYear(utcDateTime.getYear()); - protocolEntity.setProtocolNumber(protocolNumber); - protocolEntity.setTime(LocalTime.now()); - protocolEntity.setApplicationId(applicationEntity.getId()); - protocolEntity.setHubId(hubId); - protocolRepository.save(protocolEntity); - return protocolEntity; - } private void sendMailToUserAndCompany(UserEntity userEntity, ApplicationEntity applicationEntity) { CallEntity call =applicationEntity.getCall(); CompanyEntity company = applicationEntity.getCompany(); diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java index a7c3f49f..d6321fa0 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java @@ -459,7 +459,7 @@ public class ApplicationEvaluationDao { return updatedFieldList; } - private ApplicationEvaluationEntity validateApplicationEvaluation(Long id) { + public ApplicationEvaluationEntity validateApplicationEvaluation(Long id) { Optional entityOptional = applicationEvaluationRepository.findById(id); if (entityOptional.isEmpty()) { throw new ResourceNotFoundException(Status.NOT_FOUND, diff --git a/src/main/java/net/gepafin/tendermanagement/dao/CommunicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/CommunicationDao.java index 08dd12f4..9d546496 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/CommunicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/CommunicationDao.java @@ -1,6 +1,5 @@ package net.gepafin.tendermanagement.dao; -import jakarta.transaction.Transactional; import net.gepafin.tendermanagement.config.Translator; import net.gepafin.tendermanagement.constants.GepafinConstant; import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity; @@ -15,12 +14,9 @@ import net.gepafin.tendermanagement.model.request.CommunicationRequestBean; import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse; import net.gepafin.tendermanagement.model.response.CommunicationResponseBean; import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse; -import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository; -import net.gepafin.tendermanagement.repositories.ApplicationRepository; -import net.gepafin.tendermanagement.repositories.CallRepository; import net.gepafin.tendermanagement.repositories.CommunicationRepository; -import net.gepafin.tendermanagement.repositories.CompanyRepository; -import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository; +import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService; +import net.gepafin.tendermanagement.service.ApplicationService; import net.gepafin.tendermanagement.service.SystemEmailTemplatesService; import net.gepafin.tendermanagement.service.UserService; import net.gepafin.tendermanagement.util.DateTimeUtil; @@ -43,24 +39,24 @@ public class CommunicationDao { private static final Logger log = LoggerFactory.getLogger(CommunicationDao.class); @Autowired - CommunicationRepository communicationRepository; + private CommunicationRepository communicationRepository; @Autowired - ApplicationAmendmentRequestRepository applicationAmendmentRepository; + ApplicationAmendmentRequestService applicationAmendmentRequestService; @Autowired private MailUtil mailUtil; @Autowired private SystemEmailTemplatesService systemEmailTemplatesService; - + @Autowired - UserService userService; - + private ApplicationService applicationService; + @Autowired - ApplicationRepository applicationRepository; + private UserService userService; - @Transactional(rollbackOn = Exception.class) + public CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationReq, Long amendmentId) { log.info("Adding communication request..."); @@ -84,10 +80,7 @@ public class CommunicationDao { public ApplicationAmendmentResponse getAmendmentComments(Long amendmentId) { - ApplicationAmendmentRequestEntity amendmentData = applicationAmendmentRepository.findByIdAndIsDeletedFalse(amendmentId); - if (amendmentData == null) { - throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)); - } + ApplicationAmendmentRequestEntity amendmentData = applicationAmendmentRequestService.validateApplicationAmendmentRequest(amendmentId); List commentsList = communicationRepository.findCommentDetailsByAmendmentId(amendmentId); if (commentsList == null) { throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.COMMENT_NOT_FOUND)); @@ -95,7 +88,6 @@ public class CommunicationDao { return new ApplicationAmendmentResponse(amendmentData, commentsList); } - @Transactional(rollbackOn = Exception.class) public CommunicationResponseBean updateAmendmentComment(CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId) { log.info("Updating communication comment..."); @@ -126,7 +118,7 @@ public class CommunicationDao { private CommunicationEntity convertToCommunicationCommentEntity(CommunicationRequestBean communicationReq, Long amendmentId) { - ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRepository.findByIdAndIsDeletedFalse(amendmentId); + ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRequestService.validateApplicationAmendmentRequest(amendmentId); CommunicationEntity communicationEntity = new CommunicationEntity(); communicationEntity.setApplicationAmendmentRequest(amendmentRequest); communicationEntity.setCommunicationTitle(communicationReq.getTitle()); @@ -136,9 +128,10 @@ public class CommunicationDao { return communicationEntity; } - public void sendMailToNotifyBeneficiaryRegardingNewAmendment(ApplicationEntity applicationEntity) { + public void sendMailToNotifyBeneficiaryRegardingNewAmendment(ApplicationAmendmentRequestEntity applicationAmendmentRequest) { + + ApplicationEntity applicationEntity = applicationService.validateApplication(applicationAmendmentRequest.getApplicationId()); -// UserEntity user = userService.validateUser(applicationEntity.getUserId()); SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService.retrieveTemplateByTypeAndCall( SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.DOCUMENTATION_INTEGRATION_REQUEST, applicationEntity.getCall(), null); @@ -151,14 +144,15 @@ public class CommunicationDao { Map bodyPlaceholders = new HashMap<>(); bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName()); bodyPlaceholders.put("{{protocol_number}}", applicationEntity.getProtocol().getProtocolNumber().toString()); - bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatCreatedDate(applicationEntity.getProtocol().getCreatedDate())); - bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS)); + bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatLocalDateTime(applicationAmendmentRequest.getProtocol().getCreatedDate(), GepafinConstant.DD_MM_YYYY)); + bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationAmendmentRequest.getProtocol().getTime(), GepafinConstant.HH_MM_SS)); bodyPlaceholders.put("{{form_dataInput}}", ""); // Replace placeholders in the subject and body String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders); String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders); - mailUtil.sendByMailGun(subject, body, List.of("piyush1.kag1@gmail.com"), null); + UserEntity userEntity = userService.validateUser(applicationEntity.getUserId()); + mailUtil.sendByMailGun(subject, body, List.of(userEntity.getBeneficiary().getEmail()), null); } public void sendApplicationFailureNotificationEmail(String userEmail, ApplicationEntity applicationEntity) { diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ProtocolDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ProtocolDao.java new file mode 100644 index 00000000..97ecde18 --- /dev/null +++ b/src/main/java/net/gepafin/tendermanagement/dao/ProtocolDao.java @@ -0,0 +1,48 @@ +package net.gepafin.tendermanagement.dao; + +import java.time.LocalDateTime; +import java.time.LocalTime; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import net.gepafin.tendermanagement.entities.ApplicationEntity; +import net.gepafin.tendermanagement.entities.HubEntity; +import net.gepafin.tendermanagement.entities.ProtocolEntity; +import net.gepafin.tendermanagement.repositories.ProtocolRepository; +import net.gepafin.tendermanagement.util.DateTimeUtil; + +@Component +public class ProtocolDao { + + @Autowired + private ProtocolRepository protocolRepository; + + + @Value("${default.hub.uuid}") + private String defaultHubUuid; + + + public 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 ProtocolEntity createProtocolEntity(ApplicationEntity applicationEntity,Long protocolNumber, Long hubId){ + ProtocolEntity protocolEntity=new ProtocolEntity(); + protocolEntity.setCall(applicationEntity.getCall().getId()); + LocalDateTime utcDateTime = DateTimeUtil.DateServerToUTC(LocalDateTime.now()); + protocolEntity.setYear(utcDateTime.getYear()); + protocolEntity.setProtocolNumber(protocolNumber); + protocolEntity.setTime(LocalTime.now()); + protocolEntity.setApplicationId(applicationEntity.getId()); + protocolEntity.setHubId(hubId); + protocolRepository.save(protocolEntity); + return protocolEntity; + } +} diff --git a/src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java index e4d32cf2..6f5a4c40 100644 --- a/src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java +++ b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationAmendmentRequestEntity.java @@ -1,15 +1,8 @@ package net.gepafin.tendermanagement.entities; -import com.fasterxml.jackson.annotation.JsonIgnore; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.OneToMany; -import jakarta.persistence.Table; +import jakarta.persistence.*; import lombok.Data; -import java.util.List; - @Entity @Table(name="application_amendment_request") @Data @@ -27,14 +20,21 @@ public class ApplicationAmendmentRequestEntity extends BaseEntity { @Column(name = "IS_EMAIL") private Boolean isEmail=false; + @Column(name = "APPLICATION_ID") + private Long applicationId; + @Column(name = "FORM_FIELDS") private String formFields; @Column(name="IS_DELETED") private Boolean isDeleted=false; - @OneToMany(mappedBy = "applicationAmendmentRequest", fetch = FetchType.LAZY) - @JsonIgnore - private List communicationList; + @ManyToOne + @JoinColumn(name = "APPLICATION_EVALUATION_ID", nullable = false) + private ApplicationEvaluationEntity applicationEvaluationEntity; + + @OneToOne + @JoinColumn(name = "PROTOCOL_Id") + private ProtocolEntity protocol; } diff --git a/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEntity.java b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEntity.java index 5ddebe5c..68c433e2 100644 --- a/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEntity.java +++ b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEntity.java @@ -8,9 +8,6 @@ import java.time.LocalDateTime; @Entity @Table(name = "APPLICATION") @Data -@NoArgsConstructor -@AllArgsConstructor -@Builder public class ApplicationEntity extends BaseEntity { @Column(name = "USER_ID") diff --git a/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEvaluationEntity.java b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEvaluationEntity.java index 2ddad5ae..dae9a3fb 100644 --- a/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEvaluationEntity.java +++ b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEvaluationEntity.java @@ -3,14 +3,14 @@ package net.gepafin.tendermanagement.entities; import jakarta.persistence.*; import lombok.Data; -import java.time.LocalDateTime; -import java.util.List; @Data @Entity @Table(name = "application_evaluation") public class ApplicationEvaluationEntity extends BaseEntity{ + @Column(name = "application_Id") private Long applicationId; + @Column(name = "user_id") private Long userId; @@ -35,4 +35,5 @@ public class ApplicationEvaluationEntity extends BaseEntity{ @ManyToOne @JoinColumn(name = "assigned_applications_id", nullable = true) private AssignedApplicationsEntity assignedApplicationsEntity; + } diff --git a/src/main/java/net/gepafin/tendermanagement/entities/CommunicationEntity.java b/src/main/java/net/gepafin/tendermanagement/entities/CommunicationEntity.java index 09b2283c..7aa43acd 100644 --- a/src/main/java/net/gepafin/tendermanagement/entities/CommunicationEntity.java +++ b/src/main/java/net/gepafin/tendermanagement/entities/CommunicationEntity.java @@ -1,9 +1,7 @@ package net.gepafin.tendermanagement.entities; -import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.Column; import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; @@ -23,13 +21,12 @@ public class CommunicationEntity extends BaseEntity { private String communicationComment; @Column(name = "IS_DELETED") - private Boolean isDeleted; + private Boolean isDeleted = false; @Column(name = "COMMENTED_DATE") private LocalDateTime commentedDate; - @ManyToOne(fetch = FetchType.LAZY) - @JsonIgnore + @ManyToOne @JoinColumn(name = "AMENDMENT_ID", referencedColumnName = "id", nullable = false) private ApplicationAmendmentRequestEntity applicationAmendmentRequest; diff --git a/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationAmendmentRequestResponse.java b/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationAmendmentRequestResponse.java index a988a20f..eccc3b57 100644 --- a/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationAmendmentRequestResponse.java +++ b/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationAmendmentRequestResponse.java @@ -1,6 +1,7 @@ package net.gepafin.tendermanagement.model.response; import lombok.Data; +import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity; import java.time.LocalDateTime; import java.util.List; @@ -17,7 +18,9 @@ public class ApplicationAmendmentRequestResponse { private String callName; private String beneficiaryName; private List formFields; - private List updatedFormFields; + private List applicationFormFields; + private Long applicationId; + private Long applicationEvaluationId; private List commentsList; } diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/CommunicationRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/CommunicationRepository.java index a63a39d5..0e9d8d9c 100644 --- a/src/main/java/net/gepafin/tendermanagement/repositories/CommunicationRepository.java +++ b/src/main/java/net/gepafin/tendermanagement/repositories/CommunicationRepository.java @@ -11,8 +11,8 @@ import java.util.List; public interface CommunicationRepository extends JpaRepository { @Query("Select new net.gepafin.tendermanagement.model.response.CommunicationResponseBean(c.commentedDate, c.communicationComment, c.communicationTitle, c.createdDate, c.updatedDate, c.applicationAmendmentRequest.id) " + - "from CommunicationEntity c Where c.applicationAmendmentRequest.id = :id") - List findCommentsById(@Param("id") Long id); + "from CommunicationEntity c Where c.applicationAmendmentRequest.id = :applicationAmendmentRequestId") + List findCommentsByApplicationAmendmentRequestId(@Param("applicationAmendmentRequestId") Long amendmentRequestId); @Query("SELECT new net.gepafin.tendermanagement.model.response.CommunicationResponseBean( " + "c.commentedDate, c.communicationComment, c.communicationTitle, c.createdDate, c" + ".updatedDate, c.applicationAmendmentRequest.id) " + "FROM CommunicationEntity c " + "WHERE c.applicationAmendmentRequest.id = :amendmentId AND c.isDeleted = false") diff --git a/src/main/java/net/gepafin/tendermanagement/service/ApplicationAmendmentRequestService.java b/src/main/java/net/gepafin/tendermanagement/service/ApplicationAmendmentRequestService.java index d32c2a29..7e0a739c 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/ApplicationAmendmentRequestService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/ApplicationAmendmentRequestService.java @@ -1,6 +1,7 @@ package net.gepafin.tendermanagement.service; import jakarta.servlet.http.HttpServletRequest; +import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity; import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest; import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean; import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse; @@ -8,11 +9,12 @@ import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestRe import java.util.List; public interface ApplicationAmendmentRequestService { - public List getApplicationDataForAmendment(HttpServletRequest request,Long applicationId); + public List getApplicationDataForAmendment(HttpServletRequest request,Long applicationEvaluationId); public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest); void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id); ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id); List getAllApplicationAmendmentRequest(HttpServletRequest request); ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean); + ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long applicationAmendmentId); } diff --git a/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java b/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java index 8ad33689..245ad479 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/ApplicationEvaluationService.java @@ -1,12 +1,11 @@ package net.gepafin.tendermanagement.service; import jakarta.servlet.http.HttpServletRequest; +import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity; import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum; -import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum; import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest; -import net.gepafin.tendermanagement.model.request.UpdateApplicationEvaluationRequest; import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse; -import net.gepafin.tendermanagement.model.response.ApplicationResponse; + import java.util.List; @@ -18,4 +17,5 @@ public interface ApplicationEvaluationService { ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long applicationEvaluationId, ApplicationEvaluationStatusTypeEnum status); + ApplicationEvaluationEntity validateApplicationEvaluation(Long applicationEvaluationId); } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationAmendmentRequestServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationAmendmentRequestServiceImpl.java index fd190f3d..3bed33cb 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationAmendmentRequestServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationAmendmentRequestServiceImpl.java @@ -2,6 +2,7 @@ package net.gepafin.tendermanagement.service.impl; import jakarta.servlet.http.HttpServletRequest; import net.gepafin.tendermanagement.dao.ApplicationAmendmentRequestDao; +import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity; import net.gepafin.tendermanagement.entities.UserEntity; import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest; import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean; @@ -23,9 +24,9 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm private ApplicationAmendmentRequestDao applicationAmendmentRequestDao; @Override - public List getApplicationDataForAmendment(HttpServletRequest request, Long applicationId) { + public List getApplicationDataForAmendment(HttpServletRequest request, Long applicationEvaluationId) { UserEntity user= validator.validateUser(request); - return applicationAmendmentRequestDao.getApplicationDataForAmendment(request,applicationId); + return applicationAmendmentRequestDao.getApplicationDataForAmendment(request,applicationEvaluationId); } @Override @@ -34,8 +35,6 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm return applicationAmendmentRequestDao.createApplicationAmendmentRequest(applicationEvaluationId,applicationAmendmentRequest); } - - @Override public void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id) { applicationAmendmentRequestDao.deleteById(id); @@ -57,5 +56,10 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean); } + @Override + public ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long applicationAmendmentId) { + return applicationAmendmentRequestDao.validateApplicationAmendmentRequest(applicationAmendmentId); + } + } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java index 262f4a83..1f032aff 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationEvaluationServiceImpl.java @@ -5,14 +5,13 @@ import net.gepafin.tendermanagement.config.Translator; import net.gepafin.tendermanagement.constants.GepafinConstant; import net.gepafin.tendermanagement.dao.ApplicationEvaluationDao; +import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity; import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity; import net.gepafin.tendermanagement.entities.UserEntity; import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum; -import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum; import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest; -import net.gepafin.tendermanagement.model.request.UpdateApplicationEvaluationRequest; import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse; -import net.gepafin.tendermanagement.model.response.ApplicationResponse; + import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository; import net.gepafin.tendermanagement.service.ApplicationEvaluationService; import net.gepafin.tendermanagement.util.Validator; @@ -23,7 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; + import java.util.Optional; @Service @@ -84,4 +83,9 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe return applicationEvaluationDao.updateApplicationEvaluationStatus(applicationId, status); } + + @Override + public ApplicationEvaluationEntity validateApplicationEvaluation(Long applicationEvaluationId) { + return applicationEvaluationDao.validateApplicationEvaluation(applicationEvaluationId); + } } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/CommunicationServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/CommunicationServiceImpl.java index 5738f556..5a9b9c06 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/CommunicationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/CommunicationServiceImpl.java @@ -7,6 +7,8 @@ import net.gepafin.tendermanagement.model.response.CommunicationResponseBean; import net.gepafin.tendermanagement.service.CommunicationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + @Service public class CommunicationServiceImpl implements CommunicationService { @@ -15,21 +17,25 @@ public class CommunicationServiceImpl implements CommunicationService { CommunicationDao communicationDao; @Override + @Transactional(rollbackFor = Exception.class) public CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationRequestBean, Long amendmentId) { return communicationDao.addCommentToAmendmentRequest(communicationRequestBean, amendmentId); } @Override + @Transactional(rollbackFor = Exception.class) public String deleteComment(Long amendmentId, Long commentId) { return communicationDao.deleteComment(amendmentId, commentId); } @Override + @Transactional(rollbackFor = Exception.class) public CommunicationResponseBean updateAmendmentComment(CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId) { return communicationDao.updateAmendmentComment(communicationRequestBean, amendmentId, commentId); } @Override + @Transactional(readOnly = true) public ApplicationAmendmentResponse getAmendmentComments(Long id) { return communicationDao.getAmendmentComments(id); diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/S3ReUploadMigrationService.java b/src/main/java/net/gepafin/tendermanagement/service/impl/S3ReUploadMigrationService.java index 4db4ea12..6cdac900 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/S3ReUploadMigrationService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/S3ReUploadMigrationService.java @@ -181,16 +181,10 @@ public class S3ReUploadMigrationService { private void updateDocumentPathAndDeleteOldEntry(DocumentEntity document, String newPath) { String fileName = extractFileName(newPath); - DocumentEntity newDocument = new DocumentEntity(); + DocumentEntity newDocument = document; newDocument.setFilePath(newPath); - newDocument.setSource(document.getSource()); - newDocument.setType(document.getType()); - newDocument.setIsDeleted(false); - newDocument.setSourceId(document.getSourceId()); newDocument.setFileName(fileName); - documentRepository.save(newDocument); - documentRepository.delete(document); log.info("Migrated document ID: {} to new path: {}", document.getId(), newPath); } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/UserSignedAndDelegationServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/UserSignedAndDelegationServiceImpl.java index c1228565..f1813242 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/UserSignedAndDelegationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/UserSignedAndDelegationServiceImpl.java @@ -229,15 +229,11 @@ public class UserSignedAndDelegationServiceImpl { private void updateDocumentPathAndDeleteOldEntry(ApplicationSignedDocumentEntity document, String newPath) { - ApplicationSignedDocumentEntity newDocument = new ApplicationSignedDocumentEntity(); + ApplicationSignedDocumentEntity newDocument = document; String fileName = extractFileNameFromPath(newPath); newDocument.setFilePath(newPath); newDocument.setFileName(fileName); - newDocument.setApplication(document.getApplication()); - newDocument.setStatus("ACTIVE"); - applicationSignedDocumentRepository.save(newDocument); - applicationSignedDocumentRepository.delete(document); log.info("Migrated document ID: {} to new path: {}", document.getId(), newPath); } @@ -245,17 +241,10 @@ public class UserSignedAndDelegationServiceImpl { private void updateDelegatedDocumentPathAndDeleteOldEntry(UserCompanyDelegationEntity document, String newPath) { String fileName = extractFileNameFromPath(newPath); - UserCompanyDelegationEntity newDocument = new UserCompanyDelegationEntity(); + UserCompanyDelegationEntity newDocument = document; newDocument.setFilePath(newPath); newDocument.setFileName(fileName); - newDocument.setBeneficiaryId(document.getBeneficiaryId()); - newDocument.setUserId(document.getUserId()); - newDocument.setCompanyId(document.getCompanyId()); - newDocument.setStatus("ACTIVE"); - userCompanyDelegationRepository.save(newDocument); - userCompanyDelegationRepository.delete(document); - log.info("Migrated document ID: {} to new path: {}", document.getId(), newPath); } } diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationAmendmentRequestApi.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationAmendmentRequestApi.java index 5cef3b39..91551d7e 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationAmendmentRequestApi.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationAmendmentRequestApi.java @@ -30,8 +30,8 @@ public interface ApplicationAmendmentRequestApi { @ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })), @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) - @GetMapping(value = "/{applicationId}", produces = "application/json") - ResponseEntity>> getApplicationDataForAmendment(HttpServletRequest request, @Parameter(description = "The application id", required = true) @PathVariable(value = "applicationId", required = true) Long applicationId); + @GetMapping(value = "applicationEvaluation/{id}", produces = "application/json") + ResponseEntity>> getApplicationDataForAmendment(HttpServletRequest request, @Parameter(description = "The Application Evaluation id", required = true) @PathVariable(value = "id", required = true) Long applicationEvaluationId); @Operation(summary = "Api to submit the application data for the Amendment", responses = { diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationAmendmentRequestController.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationAmendmentRequestController.java index a9bb8d8e..27316bd5 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationAmendmentRequestController.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationAmendmentRequestController.java @@ -27,8 +27,8 @@ public class ApplicationAmendmentRequestController implements ApplicationAmendme ApplicationAmendmentRequestService applicationAmendmentRequestService; @Override - public ResponseEntity>> getApplicationDataForAmendment(HttpServletRequest request, Long applicationId) { - List applicationAmendmentBean = applicationAmendmentRequestService.getApplicationDataForAmendment(request,applicationId); + public ResponseEntity>> getApplicationDataForAmendment(HttpServletRequest request, Long applicationEvaluationId) { + List applicationAmendmentBean = applicationAmendmentRequestService.getApplicationDataForAmendment(request,applicationEvaluationId); return ResponseEntity.status(HttpStatus.OK) .body(new Response<>(applicationAmendmentBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_DATA_FOR_AMENDMENT_SUCCESS_MSG))); } diff --git a/src/main/resources/db/changelog/db.changelog-1.0.0.xml b/src/main/resources/db/changelog/db.changelog-1.0.0.xml index 64fd6162..91d15122 100644 --- a/src/main/resources/db/changelog/db.changelog-1.0.0.xml +++ b/src/main/resources/db/changelog/db.changelog-1.0.0.xml @@ -1345,7 +1345,7 @@ referencedColumnNames="id"/> - + + + + + + + + + + @@ -1620,6 +1631,19 @@ + + + + + + + + diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index 6bb6f940..267ab70e 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -287,6 +287,7 @@ invalid.application.status = Invalid Application status. application.data.amendment.success = Successfully retrieved the application data for the amendment process. delete.application.amendment.success = Application Amendment successfully deleted. +create.application.data.amendment.msg = Application amendment submited succesfully. application.amendment.not.found = Application Amendment Request not found with the given ID. application.amendment.get.success = Application Amendment details fetched successfully with given ID. application.amendment.update.successfully = Application Amendment Updated Successfully. diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index b3f25678..3842f1f0 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -290,7 +290,8 @@ added.comment.to.amendment.request.success = Commento aggiunto con successo alla comment.not.found = Commento non trovato. comment.updated.successfully = Commento aggiornato con successo. comment.deleted.successfully = Commento eliminato con successo. -comment.not.associate.with.amendment = Il commento non è associato alla richiesta di emendamento. +comment.not.associate.with.amendment = Il commento non � associato alla richiesta di emendamento. amendment.found.success = Richiesta di emendamento trovata con successo. invalid.amendment.for.comment = Richiesta di emendamento non valida per il commento fornito. DD_MM_YYYY_HH_MM = DD-MM-YYYY HH:MM. +create.application.data.amendment.msg =Emendamento alla domanda inviato con successo