Resolved conflicts

This commit is contained in:
nisha
2024-11-25 00:04:57 +05:30
22 changed files with 310 additions and 112 deletions

View File

@@ -292,9 +292,12 @@ public class GepafinConstant {
public static final String ENCRYPT_KEY = "U2VjdXJlRW5jcnlwdEtleQ=="; public static final String ENCRYPT_KEY = "U2VjdXJlRW5jcnlwdEtleQ==";
public static final String APPLICATION_DOCUMENTS_NOT_FOUND_MSG = "application.documents.not.found"; 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 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 COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL = "company.id.required.for.preferred.call";
public static final String CREATED_DATE = "createdDate"; public static final String CREATED_DATE = "createdDate";
public static final String RESPONSE_DAYS_NOT_NULL="response.days.not.null"; 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 APPLICATION_CANNOT_APPROVED_OR_REJECTED="application.cannot.approved.or.rejected";
public static final String SUBMISSION_DATE = "submissionDate";
public static final String ASSIGNED_AT = "assignedAt";
} }

View File

@@ -94,6 +94,8 @@ public class ApplicationAmendmentRequestDao {
@Autowired @Autowired
private Validator validator; private Validator validator;
@Autowired
private ApplicationDao applicationDao;
@Autowired @Autowired
private EmailLogDao emailLogDao; private EmailLogDao emailLogDao;
@@ -258,20 +260,23 @@ public class ApplicationAmendmentRequestDao {
userEntity.getHub().getId()); userEntity.getHub().getId());
applicationAmendmentRequestEntity.setProtocol(protocolEntity); applicationAmendmentRequestEntity.setProtocol(protocolEntity);
ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity); ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity);
String evaluationStatusType = applicationEvaluationEntity.getStatus();
//Set Status if (Boolean.FALSE.equals(evaluationStatusType.equals((ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue())))){
applicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue()); applicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
applicationEvaluationRepository.save(applicationEvaluationEntity); applicationEvaluationRepository.save(applicationEvaluationEntity);
}
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId); ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
String applicationStatusType = applicationEntity.getStatus();
if (Boolean.FALSE.equals(applicationStatusType.equals((ApplicationStatusTypeEnum.SOCCORSO.getValue())))) {
applicationEntity.setStatus(ApplicationStatusTypeEnum.SOCCORSO.getValue()); applicationEntity.setStatus(ApplicationStatusTypeEnum.SOCCORSO.getValue());
applicationRepository.save(applicationEntity); applicationRepository.save(applicationEntity);
}
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId); AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsService.validateAssignedApplication(assignedApplicationId);
String assignedStatusType = assignedApplicationsEntity.getStatus();
if (Boolean.FALSE.equals(assignedStatusType.equals((AssignedApplicationEnum.SOCCORSO.getValue())))) {
assignedApplicationsEntity.setStatus(AssignedApplicationEnum.SOCCORSO.getValue()); assignedApplicationsEntity.setStatus(AssignedApplicationEnum.SOCCORSO.getValue());
assignedApplicationsRepository.save(assignedApplicationsEntity); assignedApplicationsRepository.save(assignedApplicationsEntity);
}
return applicationAmendment; return applicationAmendment;
} }
@@ -578,11 +583,10 @@ public class ApplicationAmendmentRequestDao {
// Add valid new document IDs from the request // Add valid new document IDs from the request
existingDocumentIds.addAll(validDocumentIds); existingDocumentIds.addAll(validDocumentIds);
applicationDao.updateDocumentDeletionStatus(formEntity, updatedFormField, formEntity.getApplicationForm().getForm(), null,validDocumentIds,true);
// Set the combined document IDs back as the field value // Set the combined document IDs back as the field value
formEntity.setFieldValue(String.join(",", existingDocumentIds)); formEntity.setFieldValue(String.join(",", existingDocumentIds));
applicationFormFieldRepository.save(formEntity); applicationFormFieldRepository.save(formEntity);
log.info("Updated field value for application ID {} and field ID {} with document IDs {}", log.info("Updated field value for application ID {} and field ID {} with document IDs {}",
applicationAmendment.getApplicationId(), updatedFormField.getFieldId(), String.join(",", existingDocumentIds)); applicationAmendment.getApplicationId(), updatedFormField.getFieldId(), String.join(",", existingDocumentIds));
fieldUpdated = true; fieldUpdated = true;
@@ -684,12 +688,16 @@ public class ApplicationAmendmentRequestDao {
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment); ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment);
List<ApplicationAmendmentRequestEntity> amendmentRequests = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(existingApplicationAmendment.getApplicationEvaluationEntity().getId()); List<ApplicationAmendmentRequestEntity> amendmentRequests = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(existingApplicationAmendment.getApplicationEvaluationEntity().getId());
boolean allClosed = amendmentRequests.stream() Boolean allClosed = amendmentRequests.stream()
.allMatch(amendment -> amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue())); .allMatch(amendment -> amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()));
ApplicationEntity application = applicationService.validateApplication(existingApplicationAmendment.getApplicationId());
if (allClosed) { if (Boolean.TRUE.equals(allClosed)){
existingApplicationAmendment.getApplicationEvaluationEntity().setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue()); existingApplicationAmendment.getApplicationEvaluationEntity().setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
applicationEvaluationRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity()); 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("All amendments are closed. Application Evaluation status set to OPEN.");
} }
log.info("Application Amendment closed successfully: {}", response); log.info("Application Amendment closed successfully: {}", response);

