Resolved conflicts
This commit is contained in:
@@ -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<ApplicationAmendmentRequestEntity> 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);
|
||||
|
||||
@@ -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<Long> 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<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) {
|
||||
List<Long> documentIds=null;
|
||||
|
||||
@@ -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<DocumentResponseBean> 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<DocumentResponseBean> 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<DocumentResponseBean> 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<DocumentResponseBean> 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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user