diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index 9d477c37..3deb8347 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -292,9 +292,12 @@ public class GepafinConstant { public static final String ENCRYPT_KEY = "U2VjdXJlRW5jcnlwdEtleQ=="; public static final String APPLICATION_DOCUMENTS_NOT_FOUND_MSG = "application.documents.not.found"; public static final String DUPLICATE_BENEFICIARY_CALL = "beneficiary.call.duplicate"; + public static final String USER_MUST_BE_ASSOCIATED_WITH_COMPANY="user.must.be.associated.with.company.to.create.application"; public static final String COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL = "company.id.required.for.preferred.call"; public static final String CREATED_DATE = "createdDate"; public static final String RESPONSE_DAYS_NOT_NULL="response.days.not.null"; public static final String APPLICATION_CANNOT_APPROVED_OR_REJECTED="application.cannot.approved.or.rejected"; + public static final String SUBMISSION_DATE = "submissionDate"; + public static final String ASSIGNED_AT = "assignedAt"; } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java index c646c73b..c0908b8e 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationAmendmentRequestDao.java @@ -94,6 +94,8 @@ public class ApplicationAmendmentRequestDao { @Autowired private Validator validator; + @Autowired + private ApplicationDao applicationDao; @Autowired private EmailLogDao emailLogDao; @@ -258,20 +260,23 @@ public class ApplicationAmendmentRequestDao { userEntity.getHub().getId()); applicationAmendmentRequestEntity.setProtocol(protocolEntity); ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity); - - //Set Status - applicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue()); - + String evaluationStatusType = applicationEvaluationEntity.getStatus(); + if (Boolean.FALSE.equals(evaluationStatusType.equals((ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue())))){ + applicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue()); applicationEvaluationRepository.save(applicationEvaluationEntity); - + } ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId); - applicationEntity.setStatus(ApplicationStatusTypeEnum.SOCCORSO.getValue()); - applicationRepository.save(applicationEntity); - + String applicationStatusType = applicationEntity.getStatus(); + if (Boolean.FALSE.equals(applicationStatusType.equals((ApplicationStatusTypeEnum.SOCCORSO.getValue())))) { + applicationEntity.setStatus(ApplicationStatusTypeEnum.SOCCORSO.getValue()); + applicationRepository.save(applicationEntity); + } AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId); - assignedApplicationsEntity.setStatus(AssignedApplicationEnum.SOCCORSO.getValue()); - assignedApplicationsRepository.save(assignedApplicationsEntity); - + String assignedStatusType = assignedApplicationsEntity.getStatus(); + if (Boolean.FALSE.equals(assignedStatusType.equals((AssignedApplicationEnum.SOCCORSO.getValue())))) { + assignedApplicationsEntity.setStatus(AssignedApplicationEnum.SOCCORSO.getValue()); + assignedApplicationsRepository.save(assignedApplicationsEntity); + } return applicationAmendment; } @@ -578,11 +583,10 @@ public class ApplicationAmendmentRequestDao { // Add valid new document IDs from the request existingDocumentIds.addAll(validDocumentIds); - + applicationDao.updateDocumentDeletionStatus(formEntity, updatedFormField, formEntity.getApplicationForm().getForm(), null,validDocumentIds,true); // Set the combined document IDs back as the field value formEntity.setFieldValue(String.join(",", existingDocumentIds)); applicationFormFieldRepository.save(formEntity); - log.info("Updated field value for application ID {} and field ID {} with document IDs {}", applicationAmendment.getApplicationId(), updatedFormField.getFieldId(), String.join(",", existingDocumentIds)); fieldUpdated = true; @@ -684,12 +688,16 @@ public class ApplicationAmendmentRequestDao { ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment); List amendmentRequests = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(existingApplicationAmendment.getApplicationEvaluationEntity().getId()); - boolean allClosed = amendmentRequests.stream() + Boolean allClosed = amendmentRequests.stream() .allMatch(amendment -> amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue())); - - if (allClosed) { + ApplicationEntity application = applicationService.validateApplication(existingApplicationAmendment.getApplicationId()); + if (Boolean.TRUE.equals(allClosed)){ existingApplicationAmendment.getApplicationEvaluationEntity().setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue()); applicationEvaluationRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity()); + application.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue()); + applicationRepository.save(application); + existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().setStatus(AssignedApplicationEnum.OPEN.getValue()); + assignedApplicationsRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity()); log.info("All amendments are closed. Application Evaluation status set to OPEN."); } log.info("Application Amendment closed successfully: {}", response); diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index 58f41f7c..017870ed 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -337,8 +337,11 @@ public class ApplicationDao { .collect(Collectors.toList()); predicate = builder.and(predicate, root.get("status").in(statusNames)); } + query.orderBy( + builder.desc(builder.isNotNull(root.get(GepafinConstant.SUBMISSION_DATE))), + builder.desc(root.get(GepafinConstant.SUBMISSION_DATE)) + ); predicate = builder.and(predicate, builder.equal(root.get("hubId"), userEntity.getHub().getId())); - query.orderBy(builder.desc(root.get(GepafinConstant.CREATED_DATE))); return predicate; }; } @@ -409,7 +412,7 @@ public class ApplicationDao { ApplicationFormFieldEntity applicationFormFieldEntity=null; - validateFileUploadDocuments(applicationFormFieldRequestBean, formEntity); + List newDocumentIds =validateFileUploadDocuments(applicationFormFieldRequestBean, formEntity); if(applicationFormFieldEntities==null || applicationFormFieldEntities.isEmpty()){ applicationFormFieldEntity = new ApplicationFormFieldEntity(); @@ -431,13 +434,79 @@ public class ApplicationDao { Utils.setIfUpdated(applicationFormFieldEntity::getFieldId, applicationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId()); if(applicationFormFieldRequestBean.getFieldValue() !=null ) { - applicationFormFieldEntity.setFieldValue(Utils.convertObjectToJsonString(applicationFormFieldRequestBean.getFieldValue())); - } + updateDocumentDeletionStatus(applicationFormFieldEntity, applicationFormFieldRequestBean,formEntity,newDocumentIds,null,false); + applicationFormFieldEntity.setFieldValue(Utils.convertObjectToJsonString(applicationFormFieldRequestBean.getFieldValue())); + } if(applicationFormFieldRequestBean.getFieldValue() ==null ) { + updateDocumentDeletionStatus(applicationFormFieldEntity, applicationFormFieldRequestBean,formEntity,newDocumentIds,null,false); applicationFormFieldEntity.setFieldValue(null); } return applicationFormFieldRepository.save(applicationFormFieldEntity); } + void updateDocumentDeletionStatus(ApplicationFormFieldEntity applicationFormFieldEntity, ApplicationFormFieldRequestBean applicationFormFieldRequestBean, FormEntity formEntity, List newDocumentIds, + List preInstructorDocumentId,boolean isPreInstructor) { + if (newDocumentIds == null) { + newDocumentIds = Collections.emptyList(); + } + if (preInstructorDocumentId == null) { + preInstructorDocumentId = Collections.emptyList(); + } + + List contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); + for (ContentResponseBean contentResponseBean : contentResponseBeans) { + if (Boolean.FALSE.equals(contentResponseBean.getName().equals("fileupload"))) { + return; + } + } + if(!isPreInstructor){ + List currentDocumentIds = parseDocumentIds(applicationFormFieldEntity.getFieldValue()); + if (Boolean.TRUE.equals(newDocumentIds.isEmpty())) { + currentDocumentIds.forEach(docId -> documentService.deleteFile(docId)); + } else { + List finalNewDocumentIds = newDocumentIds; + List documentsToDelete = currentDocumentIds.stream() + .filter(docId -> !finalNewDocumentIds.contains(docId)) + .toList(); + documentsToDelete.forEach(docId -> documentService.deleteFile(docId)); + }} + else{ + List currentDocumentIds = parseDocumentIds(applicationFormFieldEntity.getFieldValue()); + if (Boolean.TRUE.equals(preInstructorDocumentId.isEmpty())) { + currentDocumentIds.forEach(docId -> documentService.deleteFile(docId)); + } else { + List preInstructorDocIds = preInstructorDocumentId.stream() + .map(Long::valueOf) + .collect(Collectors.toList()); + + List documentsToDelete = currentDocumentIds.stream() + .filter(docId -> !preInstructorDocIds.contains(docId)) + .toList(); + documentsToDelete.forEach(docId -> documentService.deleteFile(docId)); + }} + } + + + private List parseDocumentIds(String fieldValue) { + if (fieldValue == null || fieldValue.isEmpty()) { + return Collections.emptyList(); + } + if (fieldValue.contains(",")) { + return Arrays.stream(fieldValue.split(",")) + .map(String::trim) + .map(Long::parseLong) + .collect(Collectors.toList()); + } else { + try { + return Collections.singletonList(Long.parseLong(fieldValue.trim())); + } catch (NumberFormatException e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + } + + + private List validateFileUploadDocuments(ApplicationFormFieldRequestBean applicationFormFieldRequestBean, FormEntity formEntity) { List documentIds=null; diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java index e9bd2098..75ba1ee3 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java @@ -15,6 +15,7 @@ import net.gepafin.tendermanagement.model.request.FieldRequest; import net.gepafin.tendermanagement.model.response.*; import net.gepafin.tendermanagement.repositories.*; import net.gepafin.tendermanagement.service.ApplicationService; +import net.gepafin.tendermanagement.service.AssignedApplicationsService; import net.gepafin.tendermanagement.service.CallService; import net.gepafin.tendermanagement.service.UserService; import net.gepafin.tendermanagement.util.DateTimeUtil; @@ -83,12 +84,15 @@ public class ApplicationEvaluationDao { @Autowired private FormDao formDao; + + @Autowired + private AssignedApplicationsService assignedApplicationsService; private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) { ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity(); - AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplciationId).orElse(null); + AssignedApplicationsEntity assignedApplications = assignedApplicationsService.validateAssignedApplication(assignedApplciationId); ApplicationEntity application = applicationService.validateApplication(assignedApplications.getApplication().getId()); entity.setApplicationId(application.getId()); entity.setAssignedApplicationsEntity(assignedApplications); @@ -97,6 +101,7 @@ public class ApplicationEvaluationDao { entity.setChecklist(Utils.convertObjectToJson(req.getChecklist())); entity.setFile(Utils.convertObjectToJson(req.getFiles())); entity.setNote(req.getNote()); + entity.setMotivation(req.getMotivation()); entity.setIsDeleted(false); entity.setInitialDays(30L); entity.setRemainingDays(30L); @@ -133,6 +138,7 @@ public class ApplicationEvaluationDao { AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(entity.getAssignedApplicationsEntity().getId()).orElse(null); response.setAssignedApplicationId(assignedApplications.getId()); response.setNote(entity.getNote()); + response.setMotivation(entity.getMotivation()); response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(entity.getStatus())); response.setEvaluationEndDate(entity.getEndDate()); response.setCreatedDate(entity.getCreatedDate()); @@ -257,19 +263,21 @@ public class ApplicationEvaluationDao { List documentResponseBeans = new ArrayList<>(); for (String docId : documentIds) { - Long documentId = Long.valueOf(docId.trim()); - documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { - DocumentResponseBean responseBean = new DocumentResponseBean(); - responseBean.setId(documentEntity.getId()); - responseBean.setName(documentEntity.getFileName()); - responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType())); - responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource())); - responseBean.setSourceId(documentEntity.getSourceId()); - responseBean.setFilePath(documentEntity.getFilePath()); - responseBean.setCreatedDate(documentEntity.getCreatedDate()); - responseBean.setUpdatedDate(documentEntity.getUpdatedDate()); - documentResponseBeans.add(responseBean); - }); + if (Boolean.FALSE.equals(docId.isEmpty())){ + Long documentId = Long.valueOf(docId.trim()); + documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { + DocumentResponseBean responseBean = new DocumentResponseBean(); + responseBean.setId(documentEntity.getId()); + responseBean.setName(documentEntity.getFileName()); + responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType())); + responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource())); + responseBean.setSourceId(documentEntity.getSourceId()); + responseBean.setFilePath(documentEntity.getFilePath()); + responseBean.setCreatedDate(documentEntity.getCreatedDate()); + responseBean.setUpdatedDate(documentEntity.getUpdatedDate()); + documentResponseBeans.add(responseBean); + }); + } } mappedField.setFieldValue(documentResponseBeans); } @@ -359,19 +367,21 @@ public class ApplicationEvaluationDao { List documentResponseBeans = new ArrayList<>(); for (String docId : documentIds) { - Long documentId = Long.valueOf(docId.trim()); - documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { - DocumentResponseBean responseBean = new DocumentResponseBean(); - responseBean.setId(documentEntity.getId()); - responseBean.setName(documentEntity.getFileName()); - responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType())); - responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource())); - responseBean.setSourceId(documentEntity.getSourceId()); - responseBean.setFilePath(documentEntity.getFilePath()); - responseBean.setCreatedDate(documentEntity.getCreatedDate()); - responseBean.setUpdatedDate(documentEntity.getUpdatedDate()); - documentResponseBeans.add(responseBean); - }); + if (Boolean.FALSE.equals(docId.isEmpty())){ + Long documentId = Long.valueOf(docId.trim()); + documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { + DocumentResponseBean responseBean = new DocumentResponseBean(); + responseBean.setId(documentEntity.getId()); + responseBean.setName(documentEntity.getFileName()); + responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType())); + responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource())); + responseBean.setSourceId(documentEntity.getSourceId()); + responseBean.setFilePath(documentEntity.getFilePath()); + responseBean.setCreatedDate(documentEntity.getCreatedDate()); + responseBean.setUpdatedDate(documentEntity.getUpdatedDate()); + documentResponseBeans.add(responseBean); + }); + } } fieldResponse.setFileDetail(documentResponseBeans); @@ -436,6 +446,7 @@ public class ApplicationEvaluationDao { entity.setFile(Utils.convertObjectToJson(filterNonNullFields(processField(entity, req)))); entity.setIsDeleted(false); setIfUpdated(entity::getNote, entity::setNote, req.getNote()); + setIfUpdated(entity::getMotivation, entity::setMotivation, req.getMotivation()); } else { entity = convertToEntity(user, req, assignedApplicationId); } @@ -635,6 +646,7 @@ public class ApplicationEvaluationDao { response.setApplicationId(application.getId()); response.setAssignedApplicationId(assignedApplications.getId()); response.setNote(null); + response.setMotivation(null); response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus())); response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(ApplicationEvaluationStatusTypeEnum.OPEN.getValue())); response.setMinScore(call.getThreshold()!=null?call.getThreshold():null); @@ -896,19 +908,21 @@ public class ApplicationEvaluationDao { List documentResponseBeans = new ArrayList<>(); for (String docId : documentIds) { - Long documentId = Long.valueOf(docId.trim()); - documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { - DocumentResponseBean responseBean = new DocumentResponseBean(); - responseBean.setId(documentEntity.getId()); - responseBean.setName(documentEntity.getFileName()); - responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType())); - responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource())); - responseBean.setSourceId(documentEntity.getSourceId()); - responseBean.setFilePath(documentEntity.getFilePath()); - responseBean.setCreatedDate(documentEntity.getCreatedDate()); - responseBean.setUpdatedDate(documentEntity.getUpdatedDate()); - documentResponseBeans.add(responseBean); - }); + if (Boolean.FALSE.equals(docId.isEmpty())) { + Long documentId = Long.valueOf(docId.trim()); + documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { + DocumentResponseBean responseBean = new DocumentResponseBean(); + responseBean.setId(documentEntity.getId()); + responseBean.setName(documentEntity.getFileName()); + responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType())); + responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource())); + responseBean.setSourceId(documentEntity.getSourceId()); + responseBean.setFilePath(documentEntity.getFilePath()); + responseBean.setCreatedDate(documentEntity.getCreatedDate()); + responseBean.setUpdatedDate(documentEntity.getUpdatedDate()); + documentResponseBeans.add(responseBean); + }); + } } fieldResponse.setFileDetail(documentResponseBeans); @@ -1254,21 +1268,22 @@ public class ApplicationEvaluationDao { List documentResponseBeans = new ArrayList<>(); for (String docId : documentIds) { - Long documentId = Long.valueOf(docId.trim()); - documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { - DocumentResponseBean responseBean = new DocumentResponseBean(); - responseBean.setId(documentEntity.getId()); - responseBean.setName(documentEntity.getFileName()); - responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType())); - responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource())); - responseBean.setSourceId(documentEntity.getSourceId()); - responseBean.setFilePath(documentEntity.getFilePath()); - responseBean.setCreatedDate(documentEntity.getCreatedDate()); - responseBean.setUpdatedDate(documentEntity.getUpdatedDate()); - documentResponseBeans.add(responseBean); - }); + if (Boolean.FALSE.equals(docId.isEmpty())){ + Long documentId = Long.valueOf(docId.trim()); + documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { + DocumentResponseBean responseBean = new DocumentResponseBean(); + responseBean.setId(documentEntity.getId()); + responseBean.setName(documentEntity.getFileName()); + responseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType())); + responseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource())); + responseBean.setSourceId(documentEntity.getSourceId()); + responseBean.setFilePath(documentEntity.getFilePath()); + responseBean.setCreatedDate(documentEntity.getCreatedDate()); + responseBean.setUpdatedDate(documentEntity.getUpdatedDate()); + documentResponseBeans.add(responseBean); + }); + } } - fieldResponse.setFileDetail(documentResponseBeans); fieldResponses.add(fieldResponse); } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/AssignedApplicationsDao.java b/src/main/java/net/gepafin/tendermanagement/dao/AssignedApplicationsDao.java index b3e27da5..1617b3e7 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/AssignedApplicationsDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/AssignedApplicationsDao.java @@ -8,6 +8,7 @@ import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity; import net.gepafin.tendermanagement.entities.UserEntity; import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum; import net.gepafin.tendermanagement.enums.AssignedApplicationEnum; +import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest; import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest; import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse; import net.gepafin.tendermanagement.repositories.ApplicationRepository; @@ -47,6 +48,8 @@ public class AssignedApplicationsDao { @Autowired private Validator validator; + @Autowired + private ApplicationEvaluationDao applicationEvaluationDao; public AssignedApplicationsResponse createAssignedApplications(Long applicationId, Long userId, UserEntity assignedByUser, AssignedApplicationsRequest assignedApplicationsRequest){ log.info("Assigning application to pre-Instructor with details: {}", applicationId,userId); @@ -69,7 +72,7 @@ public class AssignedApplicationsDao { UserEntity user = userService.validateUser(userId); AssignedApplicationsEntity assignment = createAssignmentEntity(application, user.getId(), assignedByUser, assignedApplicationsRequest); AssignedApplicationsResponse assignApplicationToInstructorResponse = convertEntityToResponse(assignment); - + applicationEvaluationDao.createOrUpdateApplicationEvaluation(user, new ApplicationEvaluationRequest(), assignApplicationToInstructorResponse.getId()); log.info("Application assigned succesfully {}", assignApplicationToInstructorResponse); return assignApplicationToInstructorResponse; } @@ -128,6 +131,7 @@ public class AssignedApplicationsDao { assignedApplicationsResponse.setAssignedAt(assignedApplications.getAssignedAt()); assignedApplicationsResponse.setProtocolNumber(protocolNumber); assignedApplicationsResponse.setCallName(callName); + assignedApplicationsResponse.setCompanyName(application.getCompany().getCompanyName()); assignedApplicationsResponse.setBeneficiaryName(beneficiaryName); assignedApplicationsResponse.setSubmissionDate(submissionDate); assignedApplicationsResponse.setCallEndDate(callEndDate); @@ -171,6 +175,10 @@ public class AssignedApplicationsDao { if (userId != null) { predicate = builder.and(predicate, builder.equal(root.get("userId"), userId)); } + query.orderBy( + builder.desc(builder.isNotNull(root.get(GepafinConstant.ASSIGNED_AT))), + builder.desc(root.get(GepafinConstant.ASSIGNED_AT)) + ); predicate = builder.and(predicate, builder.equal(root.get("application").get("hubId"), hubId)); return predicate; }; diff --git a/src/main/java/net/gepafin/tendermanagement/dao/CommunicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/CommunicationDao.java index afe7e21e..75926512 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/CommunicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/CommunicationDao.java @@ -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; } } diff --git a/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEvaluationEntity.java b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEvaluationEntity.java index 8f6eb656..e33881b1 100644 --- a/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEvaluationEntity.java +++ b/src/main/java/net/gepafin/tendermanagement/entities/ApplicationEvaluationEntity.java @@ -30,6 +30,9 @@ public class ApplicationEvaluationEntity extends BaseEntity{ @Column(name = "status") private String status; + + @Column(name = "MOTIVATION") + private String motivation; @Column(name="IS_DELETED") private Boolean isDeleted; diff --git a/src/main/java/net/gepafin/tendermanagement/entities/CommunicationEntity.java b/src/main/java/net/gepafin/tendermanagement/entities/CommunicationEntity.java index 7aa43acd..9029649e 100644 --- a/src/main/java/net/gepafin/tendermanagement/entities/CommunicationEntity.java +++ b/src/main/java/net/gepafin/tendermanagement/entities/CommunicationEntity.java @@ -26,6 +26,12 @@ public class CommunicationEntity extends BaseEntity { @Column(name = "COMMENTED_DATE") private LocalDateTime commentedDate; + @Column(name = "SENDER_USER_ID") + private Long senderUserId; + + @Column(name = "RECEIVER_USER_ID") + private Long receiverUserId; + @ManyToOne @JoinColumn(name = "AMENDMENT_ID", referencedColumnName = "id", nullable = false) private ApplicationAmendmentRequestEntity applicationAmendmentRequest; diff --git a/src/main/java/net/gepafin/tendermanagement/model/request/ApplicationEvaluationRequest.java b/src/main/java/net/gepafin/tendermanagement/model/request/ApplicationEvaluationRequest.java index 9563f00b..df29c1d8 100644 --- a/src/main/java/net/gepafin/tendermanagement/model/request/ApplicationEvaluationRequest.java +++ b/src/main/java/net/gepafin/tendermanagement/model/request/ApplicationEvaluationRequest.java @@ -12,4 +12,5 @@ public class ApplicationEvaluationRequest { private List files; private String note; private ApplicationStatusForEvaluation applicationStatus; + private String motivation; } diff --git a/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationResponse.java b/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationResponse.java index 81d4314d..8d144e50 100644 --- a/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationResponse.java +++ b/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationEvaluationResponse.java @@ -26,6 +26,7 @@ public class ApplicationEvaluationResponse { private String beneficiary; private Long protocolNumber; private String callName; + private String motivation; private LocalDateTime submissionDate; private LocalDateTime evaluationEndDate; private LocalDateTime callEndDate; diff --git a/src/main/java/net/gepafin/tendermanagement/model/response/AssignedApplicationsResponse.java b/src/main/java/net/gepafin/tendermanagement/model/response/AssignedApplicationsResponse.java index b5ad3aae..3affe42f 100644 --- a/src/main/java/net/gepafin/tendermanagement/model/response/AssignedApplicationsResponse.java +++ b/src/main/java/net/gepafin/tendermanagement/model/response/AssignedApplicationsResponse.java @@ -20,6 +20,7 @@ public class AssignedApplicationsResponse extends BaseBean { private LocalDateTime submissionDate; private LocalDateTime callStartDate; private LocalDateTime callEndDate; + private String companyName; } diff --git a/src/main/java/net/gepafin/tendermanagement/model/response/CommunicationResponseBean.java b/src/main/java/net/gepafin/tendermanagement/model/response/CommunicationResponseBean.java index d1405dd8..13afde4b 100644 --- a/src/main/java/net/gepafin/tendermanagement/model/response/CommunicationResponseBean.java +++ b/src/main/java/net/gepafin/tendermanagement/model/response/CommunicationResponseBean.java @@ -16,6 +16,10 @@ public class CommunicationResponseBean { private LocalDateTime updatedDate; + private Long senderUserId; + + private Long receiverUserId; + private Long amendmentId; public CommunicationResponseBean(LocalDateTime commentedDate, String comment, String title, LocalDateTime createdDate, LocalDateTime updatedDate, Long amendmentId) { diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/BeneficiaryPreferredCallRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/BeneficiaryPreferredCallRepository.java index 1101d1a6..c83be4d8 100644 --- a/src/main/java/net/gepafin/tendermanagement/repositories/BeneficiaryPreferredCallRepository.java +++ b/src/main/java/net/gepafin/tendermanagement/repositories/BeneficiaryPreferredCallRepository.java @@ -13,7 +13,7 @@ public interface BeneficiaryPreferredCallRepository extends JpaRepository findByBeneficiaryIdAndIsDeletedFalse(Long beneficiaryId); List findByUserIdAndIsDeletedFalse(Long userId); - @Query("SELECT preferredCall FROM BeneficiaryPreferredCallEntity preferredCall where preferredCall.userId=:userId AND (:companyId is null OR preferredCall.companyId=:companyId)") + @Query("SELECT preferredCall FROM BeneficiaryPreferredCallEntity preferredCall where preferredCall.userId=:userId AND (:companyId is null OR preferredCall.companyId=:companyId) AND isDeleted=false") List findByUserIdAndCompanyIdAndIsDeletedFalse(@Param("userId") Long userId, @Param("companyId") Long companyId); List findByBeneficiaryIdAndCompanyId(Long beneficiaryId,Long companyId); List findByUserIdAndCallIdInAndIsDeletedFalse(Long userId, List callIds); diff --git a/src/main/java/net/gepafin/tendermanagement/service/CommunicationService.java b/src/main/java/net/gepafin/tendermanagement/service/CommunicationService.java index 5f8f1cd3..6c99f4a9 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/CommunicationService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/CommunicationService.java @@ -1,15 +1,16 @@ package net.gepafin.tendermanagement.service; +import jakarta.servlet.http.HttpServletRequest; import net.gepafin.tendermanagement.model.request.CommunicationRequestBean; import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse; import net.gepafin.tendermanagement.model.response.CommunicationResponseBean; public interface CommunicationService { - CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationRequestBean, Long amendmentId); + CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request ,CommunicationRequestBean communicationRequestBean, Long amendmentId); - String deleteComment(Long amendmentId, Long commentId); + String deleteComment(HttpServletRequest request,Long amendmentId, Long commentId); - CommunicationResponseBean updateAmendmentComment(CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId); + CommunicationResponseBean updateAmendmentComment(HttpServletRequest request,CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId); - ApplicationAmendmentResponse getAmendmentComments(Long id); + ApplicationAmendmentResponse getAmendmentComments(HttpServletRequest request,Long id); } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java index 0fec17a7..a8d63f1c 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java @@ -1,6 +1,8 @@ package net.gepafin.tendermanagement.service.impl; import jakarta.servlet.http.HttpServletRequest; +import net.gepafin.tendermanagement.config.Translator; +import net.gepafin.tendermanagement.constants.GepafinConstant; import net.gepafin.tendermanagement.dao.ApplicationDao; import net.gepafin.tendermanagement.dao.FlowFormDao; import net.gepafin.tendermanagement.entities.ApplicationEntity; @@ -17,6 +19,8 @@ import net.gepafin.tendermanagement.model.response.ApplicationSignedDocumentResp import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse; import net.gepafin.tendermanagement.service.ApplicationService; 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.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -64,6 +68,9 @@ public class ApplicationServiceImpl implements ApplicationService { @Transactional(rollbackFor = Exception.class) public ApplicationResponse createApplication(HttpServletRequest request, Long companyId, ApplicationRequest applicationRequest, Long callId) { UserEntity userEntity = validator.validateUser(request); + if(companyId==null){ + throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.USER_MUST_BE_ASSOCIATED_WITH_COMPANY)); + } CompanyEntity companyEntity = validator.validateUserWithCompany(request, companyId); validator.validateUserWithCall(userEntity, callId); return applicationDao.createApplicationByCallId(companyEntity, applicationRequest, callId, userEntity); 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 5a9b9c06..de3e5030 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/CommunicationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/CommunicationServiceImpl.java @@ -1,43 +1,76 @@ package net.gepafin.tendermanagement.service.impl; +import jakarta.servlet.http.HttpServletRequest; +import net.gepafin.tendermanagement.dao.ApplicationAmendmentRequestDao; import net.gepafin.tendermanagement.dao.CommunicationDao; +import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity; 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.service.CommunicationService; +import net.gepafin.tendermanagement.util.Validator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; + @Service public class CommunicationServiceImpl implements CommunicationService { @Autowired CommunicationDao communicationDao; + @Autowired + ApplicationAmendmentRequestDao applicationAmendmentRequestDao; + + @Autowired + Validator validator; + @Override @Transactional(rollbackFor = Exception.class) - public CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationRequestBean, Long amendmentId) { - - return communicationDao.addCommentToAmendmentRequest(communicationRequestBean, amendmentId); + public CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request ,CommunicationRequestBean communicationRequestBean, Long amendmentId) { + ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId); + if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) { + validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId()); + } else { + validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId()); + } + return communicationDao.addCommentToAmendmentRequest(request,communicationRequestBean, amendmentId); } + @Override @Transactional(rollbackFor = Exception.class) - public String deleteComment(Long amendmentId, Long commentId) { - + public String deleteComment(HttpServletRequest request ,Long amendmentId, Long commentId) { + ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId); + if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) { + validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId()); + } else { + validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId()); + } return communicationDao.deleteComment(amendmentId, commentId); } @Override @Transactional(rollbackFor = Exception.class) - public CommunicationResponseBean updateAmendmentComment(CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId) { - + public CommunicationResponseBean updateAmendmentComment(HttpServletRequest request,CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId) { + ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId); + if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) { + validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId()); + } else { + validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId()); + } return communicationDao.updateAmendmentComment(communicationRequestBean, amendmentId, commentId); } + @Override @Transactional(readOnly = true) - public ApplicationAmendmentResponse getAmendmentComments(Long id) { - + public ApplicationAmendmentResponse getAmendmentComments(HttpServletRequest request,Long id) { + ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(id); + if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) { + validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId()); + } else { + validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId()); + } return communicationDao.getAmendmentComments(id); } } diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java index d37c004e..d72f4daf 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java @@ -99,7 +99,7 @@ public interface ApplicationApi { @PostMapping(value = "/call/{callId}", produces = { "application/json" }) ResponseEntity> createApplicationByCallId(HttpServletRequest request, - @Parameter(description = "The company ID", required = true) @RequestParam(value = "companyId", required = true) Long companyId, + @Parameter(description = "The company ID") @RequestParam(value = "companyId", required = false) Long companyId, @Parameter(description = " Flow request object", required = true) @Valid @RequestBody ApplicationRequest applicationRequest, @Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId); diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/CommunicationApi.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/CommunicationApi.java index eb1351c9..a648b08b 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/CommunicationApi.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/CommunicationApi.java @@ -14,6 +14,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants; import org.springframework.data.repository.query.Param; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -32,6 +33,7 @@ public interface CommunicationApi { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @PostMapping(value = "/{amendmentId}", produces = { "application/json" }) + @PreAuthorize("hasRole('ROLE_PRE_INSTRUCTOR') || hasRole('ROLE_BENEFICIARY')") ResponseEntity> addCommentToAmendmentRequest(HttpServletRequest request, @RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId); @@ -43,7 +45,7 @@ public interface CommunicationApi { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE))) }) @GetMapping(value = "/{amendmentId}", produces = "application/json") - public ResponseEntity> getAmendmentComments(@PathVariable(value = "amendmentId") Long amendmentId); + public ResponseEntity> getAmendmentComments(HttpServletRequest request,@PathVariable(value = "amendmentId") Long amendmentId); @Operation(summary = "Api to update communication comments", responses = { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @@ -53,6 +55,7 @@ public interface CommunicationApi { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @PutMapping(value = "/{amendmentId}/{commentId}", produces = { "application/json" }) + @PreAuthorize("hasRole('ROLE_PRE_INSTRUCTOR') || hasRole('ROLE_BENEFICIARY')") ResponseEntity> updateCommunicationAmendment(HttpServletRequest request, @RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId, @PathVariable(value = "commentId") Long commentId); diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/CommunicationController.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/CommunicationController.java index 4805d2ce..92aa71cf 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/CommunicationController.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/CommunicationController.java @@ -27,28 +27,28 @@ public class CommunicationController implements CommunicationApi { public ResponseEntity> addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationRequestBean, Long amendmentId) { - CommunicationResponseBean communicationResponseBean = communicationService.addCommentToAmendmentRequest(communicationRequestBean, amendmentId); + CommunicationResponseBean communicationResponseBean = communicationService.addCommentToAmendmentRequest(request,communicationRequestBean, amendmentId); return ResponseEntity.status(HttpStatus.CREATED) .body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS))); } @Override - public ResponseEntity> getAmendmentComments(Long amendmentId) { + public ResponseEntity> getAmendmentComments(HttpServletRequest request,Long amendmentId) { - ApplicationAmendmentResponse response = communicationService.getAmendmentComments(amendmentId); + ApplicationAmendmentResponse response = communicationService.getAmendmentComments(request,amendmentId); return ResponseEntity.ok(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.AMENDMENT_FOUND_SUCCESS))); } @Override public ResponseEntity> updateCommunicationAmendment(HttpServletRequest request, CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId) { - CommunicationResponseBean communicationResponseBean = communicationService.updateAmendmentComment(communicationRequestBean, amendmentId, commentId); + CommunicationResponseBean communicationResponseBean = communicationService.updateAmendmentComment(request,communicationRequestBean, amendmentId, commentId); return ResponseEntity.status(HttpStatus.OK) .body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_UPDATED_SUCCESS_MSG))); } @Override public ResponseEntity> deleteApplicationAmendmentComment(HttpServletRequest request, Long applicationAmendId, Long commentId) { - String communicationResponseBean = communicationService.deleteComment(applicationAmendId, commentId); + String communicationResponseBean = communicationService.deleteComment(request,applicationAmendId, commentId); return ResponseEntity.status(HttpStatus.OK) .body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_DELETED_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 faab8f35..dfb8113f 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"/> - + - + @@ -1693,15 +1693,15 @@ - - - UNIQUE_UUID = 'p4lk3bcx1RStqTaIVVbXs' - - - - UNIQUE_UUID = 't7jh5wfg9QXylNaTZkPoE' - - + + + UNIQUE_UUID = 'p4lk3bcx1RStqTaIVVbXs' + + + + UNIQUE_UUID = 't7jh5wfg9QXylNaTZkPoE' + + select setval('gepafin_schema.system_email_template_id_seq', (select @@ -1763,7 +1763,7 @@ - + @@ -1771,11 +1771,11 @@ - + - + @@ -1799,6 +1799,24 @@ + + + + + + + + + + + + + role_type = 'ROLE_PRE_INSTRUCTOR' + + + + + diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index 4576117e..d6aa4578 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -308,6 +308,7 @@ invalid.amendment.for.comment = Invalid Amendment Request for the Given Comment. DD_MM_YYYY_HH_MM = dd_MM_yyyy HH:mm application.documents.not.found=No documents found for the application. beneficiary.call.duplicate = A preferred call with this call ID and company ID already exists for this user. +user.must.be.associated.with.company.to.create.application=You must be associated with a company to apply for this application. company.id.required.for.preferred.call=Company ID is required when requesting only preferred calls. response.days.not.null=Response days should not be null and greater than zero. diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index 937a2d21..051ed432 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -303,6 +303,7 @@ beneficiary.email.not.found.msg=L'indirizzo email per il beneficiario non � st reminder.email.sent.success.msg=Email di promemoria inviata con successo! application.documents.not.found=Nessun documento trovato per la domanda. beneficiary.call.duplicate = Una chiamata preferita con questo ID di chiamata e ID azienda esiste gi� per questo utente. +user.must.be.associated.with.company.to.create.application=Devi essere associato a un'azienda per poter presentare domanda per questa applicazione. company.id.required.for.preferred.call=ID azienda obbligatorio quando si richiedono solo chiamate preferite. response.days.not.null=I giorni di risposta non devono essere nulli e maggiori di zero. application.cannot.approved.or.rejected=La domanda non può essere approvata o rifiutata perché l'emendamento è attivo.