Merge pull request #130 from Kitzanos/evaluation-document-changes

Done changes related to evaluation document
This commit is contained in:
rajeshkhore
2024-12-12 14:57:01 +05:30
committed by GitHub
28 changed files with 318 additions and 92 deletions

View File

@@ -1080,7 +1080,7 @@ public class ApplicationDao {
}
private String generateS3PathForDelegation(Long callId, Long applicationId) {
try {
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, callId, applicationId,0L);
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, callId, applicationId,0L,0L);
} catch (IllegalArgumentException e) {
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
}
@@ -1244,7 +1244,7 @@ public class ApplicationDao {
try (ByteArrayOutputStream zipOutputStream = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(zipOutputStream)) {
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.APPLICATION, applicationEntity.getCall().getId(), applicationId,0L);
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.APPLICATION, applicationEntity.getCall().getId(), applicationId,0L,0L);
for (DocumentEntity document : documents) {
String fileName = Utils.extractFileName(document.getFilePath());
@@ -1252,7 +1252,7 @@ public class ApplicationDao {
}
if (signedDocument != null) {
String signedDocS3Folder = s3PathConfig.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, applicationEntity.getCall().getId(), applicationId,0L);
String signedDocS3Folder = s3PathConfig.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, applicationEntity.getCall().getId(), applicationId,0L,0L);
String signedDocFileName = signedDocument.getFileName();
addDocumentToZip(zos, signedDocS3Folder, signedDocument.getFilePath(), signedDocFileName);
}

View File