View File

@@ -337,8 +337,11 @@ public class ApplicationDao {
.collect(Collectors.toList()); .collect(Collectors.toList());
predicate = builder.and(predicate, root.get("status").in(statusNames)); 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())); predicate = builder.and(predicate, builder.equal(root.get("hubId"), userEntity.getHub().getId()));
query.orderBy(builder.desc(root.get(GepafinConstant.CREATED_DATE)));
return predicate; return predicate;
}; };
} }
@@ -409,7 +412,7 @@ public class ApplicationDao {
ApplicationFormFieldEntity applicationFormFieldEntity=null; ApplicationFormFieldEntity applicationFormFieldEntity=null;
validateFileUploadDocuments(applicationFormFieldRequestBean, formEntity); List<Long> newDocumentIds =validateFileUploadDocuments(applicationFormFieldRequestBean, formEntity);
if(applicationFormFieldEntities==null || applicationFormFieldEntities.isEmpty()){ if(applicationFormFieldEntities==null || applicationFormFieldEntities.isEmpty()){
applicationFormFieldEntity = new ApplicationFormFieldEntity(); applicationFormFieldEntity = new ApplicationFormFieldEntity();
@@ -431,13 +434,79 @@ public class ApplicationDao {
Utils.setIfUpdated(applicationFormFieldEntity::getFieldId, applicationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId()); Utils.setIfUpdated(applicationFormFieldEntity::getFieldId, applicationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId());
if(applicationFormFieldRequestBean.getFieldValue() !=null ) { if(applicationFormFieldRequestBean.getFieldValue() !=null ) {
updateDocumentDeletionStatus(applicationFormFieldEntity, applicationFormFieldRequestBean,formEntity,newDocumentIds,null,false);
applicationFormFieldEntity.setFieldValue(Utils.convertObjectToJsonString(applicationFormFieldRequestBean.getFieldValue())); applicationFormFieldEntity.setFieldValue(Utils.convertObjectToJsonString(applicationFormFieldRequestBean.getFieldValue()));
} }
if(applicationFormFieldRequestBean.getFieldValue() ==null ) { if(applicationFormFieldRequestBean.getFieldValue() ==null ) {
updateDocumentDeletionStatus(applicationFormFieldEntity, applicationFormFieldRequestBean,formEntity,newDocumentIds,null,false);
applicationFormFieldEntity.setFieldValue(null); applicationFormFieldEntity.setFieldValue(null);
} }
return applicationFormFieldRepository.save(applicationFormFieldEntity); return applicationFormFieldRepository.save(applicationFormFieldEntity);
} }
void updateDocumentDeletionStatus(ApplicationFormFieldEntity applicationFormFieldEntity, ApplicationFormFieldRequestBean applicationFormFieldRequestBean, FormEntity formEntity, List<Long> newDocumentIds,
List<String> preInstructorDocumentId,boolean isPreInstructor) {
if (newDocumentIds == null) {
newDocumentIds = Collections.emptyList();
}
if (preInstructorDocumentId == null) {
preInstructorDocumentId = Collections.emptyList();
}
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
if (Boolean.FALSE.equals(contentResponseBean.getName().equals("fileupload"))) {
return;
}
}
if(!isPreInstructor){
List<Long> currentDocumentIds = parseDocumentIds(applicationFormFieldEntity.getFieldValue());
if (Boolean.TRUE.equals(newDocumentIds.isEmpty())) {
currentDocumentIds.forEach(docId -> documentService.deleteFile(docId));
} else {
List<Long> finalNewDocumentIds = newDocumentIds;
List<Long> documentsToDelete = currentDocumentIds.stream()
.filter(docId -> !finalNewDocumentIds.contains(docId))
.toList();
documentsToDelete.forEach(docId -> documentService.deleteFile(docId));
}}
else{
List<Long> currentDocumentIds = parseDocumentIds(applicationFormFieldEntity.getFieldValue());
if (Boolean.TRUE.equals(preInstructorDocumentId.isEmpty())) {
currentDocumentIds.forEach(docId -> documentService.deleteFile(docId));
} else {
List<Long> preInstructorDocIds = preInstructorDocumentId.stream()
.map(Long::valueOf)
.collect(Collectors.toList());
List<Long> documentsToDelete = currentDocumentIds.stream()
.filter(docId -> !preInstructorDocIds.contains(docId))
.toList();
documentsToDelete.forEach(docId -> documentService.deleteFile(docId));
}}
}
private List<Long> 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<Long> validateFileUploadDocuments(ApplicationFormFieldRequestBean applicationFormFieldRequestBean, FormEntity formEntity) { private List<Long> validateFileUploadDocuments(ApplicationFormFieldRequestBean applicationFormFieldRequestBean, FormEntity formEntity) {
List<Long> documentIds=null; List<Long> documentIds=null;

View File

@@ -15,6 +15,7 @@ import net.gepafin.tendermanagement.model.request.FieldRequest;
import net.gepafin.tendermanagement.model.response.*; import net.gepafin.tendermanagement.model.response.*;
import net.gepafin.tendermanagement.repositories.*; import net.gepafin.tendermanagement.repositories.*;
import net.gepafin.tendermanagement.service.ApplicationService; import net.gepafin.tendermanagement.service.ApplicationService;
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
import net.gepafin.tendermanagement.service.CallService; import net.gepafin.tendermanagement.service.CallService;
import net.gepafin.tendermanagement.service.UserService; import net.gepafin.tendermanagement.service.UserService;
import net.gepafin.tendermanagement.util.DateTimeUtil; import net.gepafin.tendermanagement.util.DateTimeUtil;
@@ -84,11 +85,14 @@ public class ApplicationEvaluationDao {
@Autowired @Autowired
private FormDao formDao; private FormDao formDao;
@Autowired
private AssignedApplicationsService assignedApplicationsService;
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) { private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity(); ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplciationId).orElse(null); AssignedApplicationsEntity assignedApplications = assignedApplicationsService.validateAssignedApplication(assignedApplciationId);
ApplicationEntity application = applicationService.validateApplication(assignedApplications.getApplication().getId()); ApplicationEntity application = applicationService.validateApplication(assignedApplications.getApplication().getId());
entity.setApplicationId(application.getId()); entity.setApplicationId(application.getId());
entity.setAssignedApplicationsEntity(assignedApplications); entity.setAssignedApplicationsEntity(assignedApplications);
@@ -97,6 +101,7 @@ public class ApplicationEvaluationDao {
entity.setChecklist(Utils.convertObjectToJson(req.getChecklist())); entity.setChecklist(Utils.convertObjectToJson(req.getChecklist()));
entity.setFile(Utils.convertObjectToJson(req.getFiles())); entity.setFile(Utils.convertObjectToJson(req.getFiles()));
entity.setNote(req.getNote()); entity.setNote(req.getNote());
entity.setMotivation(req.getMotivation());
entity.setIsDeleted(false); entity.setIsDeleted(false);
entity.setInitialDays(30L); entity.setInitialDays(30L);
entity.setRemainingDays(30L); entity.setRemainingDays(30L);
@@ -133,6 +138,7 @@ public class ApplicationEvaluationDao {
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(entity.getAssignedApplicationsEntity().getId()).orElse(null); AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(entity.getAssignedApplicationsEntity().getId()).orElse(null);
response.setAssignedApplicationId(assignedApplications.getId()); response.setAssignedApplicationId(assignedApplications.getId());
response.setNote(entity.getNote()); response.setNote(entity.getNote());
response.setMotivation(entity.getMotivation());
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(entity.getStatus())); response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(entity.getStatus()));
response.setEvaluationEndDate(entity.getEndDate()); response.setEvaluationEndDate(entity.getEndDate());
response.setCreatedDate(entity.getCreatedDate()); response.setCreatedDate(entity.getCreatedDate());
@@ -257,6 +263,7 @@ public class ApplicationEvaluationDao {
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>(); List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
for (String docId : documentIds) { for (String docId : documentIds) {
if (Boolean.FALSE.equals(docId.isEmpty())){
Long documentId = Long.valueOf(docId.trim()); Long documentId = Long.valueOf(docId.trim());
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
DocumentResponseBean responseBean = new DocumentResponseBean(); DocumentResponseBean responseBean = new DocumentResponseBean();
@@ -271,6 +278,7 @@ public class ApplicationEvaluationDao {
documentResponseBeans.add(responseBean); documentResponseBeans.add(responseBean);
}); });
} }
}
mappedField.setFieldValue(documentResponseBeans); mappedField.setFieldValue(documentResponseBeans);
} }
} }
@@ -359,6 +367,7 @@ public class ApplicationEvaluationDao {
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>(); List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
for (String docId : documentIds) { for (String docId : documentIds) {
if (Boolean.FALSE.equals(docId.isEmpty())){
Long documentId = Long.valueOf(docId.trim()); Long documentId = Long.valueOf(docId.trim());
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
DocumentResponseBean responseBean = new DocumentResponseBean(); DocumentResponseBean responseBean = new DocumentResponseBean();
@@ -373,6 +382,7 @@ public class ApplicationEvaluationDao {
documentResponseBeans.add(responseBean); documentResponseBeans.add(responseBean);
}); });
} }
}
fieldResponse.setFileDetail(documentResponseBeans); fieldResponse.setFileDetail(documentResponseBeans);
} }
@@ -436,6 +446,7 @@ public class ApplicationEvaluationDao {
entity.setFile(Utils.convertObjectToJson(filterNonNullFields(processField(entity, req)))); entity.setFile(Utils.convertObjectToJson(filterNonNullFields(processField(entity, req))));
entity.setIsDeleted(false); entity.setIsDeleted(false);
setIfUpdated(entity::getNote, entity::setNote, req.getNote()); setIfUpdated(entity::getNote, entity::setNote, req.getNote());
setIfUpdated(entity::getMotivation, entity::setMotivation, req.getMotivation());
} else { } else {
entity = convertToEntity(user, req, assignedApplicationId); entity = convertToEntity(user, req, assignedApplicationId);
} }
@@ -635,6 +646,7 @@ public class ApplicationEvaluationDao {
response.setApplicationId(application.getId()); response.setApplicationId(application.getId());
response.setAssignedApplicationId(assignedApplications.getId()); response.setAssignedApplicationId(assignedApplications.getId());
response.setNote(null); response.setNote(null);
response.setMotivation(null);
response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus())); response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus()));
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(ApplicationEvaluationStatusTypeEnum.OPEN.getValue())); response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(ApplicationEvaluationStatusTypeEnum.OPEN.getValue()));
response.setMinScore(call.getThreshold()!=null?call.getThreshold():null); response.setMinScore(call.getThreshold()!=null?call.getThreshold():null);
@@ -896,6 +908,7 @@ public class ApplicationEvaluationDao {
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>(); List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
for (String docId : documentIds) { for (String docId : documentIds) {
if (Boolean.FALSE.equals(docId.isEmpty())) {
Long documentId = Long.valueOf(docId.trim()); Long documentId = Long.valueOf(docId.trim());
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
DocumentResponseBean responseBean = new DocumentResponseBean(); DocumentResponseBean responseBean = new DocumentResponseBean();
@@ -910,6 +923,7 @@ public class ApplicationEvaluationDao {
documentResponseBeans.add(responseBean); documentResponseBeans.add(responseBean);
}); });
} }
}
fieldResponse.setFileDetail(documentResponseBeans); fieldResponse.setFileDetail(documentResponseBeans);
} }
@@ -1254,6 +1268,7 @@ public class ApplicationEvaluationDao {
List<DocumentResponseBean> documentResponseBeans = new ArrayList<>(); List<DocumentResponseBean> documentResponseBeans = new ArrayList<>();
for (String docId : documentIds) { for (String docId : documentIds) {
if (Boolean.FALSE.equals(docId.isEmpty())){
Long documentId = Long.valueOf(docId.trim()); Long documentId = Long.valueOf(docId.trim());
documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> { documentRepository.findByIdAndNotDeleted(documentId).ifPresent(documentEntity -> {
DocumentResponseBean responseBean = new DocumentResponseBean(); DocumentResponseBean responseBean = new DocumentResponseBean();
@@ -1268,7 +1283,7 @@ public class ApplicationEvaluationDao {
documentResponseBeans.add(responseBean); documentResponseBeans.add(responseBean);
}); });
} }
}
fieldResponse.setFileDetail(documentResponseBeans); fieldResponse.setFileDetail(documentResponseBeans);
fieldResponses.add(fieldResponse); fieldResponses.add(fieldResponse);
} }

