Done changes related to evaluation document
This commit is contained in:
@@ -2,10 +2,12 @@ package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusForEvaluation;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ApplicationEvaluationService {
|
||||
ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
|
||||
HttpServletRequest request,
|
||||
@@ -18,4 +20,6 @@ public interface ApplicationEvaluationService {
|
||||
ApplicationEvaluationEntity validateApplicationEvaluation(Long applicationEvaluationId);
|
||||
|
||||
ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId);
|
||||
|
||||
ApplicationEvaluationResponse updateApplicationEvaluation(HttpServletRequest request , Long assignedApplicationId, List<EvaluationDocumentRequest> applicationEvaluationDocRequest);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
|
||||
public interface DocumentService {
|
||||
|
||||
public List<DocumentResponseBean> uploadFile(List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType);
|
||||
public List<DocumentResponseBean> uploadFile(HttpServletRequest request,List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType);
|
||||
|
||||
public void deleteFile(Long documentId);
|
||||
|
||||
|
||||
@@ -1,29 +1,24 @@
|
||||
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.ApplicationEvaluationDao;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusForEvaluation;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
|
||||
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
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;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationService {
|
||||
@@ -36,6 +31,9 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
||||
private AssignedApplicationsService assignedApplicationsService;
|
||||
@Autowired
|
||||
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||
@Autowired
|
||||
private ApplicationEvaluationService applicationEvaluationService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(
|
||||
@@ -54,31 +52,12 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
||||
@Transactional(readOnly = true)
|
||||
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(
|
||||
HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
|
||||
|
||||
if (applicationId == null && assignedApplicationId == null) {
|
||||
throw new CustomValidationException(
|
||||
Status.BAD_REQUEST,
|
||||
Translator.toLocale(GepafinConstant.EITHER_APPLICATION_OR_ASSIGNED_APPLICATION_ID_REQUIRED_MSG)
|
||||
);
|
||||
}
|
||||
UserEntity preInstructor = validator.validateUser(request);
|
||||
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
|
||||
assignedApplicationsRepository.findByApplicationIdOrIdAndIsDeletedFalse(applicationId,assignedApplicationId);
|
||||
|
||||
if (assignedApplicationId != null) {
|
||||
assignedApplicationsOptional = assignedApplicationsOptional.filter(a -> a.getId().equals(assignedApplicationId));
|
||||
}
|
||||
AssignedApplicationsEntity assignedApplications = assignedApplicationsOptional
|
||||
.orElseThrow(() -> new CustomValidationException(
|
||||
Status.BAD_REQUEST,
|
||||
Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG)
|
||||
));
|
||||
validator.validatePreInstructor(request, assignedApplications.getUserId());
|
||||
|
||||
return applicationEvaluationDao.getApplicationEvaluationByApplicationId(
|
||||
request,
|
||||
preInstructor,
|
||||
assignedApplications.getApplication().getId(),
|
||||
assignedApplications.getId()
|
||||
applicationId,
|
||||
assignedApplicationId
|
||||
);
|
||||
}
|
||||
|
||||
@@ -98,4 +77,11 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
||||
public ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId) {
|
||||
return applicationEvaluationDao.validateApplicationEvaluationByApplicationId(applicationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationEvaluationResponse updateApplicationEvaluation(HttpServletRequest request, Long assignedApplicationId, List<EvaluationDocumentRequest> evaluationDocRequest) {
|
||||
AssignedApplicationsEntity assignedApplication =assignedApplicationsService.validateAssignedApplication(assignedApplicationId);
|
||||
validator.validatePreInstructor(request, assignedApplication.getUserId());
|
||||
return applicationEvaluationDao.updateApplicationEvaluation(assignedApplicationId,evaluationDocRequest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.DocumentDao;
|
||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.service.DocumentService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -22,9 +25,13 @@ public class DocumentServiceImpl implements DocumentService {
|
||||
@Autowired
|
||||
private DocumentDao documentDao;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
@Override
|
||||
public List<DocumentResponseBean> uploadFile(List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
|
||||
return documentDao.uploadFiles(files,sourceId,sourceType,fileType);
|
||||
public List<DocumentResponseBean> uploadFile(HttpServletRequest request,List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
|
||||
Map<String, Object> userInfo = validator.getUserInfoFromToken(request);
|
||||
Long userId = validator.getUserId(userInfo);
|
||||
return documentDao.uploadFiles(userId,files,sourceId,sourceType,fileType);
|
||||
}
|
||||
@Override
|
||||
public void deleteFile(Long documentId) {
|
||||
|
||||
@@ -12,10 +12,7 @@ import net.gepafin.tendermanagement.dao.S3PathConfig;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationSignedDocumentRepository;
|
||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -73,6 +70,9 @@ public class S3ReUploadMigrationService {
|
||||
@Autowired
|
||||
private ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||
|
||||
@Autowired
|
||||
private DocumentDao documentDao;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class S3ReUploadMigrationService {
|
||||
Long callId = null;
|
||||
Long applicationId = null;
|
||||
Long amendmentId = null;
|
||||
|
||||
Long evaluationId = null;
|
||||
if (DocumentSourceTypeEnum.CALL.getValue().equalsIgnoreCase(document.getSource())) {
|
||||
callId = document.getSourceId();
|
||||
} else if (DocumentSourceTypeEnum.APPLICATION.getValue().equalsIgnoreCase(document.getSource())) {
|
||||
@@ -120,9 +120,15 @@ public class S3ReUploadMigrationService {
|
||||
ApplicationEntity applicationEntity = applicationAmendmentRequestRepository.findApplicationByAmendmentId(amendmentId);
|
||||
applicationId = applicationEntity.getId();
|
||||
callId = applicationEntity.getCall().getId();
|
||||
} else if(DocumentSourceTypeEnum.EVALUATION.getValue().equalsIgnoreCase(document.getSource())){
|
||||
evaluationId = document.getSourceId();
|
||||
ApplicationEntity applicationEntity = applicationEvaluationRepository.findApplicationByEvaluationId(evaluationId);
|
||||
applicationId = applicationEntity.getId();
|
||||
callId = applicationEntity.getCall().getId();
|
||||
}
|
||||
|
||||
documentDao.deleteFileFromS3(document,callId,applicationId,amendmentId);
|
||||
|
||||
documentDao.deleteFileFromS3(document,callId,applicationId,amendmentId,evaluationId);
|
||||
processDocuments++;
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -213,10 +219,10 @@ public class S3ReUploadMigrationService {
|
||||
Long callId;
|
||||
|
||||
if (sourceType.equals(DocumentSourceTypeEnum.CALL)) {
|
||||
return s3ConfigBean.generateDocumentPath(sourceType, document.getSourceId(), 0L,0L);
|
||||
return s3ConfigBean.generateDocumentPath(sourceType, document.getSourceId(), 0L,0L,0L);
|
||||
} else {
|
||||
callId = applicationRepository.findCallIdById(document.getSourceId());
|
||||
return s3ConfigBean.generateDocumentPath(sourceType, callId, document.getSourceId(),0L);
|
||||
return s3ConfigBean.generateDocumentPath(sourceType, callId, document.getSourceId(),0L,0L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ public class UserSignedAndDelegationServiceImpl {
|
||||
|
||||
private String generateNewS3PathForDelegationDoc() {
|
||||
|
||||
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L,0L);
|
||||
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L,0L,0l);
|
||||
}
|
||||
|
||||
private String generateNewS3PathForUserSignedDoc(ApplicationSignedDocumentEntity document) {
|
||||
|
||||
Reference in New Issue
Block a user