@@ -1,8 +1,8 @@
package net.gepafin.tendermanagement.dao;
import com.amazonaws.services.dynamodbv2.xspec.L;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
@@ -16,6 +16,7 @@ import net.gepafin.tendermanagement.service.*;
import net.gepafin.tendermanagement.util.DateTimeUtil;
import net.gepafin.tendermanagement.util.LoggingUtil;
import net.gepafin.tendermanagement.util.Utils;
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;
@@ -27,7 +28,6 @@ import java.util.*;
import java.util.stream.Collectors;
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
import static org.apache.commons.lang3.StringUtils.isNumeric;
@Component
public class ApplicationEvaluationDao {
@@ -93,6 +93,12 @@ public class ApplicationEvaluationDao {
@Autowired
private CompanyService companyService;
@Autowired
private Validator validator;
@Autowired
private DocumentService documentService;
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
@@ -132,11 +138,42 @@ public class ApplicationEvaluationDao {
setCriteriaResponses(entity, response, evaluationCriterias);
setChecklistResponses(entity, response, checklistEntities);
setFieldResponses(entity, response, applicationFormEntities);
List<EvaluationDocumentRequest> allDocs = prepareEvaluationDocumentBeanList(entity);
setEvaluationDocResponse(response, allDocs);
setApplicationDetails(response, entity);
return response;
}
private void setEvaluationDocResponse(ApplicationEvaluationResponse response, List<EvaluationDocumentRequest> docRequest) {
List<EvaluationDocumentResponse> evaluationDocResponses = new ArrayList<>();
for (EvaluationDocumentRequest doc : docRequest) {
EvaluationDocumentResponse evaluationDocResponse = new EvaluationDocumentResponse();
if (doc.getFileValue() != null) {
Long fileId = Long.valueOf(doc.getFileValue().toString());
documentRepository.findByIdAndNotDeleted(fileId).ifPresent(documentEntity -> {
DocumentResponseBean documentResponseBean = new DocumentResponseBean();
documentResponseBean.setId(documentEntity.getId());
documentResponseBean.setName(documentEntity.getFileName());
documentResponseBean.setType(DocumentTypeEnum.valueOf(documentEntity.getType()));
documentResponseBean.setSource(DocumentSourceTypeEnum.valueOf(documentEntity.getSource()));
documentResponseBean.setSourceId(documentEntity.getSourceId());
documentResponseBean.setFilePath(documentEntity.getFilePath());
documentResponseBean.setCreatedDate(documentEntity.getCreatedDate());
documentResponseBean.setUpdatedDate(documentEntity.getUpdatedDate());
evaluationDocResponse.setFileValue(documentResponseBean);
evaluationDocResponse.setNameValue(doc.getNameValue());
evaluationDocResponse.setValid(doc.getValid());
evaluationDocResponse.setFieldId(doc.getFieldId());
});
}
if (evaluationDocResponse.getFileValue() == null) {
continue;
}
evaluationDocResponses.add(evaluationDocResponse);
}
response.setEvaluationDocument(evaluationDocResponses);
}
private void populateBasicDetails(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response) {
@@ -485,9 +522,9 @@ public class ApplicationEvaluationDao {
if (existingEntityOptional.isPresent()) {
entity = existingEntityOptional.get();
oldApplicationEvaluation = Utils.getClonedEntityForData(entity);
entity.setCriteria(Utils.convertObjectToJson(filterNonNullCriteria(processCriteria(entity, req))));
entity.setChecklist(Utils.convertObjectToJson(filterNonNullChecklist(processChecklist(entity, req))));
entity.setFile(Utils.convertObjectToJson(filterNonNullFields(processField(entity, req))));
entity.setCriteria(Utils.convertObjectToJson(processCriteria(entity, req)));
entity.setChecklist(Utils.convertObjectToJson(processChecklist(entity, req)));
entity.setFile(Utils.convertObjectToJson(processField(entity, req)));
entity.setIsDeleted(false);
setIfUpdated(entity::getNote, entity::setNote, req.getNote());
setIfUpdated(entity::getMotivation, entity::setMotivation, req.getMotivation());
@@ -512,22 +549,6 @@ public class ApplicationEvaluationDao {
}
}
private List<ChecklistRequest> filterNonNullChecklist(List<ChecklistRequest> checklistRequests) {
return checklistRequests.stream().filter(request -> request.getValid() != null).collect(Collectors.toList());
}
private List<CriteriaRequest> filterNonNullCriteria(List<CriteriaRequest> criteriaRequests) {
return criteriaRequests.stream().filter(request -> request.getScore() != null && request.getValid() != null).collect(Collectors.toList());
}
private List<FieldRequest> filterNonNullFields(List<FieldRequest> fieldRequests) {
return fieldRequests.stream().filter(request -> request.getValid() != null).collect(Collectors.toList());
}
private List<CriteriaRequest> processCriteria(ApplicationEvaluationEntity entity, ApplicationEvaluationRequest req) {
List<CriteriaRequest> incomingCriteriaList = Optional.ofNullable(req.getCriteria()).orElse(new ArrayList<>());
@@ -647,11 +668,52 @@ public class ApplicationEvaluationDao {
return entityOptional.get();
}
public void validatePreinstructor(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)
);
}
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
assignedApplicationsRepository.findByApplicationIdOrIdAndIsDeletedFalse(applicationId,assignedApplicationId);
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(UserEntity user, Long applicationId, Long 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)
));
if (applicationId == null) {
applicationId = assignedApplications.getApplication().getId();
}
validator.validatePreInstructor(request, assignedApplications.getUserId());
}
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(HttpServletRequest request, UserEntity user, Long applicationID, Long assignedApplicationID) {
Long applicationId;
Long assignedApplicationId;
validatePreinstructor(request, applicationID, assignedApplicationID);
if (applicationID == null && assignedApplicationID != null) {
assignedApplicationId = assignedApplicationID;
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationId);
applicationId = assignedApplicationsOptional.map(a -> a.getApplication().getId()).orElse(null);
} else {
applicationId = applicationID;
if (assignedApplicationID == null && applicationID != null) {
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
assignedApplicationId = assignedApplicationsOptional.map(AssignedApplicationsEntity::getId).orElse(null);
} else {
assignedApplicationId = assignedApplicationID;
}
}
applicationService.validateApplication(applicationId);
Optional<ApplicationEvaluationEntity> entityOptional;
if (applicationId != null && assignedApplicationId != null) {
@@ -668,6 +730,14 @@ public class ApplicationEvaluationDao {
return getEvaluationResponseByApplicationid(user, applicationId, assignedApplicationId);
});
}
private List<EvaluationDocumentRequest> prepareEvaluationDocumentBeanList(ApplicationEvaluationEntity entity) {
List<EvaluationDocumentRequest> docRequest = new ArrayList<>();
if (entity != null && entity.getEvaluationDocument() != null) {
docRequest = Utils.convertJsonToList(entity.getEvaluationDocument(), new TypeReference<List<EvaluationDocumentRequest>>() {});
}
return docRequest;
}
public ApplicationEvaluationResponse getEvaluationResponseByApplicationid(UserEntity user, Long applicationId, Long assignedApplicationId) {
@@ -1453,5 +1523,30 @@ public class ApplicationEvaluationDao {
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_EVALUATION_NOT_FOUND)));
}
public ApplicationEvaluationResponse updateApplicationEvaluation(
Long assignedApplicationId,
List<EvaluationDocumentRequest> docRequest) {
Optional<ApplicationEvaluationEntity> entityOptional=applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId);
ApplicationEvaluationEntity applicationEvaluationEntity =null;
if(entityOptional.isPresent()) {
applicationEvaluationEntity = entityOptional.get();
if (docRequest != null) {
// String existingEvaluationDocJson = applicationEvaluationEntity.getEvaluationDocument();
List<EvaluationDocumentRequest> existingDocs = new ArrayList<>();
for (EvaluationDocumentRequest doc : docRequest) {
if (doc.getFileValue() != null) {
Long fileId = Long.valueOf(doc.getFileValue());
documentService.validateDocument(fileId);
existingDocs.add(doc);
}
}
String updatedEvaluationDocJson = Utils.convertObjectToJson(existingDocs);
applicationEvaluationEntity.setEvaluationDocument(updatedEvaluationDocJson);
}
}
ApplicationEvaluationEntity savedEntity = applicationEvaluationRepository.save(applicationEvaluationEntity);
return convertToResponse(savedEntity);
}
}