View File

@@ -8,6 +8,7 @@ import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
import net.gepafin.tendermanagement.entities.UserEntity; import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum; import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum; 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.request.AssignedApplicationsRequest;
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse; import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
import net.gepafin.tendermanagement.repositories.ApplicationRepository; import net.gepafin.tendermanagement.repositories.ApplicationRepository;
@@ -47,6 +48,8 @@ public class AssignedApplicationsDao {
@Autowired @Autowired
private Validator validator; private Validator validator;
@Autowired
private ApplicationEvaluationDao applicationEvaluationDao;
public AssignedApplicationsResponse createAssignedApplications(Long applicationId, Long userId, UserEntity assignedByUser, AssignedApplicationsRequest assignedApplicationsRequest){ public AssignedApplicationsResponse createAssignedApplications(Long applicationId, Long userId, UserEntity assignedByUser, AssignedApplicationsRequest assignedApplicationsRequest){
log.info("Assigning application to pre-Instructor with details: {}", applicationId,userId); log.info("Assigning application to pre-Instructor with details: {}", applicationId,userId);
@@ -69,7 +72,7 @@ public class AssignedApplicationsDao {
UserEntity user = userService.validateUser(userId); UserEntity user = userService.validateUser(userId);
AssignedApplicationsEntity assignment = createAssignmentEntity(application, user.getId(), assignedByUser, assignedApplicationsRequest); AssignedApplicationsEntity assignment = createAssignmentEntity(application, user.getId(), assignedByUser, assignedApplicationsRequest);
AssignedApplicationsResponse assignApplicationToInstructorResponse = convertEntityToResponse(assignment); AssignedApplicationsResponse assignApplicationToInstructorResponse = convertEntityToResponse(assignment);
applicationEvaluationDao.createOrUpdateApplicationEvaluation(user, new ApplicationEvaluationRequest(), assignApplicationToInstructorResponse.getId());
log.info("Application assigned succesfully {}", assignApplicationToInstructorResponse); log.info("Application assigned succesfully {}", assignApplicationToInstructorResponse);
return assignApplicationToInstructorResponse; return assignApplicationToInstructorResponse;
} }
@@ -128,6 +131,7 @@ public class AssignedApplicationsDao {
assignedApplicationsResponse.setAssignedAt(assignedApplications.getAssignedAt()); assignedApplicationsResponse.setAssignedAt(assignedApplications.getAssignedAt());
assignedApplicationsResponse.setProtocolNumber(protocolNumber); assignedApplicationsResponse.setProtocolNumber(protocolNumber);
assignedApplicationsResponse.setCallName(callName); assignedApplicationsResponse.setCallName(callName);
assignedApplicationsResponse.setCompanyName(application.getCompany().getCompanyName());
assignedApplicationsResponse.setBeneficiaryName(beneficiaryName); assignedApplicationsResponse.setBeneficiaryName(beneficiaryName);
assignedApplicationsResponse.setSubmissionDate(submissionDate); assignedApplicationsResponse.setSubmissionDate(submissionDate);
assignedApplicationsResponse.setCallEndDate(callEndDate); assignedApplicationsResponse.setCallEndDate(callEndDate);
@@ -171,6 +175,10 @@ public class AssignedApplicationsDao {
if (userId != null) { if (userId != null) {
predicate = builder.and(predicate, builder.equal(root.get("userId"), userId)); 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)); predicate = builder.and(predicate, builder.equal(root.get("application").get("hubId"), hubId));
return predicate; return predicate;
}; };

View File

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

View File

@@ -31,6 +31,9 @@ public class ApplicationEvaluationEntity extends BaseEntity{
@Column(name = "status") @Column(name = "status")
private String status; private String status;
@Column(name = "MOTIVATION")
private String motivation;
@Column(name="IS_DELETED") @Column(name="IS_DELETED")
private Boolean isDeleted; private Boolean isDeleted;

View File

@@ -26,6 +26,12 @@ public class CommunicationEntity extends BaseEntity {
@Column(name = "COMMENTED_DATE") @Column(name = "COMMENTED_DATE")
private LocalDateTime commentedDate; private LocalDateTime commentedDate;
@Column(name = "SENDER_USER_ID")
private Long senderUserId;
@Column(name = "RECEIVER_USER_ID")
private Long receiverUserId;
@ManyToOne @ManyToOne
@JoinColumn(name = "AMENDMENT_ID", referencedColumnName = "id", nullable = false) @JoinColumn(name = "AMENDMENT_ID", referencedColumnName = "id", nullable = false)
private ApplicationAmendmentRequestEntity applicationAmendmentRequest; private ApplicationAmendmentRequestEntity applicationAmendmentRequest;

View File

@@ -12,4 +12,5 @@ public class ApplicationEvaluationRequest {
private List<FieldRequest> files; private List<FieldRequest> files;
private String note; private String note;
private ApplicationStatusForEvaluation applicationStatus; private ApplicationStatusForEvaluation applicationStatus;
private String motivation;
} }

View File

@@ -26,6 +26,7 @@ public class ApplicationEvaluationResponse {
private String beneficiary; private String beneficiary;
private Long protocolNumber; private Long protocolNumber;
private String callName; private String callName;
private String motivation;
private LocalDateTime submissionDate; private LocalDateTime submissionDate;
private LocalDateTime evaluationEndDate; private LocalDateTime evaluationEndDate;
private LocalDateTime callEndDate; private LocalDateTime callEndDate;

View File

@@ -20,6 +20,7 @@ public class AssignedApplicationsResponse extends BaseBean {
private LocalDateTime submissionDate; private LocalDateTime submissionDate;
private LocalDateTime callStartDate; private LocalDateTime callStartDate;
private LocalDateTime callEndDate; private LocalDateTime callEndDate;
private String companyName;
} }

View File

@@ -16,6 +16,10 @@ public class CommunicationResponseBean {
private LocalDateTime updatedDate; private LocalDateTime updatedDate;
private Long senderUserId;
private Long receiverUserId;
private Long amendmentId; private Long amendmentId;
public CommunicationResponseBean(LocalDateTime commentedDate, String comment, String title, LocalDateTime createdDate, LocalDateTime updatedDate, Long amendmentId) { public CommunicationResponseBean(LocalDateTime commentedDate, String comment, String title, LocalDateTime createdDate, LocalDateTime updatedDate, Long amendmentId) {

View File

@@ -13,7 +13,7 @@ public interface BeneficiaryPreferredCallRepository extends JpaRepository<Benefi
List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndIsDeletedFalse(Long beneficiaryId); List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndIsDeletedFalse(Long beneficiaryId);
List<BeneficiaryPreferredCallEntity> findByUserIdAndIsDeletedFalse(Long userId); List<BeneficiaryPreferredCallEntity> 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<BeneficiaryPreferredCallEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(@Param("userId") Long userId, @Param("companyId") Long companyId); List<BeneficiaryPreferredCallEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(@Param("userId") Long userId, @Param("companyId") Long companyId);
List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndCompanyId(Long beneficiaryId,Long companyId); List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndCompanyId(Long beneficiaryId,Long companyId);
List<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdInAndIsDeletedFalse(Long userId, List<Long> callIds); List<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdInAndIsDeletedFalse(Long userId, List<Long> callIds);

View File

@@ -1,15 +1,16 @@
package net.gepafin.tendermanagement.service; package net.gepafin.tendermanagement.service;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean; import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse; import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean; import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
public interface CommunicationService { 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);
} }

View File

@@ -1,6 +1,8 @@
package net.gepafin.tendermanagement.service.impl; package net.gepafin.tendermanagement.service.impl;
import jakarta.servlet.http.HttpServletRequest; 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.ApplicationDao;
import net.gepafin.tendermanagement.dao.FlowFormDao; import net.gepafin.tendermanagement.dao.FlowFormDao;
import net.gepafin.tendermanagement.entities.ApplicationEntity; 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.model.response.NextOrPreviousFormResponse;
import net.gepafin.tendermanagement.service.ApplicationService; import net.gepafin.tendermanagement.service.ApplicationService;
import net.gepafin.tendermanagement.util.Validator; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -64,6 +68,9 @@ public class ApplicationServiceImpl implements ApplicationService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ApplicationResponse createApplication(HttpServletRequest request, Long companyId, ApplicationRequest applicationRequest, Long callId) { public ApplicationResponse createApplication(HttpServletRequest request, Long companyId, ApplicationRequest applicationRequest, Long callId) {
UserEntity userEntity = validator.validateUser(request); 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); CompanyEntity companyEntity = validator.validateUserWithCompany(request, companyId);
validator.validateUserWithCall(userEntity, callId); validator.validateUserWithCall(userEntity, callId);
return applicationDao.createApplicationByCallId(companyEntity, applicationRequest, callId, userEntity); return applicationDao.createApplicationByCallId(companyEntity, applicationRequest, callId, userEntity);

View File

@@ -1,43 +1,76 @@
package net.gepafin.tendermanagement.service.impl; 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.dao.CommunicationDao;
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean; import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse; import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean; import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
import net.gepafin.tendermanagement.service.CommunicationService; import net.gepafin.tendermanagement.service.CommunicationService;
import net.gepafin.tendermanagement.util.Validator;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class CommunicationServiceImpl implements CommunicationService { public class CommunicationServiceImpl implements CommunicationService {
@Autowired @Autowired
CommunicationDao communicationDao; CommunicationDao communicationDao;
@Autowired
ApplicationAmendmentRequestDao applicationAmendmentRequestDao;
@Autowired
Validator validator;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationRequestBean, Long amendmentId) { public CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request ,CommunicationRequestBean communicationRequestBean, Long amendmentId) {
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId);
return communicationDao.addCommentToAmendmentRequest(communicationRequestBean, 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 @Override
@Transactional(rollbackFor = Exception.class) @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); return communicationDao.deleteComment(amendmentId, commentId);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @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); return communicationDao.updateAmendmentComment(communicationRequestBean, amendmentId, commentId);
} }
@Override @Override
@Transactional(readOnly = true) @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); return communicationDao.getAmendmentComments(id);
} }
} }

