Merge pull request #102 from Kitzanos/feature/GEPAFINBE-117

GEPAFINBE-117(Added column to communication table)
This commit is contained in:
rbonazzo-KZ
2024-11-21 14:13:33 +01:00
committed by GitHub
8 changed files with 110 additions and 35 deletions

View File

@@ -1,5 +1,6 @@
package net.gepafin.tendermanagement.dao;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
@@ -9,6 +10,7 @@ import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
import net.gepafin.tendermanagement.repositories.CommunicationRepository;
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
import net.gepafin.tendermanagement.util.Validator;
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.slf4j.Logger;
@@ -27,9 +29,12 @@ public class CommunicationDao {
private CommunicationRepository communicationRepository;
@Autowired
ApplicationAmendmentRequestService applicationAmendmentRequestService;
private ApplicationAmendmentRequestService applicationAmendmentRequestService;
public CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationReq, Long amendmentId) {
@Autowired
private Validator validator;
public CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationReq, Long amendmentId) {
log.info("Adding communication request...");
CommunicationEntity communicationEntity = convertToCommunicationCommentEntity(communicationReq, amendmentId);
@@ -85,18 +90,28 @@ public class CommunicationDao {
response.setCreatedDate(entity.getCreatedDate());
response.setUpdatedDate(entity.getUpdatedDate());
response.setTitle(entity.getCommunicationTitle());
response.setSenderUserId(entity.getSenderUserId());
response.setReceiverUserId(entity.getReceiverUserId());
return response;
}
private CommunicationEntity convertToCommunicationCommentEntity(CommunicationRequestBean communicationReq, Long amendmentId) {
ApplicationAmendmentRequestEntity amendmentRequest = applicationAmendmentRequestService.validateApplicationAmendmentRequest(amendmentId);
CommunicationEntity communicationEntity = new CommunicationEntity();
communicationEntity.setApplicationAmendmentRequest(amendmentRequest);
communicationEntity.setCommunicationTitle(communicationReq.getTitle());
communicationEntity.setCommunicationComment(communicationReq.getComment());
communicationEntity.setIsDeleted(false);
communicationEntity.setCommentedDate(LocalDateTime.now());
if(validator.checkIsPreInstructor()){
communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId());
communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
} else if(validator.checkIsBeneficiary()) {
communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId());
}
return communicationEntity;
}
}