View File

@@ -130,7 +130,7 @@ public class CallDao {
ZipOutputStream zos = new ZipOutputStream(zipOutputStream)) {
for (DocumentEntity document : documents) {
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.CALL, callId, 0L,0L);
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.CALL, callId, 0L,0L,0L);
try (InputStream fileInputStream = amazonS3Service.getFile(s3Folder, document.getFilePath())) {
String fileName = Utils.extractFileName(document.getFilePath());
ZipEntry zipEntry = new ZipEntry(fileName);

View File

@@ -92,7 +92,7 @@ public class DelegationDao {
public ByteArrayOutputStream generateDocument(Map<String, String> placeholders, String templateName) {
try {
String s3Folder = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.TEMPLATE, 0L, 0L,0L);
String s3Folder = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.TEMPLATE, 0L, 0L,0L,0L);
InputStream templateStream = amazonS3Service.getFile(s3Folder ,templateName);
XWPFDocument doc = loadTemplate(templateStream);
replacePlaceholders(doc, placeholders);

View File

@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.enums.*;
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
import net.gepafin.tendermanagement.util.LoggingUtil;
import net.gepafin.tendermanagement.util.Utils;
@@ -54,7 +55,7 @@ public class DocumentDao {
private S3PathConfig s3ConfigBean;
@Autowired
private ApplicationRepository applicationFormRepository;
private ApplicationRepository applicationRepository;
@Autowired
ApplicationService applicationService;
@@ -64,6 +65,8 @@ public class DocumentDao {
@Autowired
ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
@Autowired
private ApplicationEvaluationRepository applicationEvaluationRepository;
@Value("${aws.s3.bucket.name}")
private String bucketName;
@@ -77,7 +80,7 @@ public class DocumentDao {
// @Value("${aws.s3.url.folder}")
// private String s3Folder;
public List<DocumentResponseBean> uploadFiles(List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
public List<DocumentResponseBean> uploadFiles(Long userId,List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
List<DocumentEntity> documentEntities = new ArrayList<>();
Long source = resolveSourceId(sourceId, sourceType);
@@ -91,6 +94,7 @@ public class DocumentDao {
documentEntity.setType(fileType.getValue());
documentEntity.setFilePath(uploadFileOnAmazonS3Response.getFilePath());
documentEntity.setIsDeleted(false);
documentEntity.setUploadedBy(userId);
documentEntities.add(documentEntity);
}
}
@@ -137,18 +141,24 @@ public class DocumentDao {
Long applicationId = 0L;
Long amendmentId = 0L;
Long evaluationId = 0L;
Long callId = sourceId;
if (type == DocumentSourceTypeEnum.APPLICATION) {
applicationId = sourceId;
callId = applicationFormRepository.findCallIdById(applicationId);
callId = applicationRepository.findCallIdById(applicationId);
} else if (type == DocumentSourceTypeEnum.AMENDMENT) {
amendmentId = sourceId;
ApplicationEntity applicationEntity = applicationAmendmentRequestRepository.findApplicationByAmendmentId(amendmentId);
applicationId = applicationEntity.getId();
callId = applicationEntity.getCall().getId();
}else if (type == DocumentSourceTypeEnum.EVALUATION) {
evaluationId = sourceId;
ApplicationEntity applicationEntity = applicationEvaluationRepository.findApplicationByEvaluationId(evaluationId);
applicationId = applicationEntity.getId();
callId = applicationEntity.getCall().getId();
}
try {
String s3Path = generateS3Path(type, callId, applicationId, amendmentId);
String s3Path = generateS3Path(type, callId, applicationId, amendmentId, evaluationId);
log.info("Generated S3 path {}", s3Path);
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
} catch (Exception e) {
@@ -156,9 +166,9 @@ public class DocumentDao {
}
}
public String generateS3Path(DocumentSourceTypeEnum typeOfDocument, Long callId, Long applicationId, Long amendmentId) {
public String generateS3Path(DocumentSourceTypeEnum typeOfDocument, Long callId, Long applicationId, Long amendmentId,Long evaluationId) {
try {
return s3ConfigBean.generateDocumentPath(typeOfDocument, callId, applicationId, amendmentId);
return s3ConfigBean.generateDocumentPath(typeOfDocument, callId, applicationId, amendmentId,evaluationId);
} catch (IllegalArgumentException e) {
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
}
@@ -188,6 +198,7 @@ public class DocumentDao {
Long callId = null;
Long applicationId = null;
Long amendmentId = null;
Long evaluationId = null;
if (DocumentSourceTypeEnum.CALL.getValue().equalsIgnoreCase(documentEntity.getSource())) {
callId = documentEntity.getSourceId();
@@ -201,9 +212,14 @@ public class DocumentDao {
ApplicationEntity applicationEntity = applicationAmendmentRequestRepository.findApplicationByAmendmentId(amendmentId);
applicationId = applicationEntity.getId();
callId = applicationEntity.getCall().getId();
} else if(DocumentSourceTypeEnum.EVALUATION.getValue().equalsIgnoreCase(documentEntity.getSource())){
evaluationId = documentEntity.getSourceId();
ApplicationEntity applicationEntity = applicationEvaluationRepository.findApplicationByEvaluationId(evaluationId);
applicationId = applicationEntity.getId();
callId = applicationEntity.getCall().getId();
}
deleteFileFromS3(documentEntity, callId, applicationId,amendmentId);
deleteFileFromS3(documentEntity, callId, applicationId,amendmentId,evaluationId);
}
@@ -241,8 +257,9 @@ public class DocumentDao {
Long callId=null;
Long applicationId=null;
Long amendmentId=null;
Long evaluationId=null;
if (type.equals(DocumentSourceTypeEnum.APPLICATION)) {
callId = applicationFormRepository.findCallIdById(id);
callId = applicationRepository.findCallIdById(id);
applicationId = id;
}
else if(type.equals(DocumentSourceTypeEnum.AMENDMENT)){
@@ -250,12 +267,18 @@ public class DocumentDao {
ApplicationEntity applicationEntity = applicationAmendmentRequestRepository.findApplicationByAmendmentId(amendmentId);
applicationId = applicationEntity.getId();
callId = applicationEntity.getCall().getId();
}else if(type.equals(DocumentSourceTypeEnum.EVALUATION)){
evaluationId = id;
ApplicationEntity applicationEntity = applicationEvaluationRepository.findApplicationByEvaluationId(evaluationId);
applicationId = applicationEntity.getId();
callId = applicationEntity.getCall().getId();
}
else {
callId = id;
applicationId = 0L;
}
String s3Path = generateS3Path(type, callId, applicationId,amendmentId);
String s3Path = generateS3Path(type, callId, applicationId,amendmentId,evaluationId);
log.info("Generated S3 path {}", s3Path);
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
} catch (Exception e) {
@@ -267,12 +290,12 @@ public class DocumentDao {
return callDao.convertToDocumentResponseBean(documentEntity);
}
public void deleteFileFromS3(DocumentEntity documentEntity, Long callId, Long applicationId,Long amendmentId) {
public void deleteFileFromS3(DocumentEntity documentEntity, Long callId, Long applicationId,Long amendmentId,Long evaluationId) {
try {
DocumentEntity oldDocumentEntity = Utils.getClonedEntityForData(documentEntity);
String oldS3Path = documentEntity.getFilePath();
String newS3Path = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.valueOf("DELETED_" + documentEntity.getSource().toUpperCase()), callId, applicationId,amendmentId);
String newS3Path = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.valueOf("DELETED_" + documentEntity.getSource().toUpperCase()), callId, applicationId,amendmentId,evaluationId);
UploadFileOnAmazonS3Response response = amazonS3Service.moveFile(documentEntity.getFileName(), oldS3Path, newS3Path);
documentEntity.setFileName(response.getFileName());
documentEntity.setFilePath(response.getFilePath());

View File

@@ -13,12 +13,12 @@ public class S3PathConfig {
@Autowired
S3ConfigRepository s3ConfigRepository;
public String generateDocumentPath(DocumentSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId) {
public String generateDocumentPath(DocumentSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId,Long evaluationId) {
S3ConfigEntity config = getDocumentPath(type);
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId,amendmentId);
}
public String generateDocumentPathForOther(DocOtherSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId) {
public String generateDocumentPathForOther(DocOtherSourceTypeEnum type, Long callId, Long applicationId,Long amendmentId,Long evaluationId) {
S3ConfigEntity config = getDocumentPathForOther(type);
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId,amendmentId);

View File

@@ -22,6 +22,9 @@ public class ApplicationEvaluationEntity extends BaseEntity{
@Column(name = "checklist")
private String checklist;
@Column(name = "EVALUATION_DOCUMENT")
private String evaluationDocument;
@Column(name = "file")
private String file;
@@ -58,4 +61,5 @@ public class ApplicationEvaluationEntity extends BaseEntity{
@Column(name = "STOP_DATE_TIME")
private LocalDateTime stopDateTime;
}

View File

@@ -32,4 +32,7 @@ public class DocumentEntity extends BaseEntity{
@Column(name="DOCUMENT_ATTACHMENT_ID")
private String documentAttachmentId;
@Column(name="uploaded_by")
private Long uploadedBy;
}

View File

@@ -6,6 +6,7 @@ public enum DocOtherSourceTypeEnum {
TEMPLATE("TEMPLATE"),
DELETED_USER_DELEGATION("DELETED_USER_DELEGATION"),
DELETED_APPLICATION("DELETED_APPLICATION"),
DELETED_EVALUATION("DELETED_EVALUATION"),
DELETED_CALL("DELETED_CALL"),
DELETED_AMENDMENT("DELETED_AMENDMENT");

View File

@@ -4,7 +4,7 @@ public enum DocumentSourceTypeEnum {
CALL("CALL"),
APPLICATION("APPLICATION"),
EVALUATION("EVALUATION"),
AMENDMENT("AMENDMENT");
private String value;

View File

@@ -136,6 +136,7 @@ public enum UserActionContextEnum {
UPDATE_EVALUATION_CRITERIA("UPDATE_EVALUATION_CRITERIA"),
DELETE_EVALUATION_CRITERIA("DELETE_EVALUATION_CRITERIA"),
CREATE_EVALUATION_CRITERIA("CREATE_EVALUATION_CRITERIA"),
UPLOAD_EVALUATION_DOC("UPLOAD_EVALUATION_DOC"),
/** communication action context **/
ADD_COMMENT_TO_AMENDMENT_REQUEST("ADD_COMMENT_TO_AMENDMENT_REQUEST"),

View File

@@ -0,0 +1,15 @@
package net.gepafin.tendermanagement.model.request;
import lombok.Data;
@Data
public class EvaluationDocumentRequest {
private String fieldId;
private String nameValue;
private String fileValue;
private Boolean valid;
}

View File

@@ -21,6 +21,7 @@ public class ApplicationEvaluationResponse {
private List<CriteriaResponse> criteria;
private List<ChecklistResponse> checklist;
private List<FieldResponse> files;
private List<EvaluationDocumentResponse> evaluationDocument;
private LocalDateTime createdDate;
private LocalDateTime updatedDate;
private String beneficiary;

View File

@@ -0,0 +1,12 @@
package net.gepafin.tendermanagement.model.response;
import lombok.Data;
@Data
public class EvaluationDocumentResponse {
private String fieldId;
private String nameValue;
private Boolean valid;
private DocumentResponseBean fileValue ;
}

View File

@@ -44,7 +44,7 @@ public interface ApplicationAmendmentRequestRepository extends JpaRepository<App
"FROM ApplicationEntity app " +
"WHERE app.id = (SELECT aar.applicationId " +
"FROM ApplicationAmendmentRequestEntity aar " +
"WHERE aar.id = :amendmentId)")
"WHERE aar.id = :amendmentId AND aar.isDeleted = false)")
ApplicationEntity findApplicationByAmendmentId(Long amendmentId);
@Query(value = "SELECT amr " +

View File

@@ -1,5 +1,6 @@
package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.ApplicationEntity;
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
@@ -21,6 +22,12 @@ public interface ApplicationEvaluationRepository extends JpaRepository<Applicati
Optional<ApplicationEvaluationEntity> findFirstByIsDeletedFalseOrderByCreatedDateDesc();
boolean existsByApplicationIdAndIsDeletedFalse(Long applicationId);
@Query("SELECT app " +
"FROM ApplicationEntity app " +
"WHERE app.id = (SELECT aar.applicationId " +
"FROM ApplicationEvaluationEntity aar " +
"WHERE aar.id = :evaluationId AND aar.isDeleted = false)")
ApplicationEntity findApplicationByEvaluationId(Long evaluationId);
@Query("SELECT a FROM ApplicationEvaluationEntity a WHERE a.isDeleted = false AND a.endDate < :currentDate")
List<ApplicationEvaluationEntity> findAllByIsDeletedFalseAndEndDateBefore(@Param("currentDate") LocalDateTime currentDate);

View File

@@ -42,6 +42,6 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.status = 'DRAFT' And a.hubId = :hubId AND a.isDeleted = false")
public Long countDraftApplicationsByHubId(@Param("hubId") Long hubId);
@Query("SELECT a.call.id FROM ApplicationEntity a WHERE a.id = :id")
@Query("SELECT a.call.id FROM ApplicationEntity a WHERE a.id = :id AND a.isDeleted = false")
Long findCallIdById(@Param("id") Long id);
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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) {

View File

@@ -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);
}
}

View File

@@ -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) {

View File

@@ -105,7 +105,7 @@ public class Validator {
}
}
private Long getUserId(Map<String, Object> userInfo) {
public Long getUserId(Map<String, Object> userInfo) {
return Long.parseLong(userInfo.get("userId").toString());
}

View File

@@ -7,8 +7,8 @@ import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
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.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
@@ -16,6 +16,8 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
public interface ApplicationEvaluationApi {
@Operation(summary = "API to create or update ApplicationEvaluation",
@@ -53,5 +55,21 @@ public interface ApplicationEvaluationApi {
ResponseEntity<Response<Void>> deleteApplicationEvaluation(HttpServletRequest request,
@Parameter( required = true) @PathVariable("id") Long id);
@Operation(summary = "Api to upload Documents for evaluation",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
})
@PutMapping(value = "/assignedApplicationId/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<ApplicationEvaluationResponse>> updateApplicationEvaluation(HttpServletRequest request,
@Parameter(description = "The AssignedApplication id", required = true) @PathVariable("id") Long id,
@Parameter(description = "Application Evaluation request object", required = true) @Valid @RequestBody List<EvaluationDocumentRequest> applicationEvaluationDocRequest);
}

View File

@@ -3,12 +3,13 @@ package net.gepafin.tendermanagement.web.rest.api.impl;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.enums.ApplicationStatusForEvaluation;
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
import net.gepafin.tendermanagement.model.request.EvaluationDocumentRequest;
import net.gepafin.tendermanagement.model.request.UserActionRequest;
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
import net.gepafin.tendermanagement.model.response.EvaluationDocumentResponse;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
import net.gepafin.tendermanagement.util.LoggingUtil;
@@ -20,6 +21,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/applicationEvaluation}")
public class ApplicationEvaluationApiController implements ApplicationEvaluationApi {
@@ -79,5 +82,15 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_DELETED_SUCCESSFULLY)));
}
@Override
public ResponseEntity<Response<ApplicationEvaluationResponse>> updateApplicationEvaluation(HttpServletRequest request, Long id, List<EvaluationDocumentRequest> applicationEvaluationDocRequest) {
/** This code is responsible for "Upload Evaluation Document" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE)
.actionContext(UserActionContextEnum.UPLOAD_EVALUATION_DOC).build());
ApplicationEvaluationResponse updateApplicationEvaluationResponse = applicationEvaluationService.updateApplicationEvaluation(request, id, applicationEvaluationDocRequest);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(updateApplicationEvaluationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_UPDATE_SUCCESSFULLY_MSG)));
}
}

View File

@@ -47,7 +47,7 @@ DocumentApiController implements DocumentApi {
/** This code is responsible for creating user action logs for the "upload document for call or application" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(httpServletRequest).actionType(UserActionLogsEnum.UPLOAD).actionContext(userActionContext).build());
List<DocumentResponseBean> responseBeans = documentService.uploadFile(files, sourceId, sourceType, fileType);
List<DocumentResponseBean> responseBeans = documentService.uploadFile(httpServletRequest,files, sourceId, sourceType, fileType);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<List<DocumentResponseBean>>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILES_UPLOADED_MSG)));
} catch (CustomValidationException ex) {

View File

@@ -1991,6 +1991,36 @@
<column name="document_attachment_id" type="TEXT"/>
</addColumn>
</changeSet>
<changeSet id="12-12-2024_2" author="Rajesh Khore">
<insert tableName="s3_path_configuration">
<column name="type" value="EVALUATION"/>
<column name="path" value="call/{call_id}/application/{application_id}/evaluation"/>
<column name="bucket_name" value="mementoresources"/>
<column name="created_date" value="2024-12-10 03:00:00"/>
<column name="updated_date" value="2024-12-10 03:00:00"/>
<column name="parent_folder" value="gepafin/local"/>
</insert>
<insert tableName="s3_path_configuration">
<column name="type" value="DELETED_EVALUATION"/>
<column name="path" value="call/{call_id}/application/{application_id}/evaluation/deleted"/>
<column name="bucket_name" value="mementoresources"/>
<column name="created_date" value="2024-12-10 03:00:00"/>
<column name="updated_date" value="2024-12-10 03:00:00"/>
<column name="parent_folder" value="gepafin/local"/>
</insert>
<addColumn tableName="application_evaluation">
<column name="EVALUATION_DOCUMENT" type="TEXT"/>
</addColumn>
<addColumn tableName="document">
<column name="uploaded_by" type="INTEGER">
<!-- <constraints nullable="false"/>-->
</column>
</addColumn>
</changeSet>
<changeSet id="12_12_2024_1" author="Nisha Kashyap">
<addColumn tableName="protocol">
<column name="type" type="VARCHAR(255)"></column>