View File

@@ -99,7 +99,7 @@ public interface ApplicationApi {
@PostMapping(value = "/call/{callId}", @PostMapping(value = "/call/{callId}",
produces = { "application/json" }) produces = { "application/json" })
ResponseEntity<Response<ApplicationResponse>> createApplicationByCallId(HttpServletRequest request, ResponseEntity<Response<ApplicationResponse>> 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 = " Flow request object", required = true) @Valid @RequestBody ApplicationRequest applicationRequest,
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId); @Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);

View File

@@ -14,6 +14,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; 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 = { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@PostMapping(value = "/{amendmentId}", produces = { "application/json" }) @PostMapping(value = "/{amendmentId}", produces = { "application/json" })
@PreAuthorize("hasRole('ROLE_PRE_INSTRUCTOR') || hasRole('ROLE_BENEFICIARY')")
ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request,
@RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId); @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 = @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value =
ErrorConstants.BADREQUEST_ERROR_EXAMPLE))) }) ErrorConstants.BADREQUEST_ERROR_EXAMPLE))) })
@GetMapping(value = "/{amendmentId}", produces = "application/json") @GetMapping(value = "/{amendmentId}", produces = "application/json")
public ResponseEntity<Response<ApplicationAmendmentResponse>> getAmendmentComments(@PathVariable(value = "amendmentId") Long amendmentId); public ResponseEntity<Response<ApplicationAmendmentResponse>> getAmendmentComments(HttpServletRequest request,@PathVariable(value = "amendmentId") Long amendmentId);
@Operation(summary = "Api to update communication comments", responses = { @ApiResponse(responseCode = "200", description = "OK"), @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 = { @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 = { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@PutMapping(value = "/{amendmentId}/{commentId}", produces = { "application/json" }) @PutMapping(value = "/{amendmentId}/{commentId}", produces = { "application/json" })
@PreAuthorize("hasRole('ROLE_PRE_INSTRUCTOR') || hasRole('ROLE_BENEFICIARY')")
ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request, ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request,
@RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId, @PathVariable(value = "commentId") Long commentId); @RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId, @PathVariable(value = "commentId") Long commentId);

View File

@@ -27,28 +27,28 @@ public class CommunicationController implements CommunicationApi {
public ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationRequestBean, public ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, CommunicationRequestBean communicationRequestBean,
Long amendmentId) { Long amendmentId) {
CommunicationResponseBean communicationResponseBean = communicationService.addCommentToAmendmentRequest(communicationRequestBean, amendmentId); CommunicationResponseBean communicationResponseBean = communicationService.addCommentToAmendmentRequest(request,communicationRequestBean, amendmentId);
return ResponseEntity.status(HttpStatus.CREATED) return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS))); .body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMUNICATION_ADDED_TO_AMENDMENT_REQUEST_SUCCESS)));
} }
@Override @Override
public ResponseEntity<Response<ApplicationAmendmentResponse>> getAmendmentComments(Long amendmentId) { public ResponseEntity<Response<ApplicationAmendmentResponse>> 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))); return ResponseEntity.ok(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.AMENDMENT_FOUND_SUCCESS)));
} }
@Override @Override
public ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request, CommunicationRequestBean communicationRequestBean, public ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request, CommunicationRequestBean communicationRequestBean,
Long amendmentId, Long commentId) { Long amendmentId, Long commentId) {
CommunicationResponseBean communicationResponseBean = communicationService.updateAmendmentComment(communicationRequestBean, amendmentId, commentId); CommunicationResponseBean communicationResponseBean = communicationService.updateAmendmentComment(request,communicationRequestBean, amendmentId, commentId);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_UPDATED_SUCCESS_MSG))); .body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_UPDATED_SUCCESS_MSG)));
} }
@Override @Override
public ResponseEntity<Response<String>> deleteApplicationAmendmentComment(HttpServletRequest request, Long applicationAmendId, Long commentId) { public ResponseEntity<Response<String>> 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) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_DELETED_SUCCESS_MSG))); .body(new Response<>(communicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMMENT_DELETED_SUCCESS_MSG)));
} }

View File

@@ -1801,4 +1801,22 @@
<column name="end_date" type="TIMESTAMP WITHOUT TIME ZONE"></column> <column name="end_date" type="TIMESTAMP WITHOUT TIME ZONE"></column>
</addColumn> </addColumn>
</changeSet> </changeSet>
<changeSet id="21-11-2024_1" author="Rajesh Khore">
<addColumn tableName="communication">
<column name="sender_user_id" type="INTEGER"></column>
<column name="receiver_user_id" type="INTEGER"></column>
</addColumn>
</changeSet>
<changeSet id="21-11-2024_2" author="Rajesh Khore">
<update tableName="role">
<column name="role_name" value='Instructor'/>
<where>role_type = 'ROLE_PRE_INSTRUCTOR'</where>
</update>
</changeSet>
<changeSet id="22-11-2024_1" author="Rajesh Khore">
<addColumn tableName="application_evaluation">
<column name="MOTIVATION" type="TEXT"></column>
</addColumn>
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View File

@@ -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 DD_MM_YYYY_HH_MM = dd_MM_yyyy HH:mm
application.documents.not.found=No documents found for the application. 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. 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. 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. response.days.not.null=Response days should not be null and greater than zero.

View File

@@ -303,6 +303,7 @@ beneficiary.email.not.found.msg=L'indirizzo email per il beneficiario non <20> st
reminder.email.sent.success.msg=Email di promemoria inviata con successo! reminder.email.sent.success.msg=Email di promemoria inviata con successo!
application.documents.not.found=Nessun documento trovato per la domanda. 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. 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. 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. 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. application.cannot.approved.or.rejected=La domanda non può essere approvata o rifiutata perché l'emendamento è attivo.