Resolve Conflict
This commit is contained in:
@@ -233,6 +233,15 @@ public class GepafinConstant {
|
|||||||
public static final String CANNOT_DELETE_COMPANY_WITH_APPLICATION_SUBMITT = "application.in.submit.status.cannot.delete.company";
|
public static final String CANNOT_DELETE_COMPANY_WITH_APPLICATION_SUBMITT = "application.in.submit.status.cannot.delete.company";
|
||||||
public static final String GET_USERS_SUCCESS_MSG = "get.users.success.msg";
|
public static final String GET_USERS_SUCCESS_MSG = "get.users.success.msg";
|
||||||
public static final String CANNOT_CREATE_BENEFICIARY_USER="cannot.create.beneficiary.user";
|
public static final String CANNOT_CREATE_BENEFICIARY_USER="cannot.create.beneficiary.user";
|
||||||
|
public static final String EVALUATION_CREATED_SUCCESSFULLY = "evaluation.created.successfully";
|
||||||
|
public static final String EVALUATION_UPDATED_SUCCESSFULLY = "evaluation.updated.successfully";
|
||||||
|
public static final String EVALUATION_FETCHED_SUCCESSFULLY = "evaluation.fetched.successfully";
|
||||||
|
public static final String EVALUATION_DELETED_SUCCESSFULLY = "evaluation.deleted.successfully";
|
||||||
|
public static final String EVALUATIONS_FETCHED_SUCCESSFULLY = "evaluations.fetched.successfully";
|
||||||
|
public static final String APPLICATION_EVALUATION_NOT_FOUND = "application.evaluation.not.found";
|
||||||
|
public static final String APPLICATION_EVALUATION_STATUS_UPDATED_SUCCESSFULLY = "application.evaluation.status.updated.successfully";
|
||||||
|
public static final String ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG = "assigned.application.not.found.with.id";
|
||||||
|
|
||||||
|
|
||||||
public static final String APPLICATION_ASSIGNED= "application.assigned.success.msg";
|
public static final String APPLICATION_ASSIGNED= "application.assigned.success.msg";
|
||||||
public static final String APPLICATION_ALREADY_ASSIGNED = "application.already.assigned.msg";
|
public static final String APPLICATION_ALREADY_ASSIGNED = "application.already.assigned.msg";
|
||||||
@@ -250,6 +259,15 @@ public class GepafinConstant {
|
|||||||
public static final String EVALUATIONCRITERIA_INVALID = "evaluationCriteria.invalid";
|
public static final String EVALUATIONCRITERIA_INVALID = "evaluationCriteria.invalid";
|
||||||
public static final String APPLICATION_NOT_IN_DRAFT_STATUS="application.not.in.draft.status";
|
public static final String APPLICATION_NOT_IN_DRAFT_STATUS="application.not.in.draft.status";
|
||||||
public static final String GET_ERROR_S3 = "get.error.s3";
|
public static final String GET_ERROR_S3 = "get.error.s3";
|
||||||
|
|
||||||
|
public static final String ADDED_S3_PATH_STRUCTURE ="added.s3.path.structure";
|
||||||
|
public static final String S3_PATH_STRUCTURE_BY_TYPE ="fetched.s3.path.structure.by.type.successfully";
|
||||||
|
public static final String S3_PATH_STRUCTURE_NOT_FOUND_BY_TYPE_MSG ="s3.path.not.found.by.type";
|
||||||
|
public static final String S3_PATH_STRUCTURE_NOT_FOUND_BY_ID_MSG ="s3.path.not.found.by.id";
|
||||||
|
public static final String S3_PATH_DELETE_MSG ="s3.path.config.delete.successfully";
|
||||||
|
public static final String S3_PATH_CONFIG_UPDATE_MSG ="s3.path.config.updated.successfully";
|
||||||
|
public static final String S3_PATH_CONFIG_DUPLICATE_TYPE_ALREADY_EXIST ="s3.path.config.already.exist.";
|
||||||
|
public static final String S3_PATH_GENERATION_ERROR_MSG ="s3.path.config.already.exist.";
|
||||||
public static final String INVALID_APPLICATION_STATUS = "invalid.application.status";
|
public static final String INVALID_APPLICATION_STATUS = "invalid.application.status";
|
||||||
|
|
||||||
public static final String APPLICATION_DATA_FOR_AMENDMENT_SUCCESS_MSG = "application.data.amendment.success";
|
public static final String APPLICATION_DATA_FOR_AMENDMENT_SUCCESS_MSG = "application.data.amendment.success";
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import net.gepafin.tendermanagement.entities.*;
|
|||||||
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
|
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationSignedDocumentStatusEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationSignedDocumentStatusEnum;
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||||
import net.gepafin.tendermanagement.enums.UserCompanyDelegationStatusEnum;
|
import net.gepafin.tendermanagement.enums.UserCompanyDelegationStatusEnum;
|
||||||
@@ -127,6 +128,9 @@ public class ApplicationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
S3PathConfig s3ConfigBean;
|
||||||
|
|
||||||
|
|
||||||
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
||||||
FormEntity formEntity = formService.validateForm(formId);
|
FormEntity formEntity = formService.validateForm(formId);
|
||||||
@@ -175,6 +179,7 @@ public class ApplicationDao {
|
|||||||
entity.setUserId(user.getId());
|
entity.setUserId(user.getId());
|
||||||
entity.setCompany(companyEntity);
|
entity.setCompany(companyEntity);
|
||||||
entity.setCall(call);
|
entity.setCall(call);
|
||||||
|
entity.setHubId(call.getHub().getId());
|
||||||
entity.setIsDeleted(false);
|
entity.setIsDeleted(false);
|
||||||
entity.setStatus(ApplicationStatusTypeEnum.DRAFT.getValue());
|
entity.setStatus(ApplicationStatusTypeEnum.DRAFT.getValue());
|
||||||
return entity;
|
return entity;
|
||||||
@@ -287,7 +292,7 @@ public class ApplicationDao {
|
|||||||
|
|
||||||
log.info("Fetching applications for RoleType: {}", userEntity.getRoleEntity().getRoleType());
|
log.info("Fetching applications for RoleType: {}", userEntity.getRoleEntity().getRoleType());
|
||||||
|
|
||||||
Specification<ApplicationEntity> spec = search(userEntity.getId(), callId, companyId,status);
|
Specification<ApplicationEntity> spec = search(userEntity, callId, companyId,status);
|
||||||
|
|
||||||
List<ApplicationEntity> applicationEntities = applicationRepository.findAll(spec);
|
List<ApplicationEntity> applicationEntities = applicationRepository.findAll(spec);
|
||||||
|
|
||||||
@@ -297,12 +302,12 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Specification<ApplicationEntity> search(Long userId, Long callId, Long companyId,String status) {
|
private Specification<ApplicationEntity> search(UserEntity userEntity, Long callId, Long companyId,String status) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
Boolean isBeneficiary = validator.checkIsBeneficiary();
|
Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||||
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
||||||
if (isBeneficiary) {
|
if (isBeneficiary) {
|
||||||
predicate = builder.and(predicate, builder.equal(root.get("userId"), userId));
|
predicate = builder.and(predicate, builder.equal(root.get("userId"), userEntity.getId()));
|
||||||
}
|
}
|
||||||
if (callId != null) {
|
if (callId != null) {
|
||||||
predicate = builder.and(predicate, builder.equal(root.get("call").get("id"), callId));
|
predicate = builder.and(predicate, builder.equal(root.get("call").get("id"), callId));
|
||||||
@@ -313,7 +318,7 @@ public class ApplicationDao {
|
|||||||
if (status != null) {
|
if (status != null) {
|
||||||
predicate = builder.and(predicate, builder.equal(root.get("status"), status));
|
predicate = builder.and(predicate, builder.equal(root.get("status"), status));
|
||||||
}
|
}
|
||||||
|
predicate = builder.and(predicate, builder.equal(root.get("hubId"), userEntity.getHub().getId()));
|
||||||
return predicate;
|
return predicate;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -600,7 +605,7 @@ public class ApplicationDao {
|
|||||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_IN_PREVIOUS_STATUS));
|
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_IN_PREVIOUS_STATUS));
|
||||||
}
|
}
|
||||||
if (status.equals(ApplicationStatusTypeEnum.SUBMIT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.READY.getValue()))) {
|
if (status.equals(ApplicationStatusTypeEnum.SUBMIT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.READY.getValue()))) {
|
||||||
callService.validatePublishedCall(applicationEntity.getCall().getId());
|
callService.validatePublishedCall(applicationEntity.getCall().getId(), userEntity.getHub().getId());
|
||||||
Long protocolNumber = getProtocolNumber(userEntity.getHub());
|
Long protocolNumber = getProtocolNumber(userEntity.getHub());
|
||||||
ProtocolEntity protocolEntity = createProtocolEntity(applicationEntity,protocolNumber, userEntity.getHub().getId());
|
ProtocolEntity protocolEntity = createProtocolEntity(applicationEntity,protocolNumber, userEntity.getHub().getId());
|
||||||
applicationEntity.setProtocol(protocolEntity);
|
applicationEntity.setProtocol(protocolEntity);
|
||||||
@@ -788,8 +793,8 @@ public class ApplicationDao {
|
|||||||
// applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue());
|
// applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue());
|
||||||
// applicationSignedDocumentRepository.save(applicationSignedDocument);
|
// applicationSignedDocumentRepository.save(applicationSignedDocument);
|
||||||
}
|
}
|
||||||
UploadFileOnAmazonS3Response uploadFileOnAmazonS3 = amazonS3Service.uploadFileOnAmazonS3(signedDocumentS3Folder,
|
UploadFileOnAmazonS3Response uploadFileOnAmazonS3 = uploadFileOnAmazonS3ForUserSignedDocument(file,
|
||||||
file);
|
applicationEntity.getCall().getId(), applicationId);
|
||||||
applicationSignedDocument = new ApplicationSignedDocumentEntity();
|
applicationSignedDocument = new ApplicationSignedDocumentEntity();
|
||||||
applicationSignedDocument.setApplication(applicationEntity);
|
applicationSignedDocument.setApplication(applicationEntity);
|
||||||
applicationSignedDocument.setFileName(uploadFileOnAmazonS3.getFileName());
|
applicationSignedDocument.setFileName(uploadFileOnAmazonS3.getFileName());
|
||||||
@@ -800,7 +805,22 @@ public class ApplicationDao {
|
|||||||
applicationRepository.save(applicationEntity);
|
applicationRepository.save(applicationEntity);
|
||||||
return convertApplicationSignedDocumentToApplicationSignedDocumentResponse(applicationSignedDocument);
|
return convertApplicationSignedDocumentToApplicationSignedDocumentResponse(applicationSignedDocument);
|
||||||
}
|
}
|
||||||
|
private UploadFileOnAmazonS3Response uploadFileOnAmazonS3ForUserSignedDocument(MultipartFile file, Long callId, Long applicationId) {
|
||||||
|
try {
|
||||||
|
String s3Path = generateS3PathForDelegation(callId, applicationId);
|
||||||
|
log.info("S3 Path {}", s3Path);
|
||||||
|
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private String generateS3PathForDelegation(Long callId, Long applicationId) {
|
||||||
|
try {
|
||||||
|
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT, callId, applicationId);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
|
||||||
|
}
|
||||||
|
}
|
||||||
private ApplicationSignedDocumentResponse convertApplicationSignedDocumentToApplicationSignedDocumentResponse(
|
private ApplicationSignedDocumentResponse convertApplicationSignedDocumentToApplicationSignedDocumentResponse(
|
||||||
ApplicationSignedDocumentEntity applicationSignedDocument) {
|
ApplicationSignedDocumentEntity applicationSignedDocument) {
|
||||||
ApplicationSignedDocumentResponse applicationSignedDocumentResponse = new ApplicationSignedDocumentResponse();
|
ApplicationSignedDocumentResponse applicationSignedDocumentResponse = new ApplicationSignedDocumentResponse();
|
||||||
@@ -869,7 +889,7 @@ public class ApplicationDao {
|
|||||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
|
||||||
}
|
}
|
||||||
|
|
||||||
applicationEntity.setStatus(ApplicationStatusTypeEnum.AWAIT.getValue());
|
applicationEntity.setStatus(ApplicationStatusTypeEnum.AWAITING.getValue());
|
||||||
applicationEntity = saveApplicationEntity(applicationEntity);
|
applicationEntity = saveApplicationEntity(applicationEntity);
|
||||||
return getApplicationResponse(applicationEntity);
|
return getApplicationResponse(applicationEntity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,852 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ChecklistRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.request.CriteriaRequest;
|
||||||
|
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.UserService;
|
||||||
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
|
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.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ApplicationEvaluationDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||||
|
@Autowired
|
||||||
|
private ApplicationService applicationService;
|
||||||
|
@Autowired
|
||||||
|
private CallRepository callRepository;
|
||||||
|
@Autowired
|
||||||
|
private ApplicationRepository applicationRepository;
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
@Autowired
|
||||||
|
private EvaluationCriteriaRepository evaluationCriteriaRepository;
|
||||||
|
@Autowired
|
||||||
|
private FormRepository formRepository;
|
||||||
|
@Autowired
|
||||||
|
private CallTargetAudienceChecklistRepository callTargetAudienceChecklistRepository;
|
||||||
|
@Autowired
|
||||||
|
private DocumentRepository documentRepository;
|
||||||
|
@Autowired
|
||||||
|
private ApplicationFormRepository applicationFormRepository;
|
||||||
|
@Autowired
|
||||||
|
private ApplicationFormFieldRepository applicationFormFieldRepository;
|
||||||
|
@Autowired
|
||||||
|
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||||
|
@Autowired
|
||||||
|
private CriteriaFormFieldRepository criteriaFormFieldRepository;
|
||||||
|
|
||||||
|
|
||||||
|
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req,Long applicationId) {
|
||||||
|
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
||||||
|
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
||||||
|
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId).orElse(null);
|
||||||
|
entity.setApplicationId(application.getId());
|
||||||
|
entity.setAssignedApplicationsEntity(assignedApplications);
|
||||||
|
entity.setUserId(user.getId());
|
||||||
|
entity.setCriteria(Utils.convertObjectToJson(req.getCriteria()));
|
||||||
|
entity.setChecklist(Utils.convertObjectToJson(req.getChecklist()));
|
||||||
|
entity.setFile(Utils.convertObjectToJson(req.getField()));
|
||||||
|
entity.setNote(req.getNote());
|
||||||
|
entity.setIsDeleted(false);
|
||||||
|
entity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicationEvaluationResponse convertToResponse(ApplicationEvaluationEntity entity) {
|
||||||
|
ApplicationEvaluationResponse response = new ApplicationEvaluationResponse();
|
||||||
|
populateBasicDetails(entity, response);
|
||||||
|
|
||||||
|
CallEntity call = callRepository.findCallEntityByApplicationId(entity.getApplicationId());
|
||||||
|
List<EvaluationCriteriaEntity> evaluationCriterias = evaluationCriteriaRepository.findByCallId(call.getId());
|
||||||
|
List<CallTargetAudienceChecklistEntity> checklistEntities = callTargetAudienceChecklistRepository.findByCallId(call.getId());
|
||||||
|
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(entity.getApplicationId());
|
||||||
|
|
||||||
|
setCriteriaResponses(entity, response, evaluationCriterias);
|
||||||
|
setChecklistResponses(entity, response, checklistEntities);
|
||||||
|
setFieldResponses(entity, response, applicationFormEntities);
|
||||||
|
|
||||||
|
setApplicationDetails(response, entity);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateBasicDetails(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response) {
|
||||||
|
response.setId(entity.getId());
|
||||||
|
response.setApplicationId(entity.getApplicationId());
|
||||||
|
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(entity.getApplicationId()).orElse(null);
|
||||||
|
response.setAssignedApplicationId(assignedApplications.getId());
|
||||||
|
response.setNote(entity.getNote());
|
||||||
|
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(entity.getStatus()));
|
||||||
|
response.setCreatedDate(entity.getCreatedDate());
|
||||||
|
response.setUpdatedDate(entity.getUpdatedDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCriteriaResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List<EvaluationCriteriaEntity> evaluationCriterias) {
|
||||||
|
List<CriteriaResponse> criteriaResponsesFromEntity = entity.getCriteria() != null
|
||||||
|
? Utils.convertJsonToList(entity.getCriteria(), new TypeReference<List<CriteriaResponse>>() {})
|
||||||
|
: new ArrayList<>();
|
||||||
|
|
||||||
|
List<CriteriaResponse> criteriaResponsesFromDB = getCriteriaResponse(entity.getApplicationId());
|
||||||
|
addMissingCriteriaResponses(criteriaResponsesFromEntity, criteriaResponsesFromDB,entity.getApplicationId());
|
||||||
|
criteriaResponsesFromEntity.forEach(criteriaResponse -> {
|
||||||
|
EvaluationCriteriaEntity matchingEvaluationCriteria = evaluationCriterias.stream()
|
||||||
|
.filter(evaluationCriteria -> evaluationCriteria.getId().equals(criteriaResponse.getId()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (matchingEvaluationCriteria != null) {
|
||||||
|
criteriaResponse.setLabel(matchingEvaluationCriteria.getLookupData().getValue());
|
||||||
|
criteriaResponse.setMaxScore(matchingEvaluationCriteria.getScore());
|
||||||
|
|
||||||
|
List<CriteriaMappedField> mappedFields = getMappedFieldsForCriteria(matchingEvaluationCriteria.getId(), entity.getApplicationId());
|
||||||
|
criteriaResponse.setCriteriaMappedFields(mappedFields);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
response.setCriteria(criteriaResponsesFromEntity);
|
||||||
|
}
|
||||||
|
private void addMissingCriteriaResponses(List<CriteriaResponse> criteriaResponsesFromEntity, List<CriteriaResponse> criteriaResponsesFromDB,Long applicationId) {
|
||||||
|
Set<Long> existingCriteriaIds = criteriaResponsesFromEntity.stream()
|
||||||
|
.map(CriteriaResponse::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
for (CriteriaResponse dbResponse : criteriaResponsesFromDB) {
|
||||||
|
if (!existingCriteriaIds.contains(dbResponse.getId())) {
|
||||||
|
List<CriteriaMappedField> mappedFields = getMappedFieldsForCriteria(dbResponse.getId(), applicationId);
|
||||||
|
dbResponse.setCriteriaMappedFields(mappedFields);
|
||||||
|
criteriaResponsesFromEntity.add(dbResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private List<CriteriaMappedField> getMappedFieldsForCriteria(Long evaluationCriteriaId, Long applicationId) {
|
||||||
|
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository
|
||||||
|
.findByEvaluationCriteriaIdAndIsDeletedFalse(evaluationCriteriaId);
|
||||||
|
List<CriteriaMappedField> mappedFields = new ArrayList<>();
|
||||||
|
|
||||||
|
Set<String> uniqueFieldIds = new HashSet<>();
|
||||||
|
|
||||||
|
List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(applicationId);
|
||||||
|
for (ApplicationFormEntity applicationForm : applicationForms) {
|
||||||
|
for (CriteriaFormFieldEntity formField : criteriaFormFields) {
|
||||||
|
String formFieldId = formField.getFormFieldId();
|
||||||
|
|
||||||
|
if (!uniqueFieldIds.contains(formFieldId)) {
|
||||||
|
CriteriaMappedField mappedField = new CriteriaMappedField();
|
||||||
|
mappedField.setId(formFieldId);
|
||||||
|
|
||||||
|
FormEntity formEntity = formRepository.findById(formField.getFormId()).orElse(null);
|
||||||
|
if (formEntity != null) {
|
||||||
|
List<ContentResponseBean> contentBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||||
|
contentBeans.stream()
|
||||||
|
.filter(contentBean -> contentBean.getId().equals(formFieldId))
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(contentBean -> {
|
||||||
|
String label = contentBean.getLabel();
|
||||||
|
if (contentBean.getSettings() != null) {
|
||||||
|
for (SettingResponseBean setting : contentBean.getSettings()) {
|
||||||
|
if ("label".equals(setting.getName())) {
|
||||||
|
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mappedField.setFieldLabel(label);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
||||||
|
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(formFieldId, applicationForm.getId(), applicationId);
|
||||||
|
|
||||||
|
formFieldEntityOptional.ifPresent(field -> mappedField.setFieldValue(field.getFieldValue()));
|
||||||
|
|
||||||
|
mappedFields.add(mappedField);
|
||||||
|
uniqueFieldIds.add(formFieldId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mappedFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setChecklistResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List<CallTargetAudienceChecklistEntity> checklistEntities) {
|
||||||
|
List<ChecklistResponse> checklistResponsesFromEntity = entity.getChecklist() != null
|
||||||
|
? Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {})
|
||||||
|
: new ArrayList<>();
|
||||||
|
|
||||||
|
List<ChecklistResponse> checklistResponsesFromDB = getChecklistResponse(entity.getApplicationId());
|
||||||
|
addMissingChecklistResponses(checklistResponsesFromEntity, checklistResponsesFromDB);
|
||||||
|
|
||||||
|
checklistResponsesFromEntity.forEach(checklistResponse -> {
|
||||||
|
CallTargetAudienceChecklistEntity matchingChecklist = checklistEntities.stream()
|
||||||
|
.filter(checklistEntity -> checklistEntity.getId().equals(checklistResponse.getId()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (matchingChecklist != null) {
|
||||||
|
checklistResponse.setLabel(matchingChecklist.getLookupData().getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
response.setChecklist(checklistResponsesFromEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMissingChecklistResponses(List<ChecklistResponse> checklistResponsesFromEntity, List<ChecklistResponse> checklistResponsesFromDB) {
|
||||||
|
Set<Long> existingChecklistIds = checklistResponsesFromEntity.stream()
|
||||||
|
.map(ChecklistResponse::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
for (ChecklistResponse dbResponse : checklistResponsesFromDB) {
|
||||||
|
if (!existingChecklistIds.contains(dbResponse.getId())) {
|
||||||
|
checklistResponsesFromEntity.add(dbResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFieldResponses(ApplicationEvaluationEntity entity, ApplicationEvaluationResponse response, List<ApplicationFormEntity> applicationFormEntities) {
|
||||||
|
List<FieldResponse> fieldResponsesFromEntity = entity.getFile() != null
|
||||||
|
? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {})
|
||||||
|
: new ArrayList<>();
|
||||||
|
List<FieldResponse> fieldResponsesFromDB = getFieldResponses(entity.getApplicationId());
|
||||||
|
addMissingFieldResponses(fieldResponsesFromEntity, fieldResponsesFromDB);
|
||||||
|
|
||||||
|
Set<String> processedFieldIds = new HashSet<>();
|
||||||
|
|
||||||
|
fieldResponsesFromEntity.forEach(fieldResponse -> {
|
||||||
|
if (processedFieldIds.contains(fieldResponse.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
applicationFormEntities.forEach(applicationForm -> {
|
||||||
|
FormEntity formEntity = applicationForm.getForm();
|
||||||
|
if (formEntity != null) {
|
||||||
|
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||||
|
contentResponseBeans.forEach(contentResponseBean -> {
|
||||||
|
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) {
|
||||||
|
String label = null;
|
||||||
|
if (contentResponseBean.getSettings() != null) {
|
||||||
|
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||||
|
if ("label".equals(setting.getName())) {
|
||||||
|
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldResponse.setLabel(label);
|
||||||
|
|
||||||
|
Optional<ApplicationFormFieldEntity> optionalFormField = applicationFormFieldRepository
|
||||||
|
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||||
|
fieldResponse.getId(), applicationForm.getId(), entity.getApplicationId()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (optionalFormField.isPresent()) {
|
||||||
|
ApplicationFormFieldEntity formField = optionalFormField.get();
|
||||||
|
if (formField.getFieldValue() != null) {
|
||||||
|
String[] documentIds = formField.getFieldValue().split(",");
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldResponse.setFileDetail(documentResponseBeans);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
processedFieldIds.add(fieldResponse.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
response.setFiles(fieldResponsesFromEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMissingFieldResponses(List<FieldResponse> fieldResponsesFromEntity, List<FieldResponse> fieldResponsesFromDB) {
|
||||||
|
Set<String> existingFieldIds = fieldResponsesFromEntity.stream()
|
||||||
|
.map(FieldResponse::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
for (FieldResponse dbResponse : fieldResponsesFromDB) {
|
||||||
|
if (!existingFieldIds.contains(dbResponse.getId())) {
|
||||||
|
fieldResponsesFromEntity.add(dbResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setApplicationDetails(ApplicationEvaluationResponse response, ApplicationEvaluationEntity entity) {
|
||||||
|
ApplicationEntity application = applicationService.validateApplication(entity.getApplicationId() != null ? entity.getApplicationId(): null);
|
||||||
|
UserEntity user = userService.validateUser(application.getUserId());
|
||||||
|
|
||||||
|
CallEntity call = callRepository.findCallEntityByApplicationId(entity.getApplicationId());
|
||||||
|
|
||||||
|
String firstName = user.getFirstName() != null ? user.getFirstName() : "";
|
||||||
|
String lastName = user.getLastName() != null ? user.getLastName() : "";
|
||||||
|
|
||||||
|
String beneficiary = String.join(" ", firstName, lastName).trim();
|
||||||
|
response.setBeneficiary(beneficiary);
|
||||||
|
response.setMinScore(call.getThreshold());
|
||||||
|
response.setCallName(application.getCall().getName());
|
||||||
|
response.setProtocolNumber(application.getProtocol() != null ? application.getProtocol().getProtocolNumber() : null);
|
||||||
|
response.setSubmissionDate(application.getSubmissionDate()!= null ? application.getSubmissionDate(): null);
|
||||||
|
response.setEvaluationDate(application.getSubmissionDate()!= null ? application.getSubmissionDate().plusDays(30):null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(UserEntity user, ApplicationEvaluationRequest req,Long applicationId) {
|
||||||
|
Optional<ApplicationEvaluationEntity> existingEntityOptional = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
|
||||||
|
ApplicationEvaluationEntity entity;
|
||||||
|
|
||||||
|
if (existingEntityOptional.isPresent()) {
|
||||||
|
entity = existingEntityOptional.get();
|
||||||
|
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());
|
||||||
|
} else {
|
||||||
|
entity = convertToEntity(user, req,applicationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplicationEvaluationEntity savedEntity = applicationEvaluationRepository.save(entity);
|
||||||
|
return convertToResponse(savedEntity);
|
||||||
|
}
|
||||||
|
private List<CriteriaRequest> processCriteria(ApplicationEvaluationEntity entity, ApplicationEvaluationRequest req) {
|
||||||
|
List<CriteriaResponse> existingCriteriaList = entity.getCriteria() != null ?
|
||||||
|
Utils.convertJsonToList(entity.getCriteria(), new TypeReference<List<CriteriaResponse>>() {}) : new ArrayList<>();
|
||||||
|
|
||||||
|
Map<Long, CriteriaResponse> existingCriteriaMap = existingCriteriaList.stream()
|
||||||
|
.collect(Collectors.toMap(CriteriaResponse::getId, criteria -> criteria));
|
||||||
|
|
||||||
|
List<CriteriaRequest> updatedCriteriaList = req.getCriteria().stream()
|
||||||
|
.map(incoming -> {
|
||||||
|
CriteriaRequest request = new CriteriaRequest();
|
||||||
|
request.setId(incoming.getId());
|
||||||
|
request.setScore(incoming.getScore());
|
||||||
|
request.setValid(incoming.getValid());
|
||||||
|
|
||||||
|
CriteriaResponse existingCriteria = existingCriteriaMap.get(incoming.getId());
|
||||||
|
if (existingCriteria != null) {
|
||||||
|
request.setScore(incoming.getScore() != null ? incoming.getScore() : existingCriteria.getScore());
|
||||||
|
request.setValid(incoming.getValid() != null ? incoming.getValid() : existingCriteria.getValid());
|
||||||
|
}
|
||||||
|
return request;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
List<CriteriaRequest> missingCriteriaRequests = existingCriteriaList.stream()
|
||||||
|
.filter(existing -> !updatedCriteriaList.stream()
|
||||||
|
.map(CriteriaRequest::getId)
|
||||||
|
.toList()
|
||||||
|
.contains(existing.getId()))
|
||||||
|
.map(existing -> {
|
||||||
|
CriteriaRequest request = new CriteriaRequest();
|
||||||
|
request.setId(existing.getId());
|
||||||
|
request.setScore(existing.getScore());
|
||||||
|
request.setValid(existing.getValid());
|
||||||
|
return request;
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
updatedCriteriaList.addAll(missingCriteriaRequests);
|
||||||
|
return updatedCriteriaList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ChecklistRequest> processChecklist(ApplicationEvaluationEntity entity, ApplicationEvaluationRequest req) {
|
||||||
|
List<ChecklistResponse> existingChecklistList = entity.getChecklist() != null ?
|
||||||
|
Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {}) : new ArrayList<>();
|
||||||
|
|
||||||
|
Map<Long, ChecklistResponse> existingChecklistMap = existingChecklistList.stream()
|
||||||
|
.collect(Collectors.toMap(ChecklistResponse::getId, checklist -> checklist));
|
||||||
|
|
||||||
|
List<ChecklistRequest> updatedChecklistList = req.getChecklist().stream()
|
||||||
|
.map(incoming -> {
|
||||||
|
ChecklistRequest request = new ChecklistRequest();
|
||||||
|
request.setId(incoming.getId());
|
||||||
|
request.setValid(incoming.getValid());
|
||||||
|
|
||||||
|
ChecklistResponse existingChecklist = existingChecklistMap.get(incoming.getId());
|
||||||
|
if (existingChecklist != null) {
|
||||||
|
request.setValid(incoming.getValid() != null ? incoming.getValid() : existingChecklist.getValid());
|
||||||
|
}
|
||||||
|
return request;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
List<ChecklistRequest> missingChecklistRequests = existingChecklistList.stream()
|
||||||
|
.filter(existing -> !updatedChecklistList.stream()
|
||||||
|
.map(ChecklistRequest::getId)
|
||||||
|
.toList()
|
||||||
|
.contains(existing.getId()))
|
||||||
|
.map(existing -> {
|
||||||
|
ChecklistRequest request = new ChecklistRequest();
|
||||||
|
request.setId(existing.getId());
|
||||||
|
request.setValid(existing.getValid());
|
||||||
|
return request;
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
updatedChecklistList.addAll(missingChecklistRequests);
|
||||||
|
return updatedChecklistList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FieldRequest> processField(ApplicationEvaluationEntity entity, ApplicationEvaluationRequest req) {
|
||||||
|
List<FieldResponse> existingFieldList = entity.getFile() != null ?
|
||||||
|
Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {}) : new ArrayList<>();
|
||||||
|
|
||||||
|
Map<String, FieldResponse> existingFieldMap = existingFieldList.stream()
|
||||||
|
.collect(Collectors.toMap(FieldResponse::getId, field -> field));
|
||||||
|
|
||||||
|
List<FieldRequest> updatedFieldList = req.getField().stream()
|
||||||
|
.map(incoming -> {
|
||||||
|
FieldRequest request = new FieldRequest();
|
||||||
|
request.setId(incoming.getId());
|
||||||
|
request.setValid(incoming.getValid());
|
||||||
|
|
||||||
|
FieldResponse existingField = existingFieldMap.get(incoming.getId());
|
||||||
|
if (existingField != null) {
|
||||||
|
request.setValid(incoming.getValid() != null ? incoming.getValid() : existingField.getValid());
|
||||||
|
}
|
||||||
|
return request;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
List<FieldRequest> missingFieldRequests = existingFieldList.stream()
|
||||||
|
.filter(existing -> !updatedFieldList.stream()
|
||||||
|
.map(FieldRequest::getId)
|
||||||
|
.toList()
|
||||||
|
.contains(existing.getId()))
|
||||||
|
.map(existing -> {
|
||||||
|
FieldRequest request = new FieldRequest();
|
||||||
|
request.setId(existing.getId());
|
||||||
|
request.setValid(existing.getValid());
|
||||||
|
return request;
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
updatedFieldList.addAll(missingFieldRequests);
|
||||||
|
return updatedFieldList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicationEvaluationEntity validateApplicationEvaluation(Long id) {
|
||||||
|
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findById(id);
|
||||||
|
if (entityOptional.isEmpty()) {
|
||||||
|
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
Translator.toLocale(GepafinConstant.APPLICATION_EVALUATION_NOT_FOUND, id));
|
||||||
|
}
|
||||||
|
return entityOptional.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(UserEntity user, Long applicationId, Long assignedApplicationId) {
|
||||||
|
|
||||||
|
applicationService.validateApplication(applicationId);
|
||||||
|
|
||||||
|
Optional<ApplicationEvaluationEntity> entityOptional;
|
||||||
|
|
||||||
|
if (applicationId != null && assignedApplicationId != null) {
|
||||||
|
entityOptional = applicationEvaluationRepository.findByApplicationIdAndAssignedApplicationsEntity_IdAndIsDeletedFalse(applicationId, assignedApplicationId);
|
||||||
|
} else if (applicationId != null) {
|
||||||
|
entityOptional = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
|
||||||
|
} else if (assignedApplicationId != null) {
|
||||||
|
entityOptional = applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApplicationId);
|
||||||
|
} else {
|
||||||
|
entityOptional = applicationEvaluationRepository.findFirstByIsDeletedFalseOrderByCreatedDateDesc();
|
||||||
|
}
|
||||||
|
return entityOptional.map(this::convertToResponse)
|
||||||
|
.orElseGet(() -> {
|
||||||
|
return getEvaluationResponseByApplicationid(user, applicationId, assignedApplicationId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationEvaluationResponse getEvaluationResponseByApplicationid(UserEntity user, Long applicationId,Long assignedApplicationId) {
|
||||||
|
ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity();
|
||||||
|
ApplicationEvaluationResponse response = new ApplicationEvaluationResponse();
|
||||||
|
CallEntity call=null;
|
||||||
|
AssignedApplicationsEntity assignedApplications=null;
|
||||||
|
if (applicationId != null) {
|
||||||
|
call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||||
|
assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId).orElse(null);
|
||||||
|
} else if (assignedApplicationId != null) {
|
||||||
|
call = callRepository.findCallEntityByApplicationId(assignedApplicationId);
|
||||||
|
assignedApplications = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationId).orElseThrow(()->
|
||||||
|
new ResourceNotFoundException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_MSG)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||||
|
assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId).orElse(null);}
|
||||||
|
List<EvaluationCriteriaEntity> evaluationCriterias = evaluationCriteriaRepository.findByCallId(call.getId());
|
||||||
|
List<CallTargetAudienceChecklistEntity> checklistEntities = callTargetAudienceChecklistRepository.findByCallId(call.getId());
|
||||||
|
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(applicationId);
|
||||||
|
response.setApplicationId(applicationId);
|
||||||
|
response.setAssignedApplicationId(assignedApplications.getId());
|
||||||
|
response.setNote(null);
|
||||||
|
response.setStatus(ApplicationEvaluationStatusTypeEnum.valueOf(ApplicationEvaluationStatusTypeEnum.OPEN.getValue()));
|
||||||
|
response.setMinScore(call.getThreshold());
|
||||||
|
setCriteriaResponses(entity, applicationId, response, evaluationCriterias);
|
||||||
|
setChecklistResponses(entity, applicationId, response, checklistEntities);
|
||||||
|
setFileResponses(entity, applicationId, response, applicationFormEntities);
|
||||||
|
|
||||||
|
setApplicationDetails(response, applicationId, user);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCriteriaResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response, List<EvaluationCriteriaEntity> evaluationCriterias) {
|
||||||
|
List<CriteriaResponse> criteriaResponses = entity.getCriteria() != null
|
||||||
|
? Utils.convertJsonToList(entity.getCriteria(), new TypeReference<List<CriteriaResponse>>() {})
|
||||||
|
: getCriteriaResponse(applicationId);
|
||||||
|
|
||||||
|
criteriaResponses.forEach(criteriaResponse -> {
|
||||||
|
EvaluationCriteriaEntity matchingEvaluationCriteria = evaluationCriterias.stream()
|
||||||
|
.filter(evaluationCriteria -> evaluationCriteria.getId().equals(criteriaResponse.getId()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
List<ApplicationFormEntity> applicationForms = applicationFormRepository.findByApplicationId(applicationId);
|
||||||
|
Map<String, CriteriaMappedField> mappedFieldMap = new HashMap<>();
|
||||||
|
|
||||||
|
if (matchingEvaluationCriteria != null) {
|
||||||
|
criteriaResponse.setLabel(matchingEvaluationCriteria.getLookupData().getValue());
|
||||||
|
criteriaResponse.setMaxScore(matchingEvaluationCriteria.getScore());
|
||||||
|
|
||||||
|
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository
|
||||||
|
.findByEvaluationCriteriaIdAndIsDeletedFalse(matchingEvaluationCriteria.getId());
|
||||||
|
|
||||||
|
for (ApplicationFormEntity applicationForm : applicationForms) {
|
||||||
|
for (CriteriaFormFieldEntity criteriaFormField : criteriaFormFields) {
|
||||||
|
String formFieldId = criteriaFormField.getFormFieldId();
|
||||||
|
if (!mappedFieldMap.containsKey(formFieldId)) {
|
||||||
|
CriteriaMappedField mappedField = new CriteriaMappedField();
|
||||||
|
mappedField.setId(formFieldId);
|
||||||
|
FormEntity formEntity = formRepository.findById(criteriaFormField.getFormId()).orElse(null);
|
||||||
|
|
||||||
|
if (formEntity != null) {
|
||||||
|
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||||
|
contentResponseBeans.stream()
|
||||||
|
.filter(bean -> bean.getId().equals(formFieldId))
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(contentResponseBean -> {
|
||||||
|
String label = contentResponseBean.getLabel();
|
||||||
|
if (contentResponseBean.getSettings() != null) {
|
||||||
|
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||||
|
if ("label".equals(setting.getName())) {
|
||||||
|
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mappedField.setFieldLabel(label);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Optional<ApplicationFormFieldEntity> formFieldEntityOptional = applicationFormFieldRepository
|
||||||
|
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(formFieldId, applicationForm.getId(), applicationId);
|
||||||
|
|
||||||
|
formFieldEntityOptional.ifPresent(formField -> mappedField.setFieldValue(formField.getFieldValue()));
|
||||||
|
mappedFieldMap.put(formFieldId, mappedField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
criteriaResponse.setCriteriaMappedFields(new ArrayList<>(mappedFieldMap.values()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
response.setCriteria(criteriaResponses);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setChecklistResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response, List<CallTargetAudienceChecklistEntity> checklistEntities) {
|
||||||
|
List<ChecklistResponse> checklistResponses = entity.getChecklist() != null
|
||||||
|
? Utils.convertJsonToList(entity.getChecklist(), new TypeReference<List<ChecklistResponse>>() {})
|
||||||
|
: getChecklistResponse(applicationId);
|
||||||
|
|
||||||
|
checklistResponses.forEach(checklistResponse -> {
|
||||||
|
CallTargetAudienceChecklistEntity matchingChecklist = checklistEntities.stream()
|
||||||
|
.filter(checklistEntity -> checklistEntity.getId().equals(checklistResponse.getId()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (matchingChecklist != null) {
|
||||||
|
checklistResponse.setLabel(matchingChecklist.getLookupData().getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
response.setChecklist(checklistResponses);
|
||||||
|
}
|
||||||
|
private void setFileResponses(ApplicationEvaluationEntity entity, Long applicationId, ApplicationEvaluationResponse response, List<ApplicationFormEntity> applicationFormEntities) {
|
||||||
|
List<FieldResponse> fieldResponses = entity.getFile() != null
|
||||||
|
? Utils.convertJsonToList(entity.getFile(), new TypeReference<List<FieldResponse>>() {})
|
||||||
|
: getFieldResponses(applicationId);
|
||||||
|
Set<String> processedFieldIds = new HashSet<>();
|
||||||
|
|
||||||
|
fieldResponses.forEach(fieldResponse -> {
|
||||||
|
if (processedFieldIds.contains(fieldResponse.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
applicationFormEntities.forEach(applicationForm -> {
|
||||||
|
FormEntity formEntity = applicationForm.getForm();
|
||||||
|
if (formEntity != null) {
|
||||||
|
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||||
|
contentResponseBeans.forEach(contentResponseBean -> {
|
||||||
|
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) {
|
||||||
|
String label = null;
|
||||||
|
if (contentResponseBean.getSettings() != null) {
|
||||||
|
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||||
|
if ("label".equals(setting.getName())) {
|
||||||
|
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldResponse.setLabel(label);
|
||||||
|
|
||||||
|
Optional<ApplicationFormFieldEntity> optionalFormField = applicationFormFieldRepository
|
||||||
|
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(fieldResponse.getId(), applicationForm.getId(), applicationId);
|
||||||
|
|
||||||
|
if (optionalFormField.isPresent() && optionalFormField.get().getFieldValue() != null) {
|
||||||
|
String[] documentIds = optionalFormField.get().getFieldValue().split(",");
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldResponse.setFileDetail(documentResponseBeans);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark this field ID as processed to prevent duplicates
|
||||||
|
processedFieldIds.add(fieldResponse.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
response.setFiles(fieldResponses);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void setApplicationDetails(ApplicationEvaluationResponse response, Long applicationId, UserEntity user) {
|
||||||
|
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
||||||
|
userService.validateUser(application.getUserId());
|
||||||
|
String firstName = user.getFirstName() != null ? user.getFirstName() : "";
|
||||||
|
String lastName = user.getLastName() != null ? user.getLastName() : "";
|
||||||
|
|
||||||
|
String beneficiary = String.join(" ", firstName, lastName).trim();
|
||||||
|
response.setBeneficiary(beneficiary);
|
||||||
|
|
||||||
|
response.setCallName(application.getCall().getName());
|
||||||
|
response.setProtocolNumber(application.getProtocol() != null ? application.getProtocol().getProtocolNumber() : null);
|
||||||
|
response.setSubmissionDate(application.getSubmissionDate()!= null ? application.getSubmissionDate(): null);
|
||||||
|
response.setEvaluationDate(application.getSubmissionDate()!= null ? application.getSubmissionDate().plusDays(30):null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CriteriaResponse> getCriteriaResponse(Long applicationId) {
|
||||||
|
CallEntity call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||||
|
List<EvaluationCriteriaEntity> evaluationCriterias = evaluationCriteriaRepository.findByCallId(call.getId());
|
||||||
|
|
||||||
|
List<CriteriaResponse> criteriaResponses = evaluationCriterias.stream().map(criteria -> {
|
||||||
|
CriteriaResponse response = new CriteriaResponse();
|
||||||
|
response.setId(criteria.getId());
|
||||||
|
response.setLabel(criteria.getLookupData().getValue());
|
||||||
|
response.setScore(null);
|
||||||
|
response.setMaxScore(criteria.getScore());
|
||||||
|
response.setValid(null);
|
||||||
|
|
||||||
|
List<CriteriaFormFieldEntity> criteriaFormFields = criteriaFormFieldRepository
|
||||||
|
.findByEvaluationCriteriaIdAndIsDeletedFalse(criteria.getId());
|
||||||
|
|
||||||
|
List<CriteriaMappedField> mappedFields = new ArrayList<>();
|
||||||
|
Set<String> processedFormFieldIds = new HashSet<>();
|
||||||
|
|
||||||
|
for (CriteriaFormFieldEntity criteriaFormField : criteriaFormFields) {
|
||||||
|
if (processedFormFieldIds.contains(criteriaFormField.getFormFieldId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CriteriaMappedField mappedField = new CriteriaMappedField();
|
||||||
|
mappedField.setId(criteriaFormField.getFormFieldId());
|
||||||
|
|
||||||
|
FormEntity formEntity = formRepository.findById(criteriaFormField.getFormId()).orElse(null);
|
||||||
|
if (formEntity != null) {
|
||||||
|
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(
|
||||||
|
formEntity.getContent(), ContentResponseBean.class);
|
||||||
|
contentResponseBeans.stream()
|
||||||
|
.filter(bean -> bean.getId().equals(criteriaFormField.getFormFieldId()))
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(contentResponseBean -> {
|
||||||
|
String label = contentResponseBean.getLabel();
|
||||||
|
if (contentResponseBean.getSettings() != null) {
|
||||||
|
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||||
|
if ("label".equals(setting.getName())) {
|
||||||
|
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mappedField.setFieldLabel(label);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
applicationFormRepository.findByApplicationId(applicationId).stream()
|
||||||
|
.flatMap(applicationForm -> applicationFormFieldRepository
|
||||||
|
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||||
|
criteriaFormField.getFormFieldId(), applicationForm.getId(), applicationId)
|
||||||
|
.stream())
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(formField -> mappedField.setFieldValue(formField.getFieldValue()));
|
||||||
|
|
||||||
|
mappedFields.add(mappedField);
|
||||||
|
processedFormFieldIds.add(criteriaFormField.getFormFieldId());
|
||||||
|
}
|
||||||
|
|
||||||
|
response.setCriteriaMappedFields(mappedFields);
|
||||||
|
return response;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return criteriaResponses;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ChecklistResponse> getChecklistResponse(Long applicationId){ CallEntity call = callRepository.findCallEntityByApplicationId(applicationId);
|
||||||
|
List<CallTargetAudienceChecklistEntity> checklistEntities = callTargetAudienceChecklistRepository.findByCallId(call.getId());
|
||||||
|
List<ChecklistResponse> checklistResponses = checklistEntities.stream().map(checklist -> {
|
||||||
|
ChecklistResponse response = new ChecklistResponse();
|
||||||
|
response.setId(checklist.getId());
|
||||||
|
response.setLabel(checklist.getLookupData().getValue());
|
||||||
|
response.setValid(null);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return checklistResponses;
|
||||||
|
}
|
||||||
|
public List<FieldResponse> getFieldResponses(Long applicationId) {
|
||||||
|
List<ApplicationFormEntity> applicationFormEntities = applicationFormRepository.findByApplicationId(applicationId);
|
||||||
|
List<FieldResponse> fieldResponses = new ArrayList<>();
|
||||||
|
|
||||||
|
for (ApplicationFormEntity applicationForm : applicationFormEntities) {
|
||||||
|
FormEntity formEntity = applicationForm.getForm();
|
||||||
|
|
||||||
|
if (formEntity != null) {
|
||||||
|
List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||||
|
|
||||||
|
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
|
||||||
|
if ("fileupload".equals(contentResponseBean.getName())) {
|
||||||
|
String fieldId = contentResponseBean.getId();
|
||||||
|
Long applicationFormId = applicationForm.getId();
|
||||||
|
|
||||||
|
Optional<ApplicationFormFieldEntity> optionalFormField = applicationFormFieldRepository
|
||||||
|
.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(fieldId, applicationFormId, applicationId);
|
||||||
|
|
||||||
|
if (optionalFormField.isPresent()) {
|
||||||
|
ApplicationFormFieldEntity formField = optionalFormField.get();
|
||||||
|
|
||||||
|
if (formField.getFieldValue() != null) {
|
||||||
|
FieldResponse fieldResponse = new FieldResponse();
|
||||||
|
fieldResponse.setId(fieldId);
|
||||||
|
String label = null;
|
||||||
|
if (contentResponseBean.getSettings() != null) {
|
||||||
|
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||||
|
if ("label".equals(setting.getName())) {
|
||||||
|
label = setting.getValue() != null ? setting.getValue().toString() : label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldResponse.setLabel(label);
|
||||||
|
fieldResponse.setValid(null);
|
||||||
|
String[] documentIds = formField.getFieldValue().split(",");
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldResponse.setFileDetail(documentResponseBeans);
|
||||||
|
|
||||||
|
// Now add fieldResponse to the list
|
||||||
|
fieldResponses.add(fieldResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fieldResponses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteById(Long id) {
|
||||||
|
ApplicationEvaluationEntity applicationEvaluationEntity= validateApplicationEvaluation(id);
|
||||||
|
applicationEvaluationEntity.setIsDeleted(true);
|
||||||
|
applicationEvaluationEntity=saveApplicationEvaluationEntity(applicationEvaluationEntity);
|
||||||
|
}
|
||||||
|
public ApplicationEvaluationEntity saveApplicationEvaluationEntity(ApplicationEvaluationEntity applicationEvaluationEntityData){
|
||||||
|
return applicationEvaluationRepository.save(applicationEvaluationEntityData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationEvaluationResponse updateApplicationEvaluationStatus(Long applicationId, ApplicationEvaluationStatusTypeEnum status) {
|
||||||
|
ApplicationEvaluationEntity existingEntity = validateApplicationEvaluation(applicationId);
|
||||||
|
if (status != null && !status.getValue().equals(existingEntity.getStatus())) {
|
||||||
|
existingEntity.setStatus(status.getValue());
|
||||||
|
}
|
||||||
|
ApplicationEvaluationEntity updatedEntity = applicationEvaluationRepository.save(existingEntity);
|
||||||
|
return convertToResponse(updatedEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
import jakarta.persistence.criteria.Predicate;
|
import jakarta.persistence.criteria.Predicate;
|
||||||
|
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.ApplicationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
@@ -9,10 +10,12 @@ import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
|||||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||||
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.AssignedApplicationsRepository;
|
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
import net.gepafin.tendermanagement.service.UserService;
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
|
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.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
@@ -31,13 +34,19 @@ import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
|||||||
public class AssignedApplicationsDao {
|
public class AssignedApplicationsDao {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ApplicationService applicationService;
|
private ApplicationService applicationService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
AssignedApplicationsRepository assignedApplicationsRepository;
|
private ApplicationRepository applicationRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
UserService userService;
|
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
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);
|
||||||
@@ -47,9 +56,19 @@ public class AssignedApplicationsDao {
|
|||||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_ASSIGNED));
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_ASSIGNED));
|
||||||
}
|
}
|
||||||
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
||||||
|
|
||||||
|
|
||||||
|
if (Boolean.FALSE.equals(ApplicationStatusTypeEnum.SUBMIT.getValue().equals(application.getStatus()))) {
|
||||||
|
throw new CustomValidationException(
|
||||||
|
Status.BAD_REQUEST,
|
||||||
|
Translator.toLocale(GepafinConstant.INVALID_APPLICATION_STATUS)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
application.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue());
|
||||||
|
applicationRepository.save(application);
|
||||||
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, assignedApplicationsRequest);
|
AssignedApplicationsResponse assignApplicationToInstructorResponse = convertEntityToResponse(assignment);
|
||||||
|
|
||||||
log.info("Application assigned succesfully {}", assignApplicationToInstructorResponse);
|
log.info("Application assigned succesfully {}", assignApplicationToInstructorResponse);
|
||||||
return assignApplicationToInstructorResponse;
|
return assignApplicationToInstructorResponse;
|
||||||
@@ -60,7 +79,10 @@ public class AssignedApplicationsDao {
|
|||||||
assignApplication.setApplication(application);
|
assignApplication.setApplication(application);
|
||||||
assignApplication.setAssignedBy(assignedByUser.getId());
|
assignApplication.setAssignedBy(assignedByUser.getId());
|
||||||
assignApplication.setUserId(userId);
|
assignApplication.setUserId(userId);
|
||||||
|
assignApplication.setStatus(AssignedApplicationEnum.OPEN.getValue());
|
||||||
|
if(assignedApplicationsRequest.getStatus() != null) {
|
||||||
assignApplication.setStatus(assignedApplicationsRequest.getStatus().getValue());
|
assignApplication.setStatus(assignedApplicationsRequest.getStatus().getValue());
|
||||||
|
}
|
||||||
assignApplication.setNote(assignedApplicationsRequest.getNote());
|
assignApplication.setNote(assignedApplicationsRequest.getNote());
|
||||||
assignApplication.setIsDeleted(false);
|
assignApplication.setIsDeleted(false);
|
||||||
assignApplication.setAssignedAt(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
assignApplication.setAssignedAt(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
@@ -73,17 +95,44 @@ public class AssignedApplicationsDao {
|
|||||||
return assignedApplication;
|
return assignedApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssignedApplicationsResponse convertEntityToResponse(AssignedApplicationsEntity application, AssignedApplicationsRequest assignedApplicationsRequest){
|
public AssignedApplicationsResponse convertEntityToResponse(AssignedApplicationsEntity assignedApplications){
|
||||||
AssignedApplicationsResponse assignedApplicationsResponse = new AssignedApplicationsResponse();
|
AssignedApplicationsResponse assignedApplicationsResponse = new AssignedApplicationsResponse();
|
||||||
assignedApplicationsResponse.setId(application.getId());
|
assignedApplicationsResponse.setId(assignedApplications.getId());
|
||||||
assignedApplicationsResponse.setApplicationId(application.getApplication().getId());
|
assignedApplicationsResponse.setApplicationId(assignedApplications.getApplication().getId());
|
||||||
assignedApplicationsResponse.setAssignedBy(application.getAssignedBy());
|
|
||||||
assignedApplicationsResponse.setUserId(application.getUserId());
|
ApplicationEntity application = applicationService.validateApplication(assignedApplications.getApplication().getId());
|
||||||
assignedApplicationsResponse.setCreatedDate(application.getCreatedDate());
|
String callName = application.getCall() != null ? application.getCall().getName() : "";
|
||||||
assignedApplicationsResponse.setUpdatedDate(application.getUpdatedDate());
|
LocalDateTime callEndDate = application.getCall().getEndDate();
|
||||||
assignedApplicationsResponse.setNote(application.getNote());
|
LocalDateTime callStartDate = application.getCall().getStartDate();
|
||||||
assignedApplicationsResponse.setStatus(AssignedApplicationEnum.valueOf(application.getStatus()));
|
|
||||||
assignedApplicationsResponse.setAssignedAt(application.getAssignedAt());
|
Long protocolNumber = (application.getProtocol() != null && application.getProtocol().getProtocolNumber() != null)
|
||||||
|
? application.getProtocol().getProtocolNumber()
|
||||||
|
: 0;
|
||||||
|
LocalDateTime submissionDate = application.getSubmissionDate();
|
||||||
|
UserEntity userEntity = userService.validateUser(application.getUserId());
|
||||||
|
|
||||||
|
String firstName = userEntity.getBeneficiary() != null ? userEntity.getBeneficiary().getFirstName() : null;
|
||||||
|
String lastName = userEntity.getBeneficiary() != null ? userEntity.getBeneficiary().getLastName() : null;
|
||||||
|
|
||||||
|
String beneficiaryName = (firstName != null && !firstName.isBlank() ? firstName : "") +
|
||||||
|
(lastName != null && !lastName.isBlank() ? " " + lastName : "");
|
||||||
|
|
||||||
|
beneficiaryName = beneficiaryName.isBlank() ? "" : beneficiaryName;
|
||||||
|
|
||||||
|
assignedApplicationsResponse.setAssignedBy(assignedApplications.getAssignedBy());
|
||||||
|
assignedApplicationsResponse.setUserId(assignedApplications.getUserId());
|
||||||
|
assignedApplicationsResponse.setCreatedDate(assignedApplications.getCreatedDate());
|
||||||
|
assignedApplicationsResponse.setUpdatedDate(assignedApplications.getUpdatedDate());
|
||||||
|
assignedApplicationsResponse.setNote(assignedApplications.getNote());
|
||||||
|
assignedApplicationsResponse.setStatus(AssignedApplicationEnum.valueOf(assignedApplications.getStatus()));
|
||||||
|
assignedApplicationsResponse.setAssignedAt(assignedApplications.getAssignedAt());
|
||||||
|
assignedApplicationsResponse.setProtocolNumber(protocolNumber);
|
||||||
|
assignedApplicationsResponse.setCallName(callName);
|
||||||
|
assignedApplicationsResponse.setBeneficiaryName(beneficiaryName);
|
||||||
|
assignedApplicationsResponse.setSubmissionDate(submissionDate);
|
||||||
|
assignedApplicationsResponse.setCallEndDate(callEndDate);
|
||||||
|
assignedApplicationsResponse.setCallStartDate(callStartDate);
|
||||||
|
|
||||||
return assignedApplicationsResponse;
|
return assignedApplicationsResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,38 +142,47 @@ public class AssignedApplicationsDao {
|
|||||||
return assignedApplication;
|
return assignedApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteById(Long id) {
|
public void deleteById(HttpServletRequest request, Long id) {
|
||||||
log.info("Deleting assigned application with ID: {}", id);
|
log.info("Deleting assigned application with ID: {}", id);
|
||||||
AssignedApplicationsEntity assignedApplicationsEntity= validateAssignedApplication(id);
|
AssignedApplicationsEntity assignedApplicationsEntity= validateAssignedApplication(id);
|
||||||
|
validator.validatePreInstructor(request, assignedApplicationsEntity.getUserId());
|
||||||
assignedApplicationsEntity.setIsDeleted(true);
|
assignedApplicationsEntity.setIsDeleted(true);
|
||||||
assignedApplicationsEntity= saveAssignedApplication(assignedApplicationsEntity);
|
assignedApplicationsEntity= saveAssignedApplication(assignedApplicationsEntity);
|
||||||
log.info("Assigned Application deleted with ID: {}", id);
|
log.info("Assigned Application deleted with ID: {}", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AssignedApplicationsResponse> getAllAssignedApplications(Long userId){
|
public List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId) {
|
||||||
Specification<AssignedApplicationsEntity> spec = search(userId);
|
UserEntity user = validator.validateUser(request);
|
||||||
|
if(validator.checkIsPreInstructor() && userId == null) {
|
||||||
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
|
||||||
|
}
|
||||||
|
if(userId != null) {
|
||||||
|
validator.validatePreInstructor(request, userId);
|
||||||
|
}
|
||||||
|
Specification<AssignedApplicationsEntity> spec = search(user.getHub().getId() ,userId);
|
||||||
List<AssignedApplicationsEntity> assignedApplicationsEntityList = assignedApplicationsRepository.findAll(spec);
|
List<AssignedApplicationsEntity> assignedApplicationsEntityList = assignedApplicationsRepository.findAll(spec);
|
||||||
return assignedApplicationsEntityList.stream()
|
return assignedApplicationsEntityList.stream()
|
||||||
.map(entity -> convertEntityToResponse(entity, new AssignedApplicationsRequest()))
|
.map(entity -> convertEntityToResponse(entity))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
private Specification<AssignedApplicationsEntity> search(Long userId) {
|
private Specification<AssignedApplicationsEntity> search(Long hubId, Long userId) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
predicate = builder.and(predicate, builder.equal(root.get("application").get("hubId"), hubId));
|
||||||
return predicate;
|
return predicate;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AssignedApplicationsResponse updateAssignedApplication(
|
public AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request,
|
||||||
Long id, AssignedApplicationsRequest updateRequest, UserEntity updatedByUser) {
|
Long id, AssignedApplicationsRequest updateRequest) {
|
||||||
|
UserEntity updatedByUser = validator.validateUser(request);
|
||||||
log.info("Updating assigned application with ID: {}", id);
|
log.info("Updating assigned application with ID: {}", id);
|
||||||
AssignedApplicationsEntity existingAssignment = validateAssignedApplication(id);
|
AssignedApplicationsEntity existingAssignment = validateAssignedApplication(id);
|
||||||
|
validator.validatePreInstructor(request, existingAssignment.getUserId());
|
||||||
setIfUpdated(existingAssignment::getNote, existingAssignment::setNote, updateRequest.getNote());
|
setIfUpdated(existingAssignment::getNote, existingAssignment::setNote, updateRequest.getNote());
|
||||||
setIfUpdated(existingAssignment::getStatus, existingAssignment::setStatus, updateRequest.getStatus().name());
|
setIfUpdated(existingAssignment::getStatus, existingAssignment::setStatus, updateRequest.getStatus().name());
|
||||||
setIfUpdated(existingAssignment::getAssignedBy, existingAssignment::setAssignedBy, updatedByUser.getId());
|
setIfUpdated(existingAssignment::getAssignedBy, existingAssignment::setAssignedBy, updatedByUser.getId());
|
||||||
@@ -132,15 +190,16 @@ public class AssignedApplicationsDao {
|
|||||||
existingAssignment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
existingAssignment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
|
|
||||||
AssignedApplicationsEntity updatedAssignment = saveAssignedApplication(existingAssignment);
|
AssignedApplicationsEntity updatedAssignment = saveAssignedApplication(existingAssignment);
|
||||||
AssignedApplicationsResponse response = convertEntityToResponse(updatedAssignment, updateRequest);
|
AssignedApplicationsResponse response = convertEntityToResponse(updatedAssignment);
|
||||||
log.info("Assigned application updated successfully: {}", response);
|
log.info("Assigned application updated successfully: {}", response);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssignedApplicationsResponse getAssignedApplicationById(Long id) {
|
public AssignedApplicationsResponse getAssignedApplicationById(HttpServletRequest request, Long id) {
|
||||||
log.info("Fetching assigned application with ID: {}", id);
|
log.info("Fetching assigned application with ID: {}", id);
|
||||||
AssignedApplicationsEntity assignedApplication = validateAssignedApplication(id);
|
AssignedApplicationsEntity assignedApplication = validateAssignedApplication(id);
|
||||||
AssignedApplicationsResponse response = convertEntityToResponse(assignedApplication, new AssignedApplicationsRequest());
|
validator.validatePreInstructor(request, assignedApplication.getUserId());
|
||||||
|
AssignedApplicationsResponse response = convertEntityToResponse(assignedApplication);
|
||||||
log.info("Assigned application fetched successfully: {}", response);
|
log.info("Assigned application fetched successfully: {}", response);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ import net.gepafin.tendermanagement.constants.GepafinConstant;
|
|||||||
import net.gepafin.tendermanagement.entities.BeneficiaryPreferredCallEntity;
|
import net.gepafin.tendermanagement.entities.BeneficiaryPreferredCallEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
|
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
|
||||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
|
||||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
|
||||||
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
|
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
|
||||||
import net.gepafin.tendermanagement.repositories.BeneficiaryPreferredCallRepository;
|
import net.gepafin.tendermanagement.repositories.BeneficiaryPreferredCallRepository;
|
||||||
import net.gepafin.tendermanagement.service.UserService;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
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;
|
||||||
@@ -19,10 +17,11 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class BeneficiaryPreferredCallDao {
|
public class BeneficiaryPreferredCallDao {
|
||||||
@@ -31,11 +30,14 @@ public class BeneficiaryPreferredCallDao {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BeneficiaryPreferredCallRepository beneficiaryPreferredCallRepository;
|
private BeneficiaryPreferredCallRepository beneficiaryPreferredCallRepository;
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(BeneficiaryPreferredCallReq request,UserEntity user) {
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
|
|
||||||
|
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest httpServletRequest, BeneficiaryPreferredCallReq request,UserEntity user) {
|
||||||
log.info("Creating new beneficiary preferred call with details: {}", request);
|
log.info("Creating new beneficiary preferred call with details: {}", request);
|
||||||
|
validator.validateUserWithCompany(httpServletRequest, request.getCompanyId());
|
||||||
BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request,user);
|
BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request,user);
|
||||||
entity = beneficiaryPreferredCallRepository.save(entity);
|
entity = beneficiaryPreferredCallRepository.save(entity);
|
||||||
log.info("Beneficiary preferred call created with ID: {}", entity.getId());
|
log.info("Beneficiary preferred call created with ID: {}", entity.getId());
|
||||||
@@ -44,9 +46,8 @@ public class BeneficiaryPreferredCallDao {
|
|||||||
|
|
||||||
private BeneficiaryPreferredCallEntity convertRequestToEntity(BeneficiaryPreferredCallReq request,UserEntity userEntity) {
|
private BeneficiaryPreferredCallEntity convertRequestToEntity(BeneficiaryPreferredCallReq request,UserEntity userEntity) {
|
||||||
BeneficiaryPreferredCallEntity entity = new BeneficiaryPreferredCallEntity();
|
BeneficiaryPreferredCallEntity entity = new BeneficiaryPreferredCallEntity();
|
||||||
UserEntity user= userService.validateUser(userEntity.getId());
|
if (userEntity.getBeneficiary()!=null) {
|
||||||
if (user.getBeneficiary()!=null) {
|
entity.setBeneficiaryId(userEntity.getBeneficiary().getId());
|
||||||
entity.setBeneficiaryId(user.getBeneficiary().getId());
|
|
||||||
}
|
}
|
||||||
entity.setStatus(BeneficiaryCallStatus.ENABLED.getValue());
|
entity.setStatus(BeneficiaryCallStatus.ENABLED.getValue());
|
||||||
entity.setCallId(request.getCallId());
|
entity.setCallId(request.getCallId());
|
||||||
@@ -55,9 +56,10 @@ public class BeneficiaryPreferredCallDao {
|
|||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeneficiaryPreferredCallResponseBean getBeneficiaryPreferredCallById(Long id) {
|
public BeneficiaryPreferredCallResponseBean getBeneficiaryPreferredCallById(HttpServletRequest request, Long id) {
|
||||||
log.info("Fetching beneficiary preferred call with ID: {}", id);
|
log.info("Fetching beneficiary preferred call with ID: {}", id);
|
||||||
BeneficiaryPreferredCallEntity entity = validateBeneficiaryPreferredCall(id);
|
BeneficiaryPreferredCallEntity entity = validateBeneficiaryPreferredCall(id);
|
||||||
|
validator.validateUserId(request, entity.getUserId());
|
||||||
log.info("Beneficiary preferred call found: {}", entity);
|
log.info("Beneficiary preferred call found: {}", entity);
|
||||||
return convertEntityToResponse(entity);
|
return convertEntityToResponse(entity);
|
||||||
}
|
}
|
||||||
@@ -74,20 +76,18 @@ public class BeneficiaryPreferredCallDao {
|
|||||||
// return convertEntityToResponse(existingEntity);
|
// return convertEntityToResponse(existingEntity);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private boolean isUserABeneficiary(Long userId) {
|
public void deleteBeneficiaryPreferredCallById(HttpServletRequest request, Long id) {
|
||||||
UserEntity user=userService.validateUser(userId);
|
|
||||||
return RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(user.getRoleEntity().getRoleType());
|
|
||||||
}
|
|
||||||
public void deleteBeneficiaryPreferredCallById(Long id) {
|
|
||||||
log.info("Deleting beneficiary preferred call with ID: {}", id);
|
log.info("Deleting beneficiary preferred call with ID: {}", id);
|
||||||
validateBeneficiaryPreferredCall(id);
|
BeneficiaryPreferredCallEntity entity = validateBeneficiaryPreferredCall(id);
|
||||||
|
validator.validateUserId(request, entity.getUserId());
|
||||||
beneficiaryPreferredCallRepository.deleteById(id);
|
beneficiaryPreferredCallRepository.deleteById(id);
|
||||||
log.info("Beneficiary preferred call deleted with ID: {}", id);
|
log.info("Beneficiary preferred call deleted with ID: {}", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BeneficiaryPreferredCallResponseBean> getAllBeneficiaryPreferredCalls() {
|
public List<BeneficiaryPreferredCallResponseBean> getAllBeneficiaryPreferredCalls(HttpServletRequest request) {
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
log.info("Fetching all beneficiary preferred calls");
|
log.info("Fetching all beneficiary preferred calls");
|
||||||
List<BeneficiaryPreferredCallResponseBean> calls = beneficiaryPreferredCallRepository.findAll()
|
List<BeneficiaryPreferredCallResponseBean> calls = beneficiaryPreferredCallRepository.findByUserId(userEntity.getId())
|
||||||
.stream()
|
.stream()
|
||||||
.map(this::convertEntityToResponse)
|
.map(this::convertEntityToResponse)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ public class CallDao {
|
|||||||
criteriaEntity = new EvaluationCriteriaEntity();
|
criteriaEntity = new EvaluationCriteriaEntity();
|
||||||
criteriaEntity.setCall(callEntity);
|
criteriaEntity.setCall(callEntity);
|
||||||
criteriaEntity.setLookupData(lookupDataEntity);
|
criteriaEntity.setLookupData(lookupDataEntity);
|
||||||
|
criteriaEntity.setScore(0L);
|
||||||
criteriaEntity.setIsDeleted(false);
|
criteriaEntity.setIsDeleted(false);
|
||||||
}
|
}
|
||||||
setIfUpdated(criteriaEntity::getScore, criteriaEntity::setScore, criteriaReq.getScore());
|
setIfUpdated(criteriaEntity::getScore, criteriaEntity::setScore, criteriaReq.getScore());
|
||||||
@@ -601,6 +602,7 @@ public class CallDao {
|
|||||||
dates.add(callEntity.getStartDate());
|
dates.add(callEntity.getStartDate());
|
||||||
dates.add(callEntity.getEndDate());
|
dates.add(callEntity.getEndDate());
|
||||||
callDetailsResponseBean.setDates(dates);
|
callDetailsResponseBean.setDates(dates);
|
||||||
|
callDetailsResponseBean.setConfidi(callEntity.getConfidi());
|
||||||
callDetailsResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
callDetailsResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
||||||
callDetailsResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
callDetailsResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
||||||
callDetailsResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
callDetailsResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
||||||
@@ -619,6 +621,7 @@ public class CallDao {
|
|||||||
callDetailsResponseBean.setPhoneNumber(callEntity.getPhoneNumber());
|
callDetailsResponseBean.setPhoneNumber(callEntity.getPhoneNumber());
|
||||||
callDetailsResponseBean.setCreatedDate(callEntity.getCreatedDate());
|
callDetailsResponseBean.setCreatedDate(callEntity.getCreatedDate());
|
||||||
callDetailsResponseBean.setUpdatedDate(callEntity.getUpdatedDate());
|
callDetailsResponseBean.setUpdatedDate(callEntity.getUpdatedDate());
|
||||||
|
|
||||||
return callDetailsResponseBean;
|
return callDetailsResponseBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -651,7 +654,7 @@ public class CallDao {
|
|||||||
if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) {
|
if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) {
|
||||||
callStatusList = List.of(CallStatusEnum.PUBLISH.getValue());
|
callStatusList = List.of(CallStatusEnum.PUBLISH.getValue());
|
||||||
}
|
}
|
||||||
List<CallEntity> calls = callRepository.findByStatusIn(callStatusList);
|
List<CallEntity> calls = callRepository.findByStatusInAndHubId(callStatusList, user.getHub().getId());
|
||||||
return calls.stream()
|
return calls.stream()
|
||||||
.map(this::convertToCallDetailsResponseBean)
|
.map(this::convertToCallDetailsResponseBean)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@@ -669,13 +672,13 @@ public class CallDao {
|
|||||||
callResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
callResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
||||||
return callResponseBean;
|
return callResponseBean;
|
||||||
}
|
}
|
||||||
public CallEntity getCallEntityById(Long id){
|
// public CallEntity getCallEntityById(Long id){
|
||||||
CallEntity callEntity=callRepository.findByIdAndStatusNotIn(id,List.of(CallStatusEnum.PUBLISH.getValue()));
|
// CallEntity callEntity=callRepository.findByIdAndStatusNotInAndHubId(id, List.of(CallStatusEnum.PUBLISH.getValue()));
|
||||||
if(callEntity==null){
|
// if(callEntity==null){
|
||||||
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.CALL_NOT_FOUND));
|
// throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.CALL_NOT_FOUND));
|
||||||
}
|
// }
|
||||||
return callEntity;
|
// return callEntity;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public CallResponse updateCallStatus(CallEntity callEntity, CallStatusEnum statusReq) {
|
public CallResponse updateCallStatus(CallEntity callEntity, CallStatusEnum statusReq) {
|
||||||
CallStatusEnum currentStatus = CallStatusEnum.valueOf(callEntity.getStatus());
|
CallStatusEnum currentStatus = CallStatusEnum.valueOf(callEntity.getStatus());
|
||||||
@@ -715,9 +718,9 @@ public class CallDao {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public CallEntity validatePublishedCall(Long callId) {
|
public CallEntity validatePublishedCall(Long callId, Long hubId) {
|
||||||
CallEntity callEntity= callRepository
|
CallEntity callEntity= callRepository
|
||||||
.findByIdAndStatus(callId, CallStatusEnum.PUBLISH.getValue());
|
.findByIdAndStatusAndHubId(callId, CallStatusEnum.PUBLISH.getValue(), hubId);
|
||||||
if(callEntity==null){
|
if(callEntity==null){
|
||||||
throw new ResourceNotFoundException(
|
throw new ResourceNotFoundException(
|
||||||
Status.NOT_FOUND,
|
Status.NOT_FOUND,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class CompanyDao {
|
|||||||
|
|
||||||
|
|
||||||
public CompanyResponse createCompany(UserEntity userEntity, CompanyRequest companyRequest) {
|
public CompanyResponse createCompany(UserEntity userEntity, CompanyRequest companyRequest) {
|
||||||
CompanyEntity existingCompany = companyRepository.findByVatNumber(companyRequest.getVatNumber());
|
CompanyEntity existingCompany = companyRepository.findByVatNumberAndHubId(companyRequest.getVatNumber(), userEntity.getHub().getId());
|
||||||
UserWithCompanyEntity userWithCompanyEntity = null;
|
UserWithCompanyEntity userWithCompanyEntity = null;
|
||||||
if (existingCompany != null) {
|
if (existingCompany != null) {
|
||||||
UserWithCompanyEntity existingRelation = userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), existingCompany.getId())
|
UserWithCompanyEntity existingRelation = userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), existingCompany.getId())
|
||||||
@@ -53,8 +53,8 @@ public class CompanyDao {
|
|||||||
}
|
}
|
||||||
return convertCompanyEntityToCompanyResponse(existingCompany, userWithCompanyEntity);
|
return convertCompanyEntityToCompanyResponse(existingCompany, userWithCompanyEntity);
|
||||||
} else {
|
} else {
|
||||||
validateCompany(companyRequest);
|
validateCompany(userEntity, companyRequest);
|
||||||
CompanyEntity companyEntity = convertCompanyRequestToCompanyEntity(companyRequest);
|
CompanyEntity companyEntity = convertCompanyRequestToCompanyEntity(userEntity, companyRequest);
|
||||||
companyRepository.save(companyEntity);
|
companyRepository.save(companyEntity);
|
||||||
userWithCompanyEntity = createUserWithCompanyRelation(userEntity, companyEntity, companyRequest.getIsLegalRepresentant());
|
userWithCompanyEntity = createUserWithCompanyRelation(userEntity, companyEntity, companyRequest.getIsLegalRepresentant());
|
||||||
return convertCompanyEntityToCompanyResponse(companyEntity, userWithCompanyEntity);
|
return convertCompanyEntityToCompanyResponse(companyEntity, userWithCompanyEntity);
|
||||||
@@ -62,7 +62,7 @@ public class CompanyDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void validateCompany(CompanyRequest companyRequest) {
|
private void validateCompany(UserEntity userEntity, CompanyRequest companyRequest) {
|
||||||
|
|
||||||
if (Boolean.FALSE.equals(StringUtils.isEmpty(companyRequest.getEmail()))
|
if (Boolean.FALSE.equals(StringUtils.isEmpty(companyRequest.getEmail()))
|
||||||
&& Boolean.FALSE.equals(Utils.isValidEmail(companyRequest.getEmail()))) {
|
&& Boolean.FALSE.equals(Utils.isValidEmail(companyRequest.getEmail()))) {
|
||||||
@@ -73,7 +73,7 @@ public class CompanyDao {
|
|||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.VATNUMBER_MANDATORY));
|
Translator.toLocale(GepafinConstant.VATNUMBER_MANDATORY));
|
||||||
}
|
}
|
||||||
if (companyRepository.existsByVatNumber(companyRequest.getVatNumber())) {
|
if (companyRepository.existsByVatNumberAndHubId(companyRequest.getVatNumber(), userEntity.getHub().getId())) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.VATNUMBER_ALREADY_EXISTS));
|
Translator.toLocale(GepafinConstant.VATNUMBER_ALREADY_EXISTS));
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ public class CompanyDao {
|
|||||||
return userWithCompanyRepository.save(userWithCompanyEntity);
|
return userWithCompanyRepository.save(userWithCompanyEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompanyEntity convertCompanyRequestToCompanyEntity(CompanyRequest request) {
|
private CompanyEntity convertCompanyRequestToCompanyEntity(UserEntity userEntity, CompanyRequest request) {
|
||||||
CompanyEntity entity = new CompanyEntity();
|
CompanyEntity entity = new CompanyEntity();
|
||||||
entity.setCompanyName(request.getCompanyName());
|
entity.setCompanyName(request.getCompanyName());
|
||||||
entity.setVatNumber(request.getVatNumber());
|
entity.setVatNumber(request.getVatNumber());
|
||||||
@@ -108,6 +108,7 @@ public class CompanyDao {
|
|||||||
entity.setAnnualRevenue(request.getAnnualRevenue());
|
entity.setAnnualRevenue(request.getAnnualRevenue());
|
||||||
entity.setContactName(request.getContactName());
|
entity.setContactName(request.getContactName());
|
||||||
entity.setContactEmail(request.getContactEmail());
|
entity.setContactEmail(request.getContactEmail());
|
||||||
|
entity.setHub(userEntity.getHub());
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +187,7 @@ public class CompanyDao {
|
|||||||
public List<CompanyResponse> getCompanyByUserId(Long userId) {
|
public List<CompanyResponse> getCompanyByUserId(Long userId) {
|
||||||
UserEntity userEntity = userService.validateUser(userId);
|
UserEntity userEntity = userService.validateUser(userId);
|
||||||
List<Long> activeCompanyIds = userWithCompanyRepository.findActiveCompanyIdsByUserId(userEntity.getId());
|
List<Long> activeCompanyIds = userWithCompanyRepository.findActiveCompanyIdsByUserId(userEntity.getId());
|
||||||
List<CompanyEntity> companies = companyRepository.findByIdIn(activeCompanyIds);
|
List<CompanyEntity> companies = companyRepository.findByIdInAndHubId(activeCompanyIds, userEntity.getHub().getId());
|
||||||
return companies.stream().map(companyEntity -> {
|
return companies.stream().map(companyEntity -> {
|
||||||
UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyEntity.getId());
|
UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyEntity.getId());
|
||||||
return convertCompanyEntityToCompanyResponse(companyEntity, userWithCompanyEntity);
|
return convertCompanyEntityToCompanyResponse(companyEntity, userWithCompanyEntity);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class DashboardDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setActiveCalls(Widget1 widget1, UserEntity requestedUserEntity) {
|
private void setActiveCalls(Widget1 widget1, UserEntity requestedUserEntity) {
|
||||||
Long activeCalls = callRepository.countByStatus(CallStatusEnum.PUBLISH.getValue());
|
Long activeCalls = callRepository.countByStatusAndHubId(CallStatusEnum.PUBLISH.getValue(), requestedUserEntity.getHub().getId());
|
||||||
if (activeCalls != null) {
|
if (activeCalls != null) {
|
||||||
widget1.setNumberOfActiveCalls(activeCalls);
|
widget1.setNumberOfActiveCalls(activeCalls);
|
||||||
}
|
}
|
||||||
@@ -74,27 +74,27 @@ public class DashboardDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTotalActiveFinancing(Widget1 widget1, UserEntity requestedUserEntity) {
|
private void setTotalActiveFinancing(Widget1 widget1, UserEntity requestedUser) {
|
||||||
BigDecimal totalActiveFinancing = callRepository.findTotalAmountOfPublishedCalls();
|
BigDecimal totalActiveFinancing = callRepository.findTotalAmountOfPublishedCallsAndHubId(requestedUser.getHub().getId());
|
||||||
widget1.setTotalActiveFinancing(totalActiveFinancing);
|
widget1.setTotalActiveFinancing(totalActiveFinancing);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSubmittedApplications(Widget1 widget1, UserEntity requestedUserEntity) {
|
private void setSubmittedApplications(Widget1 widget1, UserEntity requestedUserEntity) {
|
||||||
Long submittedApplications = applicationRepository.countSubmittedApplications();
|
Long submittedApplications = applicationRepository.countSubmittedApplicationsByHubId(requestedUserEntity.getHub().getId());
|
||||||
if (submittedApplications != null) {
|
if (submittedApplications != null) {
|
||||||
widget1.setNumberOfSubmittedApplications(submittedApplications);
|
widget1.setNumberOfSubmittedApplications(submittedApplications);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDraftApplications(Widget1 widget1, UserEntity requestedUserEntity) {
|
private void setDraftApplications(Widget1 widget1, UserEntity requestedUserEntity) {
|
||||||
Long draftApplications = applicationRepository.countDraftApplications();
|
Long draftApplications = applicationRepository.countDraftApplicationsByHubId(requestedUserEntity.getHub().getId());
|
||||||
if (draftApplications != null) {
|
if (draftApplications != null) {
|
||||||
widget1.setNumberOfDraftApplications(draftApplications);
|
widget1.setNumberOfDraftApplications(draftApplications);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setNumberOfCompanies(Widget1 widget1, UserEntity requestedUserEntity) {
|
private void setNumberOfCompanies(Widget1 widget1, UserEntity requestedUserEntity) {
|
||||||
Long numberOfCompanies = companyRepository.countTotalCompanies();
|
Long numberOfCompanies = companyRepository.countTotalCompaniesByHubId(requestedUserEntity.getHub().getId());
|
||||||
if (numberOfCompanies != null) {
|
if (numberOfCompanies != null) {
|
||||||
widget1.setNumberOfCompany(numberOfCompanies);
|
widget1.setNumberOfCompany(numberOfCompanies);
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ public class DashboardDao {
|
|||||||
CompanyEntity company) {
|
CompanyEntity company) {
|
||||||
BeneficiaryWidgetResponseBean beneficiaryWidgetResponseBean = BeneficiaryWidgetResponseBean.builder()
|
BeneficiaryWidgetResponseBean beneficiaryWidgetResponseBean = BeneficiaryWidgetResponseBean.builder()
|
||||||
.numberOfApplications(0L).numberOfCalls(0L).numberOfIntegratedDocuments(0L).build();
|
.numberOfApplications(0L).numberOfCalls(0L).numberOfIntegratedDocuments(0L).build();
|
||||||
Long activeCalls = callRepository.countByStatus(CallStatusEnum.PUBLISH.getValue());
|
Long activeCalls = callRepository.countByStatusAndHubId(CallStatusEnum.PUBLISH.getValue(), userEntity.getHub().getId());
|
||||||
if (activeCalls != null) {
|
if (activeCalls != null) {
|
||||||
beneficiaryWidgetResponseBean.setNumberOfCalls(activeCalls);
|
beneficiaryWidgetResponseBean.setNumberOfCalls(activeCalls);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
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.CompanyEntity;
|
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||||
@@ -31,6 +33,7 @@ import net.gepafin.tendermanagement.service.AmazonS3Service;
|
|||||||
import net.gepafin.tendermanagement.service.UserService;
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
import net.gepafin.tendermanagement.util.Utils;
|
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.CustomValidationException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
@@ -38,7 +41,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
|||||||
@Component
|
@Component
|
||||||
public class DelegationDao {
|
public class DelegationDao {
|
||||||
|
|
||||||
private static final String DEFAULT_PLACEHOLDER = "____________________";
|
// private static final String DEFAULT_PLACEHOLDER = "____________________";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@@ -52,12 +55,18 @@ public class DelegationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DocumentRepository documentRepository;
|
private DocumentRepository documentRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private S3PathConfig s3ConfigBean;
|
||||||
|
|
||||||
@Value("${aws.s3.url.folder.delegation}")
|
@Value("${aws.s3.url.folder.delegation}")
|
||||||
private String s3Folder;
|
private String s3Folder;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserCompanyDelegationRepository userCompanyDelegationRepository;
|
private UserCompanyDelegationRepository userCompanyDelegationRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
|
|
||||||
public ByteArrayOutputStream generateDocument(Map<String, String> placeholders, String templateName) {
|
public ByteArrayOutputStream generateDocument(Map<String, String> placeholders, String templateName) {
|
||||||
try {
|
try {
|
||||||
@@ -89,9 +98,10 @@ public class DelegationDao {
|
|||||||
return new XWPFDocument(templateStream);
|
return new XWPFDocument(templateStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ByteArrayOutputStream downloadCompanyDelegation(UserEntity userEntity, Long companyId, CompanyDelegationRequest companyDelegationRequest) {
|
public ByteArrayOutputStream downloadCompanyDelegation(HttpServletRequest request, Long companyId, CompanyDelegationRequest companyDelegationRequest) {
|
||||||
Map<String, String> placeholders = getDefaultPlaceholders();
|
Map<String, String> placeholders = getDefaultPlaceholders();
|
||||||
UserResponseBean user = userService.getUserById(userEntity.getId());
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
UserResponseBean user = userService.getUserById(request, userEntity.getId());
|
||||||
CompanyEntity companyEntity = companyDao.validateCompany(companyId);
|
CompanyEntity companyEntity = companyDao.validateCompany(companyId);
|
||||||
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||||
updatePlaceholdersForDelegation(user, companyEntity, placeholders, companyDelegationRequest);
|
updatePlaceholdersForDelegation(user, companyEntity, placeholders, companyDelegationRequest);
|
||||||
@@ -179,7 +189,7 @@ public class DelegationDao {
|
|||||||
userCompanyDelegationEntity.setStatus(UserCompanyDelegationStatusEnum.INACTIVE.getValue());
|
userCompanyDelegationEntity.setStatus(UserCompanyDelegationStatusEnum.INACTIVE.getValue());
|
||||||
userCompanyDelegationRepository.save(userCompanyDelegationEntity);
|
userCompanyDelegationRepository.save(userCompanyDelegationEntity);
|
||||||
}
|
}
|
||||||
UploadFileOnAmazonS3Response uploadFileOnAmazonS3Response = amazonS3Service.uploadFileOnAmazonS3(s3Folder, file);
|
UploadFileOnAmazonS3Response uploadFileOnAmazonS3Response = uploadFileOnAmazonS3ForCompanyDelegation(file);
|
||||||
userCompanyDelegationEntity = new UserCompanyDelegationEntity();
|
userCompanyDelegationEntity = new UserCompanyDelegationEntity();
|
||||||
userCompanyDelegationEntity.setCompanyId(companyId);
|
userCompanyDelegationEntity.setCompanyId(companyId);
|
||||||
userCompanyDelegationEntity.setUserId(userEntity.getId());
|
userCompanyDelegationEntity.setUserId(userEntity.getId());
|
||||||
@@ -192,7 +202,21 @@ public class DelegationDao {
|
|||||||
userCompanyDelegationRepository.save(userCompanyDelegationEntity);
|
userCompanyDelegationRepository.save(userCompanyDelegationEntity);
|
||||||
return convertUserCompanyDelegationToCompanyDelegationResponse(userCompanyDelegationEntity);
|
return convertUserCompanyDelegationToCompanyDelegationResponse(userCompanyDelegationEntity);
|
||||||
}
|
}
|
||||||
|
private UploadFileOnAmazonS3Response uploadFileOnAmazonS3ForCompanyDelegation(MultipartFile file) {
|
||||||
|
try {
|
||||||
|
String s3Path = generateS3PathForDelegation();
|
||||||
|
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private String generateS3PathForDelegation() {
|
||||||
|
try {
|
||||||
|
return s3ConfigBean.generateDocumentPathForDelegationAndSignedDocument(DocOtherSourceTypeEnum.USER_DELEGATION);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
|
||||||
|
}
|
||||||
|
}
|
||||||
private CompanyDelegationResponse convertUserCompanyDelegationToCompanyDelegationResponse(
|
private CompanyDelegationResponse convertUserCompanyDelegationToCompanyDelegationResponse(
|
||||||
UserCompanyDelegationEntity userCompanyDelegationEntity) {
|
UserCompanyDelegationEntity userCompanyDelegationEntity) {
|
||||||
return Utils.convertSourceObjectToDestinationObject(userCompanyDelegationEntity, CompanyDelegationResponse.class);
|
return Utils.convertSourceObjectToDestinationObject(userCompanyDelegationEntity, CompanyDelegationResponse.class);
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ package net.gepafin.tendermanagement.dao;
|
|||||||
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -24,6 +27,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class DocumentDao {
|
public class DocumentDao {
|
||||||
|
|
||||||
@@ -39,6 +43,12 @@ public class DocumentDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CallService callService;
|
private CallService callService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private S3PathConfig s3ConfigBean;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationRepository applicationFormRepository;
|
||||||
|
|
||||||
@Value("${aws.s3.url.folder}")
|
@Value("${aws.s3.url.folder}")
|
||||||
private String s3Folder;
|
private String s3Folder;
|
||||||
|
|
||||||
@@ -46,8 +56,7 @@ public class DocumentDao {
|
|||||||
List<DocumentEntity> documentEntities = new ArrayList<>();
|
List<DocumentEntity> documentEntities = new ArrayList<>();
|
||||||
Long source = resolveSourceId(sourceId, sourceType);
|
Long source = resolveSourceId(sourceId, sourceType);
|
||||||
for (MultipartFile file : files) {
|
for (MultipartFile file : files) {
|
||||||
UploadFileOnAmazonS3Response uploadFileOnAmazonS3Response = amazonS3Service.uploadFileOnAmazonS3(s3Folder,
|
UploadFileOnAmazonS3Response uploadFileOnAmazonS3Response = uploadFileOnAmazonS3(file, sourceType, sourceId);
|
||||||
file);
|
|
||||||
if (uploadFileOnAmazonS3Response != null) {
|
if (uploadFileOnAmazonS3Response != null) {
|
||||||
DocumentEntity documentEntity = new DocumentEntity();
|
DocumentEntity documentEntity = new DocumentEntity();
|
||||||
documentEntity.setFileName(uploadFileOnAmazonS3Response.getFileName());
|
documentEntity.setFileName(uploadFileOnAmazonS3Response.getFileName());
|
||||||
@@ -62,6 +71,30 @@ public class DocumentDao {
|
|||||||
documentRepository.saveAll(documentEntities);
|
documentRepository.saveAll(documentEntities);
|
||||||
return documentEntities.stream().map(callDao::convertToDocumentResponseBean).collect(Collectors.toList());
|
return documentEntities.stream().map(callDao::convertToDocumentResponseBean).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
private UploadFileOnAmazonS3Response uploadFileOnAmazonS3(MultipartFile file, DocumentSourceTypeEnum type, Long sourceId) {
|
||||||
|
|
||||||
|
Long applicationId = 0L;
|
||||||
|
Long callId = sourceId;
|
||||||
|
if (type == DocumentSourceTypeEnum.APPLICATION) {
|
||||||
|
applicationId = sourceId;
|
||||||
|
callId = applicationFormRepository.findCallIdById(applicationId);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String s3Path = generateS3Path(type, callId, applicationId);
|
||||||
|
log.info("Generated S3 path {}", s3Path);
|
||||||
|
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public String generateS3Path(DocumentSourceTypeEnum typeOfDocument, Long callId, Long applicationId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
return s3ConfigBean.generateDocumentPath(typeOfDocument, callId, applicationId);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
|
||||||
|
}
|
||||||
|
}
|
||||||
private Long resolveSourceId(Long sourceId, DocumentSourceTypeEnum sourceType) {
|
private Long resolveSourceId(Long sourceId, DocumentSourceTypeEnum sourceType) {
|
||||||
if (sourceType == DocumentSourceTypeEnum.CALL) {
|
if (sourceType == DocumentSourceTypeEnum.CALL) {
|
||||||
CallEntity callEntity = callService.validateCall(sourceId);
|
CallEntity callEntity = callService.validateCall(sourceId);
|
||||||
@@ -91,7 +124,8 @@ public class DocumentDao {
|
|||||||
|
|
||||||
public DocumentResponseBean updateDocument(Long documentId, MultipartFile file, DocumentTypeEnum documentTypeEnum) {
|
public DocumentResponseBean updateDocument(Long documentId, MultipartFile file, DocumentTypeEnum documentTypeEnum) {
|
||||||
DocumentEntity documentEntity = validateDocument(documentId);
|
DocumentEntity documentEntity = validateDocument(documentId);
|
||||||
UploadFileOnAmazonS3Response uploadFileOnAmazonS3Response = amazonS3Service.uploadFileOnAmazonS3(s3Folder, file);
|
String type = documentEntity.getSource();
|
||||||
|
UploadFileOnAmazonS3Response uploadFileOnAmazonS3Response = updateFileOnAmazonS3(file, DocumentSourceTypeEnum.valueOf(type), documentEntity.getSourceId());
|
||||||
if (uploadFileOnAmazonS3Response != null) {
|
if (uploadFileOnAmazonS3Response != null) {
|
||||||
documentEntity.setFileName(uploadFileOnAmazonS3Response.getFileName());
|
documentEntity.setFileName(uploadFileOnAmazonS3Response.getFileName());
|
||||||
documentEntity.setFilePath(uploadFileOnAmazonS3Response.getFilePath());
|
documentEntity.setFilePath(uploadFileOnAmazonS3Response.getFilePath());
|
||||||
@@ -102,7 +136,25 @@ public class DocumentDao {
|
|||||||
}
|
}
|
||||||
return callDao.convertToDocumentResponseBean(documentEntity);
|
return callDao.convertToDocumentResponseBean(documentEntity);
|
||||||
}
|
}
|
||||||
|
private UploadFileOnAmazonS3Response updateFileOnAmazonS3(MultipartFile file, DocumentSourceTypeEnum type, Long id) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
Long callId;
|
||||||
|
Long applicationId;
|
||||||
|
if(type.equals("APPLICATION")){
|
||||||
|
callId = applicationFormRepository.findCallIdById(id);
|
||||||
|
applicationId = id;
|
||||||
|
}else{
|
||||||
|
callId = id;
|
||||||
|
applicationId = 0L;
|
||||||
|
}
|
||||||
|
String s3Path = generateS3Path(type, callId, applicationId);
|
||||||
|
log.info("Generated S3 path {}", s3Path);
|
||||||
|
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
||||||
|
}
|
||||||
|
}
|
||||||
public DocumentResponseBean getDocument(Long documentId) {
|
public DocumentResponseBean getDocument(Long documentId) {
|
||||||
DocumentEntity documentEntity = validateDocument(documentId);
|
DocumentEntity documentEntity = validateDocument(documentId);
|
||||||
return callDao.convertToDocumentResponseBean(documentEntity);
|
return callDao.convertToDocumentResponseBean(documentEntity);
|
||||||
|
|||||||
@@ -50,7 +50,10 @@ public class EvaluationCriteriaDao {
|
|||||||
.validateLookUpData(evaluationCriteriaRequest.getLookUpDataId());
|
.validateLookUpData(evaluationCriteriaRequest.getLookUpDataId());
|
||||||
entity.setCall(callEntity);
|
entity.setCall(callEntity);
|
||||||
entity.setLookupData(looDataEntity);
|
entity.setLookupData(looDataEntity);
|
||||||
|
entity.setScore(0L);
|
||||||
|
if (evaluationCriteriaRequest.getScore() != null) {
|
||||||
entity.setScore(evaluationCriteriaRequest.getScore());
|
entity.setScore(evaluationCriteriaRequest.getScore());
|
||||||
|
}
|
||||||
entity = evaluationCriteriaRepository.save(entity);
|
entity = evaluationCriteriaRepository.save(entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.dao;
|
|||||||
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.LoginAttemptEntity;
|
import net.gepafin.tendermanagement.entities.LoginAttemptEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.model.response.LoginAttemptPageableResponseBean;
|
import net.gepafin.tendermanagement.model.response.LoginAttemptPageableResponseBean;
|
||||||
import net.gepafin.tendermanagement.repositories.LoginAttemptRepository;
|
import net.gepafin.tendermanagement.repositories.LoginAttemptRepository;
|
||||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
@@ -29,7 +30,7 @@ public class LoginAttemptDao {
|
|||||||
loginAttemptRepository.save(loginAttemptEntity);
|
loginAttemptRepository.save(loginAttemptEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginAttemptPageableResponseBean<List<LoginAttemptEntity>> getLoginAttemptsList(Integer pageNo, Integer pageLimit) {
|
public LoginAttemptPageableResponseBean<List<LoginAttemptEntity>> getLoginAttemptsList(UserEntity userEntity, Integer pageNo, Integer pageLimit) {
|
||||||
if (pageLimit == null || pageLimit <= 0) {
|
if (pageLimit == null || pageLimit <= 0) {
|
||||||
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||||
}
|
}
|
||||||
@@ -38,7 +39,7 @@ public class LoginAttemptDao {
|
|||||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Page<LoginAttemptEntity> page = loginAttemptRepository.findAll(PageRequest.of(pageNo - 1, pageLimit, Sort.by(GepafinConstant.ATTEMPT_DATE).descending()));
|
Page<LoginAttemptEntity> page = loginAttemptRepository.findByHubId(userEntity.getHub().getId(), PageRequest.of(pageNo - 1, pageLimit, Sort.by(GepafinConstant.ATTEMPT_DATE).descending()));
|
||||||
List<LoginAttemptEntity> list = new ArrayList<>();
|
List<LoginAttemptEntity> list = new ArrayList<>();
|
||||||
for (LoginAttemptEntity loginAttemptEntity : page.getContent()) {
|
for (LoginAttemptEntity loginAttemptEntity : page.getContent()) {
|
||||||
list.add(loginAttemptEntity);
|
list.add(loginAttemptEntity);
|
||||||
|
|||||||
@@ -14,13 +14,17 @@ import net.gepafin.tendermanagement.entities.*;
|
|||||||
import net.gepafin.tendermanagement.model.request.FieldLabelValuePairRequest;
|
import net.gepafin.tendermanagement.model.request.FieldLabelValuePairRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.service.CallService;
|
import net.gepafin.tendermanagement.service.CallService;
|
||||||
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
//import com.itextpdf.layout.element.
|
//import com.itextpdf.layout.element.
|
||||||
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -37,6 +41,7 @@ public class PdfDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private Validator validator;
|
private Validator validator;
|
||||||
|
|
||||||
|
public static final Logger log = LoggerFactory.getLogger(PdfDao.class);
|
||||||
|
|
||||||
public byte[] generatePdf(HttpServletRequest request,Long applicationId) {
|
public byte[] generatePdf(HttpServletRequest request,Long applicationId) {
|
||||||
try {
|
try {
|
||||||
@@ -55,7 +60,8 @@ public class PdfDao {
|
|||||||
// writer.setPageEvent(pageEvent);
|
// writer.setPageEvent(pageEvent);
|
||||||
document.open();
|
document.open();
|
||||||
// pageEvent.setTotalPages(writer.getPageNumber());
|
// pageEvent.setTotalPages(writer.getPageNumber());
|
||||||
addLogo(document, "https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/logo.jpg"); // Add your image path here
|
// addLogo(document, "logo.jpg"); // Add your image path here the migration code after cherry-pick
|
||||||
|
addLogo(document, "https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/logo.jpg");
|
||||||
|
|
||||||
|
|
||||||
BaseColor customColor = new BaseColor(0, 128, 0); // Adjust RGB values as needed
|
BaseColor customColor = new BaseColor(0, 128, 0); // Adjust RGB values as needed
|
||||||
@@ -77,18 +83,7 @@ public class PdfDao {
|
|||||||
|
|
||||||
ApplicationGetResponseBean applicationGetResponseBean=applicationDao.getApplicationByFormId(request, applicationId, null);
|
ApplicationGetResponseBean applicationGetResponseBean=applicationDao.getApplicationByFormId(request, applicationId, null);
|
||||||
for(FormApplicationResponse formApplicationResponse: applicationGetResponseBean.getForm()) {
|
for(FormApplicationResponse formApplicationResponse: applicationGetResponseBean.getForm()) {
|
||||||
document.add(new Paragraph(formApplicationResponse.getLabel(),sectionFont));
|
List<FieldLabelValuePairRequest> fieldLabelValuePairRequests = getFormFieldsToLabels(formApplicationResponse,writer,document);
|
||||||
document.add(new Paragraph(" ")); // Add line break
|
|
||||||
List<FieldLabelValuePairRequest> fieldLabelValuePairRequests = getFormFieldsToLabels(formApplicationResponse);
|
|
||||||
for (FieldLabelValuePairRequest pair : fieldLabelValuePairRequests) {
|
|
||||||
String label = pair.getLabel();
|
|
||||||
Object value = pair.getValue();
|
|
||||||
Integer pages=0;
|
|
||||||
pages=addLabelValuePair(writer,document, label, value, labelFont,valueFont,call.getName(),pages);
|
|
||||||
if(pages !=0 ){
|
|
||||||
// pageEvent.setTotalPages(writer.getPageNumber());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
addColoredLines(writer,document,greenColor);
|
addColoredLines(writer,document,greenColor);
|
||||||
document.add(new Paragraph(" ")); // Add line break
|
document.add(new Paragraph(" ")); // Add line break
|
||||||
}
|
}
|
||||||
@@ -164,15 +159,6 @@ public class PdfDao {
|
|||||||
|
|
||||||
addColoredLines(writer,document,greenColor);
|
addColoredLines(writer,document,greenColor);
|
||||||
|
|
||||||
// System.out.println(writer.getPageSize());
|
|
||||||
// System.out.println(document.getPageSize());
|
|
||||||
// System.out.println(document.getPageNumber());
|
|
||||||
// System.out.println(writer.getPageNumber());
|
|
||||||
// document.setPageCount(100);
|
|
||||||
// document.setPageCount(writer.getPageNumber());
|
|
||||||
// System.out.println(document.getPageNumber());
|
|
||||||
|
|
||||||
// Close the document
|
|
||||||
document.close();
|
document.close();
|
||||||
|
|
||||||
// Convert to byte array for response
|
// Convert to byte array for response
|
||||||
@@ -185,12 +171,13 @@ public class PdfDao {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer addLabelValuePair(PdfWriter writer,Document document, String label, Object value, Font labelFont,Font valueFont,String title,Integer totalPages) throws DocumentException {
|
private void addLabelValuePair(PdfWriter writer,Document document, String label, Object value, Font labelFont,Font valueFont,ContentResponseBean contentResponseBean) throws DocumentException {
|
||||||
// Add label
|
// Add label
|
||||||
|
Map<String, Boolean> stateFieldMap= new HashMap<>();
|
||||||
|
|
||||||
Paragraph labelParagraph = new Paragraph(label, labelFont);
|
Paragraph labelParagraph = new Paragraph(label, labelFont);
|
||||||
document.add(labelParagraph);
|
document.add(labelParagraph);
|
||||||
float leftMargin = 20f;
|
float leftMargin = 20f;
|
||||||
|
|
||||||
PdfContentByte canvas = writer.getDirectContent();
|
PdfContentByte canvas = writer.getDirectContent();
|
||||||
|
|
||||||
// Setting the color and width of the line
|
// Setting the color and width of the line
|
||||||
@@ -204,8 +191,6 @@ public class PdfDao {
|
|||||||
|
|
||||||
if (yPos <= 140) {
|
if (yPos <= 140) {
|
||||||
// If xEnd is less than or equal to 200, generate a new page
|
// If xEnd is less than or equal to 200, generate a new page
|
||||||
|
|
||||||
totalPages++;
|
|
||||||
document.newPage();
|
document.newPage();
|
||||||
} // Add a gap between the label and value
|
} // Add a gap between the label and value
|
||||||
document.add(new Paragraph(" ")); // Adding an empty paragraph for spacing
|
document.add(new Paragraph(" ")); // Adding an empty paragraph for spacing
|
||||||
@@ -235,45 +220,56 @@ public class PdfDao {
|
|||||||
|
|
||||||
// Finally, add the table to the document
|
// Finally, add the table to the document
|
||||||
document.add(valueTable);
|
document.add(valueTable);
|
||||||
} else {
|
|
||||||
boolean containsThreeValues = false; // Variable to track if any map contains three keys
|
|
||||||
List<Map<String, Object>> dataList = (List<Map<String, Object>>) value; // Cast Object to List of Maps
|
|
||||||
for (Map<String, Object> entry : dataList) {
|
|
||||||
if (entry.size() == 3) { // Check if the current map has three keys
|
|
||||||
containsThreeValues = true; // If found, set the variable to true
|
|
||||||
break; // No need to check further, exit loop
|
|
||||||
}
|
}
|
||||||
}
|
else if (!list.isEmpty() && list.get(0) instanceof Map<?, ?>) {
|
||||||
List<Map<String, String>> extractedData = new ArrayList<>(); // To hold extracted data
|
Object object = value;
|
||||||
for (Map<String, Object> entry : dataList) {
|
String stringvalue = Utils.convertToString(object);
|
||||||
Map<String, String> extractedMap = new HashMap<>(); // To hold the current extracted row of data
|
List<Map<String, Object>> fieldValueList = Utils.convertJsonStringIntoJsonList(stringvalue);
|
||||||
|
|
||||||
List<String> keys = new ArrayList<>(entry.keySet()); // Get all keys in the current map
|
document = createPdfTable(fieldValueList, document, contentResponseBean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
// Handle based on the number of keys in the map
|
String fieldValue=Utils.convertToString(value);
|
||||||
if (Boolean.FALSE.equals(containsThreeValues) && keys.size() == 2) {
|
Image img = null; // This may throw MalformedURLException
|
||||||
// Treat the first key as the "key" and second key as the "value"
|
if (fieldValue.trim().equalsIgnoreCase("true")) {
|
||||||
String heading = (String) entry.get(keys.get(0)); // Get value of first key
|
// Use images for tick and cross
|
||||||
String value1 = (String) entry.get(keys.get(1)); // Get value of second key
|
try {
|
||||||
extractedMap.put(heading,value1); // Store the first key's value as "heading"
|
// img = Image.getInstance("true.jpg"); update code after cherry-pick
|
||||||
} if (Boolean.TRUE.equals(containsThreeValues) ) {
|
img = Image.getInstance("https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/true.png");
|
||||||
String amount="";
|
} catch (IOException e) {
|
||||||
// Treat the first as number, second as description, third as amount
|
log.error("Error while uploading image for pdf for true");
|
||||||
if(keys.size()==3){
|
|
||||||
amount = (String) entry.get(keys.get(2)); // Third key's value
|
|
||||||
}
|
}
|
||||||
String number = (String) entry.get(keys.get(0)); // First key's value
|
img.scaleAbsolute(15, 15); // Resize the image if needed
|
||||||
String description = (String) entry.get(keys.get(1)); // Second key's value
|
|
||||||
|
|
||||||
// Store the combined result as a value in the map, with a suitable key
|
PdfPCell cell = new PdfPCell(img);
|
||||||
String combinedValue = number + "; " + description + "; " + amount; // Concatenate them as a single value
|
cell.setPadding(0); // Remove padding
|
||||||
extractedMap.put("combined", combinedValue); // Store as a single entry, key as "combined"
|
cell.setBorder(Rectangle.NO_BORDER); // Remove border
|
||||||
}
|
cell.setMinimumHeight(15f); // Set height to fit checkbox image
|
||||||
|
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||||
|
cell.setHorizontalAlignment(Element.ALIGN_LEFT); // Align the checkbox image to the left
|
||||||
|
|
||||||
extractedData.add(extractedMap); // Add each extracted map to the list
|
valueTable.addCell(cell); // Add cell with checkbox to the table
|
||||||
}
|
document.add(valueTable);
|
||||||
document=createPdfTable(extractedData,document);
|
} else if (fieldValue.trim().equalsIgnoreCase("false")) {
|
||||||
|
// Use images for tick and cross
|
||||||
|
try {
|
||||||
|
img = Image.getInstance("https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/false.png");
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("Error while uploading image for pdf for false");
|
||||||
}
|
}
|
||||||
|
img.scaleAbsolute(15, 15); // Resize the image if needed
|
||||||
|
|
||||||
|
PdfPCell cell = new PdfPCell(img);
|
||||||
|
cell.setPadding(0); // Remove padding
|
||||||
|
cell.setBorder(Rectangle.NO_BORDER); // Remove border
|
||||||
|
cell.setMinimumHeight(15f); // Set height to fit checkbox image
|
||||||
|
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||||
|
cell.setHorizontalAlignment(Element.ALIGN_LEFT); // Align the checkbox image to the left
|
||||||
|
|
||||||
|
valueTable.addCell(cell); // Add cell with checkbox to the table
|
||||||
|
document.add(valueTable);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PdfPCell valueCell = new PdfPCell(new Phrase(String.valueOf(value), valueFont));
|
PdfPCell valueCell = new PdfPCell(new Phrase(String.valueOf(value), valueFont));
|
||||||
@@ -288,151 +284,115 @@ public class PdfDao {
|
|||||||
document.add(valueTable);
|
document.add(valueTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
document.add(new Paragraph("\n")); // Add line break after each value
|
document.add(new Paragraph("\n")); // Add line break after each value
|
||||||
return totalPages;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Document createPdfTable(List<Map<String, String>> extractedData,Document document) throws DocumentException {
|
private Document createPdfTable(List<Map<String, Object>> extractedData, Document document, ContentResponseBean contentResponseBean) throws DocumentException {
|
||||||
// Create a PdfPTable with 2 columns
|
// Create a PdfPTable with dynamic column count based on stateFieldMap size
|
||||||
PdfPTable table = new PdfPTable(2); // Initial assumption for 2 columns
|
Map<String, String> stateFieldMap = new HashMap<>();
|
||||||
|
Map<String, Boolean> stateFieldBoolean = new HashMap<>();
|
||||||
|
|
||||||
|
// Populate stateFieldMap from contentResponseBean settings
|
||||||
|
contentResponseBean.getSettings().stream()
|
||||||
|
.filter(setting -> "table_columns".equals(setting.getName())) // Check for "table_columns"
|
||||||
|
.map(SettingResponseBean::getValue)
|
||||||
|
.filter(Objects::nonNull) // Ensure value is not null
|
||||||
|
.filter(settingValue -> settingValue instanceof Map) // Ensure value is a Map
|
||||||
|
.map(settingValue -> (Map<String, Object>) settingValue) // Cast to Map
|
||||||
|
.map(valueMap -> (List<Map<String, Object>>) valueMap.get("stateFieldData")) // Extract stateFieldData list
|
||||||
|
.filter(Objects::nonNull) // Ensure stateFieldData is not null
|
||||||
|
.flatMap(List::stream) // Flatten the list of field data maps
|
||||||
|
.forEach(fieldData -> {
|
||||||
|
String fieldName = (String) fieldData.get("name"); // Get the name field
|
||||||
|
String fieldDataValue = (String) fieldData.get("label"); // Get the predefined field
|
||||||
|
|
||||||
|
if (fieldName != null && fieldDataValue != null) {
|
||||||
|
stateFieldMap.put(fieldName, fieldDataValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
contentResponseBean.getSettings().stream()
|
||||||
|
.filter(setting -> "table_columns".equals(setting.getName())) // Check for "table_columns"
|
||||||
|
.map(SettingResponseBean::getValue)
|
||||||
|
.filter(Objects::nonNull) // Ensure value is not null
|
||||||
|
.filter(settingValue -> settingValue instanceof Map) // Ensure value is a Map
|
||||||
|
.map(settingValue -> (Map<String, Object>) settingValue) // Cast to Map
|
||||||
|
.map(valueMap -> (List<Map<String, Object>>) valueMap.get("stateFieldData")) // Extract stateFieldData list
|
||||||
|
.filter(Objects::nonNull) // Ensure stateFieldData is not null
|
||||||
|
.flatMap(List::stream) // Flatten the list of field data maps
|
||||||
|
.forEach(fieldData -> {
|
||||||
|
String fieldName = (String) fieldData.get("name"); // Get the name field
|
||||||
|
Boolean predefined = (Boolean) fieldData.get("predefined"); // Get the predefined field
|
||||||
|
if (fieldName != null && fieldName != null) {
|
||||||
|
stateFieldBoolean.put(fieldName, predefined);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
PdfPTable table = new PdfPTable(stateFieldMap.size()); // Number of columns equals the number of map entries
|
||||||
table.setWidthPercentage(100); // Set table width to 100%
|
table.setWidthPercentage(100); // Set table width to 100%
|
||||||
table.setTableEvent(new RoundedBorderEvent());
|
table.setTableEvent(new RoundedBorderEvent());
|
||||||
|
|
||||||
Font textFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new BaseColor(105, 105, 105)); // Gray text
|
Font textFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new BaseColor(105, 105, 105)); // Gray text
|
||||||
boolean combinedHeaderAdded = false; // Flag to track if headers for combined have been added
|
float rowHeight = 20f; // Example row height
|
||||||
float rowHeight = 50f; // Example row height, adjust as necessary
|
|
||||||
float maxTableHeight = 700f; // Maximum height of the table before a page break
|
float maxTableHeight = 700f; // Maximum height of the table before a page break
|
||||||
float[] columnWidths = {0.7f, 0.3f};
|
boolean headersAdded = false; // Flag to check if headers have been added
|
||||||
table.setWidths(columnWidths);
|
|
||||||
|
|
||||||
|
|
||||||
// Add table header
|
|
||||||
// Populate the table with extracted data and style rows
|
|
||||||
for (Map<String, String> row : extractedData) {
|
|
||||||
for (Map.Entry<String, String> entry : row.entrySet()) {
|
|
||||||
String key = entry.getKey(); // This will give you the key
|
|
||||||
String value = entry.getValue(); // This will give you the value
|
|
||||||
|
|
||||||
// Check if the current entry is for the combined section
|
|
||||||
if ("combined".equals(key)) {
|
|
||||||
// Ensure the combined header is added only once
|
|
||||||
if (!combinedHeaderAdded) {
|
|
||||||
// Create a new table for combined entries
|
|
||||||
table = new PdfPTable(3); // 3 columns for combined entries
|
|
||||||
|
|
||||||
PdfPCell headerCell1 = new PdfPCell(new Phrase("Number"));
|
|
||||||
headerCell1.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
|
||||||
headerCell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
||||||
headerCell1.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
|
|
||||||
table.addCell(headerCell1);
|
|
||||||
|
|
||||||
PdfPCell headerCell2 = new PdfPCell(new Phrase("Details"));
|
|
||||||
headerCell2.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
|
||||||
headerCell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
||||||
headerCell2.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
|
|
||||||
table.addCell(headerCell2);
|
|
||||||
|
|
||||||
PdfPCell headerCell3 = new PdfPCell(new Phrase("Amount"));
|
|
||||||
headerCell3.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
|
||||||
headerCell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
||||||
headerCell3.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
|
|
||||||
table.addCell(headerCell3);
|
|
||||||
|
|
||||||
combinedHeaderAdded = true; // Mark header as added
|
|
||||||
}
|
|
||||||
|
|
||||||
// Split the value for "combined" into separate parts
|
|
||||||
String[] combinedValues = value.split("; ");
|
|
||||||
|
|
||||||
// Check if we have 3 parts (number, description, amount)
|
|
||||||
String number = combinedValues[0]; // 1st part (number)
|
|
||||||
String description = combinedValues[1]; // 2nd part (description)
|
|
||||||
String amount = "";
|
|
||||||
if (combinedValues.length == 3) {
|
|
||||||
amount = combinedValues[2]; // 3rd part (amount)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create PDF cells using the split values
|
|
||||||
PdfPCell cellNumber = new PdfPCell(new Phrase(number, textFont)); // Cell for number
|
|
||||||
PdfPCell cellDescription = new PdfPCell(new Phrase(description, textFont)); // Cell for description
|
|
||||||
PdfPCell cellAmount = new PdfPCell(new Phrase(amount, textFont)); // Cell for amount
|
|
||||||
|
|
||||||
// Set row background color for combined values
|
|
||||||
cellNumber.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for combined rows
|
|
||||||
cellDescription.setBackgroundColor(new BaseColor(239, 243, 248));
|
|
||||||
cellAmount.setBackgroundColor(new BaseColor(239, 243, 248));
|
|
||||||
|
|
||||||
// Set cell height and add rounded borders
|
|
||||||
// cellNumber.setFixedHeight(rowHeight);
|
|
||||||
// cellDescription.setFixedHeight(rowHeight);
|
|
||||||
// cellAmount.setFixedHeight(rowHeight);
|
|
||||||
|
|
||||||
cellNumber.setMinimumHeight(20f); // Set minimum height for better appearance
|
|
||||||
cellDescription.setMinimumHeight(20f); // Set minimum height for better appearance
|
|
||||||
cellAmount.setMinimumHeight(20f); // Set minimum height for better appearance
|
|
||||||
|
|
||||||
cellNumber.setPadding(7f);
|
|
||||||
cellDescription.setPadding(7f);
|
|
||||||
cellAmount.setPadding(7f);
|
|
||||||
|
|
||||||
// Add the cells to the table only once
|
|
||||||
table.addCell(cellNumber);
|
|
||||||
table.addCell(cellDescription);
|
|
||||||
table.addCell(cellAmount);
|
|
||||||
|
|
||||||
|
|
||||||
|
List<String> trueKeys = new ArrayList<>();
|
||||||
|
List<String> falseKeys = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, Boolean> entry : stateFieldBoolean.entrySet()) {
|
||||||
|
if (Boolean.TRUE.equals(entry.getValue())) {
|
||||||
|
trueKeys.add(entry.getKey()); // Store true keys
|
||||||
} else {
|
} else {
|
||||||
if (!combinedHeaderAdded) {
|
falseKeys.add(entry.getKey()); // Store false keys
|
||||||
// Create a new table for combined entries
|
|
||||||
table= new PdfPTable(2); // 3 columns for combined entries
|
|
||||||
table.setWidthPercentage(100);
|
|
||||||
|
|
||||||
PdfPCell headerCell1 = new PdfPCell(new Phrase("Details"));
|
|
||||||
headerCell1.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
|
||||||
headerCell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
||||||
headerCell1.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
|
|
||||||
table.addCell(headerCell1);
|
|
||||||
|
|
||||||
PdfPCell headerCell2 = new PdfPCell(new Phrase("Amount"));
|
|
||||||
headerCell2.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
|
||||||
headerCell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
||||||
headerCell2.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
|
|
||||||
table.addCell(headerCell2);
|
|
||||||
combinedHeaderAdded=true;
|
|
||||||
}
|
}
|
||||||
// Add cells for regular key-value pairs without headers
|
|
||||||
PdfPCell cellKey = new PdfPCell(new Phrase(key, textFont));
|
|
||||||
PdfPCell cellValue = new PdfPCell(new Phrase(value, textFont));
|
|
||||||
|
|
||||||
// Set background color for both cells
|
|
||||||
cellKey.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for other rows
|
|
||||||
cellValue.setBackgroundColor(new BaseColor(239, 243, 248));
|
|
||||||
|
|
||||||
cellKey.setPadding(7f);
|
|
||||||
cellValue.setPadding(7f);
|
|
||||||
// Set cell height and add rounded borders
|
|
||||||
cellKey.setFixedHeight(rowHeight);
|
|
||||||
cellValue.setFixedHeight(rowHeight);
|
|
||||||
|
|
||||||
// Add the cells to the table
|
|
||||||
table.addCell(cellKey);
|
|
||||||
table.addCell(cellValue);
|
|
||||||
}
|
}
|
||||||
|
List<String> orderedKeys = new ArrayList<>(trueKeys);
|
||||||
|
orderedKeys.addAll(falseKeys);
|
||||||
|
// Iterate through extracted data to populate the table
|
||||||
|
for (Map<String, Object> row : extractedData) {
|
||||||
|
// Add headers once
|
||||||
|
if (!headersAdded) {
|
||||||
|
for (String key : orderedKeys) {
|
||||||
|
String headerValue = stateFieldMap.get(key); // Header text
|
||||||
|
PdfPCell headerCell = new PdfPCell(new Phrase(headerValue)); // Create a new PdfPCell for the header
|
||||||
|
headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
||||||
|
headerCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||||
|
headerCell.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
|
||||||
|
|
||||||
|
table.addCell(headerCell); // Add the header cell to the table
|
||||||
|
}
|
||||||
|
headersAdded = true; // Prevent headers from being added again
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add data rows matching stateFieldMap keys
|
||||||
|
for (Map.Entry<String, String> stateField : stateFieldMap.entrySet()) {
|
||||||
|
for (String key : orderedKeys) { // Iterate over the ordered keys
|
||||||
|
Object value = row.getOrDefault(key, ""); // Fetch value or use empty string if key not present
|
||||||
|
PdfPCell dynamicCell = new PdfPCell(new Phrase(value != null ? value.toString() : "", textFont));
|
||||||
|
dynamicCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell
|
||||||
|
dynamicCell.setMinimumHeight(rowHeight);
|
||||||
|
dynamicCell.setPadding(7f);
|
||||||
|
|
||||||
|
table.addCell(dynamicCell); // Add the dynamically created cell to the table
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if adding another row would exceed max height
|
||||||
if (table.getTotalHeight() + rowHeight > maxTableHeight) {
|
if (table.getTotalHeight() + rowHeight > maxTableHeight) {
|
||||||
// Start a new page if needed
|
document.add(table); // Add the table to the document
|
||||||
|
document.newPage(); // Start a new page
|
||||||
|
table = new PdfPTable(stateFieldMap.size()); // Create a new table for the new page
|
||||||
|
table.setWidthPercentage(100); // Reset table width
|
||||||
|
|
||||||
|
headersAdded = false; // Reset the header flag for the new page
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the last table to the document
|
||||||
document.add(table);
|
document.add(table);
|
||||||
table = new PdfPTable(2); // Reset table for new page
|
|
||||||
table.setWidthPercentage(100); // Reset width percentage
|
|
||||||
combinedHeaderAdded = false; // Reset header flag
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
document.add(table); // Add the last table before returning
|
|
||||||
|
|
||||||
|
|
||||||
// Check if adding a new row would exceed the maximum height
|
|
||||||
// Return the populated table
|
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RoundedBorderEvent implements PdfPTableEvent {
|
public static class RoundedBorderEvent implements PdfPTableEvent {
|
||||||
@Override
|
@Override
|
||||||
public void tableLayout(PdfPTable table, float[][] widths, float[] heights,
|
public void tableLayout(PdfPTable table, float[][] widths, float[] heights,
|
||||||
@@ -453,83 +413,99 @@ public class PdfDao {
|
|||||||
canvas.stroke();
|
canvas.stroke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public List<FieldLabelValuePairRequest> getFormFieldsToLabels(FormApplicationResponse responseBean) {
|
public List<FieldLabelValuePairRequest> getFormFieldsToLabels(FormApplicationResponse responseBean,PdfWriter writer,Document document) {
|
||||||
List<FieldLabelValuePairRequest> labelValuePairs = new ArrayList<>();
|
List<FieldLabelValuePairRequest> labelValuePairs = new ArrayList<>();
|
||||||
|
|
||||||
// Iterate through each form in the application response
|
Font labelFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12,new BaseColor(113,121,126)); // Light grey);
|
||||||
|
Font valueFont=FontFactory.getFont(FontFactory.HELVETICA_BOLD,10,new BaseColor(178, 190, 181));
|
||||||
|
|
||||||
|
|
||||||
|
// Get form fields and contents from the response
|
||||||
List<ApplicationFormFieldResponseBean> formFields = responseBean.getFormFields();
|
List<ApplicationFormFieldResponseBean> formFields = responseBean.getFormFields();
|
||||||
List<ContentResponseBean> contents = responseBean.getContent();
|
List<ContentResponseBean> contents = responseBean.getContent();
|
||||||
|
|
||||||
// Iterate through each formField in the current form
|
// Iterate through each content in the response
|
||||||
for (ApplicationFormFieldResponseBean formField : formFields) {
|
for (ContentResponseBean content : contents) {
|
||||||
String fieldId = formField.getFieldId();
|
String contentId = content.getId(); // Content ID
|
||||||
Object fieldValue = formField.getFieldValue();
|
String label = content.getLabel(); // Content label
|
||||||
|
String name = content.getName(); // Content name
|
||||||
|
Object fieldValue = null;
|
||||||
|
|
||||||
// Find the content in the form that matches the fieldId
|
String contentLabel = content.getSettings().stream()
|
||||||
Optional<ContentResponseBean> matchingContent = contents.stream()
|
.filter(setting -> "label".equals(setting.getName())) // Filter settings by name
|
||||||
.filter(content -> content.getId().equals(fieldId))
|
.map(SettingResponseBean::getValue) // Extract the value from the matching setting
|
||||||
|
.map(Object::toString) // Convert the value to a string
|
||||||
|
.findFirst() // Get the first matching value
|
||||||
|
.orElse(null); // If no match is found, set label to null
|
||||||
|
// Find the form field in the response that matches the contentId
|
||||||
|
Optional<ApplicationFormFieldResponseBean> matchingFormField = formFields.stream()
|
||||||
|
.filter(formField -> formField.getFieldId().equals(contentId))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
|
// If a matching form field is found, process its value
|
||||||
|
if (matchingFormField.isPresent()) {
|
||||||
|
ApplicationFormFieldResponseBean formField = matchingFormField.get();
|
||||||
|
fieldValue = formField.getFieldValue();
|
||||||
|
|
||||||
// If the content with the matching fieldId is found, create a label-value pair
|
// If fieldValue is null, set it to an empty string
|
||||||
if (matchingContent.isPresent()) {
|
if (fieldValue == null) {
|
||||||
String name = matchingContent.get().getName();
|
fieldValue = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process 'fileupload' and 'checkboxes' cases as in the original logic
|
||||||
if (name.equals("fileupload")) {
|
if (name.equals("fileupload")) {
|
||||||
|
|
||||||
// Step 1: Check if fieldValue is an instance of List<DocumentResponseBean>
|
|
||||||
if (fieldValue instanceof List<?> && ((List<?>) fieldValue).stream().allMatch(item -> item instanceof DocumentResponseBean)) {
|
if (fieldValue instanceof List<?> && ((List<?>) fieldValue).stream().allMatch(item -> item instanceof DocumentResponseBean)) {
|
||||||
// Step 2: Safely cast to List<DocumentResponseBean>
|
|
||||||
List<DocumentResponseBean> documentList = (List<DocumentResponseBean>) fieldValue;
|
List<DocumentResponseBean> documentList = (List<DocumentResponseBean>) fieldValue;
|
||||||
|
|
||||||
// Step 3: Extract names from the document list
|
|
||||||
List<String> names = documentList.stream()
|
List<String> names = documentList.stream()
|
||||||
.map(DocumentResponseBean::getName) // Extract the name from each DocumentResponseBean
|
.map(DocumentResponseBean::getName)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
fieldValue = names;
|
fieldValue = names;
|
||||||
}
|
}
|
||||||
}
|
} else if (name.equals("checkboxes")) {
|
||||||
if(name.equals("checkboxes")) {
|
|
||||||
List<String> check = (List<String>) fieldValue;
|
List<String> check = (List<String>) fieldValue;
|
||||||
List<SettingResponseBean> settingResponseBeans = matchingContent.get().getSettings();
|
List<SettingResponseBean> settingResponseBeans = content.getSettings();
|
||||||
for (SettingResponseBean settingResponseBean : settingResponseBeans) {
|
|
||||||
// Initialize a list to hold matched labels for each SettingResponseBean
|
|
||||||
List<String> matchedLabels = new ArrayList<>();
|
List<String> matchedLabels = new ArrayList<>();
|
||||||
if (settingResponseBean.getValue() instanceof List<?>) {
|
|
||||||
|
|
||||||
List<?> valueList = (List<?>) settingResponseBean.getValue();
|
for (SettingResponseBean settingResponseBean : settingResponseBeans) {
|
||||||
if (!valueList.isEmpty() && valueList.get(0) instanceof Map<?, ?>) {
|
if (settingResponseBean.getValue() instanceof List<?>) {
|
||||||
// Cast to List<Map<String, String>>
|
List<Map<String, String>> options = (List<Map<String, String>>) settingResponseBean.getValue();
|
||||||
List<Map<String, String>> options = (List<Map<String, String>>) valueList;
|
|
||||||
for (Map<String, String> field : options) {
|
for (Map<String, String> field : options) {
|
||||||
for (String val : check) {
|
for (String val : check) {
|
||||||
String name1 = field.get("name");
|
String name1 = field.get("name");
|
||||||
if (val.equals(name1)) { // Check if the key exists in the current field map
|
if (val.equals(name1)) {
|
||||||
String label = field.get("label"); // Extract the label
|
String labelVal = field.get("label");
|
||||||
if (field != null) { // Check if the value is not null
|
if (labelVal != null) {
|
||||||
matchedLabels.add(label); // Add the value to the matchedValues list
|
matchedLabels.add(labelVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fieldValue = matchedLabels;
|
fieldValue = matchedLabels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Further processing of field value (e.g., finding labels in options)
|
||||||
|
fieldValue = findLabelInOptions(content.getSettings(), fieldValue);
|
||||||
|
} else {
|
||||||
|
// If no matching form field is found, store contentId with an empty string
|
||||||
|
fieldValue = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
addLabelValuePair(writer,document, contentLabel, fieldValue, labelFont,valueFont,content);
|
||||||
|
} catch (DocumentException e) {
|
||||||
|
log.error("Error checking object: " + e.getMessage(), e);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
// } labelValuePairs.add(new FieldLabelValuePairRequest(contentLabel, fieldValue));
|
||||||
String label = matchingContent.get().getLabel();
|
|
||||||
// Add the label-value pair to the list
|
|
||||||
if (fieldValue != null && !fieldValue.toString().trim().isEmpty()) {
|
|
||||||
fieldValue = findLabelInOptions(matchingContent.get().getSettings(), fieldValue);
|
|
||||||
labelValuePairs.add(new FieldLabelValuePairRequest(label, fieldValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return labelValuePairs;
|
return labelValuePairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Object findLabelInOptions(List<SettingResponseBean> settings, Object valueToFind) {
|
public static Object findLabelInOptions(List<SettingResponseBean> settings, Object valueToFind) {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
|||||||
104
src/main/java/net/gepafin/tendermanagement/dao/S3ConfigDao.java
Normal file
104
src/main/java/net/gepafin/tendermanagement/dao/S3ConfigDao.java
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.S3ConfigReq;
|
||||||
|
import net.gepafin.tendermanagement.model.response.S3ConfigBean;
|
||||||
|
import net.gepafin.tendermanagement.repositories.S3ConfigRepository;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class S3ConfigDao {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(S3ConfigDao.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
S3ConfigRepository s3ConfigRepository;
|
||||||
|
|
||||||
|
public S3ConfigBean addS3Path(S3ConfigReq s3PathConfigurationReq) {
|
||||||
|
|
||||||
|
log.info("Adding s3 s3PathConfigurationReq structure with it's type..");
|
||||||
|
S3ConfigEntity s3PathConfigurationEntity = convertToS3pathEntity(s3PathConfigurationReq);
|
||||||
|
s3PathConfigurationEntity = s3ConfigRepository.save(s3PathConfigurationEntity);
|
||||||
|
log.info("Added s3 path config details {} to DB.", s3PathConfigurationEntity);
|
||||||
|
return convertToS3pathBean(s3PathConfigurationEntity);
|
||||||
|
}
|
||||||
|
private S3ConfigEntity convertToS3pathEntity(S3ConfigReq s3PathConfigReq) {
|
||||||
|
|
||||||
|
S3ConfigEntity s3PathConfigEntity = new S3ConfigEntity();
|
||||||
|
s3PathConfigEntity.setPath(s3PathConfigReq.getPath());
|
||||||
|
s3PathConfigEntity.setType(s3PathConfigReq.getType());
|
||||||
|
s3PathConfigEntity.setBucketName(s3PathConfigReq.getBucketName());
|
||||||
|
return s3PathConfigEntity;
|
||||||
|
}
|
||||||
|
private S3ConfigBean convertToS3pathBean(S3ConfigEntity s3PathConfigReq) {
|
||||||
|
|
||||||
|
S3ConfigBean s3PathConfigBean = new S3ConfigBean();
|
||||||
|
s3PathConfigBean.setPath(s3PathConfigReq.getPath());
|
||||||
|
s3PathConfigBean.setType(s3PathConfigReq.getType());
|
||||||
|
s3PathConfigBean.setBucketName(s3PathConfigReq.getBucketName());
|
||||||
|
return s3PathConfigBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<S3ConfigEntity> getS3PathByType(String type) {
|
||||||
|
|
||||||
|
log.info("Fetching S3-Path structure by type: {}", type);
|
||||||
|
Optional<S3ConfigEntity> s3PathData = s3ConfigRepository.getPathByType(type);
|
||||||
|
if (s3PathData == null) {
|
||||||
|
log.error("No S3-Path found for type: {}", type);
|
||||||
|
throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.S3_PATH_STRUCTURE_NOT_FOUND_BY_TYPE_MSG));
|
||||||
|
}
|
||||||
|
log.info("Fetched S3-Path: {} for type: {}", s3PathData, type);
|
||||||
|
return s3PathData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public S3ConfigEntity deleteS3PathConfigById(Long id) {
|
||||||
|
|
||||||
|
log.info("Checking s3-path associated with this id {} to delete....", id);
|
||||||
|
S3ConfigEntity s3PathConfigData = s3ConfigRepository.findS3PathConfigurationById(id);
|
||||||
|
if (s3PathConfigData == null) {
|
||||||
|
log.error("No S3-Path found for id: {}", id);
|
||||||
|
throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.S3_PATH_STRUCTURE_NOT_FOUND_BY_ID_MSG));
|
||||||
|
} else {
|
||||||
|
log.info("Found s3-path associated with this id {} to delete.", id);
|
||||||
|
s3ConfigRepository.deleteById(id);
|
||||||
|
log.error("Deleted s3-path configuration successfully for id: {}", id);
|
||||||
|
return s3PathConfigData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public S3ConfigBean updateS3PathConfiguration(S3ConfigReq s3PathConfigurationReq, Long id) {
|
||||||
|
|
||||||
|
log.info("Updating S3-path Configuration.");
|
||||||
|
S3ConfigEntity s3PathConfigDataExists = s3ConfigRepository.findS3PathConfigurationById(id);
|
||||||
|
if (s3PathConfigDataExists == null) {
|
||||||
|
log.error("No S3-Path found for id: {}", id);
|
||||||
|
throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.S3_PATH_STRUCTURE_NOT_FOUND_BY_ID_MSG));
|
||||||
|
} else {
|
||||||
|
Optional<S3ConfigEntity> s3PathData = s3ConfigRepository.getPathByType(s3PathConfigurationReq.getType());
|
||||||
|
if(s3PathData != null){
|
||||||
|
log.error("S3-Path type already exist. {}", s3PathData);
|
||||||
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.S3_PATH_CONFIG_DUPLICATE_TYPE_ALREADY_EXIST));
|
||||||
|
}
|
||||||
|
S3ConfigEntity s3PathConfigurationEntity = convertToS3pathEntity(s3PathConfigurationReq);
|
||||||
|
setIfUpdated(s3PathConfigurationEntity::getPath, s3PathConfigurationEntity::setPath, s3PathConfigurationReq.getPath());
|
||||||
|
setIfUpdated(s3PathConfigurationEntity::getBucketName, s3PathConfigurationEntity::setBucketName, s3PathConfigurationReq.getBucketName());
|
||||||
|
setIfUpdated(s3PathConfigurationEntity::getType, s3PathConfigurationEntity::setType, s3PathConfigurationReq.getType());
|
||||||
|
// s3PathConfigurationEntity.setType(s3PathConfigurationReq.getType());
|
||||||
|
// s3PathConfigurationEntity.setPath(s3PathConfigurationReq.getPath());
|
||||||
|
// s3PathConfigurationEntity.setBucketName(s3PathConfigurationReq.getBucketName());
|
||||||
|
s3ConfigRepository.save(s3PathConfigurationEntity);
|
||||||
|
log.info("Updated S3-path-configuration successfully.");
|
||||||
|
return convertToS3pathBean(s3PathConfigurationEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.repositories.S3ConfigRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class S3PathConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
S3ConfigRepository s3ConfigRepository;
|
||||||
|
|
||||||
|
public String generateDocumentPath(DocumentSourceTypeEnum type, Long callId, Long applicationId) {
|
||||||
|
|
||||||
|
S3ConfigEntity config = getDocumentPath(type);
|
||||||
|
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId);
|
||||||
|
}
|
||||||
|
public String generateDocumentPathForOther(DocOtherSourceTypeEnum type, Long callId, Long applicationId) {
|
||||||
|
|
||||||
|
S3ConfigEntity config = getDocumentPathForOther(type);
|
||||||
|
return config.getParentFolder() + "/" + buildS3Path(config.getPath(), callId, applicationId);
|
||||||
|
}
|
||||||
|
private String buildS3Path(String pathTemplate, Long callId, Long applicationId) {
|
||||||
|
|
||||||
|
return pathTemplate.replace("{call_id}", callId != null && callId != 0L ? "call_" + callId : "").replace("{application_id}", applicationId != null && applicationId != 0L ? "application_" + applicationId : "");
|
||||||
|
}
|
||||||
|
public String generateDocumentPathForDelegationAndSignedDocument(DocOtherSourceTypeEnum type) {
|
||||||
|
|
||||||
|
S3ConfigEntity config = getDocumentPathForOther(type);
|
||||||
|
return config.getParentFolder() + "/" + config.getPath();
|
||||||
|
}
|
||||||
|
private S3ConfigEntity getDocumentPath(DocumentSourceTypeEnum type) {
|
||||||
|
|
||||||
|
return s3ConfigRepository.getPathByType(type.name()).orElseThrow(() -> new IllegalArgumentException("No path configuration found for type: " + type));
|
||||||
|
}
|
||||||
|
private S3ConfigEntity getDocumentPathForOther(DocOtherSourceTypeEnum type) {
|
||||||
|
|
||||||
|
return s3ConfigRepository.getPathByType(type.name()).orElseThrow(() -> new IllegalArgumentException("No path configuration found for type: " + type));
|
||||||
|
}
|
||||||
|
public String getBucketNameForOtherType(DocOtherSourceTypeEnum type){
|
||||||
|
return s3ConfigRepository.getBucketNameByType(type);
|
||||||
|
}
|
||||||
|
public String getBucketNameForCallAppType(DocumentSourceTypeEnum type){
|
||||||
|
return s3ConfigRepository.getBucketNameByType(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import net.gepafin.tendermanagement.config.SamlSuccessHandler;
|
|||||||
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.BeneficiaryEntity;
|
import net.gepafin.tendermanagement.entities.BeneficiaryEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.HubEntity;
|
||||||
import net.gepafin.tendermanagement.entities.RoleEntity;
|
import net.gepafin.tendermanagement.entities.RoleEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||||
@@ -84,17 +85,17 @@ public class UserDao {
|
|||||||
if(StringUtils.isEmpty(userReq.getHubUuid())) {
|
if(StringUtils.isEmpty(userReq.getHubUuid())) {
|
||||||
userReq.setHubUuid(defaultHubUuid);
|
userReq.setHubUuid(defaultHubUuid);
|
||||||
}
|
}
|
||||||
validateUserRequest(request, tempToken, userReq);
|
HubEntity hub = hubService.getHubByUuid(userReq.getHubUuid());
|
||||||
|
validateUserRequest(request, tempToken, userReq, hub);
|
||||||
validatePassword(userReq.getPassword(), userReq.getConfPassword(), tempToken);
|
validatePassword(userReq.getPassword(), userReq.getConfPassword(), tempToken);
|
||||||
|
|
||||||
RoleEntity roleEntity = getRoleEntity(userReq.getRoleId());
|
RoleEntity roleEntity = getRoleEntity(userReq.getRoleId());
|
||||||
BeneficiaryEntity beneficiary = createBeneficiary(roleEntity, userReq);
|
BeneficiaryEntity beneficiary = createBeneficiary(roleEntity, userReq, hub);
|
||||||
UserEntity userEntity = convertUserRequestToUserEntity(beneficiary, roleEntity, userReq);
|
UserEntity userEntity = convertUserRequestToUserEntity(beneficiary, roleEntity, userReq, hub);
|
||||||
log.info("User created with ID: {}", userEntity.getId());
|
log.info("User created with ID: {}", userEntity.getId());
|
||||||
return authService.getJWTTokenBean(userEntity, Boolean.TRUE);
|
return authService.getJWTTokenBean(userEntity, Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BeneficiaryEntity createBeneficiary(RoleEntity roleEntity, UserReq userReq) {
|
private BeneficiaryEntity createBeneficiary(RoleEntity roleEntity, UserReq userReq, HubEntity hub) {
|
||||||
BeneficiaryEntity beneficiaryEntity = null;
|
BeneficiaryEntity beneficiaryEntity = null;
|
||||||
if (RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleEntity.getRoleType())) {
|
if (RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleEntity.getRoleType())) {
|
||||||
beneficiaryEntity = new BeneficiaryEntity();
|
beneficiaryEntity = new BeneficiaryEntity();
|
||||||
@@ -114,20 +115,22 @@ public class UserDao {
|
|||||||
beneficiaryEntity.setMarketing(userReq.getMarketing());
|
beneficiaryEntity.setMarketing(userReq.getMarketing());
|
||||||
beneficiaryEntity.setThirdParty(userReq.getThirdParty());
|
beneficiaryEntity.setThirdParty(userReq.getThirdParty());
|
||||||
beneficiaryEntity.setEmailPec(userReq.getEmailPec());
|
beneficiaryEntity.setEmailPec(userReq.getEmailPec());
|
||||||
|
beneficiaryEntity.setHubId(hub.getId());
|
||||||
beneficiaryEntity =beneficiaryRepository.save(beneficiaryEntity);
|
beneficiaryEntity =beneficiaryRepository.save(beneficiaryEntity);
|
||||||
}
|
}
|
||||||
return beneficiaryEntity;
|
return beneficiaryEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateUserRequest(HttpServletRequest request, String tempToken, UserReq userReq) {
|
private void validateUserRequest(HttpServletRequest request, String tempToken, UserReq userReq, HubEntity hub) {
|
||||||
|
|
||||||
if (tempToken == null) {
|
if (tempToken == null) {
|
||||||
validator.validateRequest(request,RoleStatusEnum.ROLE_SUPER_ADMIN);
|
validator.validateRequest(request,RoleStatusEnum.ROLE_SUPER_ADMIN);
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
userReq.setHubUuid(userEntity.getHub().getUniqueUuid());
|
||||||
}else {
|
}else {
|
||||||
samlSuccessHandler.validateToken(tempToken, userReq.getCodiceFiscale(), userReq.getHubUuid());
|
samlSuccessHandler.validateToken(tempToken, userReq.getCodiceFiscale(), userReq.getHubUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
RoleEntity role = roleService.validateRole(userReq.getRoleId());
|
|
||||||
if (Boolean.FALSE.equals(Utils.isValidEmail(userReq.getEmail()))) {
|
if (Boolean.FALSE.equals(Utils.isValidEmail(userReq.getEmail()))) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.VALIDATE_EMAIL));
|
Translator.toLocale(GepafinConstant.VALIDATE_EMAIL));
|
||||||
@@ -139,7 +142,7 @@ public class UserDao {
|
|||||||
Translator.toLocale(GepafinConstant.EMAIL_ALREADY_EXISTS));
|
Translator.toLocale(GepafinConstant.EMAIL_ALREADY_EXISTS));
|
||||||
}
|
}
|
||||||
if (Boolean.FALSE.equals(StringUtils.isEmpty(userReq.getCodiceFiscale()))
|
if (Boolean.FALSE.equals(StringUtils.isEmpty(userReq.getCodiceFiscale()))
|
||||||
&& userRepository.existsByBeneficiaryCodiceFiscale(userReq.getCodiceFiscale())) {
|
&& userRepository.existsByBeneficiaryCodiceFiscaleAndHubId(userReq.getCodiceFiscale(), hub.getId())) {
|
||||||
log.error("User creation failed: CodiceFiscale {} already exists", userReq.getCodiceFiscale());
|
log.error("User creation failed: CodiceFiscale {} already exists", userReq.getCodiceFiscale());
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.CODICE_FISCALE_EXISTS));
|
Translator.toLocale(GepafinConstant.CODICE_FISCALE_EXISTS));
|
||||||
@@ -151,11 +154,15 @@ public class UserDao {
|
|||||||
if (tempToken != null) {
|
if (tempToken != null) {
|
||||||
userReq.setRoleId(null);
|
userReq.setRoleId(null);
|
||||||
}
|
}
|
||||||
if(tempToken == null && Boolean.TRUE.equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(role.getRoleType()))){
|
|
||||||
|
if (tempToken == null) {
|
||||||
|
RoleEntity role = roleService.validateRole(userReq.getRoleId());
|
||||||
|
if (Boolean.TRUE.equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(role.getRoleType()))) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.CANNOT_CREATE_BENEFICIARY_USER));
|
Translator.toLocale(GepafinConstant.CANNOT_CREATE_BENEFICIARY_USER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void validatePassword(String password, String confirmPassword, String tempToken) {
|
private void validatePassword(String password, String confirmPassword, String tempToken) {
|
||||||
if (StringUtils.isEmpty(password) || StringUtils.isEmpty(confirmPassword)) {
|
if (StringUtils.isEmpty(password) || StringUtils.isEmpty(confirmPassword)) {
|
||||||
@@ -206,7 +213,7 @@ public class UserDao {
|
|||||||
return convertUserEntityToUserResponse(userEntity);
|
return convertUserEntityToUserResponse(userEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserEntity convertUserRequestToUserEntity(BeneficiaryEntity beneficiary, RoleEntity roleEntity, UserReq userReq) {
|
private UserEntity convertUserRequestToUserEntity(BeneficiaryEntity beneficiary, RoleEntity roleEntity, UserReq userReq, HubEntity hub) {
|
||||||
UserEntity userEntity = new UserEntity();
|
UserEntity userEntity = new UserEntity();
|
||||||
if(Boolean.FALSE.equals(StringUtils.isEmpty(userReq.getPassword()))) {
|
if(Boolean.FALSE.equals(StringUtils.isEmpty(userReq.getPassword()))) {
|
||||||
userEntity.setPassword(passwordEncoder.encode(userReq.getPassword()));
|
userEntity.setPassword(passwordEncoder.encode(userReq.getPassword()));
|
||||||
@@ -215,7 +222,7 @@ public class UserDao {
|
|||||||
userEntity.setEmail(userReq.getEmail());
|
userEntity.setEmail(userReq.getEmail());
|
||||||
userEntity.setStatus(UserStatusEnum.ACTIVE.getValue());
|
userEntity.setStatus(UserStatusEnum.ACTIVE.getValue());
|
||||||
userEntity.setBeneficiary(beneficiary);
|
userEntity.setBeneficiary(beneficiary);
|
||||||
userEntity.setHub(hubService.getHubByUuid(userReq.getHubUuid()));
|
userEntity.setHub(hub);
|
||||||
if (Boolean.FALSE.equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleEntity.getRoleType()))) {
|
if (Boolean.FALSE.equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleEntity.getRoleType()))) {
|
||||||
userEntity.setFirstName(userReq.getFirstName());
|
userEntity.setFirstName(userReq.getFirstName());
|
||||||
userEntity.setLastName(userReq.getLastName());
|
userEntity.setLastName(userReq.getLastName());
|
||||||
|
|||||||
@@ -39,4 +39,7 @@ public class ApplicationEntity extends BaseEntity {
|
|||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "PROTOCOL_NUMBER")
|
@JoinColumn(name = "PROTOCOL_NUMBER")
|
||||||
private ProtocolEntity protocol;
|
private ProtocolEntity protocol;
|
||||||
|
|
||||||
|
@Column(name = "HUB_ID")
|
||||||
|
private Long hubId;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
@Table(name = "application_evaluation")
|
||||||
|
public class ApplicationEvaluationEntity extends BaseEntity{
|
||||||
|
@Column(name = "application_Id")
|
||||||
|
private Long applicationId;
|
||||||
|
@Column(name = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Column(name = "criteria")
|
||||||
|
private String criteria;
|
||||||
|
|
||||||
|
@Column(name = "checklist")
|
||||||
|
private String checklist;
|
||||||
|
|
||||||
|
@Column(name = "file")
|
||||||
|
private String file;
|
||||||
|
|
||||||
|
@Column(name = "note")
|
||||||
|
private String note;
|
||||||
|
|
||||||
|
@Column(name = "status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Column(name="IS_DELETED")
|
||||||
|
private Boolean isDeleted;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "assigned_applications_id", nullable = true)
|
||||||
|
private AssignedApplicationsEntity assignedApplicationsEntity;
|
||||||
|
}
|
||||||
@@ -61,4 +61,7 @@ public class BeneficiaryEntity extends BaseEntity {
|
|||||||
|
|
||||||
@Column(name = "EMAIL_PEC")
|
@Column(name = "EMAIL_PEC")
|
||||||
private String emailPec;
|
private String emailPec;
|
||||||
|
|
||||||
|
@Column(name = "HUB_ID")
|
||||||
|
private Long hubId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import java.math.BigDecimal;
|
|||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -56,4 +58,9 @@ public class CompanyEntity extends BaseEntity{
|
|||||||
|
|
||||||
@Column(name = "CONTACT_EMAIL")
|
@Column(name = "CONTACT_EMAIL")
|
||||||
private String contactEmail;
|
private String contactEmail;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "HUB_ID")
|
||||||
|
private HubEntity hub;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "s3_path_configuration")
|
||||||
|
@Data
|
||||||
|
public class S3ConfigEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column(name = "TYPE")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@Column(name = "PATH")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
@Column(name = "BUCKET_NAME")
|
||||||
|
private String bucketName;
|
||||||
|
|
||||||
|
@Column(name = "PARENT_FOLDER")
|
||||||
|
private String parentFolder;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
public enum ApplicationEvaluationStatusTypeEnum {
|
||||||
|
OPEN ("OPEN"),
|
||||||
|
SOCCORSO("SOCCORSO"),
|
||||||
|
CLOSE("CLOSE");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
ApplicationEvaluationStatusTypeEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,13 @@ public enum ApplicationStatusTypeEnum {
|
|||||||
|
|
||||||
DRAFT("DRAFT"),
|
DRAFT("DRAFT"),
|
||||||
SUBMIT("SUBMIT"),
|
SUBMIT("SUBMIT"),
|
||||||
AWAIT("AWAIT"),
|
AWAITING("AWAITING"),
|
||||||
READY("READY"),
|
READY("READY"),
|
||||||
DISCARD("DISCARD");
|
DISCARD("DISCARD"),
|
||||||
|
SOCCORSO("SOCCORSO"),
|
||||||
|
APPROVED("APPROVED"),
|
||||||
|
REJECTED("REJECTED"),
|
||||||
|
EVALUATION("EVALUATION");
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package net.gepafin.tendermanagement.enums;
|
|||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
public enum AssignedApplicationEnum {
|
public enum AssignedApplicationEnum {
|
||||||
ASSIGNED("ASSIGNED"),
|
OPEN ("OPEN"),
|
||||||
APPROVED("APPROVED"),
|
SOCCORSO("SOCCORSO"),
|
||||||
REJECTED("REJECTED");
|
CLOSE("CLOSE");
|
||||||
|
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
public enum DocOtherSourceTypeEnum {
|
||||||
|
USER_SIGNED_DOCUMENT("USER_SIGNED_DOCUMENT"),
|
||||||
|
USER_DELEGATION("USER_DELEGATION"),
|
||||||
|
TEMPLATE("TEMPLATE");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
DocOtherSourceTypeEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
@Data
|
||||||
|
public class ApplicationEvaluationRequest {
|
||||||
|
|
||||||
|
private List<CriteriaRequest> criteria;
|
||||||
|
private List<ChecklistRequest> checklist;
|
||||||
|
private List<FieldRequest> field;
|
||||||
|
private String note;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChecklistRequest {
|
||||||
|
private Long id;
|
||||||
|
private Boolean valid;
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@ package net.gepafin.tendermanagement.model.request;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CriteriaRequest {
|
||||||
|
private Long id;
|
||||||
|
private Long score;
|
||||||
|
private Boolean valid;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FieldRequest {
|
||||||
|
private String id;
|
||||||
|
private Boolean valid;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class S3ConfigReq {
|
||||||
|
@NotNull
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String bucketName;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private String parentFolder;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;public class UpdateApplicationEvaluationRequest {
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApplicationEvaluationResponse {
|
||||||
|
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long applicationId;
|
||||||
|
private Long assignedApplicationId;
|
||||||
|
private String note;
|
||||||
|
private ApplicationEvaluationStatusTypeEnum status;
|
||||||
|
private Long minScore;
|
||||||
|
private List<CriteriaResponse> criteria;
|
||||||
|
private List<ChecklistResponse> checklist;
|
||||||
|
private List<FieldResponse> files;
|
||||||
|
private LocalDateTime createdDate;
|
||||||
|
private LocalDateTime updatedDate;
|
||||||
|
private String beneficiary;
|
||||||
|
private Long protocolNumber;
|
||||||
|
private String callName;
|
||||||
|
private LocalDateTime submissionDate;
|
||||||
|
private LocalDateTime evaluationDate;
|
||||||
|
}
|
||||||
@@ -14,6 +14,13 @@ public class AssignedApplicationsResponse extends BaseBean {
|
|||||||
private AssignedApplicationEnum status;
|
private AssignedApplicationEnum status;
|
||||||
private String note;
|
private String note;
|
||||||
private LocalDateTime assignedAt;
|
private LocalDateTime assignedAt;
|
||||||
|
private Long protocolNumber;
|
||||||
|
private String callName;
|
||||||
|
private String beneficiaryName;
|
||||||
|
private LocalDateTime submissionDate;
|
||||||
|
private LocalDateTime callStartDate;
|
||||||
|
private LocalDateTime callEndDate;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ public class CallDetailsResponseBean {
|
|||||||
|
|
||||||
private List<LocalDateTime> dates;
|
private List<LocalDateTime> dates;
|
||||||
|
|
||||||
|
private Boolean confidi;
|
||||||
|
|
||||||
private CallStatusEnum status;
|
private CallStatusEnum status;
|
||||||
|
|
||||||
private Long regionId;
|
private Long regionId;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChecklistResponse {
|
||||||
|
private Long id;
|
||||||
|
private String label;
|
||||||
|
private Boolean valid;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CriteriaMappedField {
|
||||||
|
private String id;
|
||||||
|
private String fieldLabel;
|
||||||
|
private String fieldValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CriteriaResponse {
|
||||||
|
private Long id;
|
||||||
|
private String label;
|
||||||
|
private Long score;
|
||||||
|
private Long maxScore;
|
||||||
|
private List<CriteriaMappedField> criteriaMappedFields;
|
||||||
|
private Boolean valid;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FieldResponse {
|
||||||
|
private String id;
|
||||||
|
private String label;
|
||||||
|
private Boolean valid;
|
||||||
|
private List<DocumentResponseBean> fileDetail ;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class S3ConfigBean {
|
||||||
|
private String path;
|
||||||
|
private String type;
|
||||||
|
private String bucketName;
|
||||||
|
private String parentFolder;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ApplicationEvaluationRepository extends JpaRepository<ApplicationEvaluationEntity, Long> {
|
||||||
|
|
||||||
|
Optional<ApplicationEvaluationEntity> findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
||||||
|
|
||||||
|
Optional<ApplicationEvaluationEntity> findByAssignedApplicationsEntity_IdAndIsDeletedFalse(Long assignedApplicationId);
|
||||||
|
|
||||||
|
Optional<ApplicationEvaluationEntity> findByApplicationIdAndAssignedApplicationsEntity_IdAndIsDeletedFalse(Long applicationId, Long assignedApplicationId);
|
||||||
|
|
||||||
|
Optional<ApplicationEvaluationEntity> findFirstByIsDeletedFalseOrderByCreatedDateDesc();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -23,6 +23,17 @@ public interface ApplicationFormFieldRepository extends JpaRepository<Applicatio
|
|||||||
|
|
||||||
public List<ApplicationFormFieldEntity> findByFieldValueInAndApplicationFormApplicationId(
|
public List<ApplicationFormFieldEntity> findByFieldValueInAndApplicationFormApplicationId(
|
||||||
List<String> fieldValue, Long applicationId);
|
List<String> fieldValue, Long applicationId);
|
||||||
|
/**
|
||||||
|
* Find ApplicationFormField entity by Field ID, Form ID, and Application ID.
|
||||||
|
*
|
||||||
|
* @param fieldId The Field ID to search.
|
||||||
|
* @param formId The Form ID to search.
|
||||||
|
* @param applicationId The Application ID to search.
|
||||||
|
* @return Optional of ApplicationFormFieldEntity
|
||||||
|
*/
|
||||||
|
Optional<ApplicationFormFieldEntity> findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||||
|
String fieldId, Long formId, Long applicationId);
|
||||||
|
|
||||||
|
|
||||||
public ApplicationFormFieldEntity findByFieldId(String FieldId);
|
public ApplicationFormFieldEntity findByFieldId(String FieldId);
|
||||||
|
|
||||||
|
|||||||
@@ -32,13 +32,14 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
|||||||
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.userId = :userId AND a.company.id = :companyId AND a.status = 'SUBMIT' ")
|
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.userId = :userId AND a.company.id = :companyId AND a.status = 'SUBMIT' ")
|
||||||
Long countSubmittedApplicationsByUserId(@Param("userId") Long userId, @Param("companyId") Long companyId);
|
Long countSubmittedApplicationsByUserId(@Param("userId") Long userId, @Param("companyId") Long companyId);
|
||||||
|
|
||||||
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.status = 'SUBMIT'")
|
|
||||||
Long countSubmittedApplications();
|
|
||||||
|
|
||||||
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.status = 'DRAFT'")
|
|
||||||
Long countDraftApplications();
|
|
||||||
|
|
||||||
List<ApplicationEntity> findByCompanyIdAndUserIdAndIsDeletedFalse(Long companyId,Long userId);
|
List<ApplicationEntity> findByCompanyIdAndUserIdAndIsDeletedFalse(Long companyId,Long userId);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.status = 'SUBMIT' And a.hubId = :hubId")
|
||||||
|
public Long countSubmittedApplicationsByHubId(@Param("hubId") Long hubId);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.status = 'DRAFT' And a.hubId = :hubId")
|
||||||
|
public Long countDraftApplicationsByHubId(@Param("hubId") Long hubId);
|
||||||
|
|
||||||
|
@Query("SELECT a.call.id FROM ApplicationEntity a WHERE a.id = :id")
|
||||||
|
Long findCallIdById(@Param("id") Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,24 @@
|
|||||||
package net.gepafin.tendermanagement.repositories;
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationSignedDocumentEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationSignedDocumentEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ApplicationSignedDocumentRepository extends JpaRepository<ApplicationSignedDocumentEntity, Long> {
|
public interface ApplicationSignedDocumentRepository extends JpaRepository<ApplicationSignedDocumentEntity, Long> {
|
||||||
|
|
||||||
ApplicationSignedDocumentEntity findByApplicationIdAndStatus(Long applicationId, String status);
|
ApplicationSignedDocumentEntity findByApplicationIdAndStatus(Long applicationId, String status);
|
||||||
|
|
||||||
|
Long findApplicationIdById(Long id);
|
||||||
|
|
||||||
|
@Query("SELECT a.id FROM ApplicationSignedDocumentEntity d JOIN d.application a WHERE d.id = :id")
|
||||||
|
List<Long> findApplicationIdIdsById(@Param("id") Long id);
|
||||||
|
|
||||||
|
@Query("SELECT d FROM ApplicationSignedDocumentEntity d WHERE d.status = :status")
|
||||||
|
List<ApplicationSignedDocumentEntity> findAllByIsStatus(@Param("status")String status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package net.gepafin.tendermanagement.repositories;
|
|||||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -9,5 +11,11 @@ import java.util.Optional;
|
|||||||
public interface AssignedApplicationsRepository extends JpaRepository<AssignedApplicationsEntity,Long>, JpaSpecificationExecutor<AssignedApplicationsEntity>{
|
public interface AssignedApplicationsRepository extends JpaRepository<AssignedApplicationsEntity,Long>, JpaSpecificationExecutor<AssignedApplicationsEntity>{
|
||||||
Optional<AssignedApplicationsEntity> findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
Optional<AssignedApplicationsEntity> findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
||||||
Optional<AssignedApplicationsEntity> findByIdAndIsDeletedFalse(Long id);
|
Optional<AssignedApplicationsEntity> findByIdAndIsDeletedFalse(Long id);
|
||||||
|
@Query("SELECT aa FROM AssignedApplicationsEntity aa WHERE aa.isDeleted = false " +
|
||||||
|
"AND (:applicationId IS NULL OR aa.application.id = :applicationId) " +
|
||||||
|
"AND (:id IS NULL OR aa.id = :id)")
|
||||||
|
Optional<AssignedApplicationsEntity> findByApplicationIdOrId(@Param("applicationId") Long applicationId,
|
||||||
|
@Param("id") Long id);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package net.gepafin.tendermanagement.repositories;
|
package net.gepafin.tendermanagement.repositories;
|
||||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -11,18 +11,38 @@ import java.util.List;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface CallRepository extends JpaRepository<CallEntity, Long> {
|
public interface CallRepository extends JpaRepository<CallEntity, Long> {
|
||||||
|
|
||||||
public CallEntity findByIdAndStatusNotIn(Long id, List<String> status);
|
// public CallEntity findByIdAndStatusNotIn(Long id, List<String> status);
|
||||||
List<CallEntity> findByStatusIn(List<String> callStatus);
|
|
||||||
|
|
||||||
public CallEntity findByIdAndStatus(Long id,String status);
|
// List<CallEntity> findByStatusIn(List<String> callStatus);
|
||||||
|
|
||||||
public Long countByStatus(String status);
|
// public CallEntity findByIdAndStatus(Long id,String status);
|
||||||
|
|
||||||
@Query("SELECT COALESCE(SUM(c.amount), 0) FROM CallEntity c WHERE c.status = 'PUBLISH'")
|
// public Long countByStatus(String status);
|
||||||
BigDecimal findTotalAmountOfPublishedCalls();
|
|
||||||
|
// @Query("SELECT COALESCE(SUM(c.amount), 0) FROM CallEntity c WHERE c.status = 'PUBLISH'")
|
||||||
|
// BigDecimal findTotalAmountOfPublishedCalls();
|
||||||
|
|
||||||
@Query("SELECT c.name, COUNT(a.id) " +
|
@Query("SELECT c.name, COUNT(a.id) " +
|
||||||
"FROM CallEntity c LEFT JOIN ApplicationEntity a ON c.id = a.call.id " +
|
"FROM CallEntity c LEFT JOIN ApplicationEntity a ON c.id = a.call.id " +
|
||||||
"GROUP BY c.name")
|
"GROUP BY c.name")
|
||||||
List<Object[]> findApplicationsPerCall();
|
List<Object[]> findApplicationsPerCall();
|
||||||
|
|
||||||
|
|
||||||
|
@Query("SELECT c FROM CallEntity c JOIN ApplicationEntity a ON c.id = a.call.id WHERE a.id = :applicationId")
|
||||||
|
CallEntity findCallEntityByApplicationId(Long applicationId);
|
||||||
|
// @Query("SELECT c.name, COUNT(a.id) " +
|
||||||
|
// "FROM CallEntity c LEFT JOIN ApplicationEntity a ON c.id = a.call.id " +
|
||||||
|
// "GROUP BY c.name")
|
||||||
|
// List<Object[]> findApplicationsPerCall();
|
||||||
|
|
||||||
|
public List<CallEntity> findByStatusInAndHubId(List<String> callStatus, Long hubId);
|
||||||
|
|
||||||
|
public CallEntity findByIdAndStatusAndHubId(Long id, String status, Long hubId);
|
||||||
|
|
||||||
|
public Long countByStatusAndHubId(String status, Long hubId);
|
||||||
|
|
||||||
|
public CallEntity findByIdAndStatusNotInAndHubId(Long id, List<String> status, Long hubId);
|
||||||
|
|
||||||
|
@Query("SELECT COALESCE(SUM(c.amount), 0) FROM CallEntity c WHERE c.status = 'PUBLISH' And c.hub.id = :hubId")
|
||||||
|
BigDecimal findTotalAmountOfPublishedCallsAndHubId(@Param("hubId") Long hubId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,5 @@ public interface CallTargetAudienceChecklistRepository extends JpaRepository<Cal
|
|||||||
Optional<CallTargetAudienceChecklistEntity> findById(@Param("id") Long id);
|
Optional<CallTargetAudienceChecklistEntity> findById(@Param("id") Long id);
|
||||||
|
|
||||||
List<CallTargetAudienceChecklistEntity> findByCallIdAndLookupDataTypeAndIsDeletedFalse(Long id, String type);
|
List<CallTargetAudienceChecklistEntity> findByCallIdAndLookupDataTypeAndIsDeletedFalse(Long id, String type);
|
||||||
|
List<CallTargetAudienceChecklistEntity> findByCallId(Long callId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||||
@@ -11,13 +12,14 @@ import net.gepafin.tendermanagement.entities.CompanyEntity;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface CompanyRepository extends JpaRepository<CompanyEntity, Long> {
|
public interface CompanyRepository extends JpaRepository<CompanyEntity, Long> {
|
||||||
|
|
||||||
List<CompanyEntity> findByIdIn(List<Long> companyIds);
|
List<CompanyEntity> findByIdInAndHubId(List<Long> companyIds, Long hubId);
|
||||||
|
|
||||||
Boolean existsByVatNumber(String vatNumber);
|
Boolean existsByVatNumberAndHubId(String vatNumber, Long hubId);
|
||||||
CompanyEntity findByVatNumber(String vatNumber);
|
|
||||||
|
|
||||||
@Query("SELECT COUNT(c) FROM CompanyEntity c")
|
@Query("SELECT COUNT(c) FROM CompanyEntity c where c.hub.id = :hubId")
|
||||||
long countTotalCompanies();
|
long countTotalCompaniesByHubId(@Param("hubId") Long hubId);
|
||||||
|
|
||||||
|
CompanyEntity findByVatNumberAndHubId(String vatNumber, Long hubId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.springframework.stereotype.Repository;
|
|||||||
public interface DocumentRepository extends JpaRepository<DocumentEntity, Long> {
|
public interface DocumentRepository extends JpaRepository<DocumentEntity, Long> {
|
||||||
|
|
||||||
@Query("SELECT d FROM DocumentEntity d WHERE d.id = :id AND d.isDeleted = false")
|
@Query("SELECT d FROM DocumentEntity d WHERE d.id = :id AND d.isDeleted = false")
|
||||||
Optional<DocumentEntity> findById(@Param("id") Long id);
|
Optional<DocumentEntity> findByIdAndNotDeleted(@Param("id") Long id);
|
||||||
|
|
||||||
// List<DocumentEntity> findBySourceIdAndTypeAndIsDeletedFalse(Long sourceId, String type);
|
// List<DocumentEntity> findBySourceIdAndTypeAndIsDeletedFalse(Long sourceId, String type);
|
||||||
|
|
||||||
@@ -25,5 +25,7 @@ public interface DocumentRepository extends JpaRepository<DocumentEntity, Long>
|
|||||||
|
|
||||||
Optional<DocumentEntity> findByIdAndSourceIdAndSourceAndIsDeletedFalse(Long id, Long sourceId, String source);
|
Optional<DocumentEntity> findByIdAndSourceIdAndSourceAndIsDeletedFalse(Long id, Long sourceId, String source);
|
||||||
|
|
||||||
|
@Query("SELECT d FROM DocumentEntity d WHERE d.isDeleted = false")
|
||||||
|
List<DocumentEntity> findAllByIsDeleteFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,6 @@ public interface EvaluationCriteriaRepository extends JpaRepository<EvaluationCr
|
|||||||
Optional<EvaluationCriteriaEntity> findById(@Param("id") Long id);
|
Optional<EvaluationCriteriaEntity> findById(@Param("id") Long id);
|
||||||
|
|
||||||
List<EvaluationCriteriaEntity> findByCallIdAndLookupDataTypeAndIsDeletedFalse(Long callId, String type);
|
List<EvaluationCriteriaEntity> findByCallIdAndLookupDataTypeAndIsDeletedFalse(Long callId, String type);
|
||||||
|
List<EvaluationCriteriaEntity> findByCallId(Long callId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
package net.gepafin.tendermanagement.repositories;
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.LoginAttemptEntity;
|
import net.gepafin.tendermanagement.entities.LoginAttemptEntity;
|
||||||
|
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface LoginAttemptRepository extends JpaRepository<LoginAttemptEntity,Long> {
|
public interface LoginAttemptRepository extends JpaRepository<LoginAttemptEntity,Long> {
|
||||||
|
|
||||||
|
@Query("SELECT la FROM LoginAttemptEntity la LEFT JOIN UserEntity u ON u.email = la.username WHERE u.hub.id = :hubId")
|
||||||
|
Page<LoginAttemptEntity> findByHubId(@Param("hubId") Long hubId, PageRequest pageRequest);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface S3ConfigRepository extends JpaRepository<S3ConfigEntity, Long> {
|
||||||
|
Optional<S3ConfigEntity> getPathByType(String type);
|
||||||
|
|
||||||
|
S3ConfigEntity findS3PathConfigurationById(Long id);
|
||||||
|
|
||||||
|
String getBucketNameByType(DocumentSourceTypeEnum type);
|
||||||
|
|
||||||
|
String getBucketNameByType(DocOtherSourceTypeEnum type);
|
||||||
|
|
||||||
|
@Query("Select s3.parentFolder From S3ConfigEntity s3 Where s3.type = :s")
|
||||||
|
String getPathByTypeOther(String s);
|
||||||
|
}
|
||||||
@@ -2,9 +2,15 @@ package net.gepafin.tendermanagement.repositories;
|
|||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import net.gepafin.tendermanagement.entities.UserCompanyDelegationEntity;
|
import net.gepafin.tendermanagement.entities.UserCompanyDelegationEntity;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface UserCompanyDelegationRepository extends JpaRepository<UserCompanyDelegationEntity, Long> {
|
public interface UserCompanyDelegationRepository extends JpaRepository<UserCompanyDelegationEntity, Long> {
|
||||||
|
|
||||||
UserCompanyDelegationEntity findByUserIdAndCompanyIdAndStatus(Long userId, Long companyId, String status);
|
UserCompanyDelegationEntity findByUserIdAndCompanyIdAndStatus(Long userId, Long companyId, String status);
|
||||||
|
|
||||||
|
@Query("SELECT d FROM UserCompanyDelegationEntity d where d.status = :status")
|
||||||
|
List<UserCompanyDelegationEntity> findAllByStatus(@Param("status") String status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,21 +10,9 @@ import java.util.Optional;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
||||||
|
|
||||||
// Optional<UserEntity> findByEmailIgnoreCase(String email);
|
|
||||||
|
|
||||||
// boolean existsByEmailIgnoreCase(String email);
|
|
||||||
|
|
||||||
// UserEntity findByEmail(String email);
|
|
||||||
|
|
||||||
Optional<UserEntity> findByBeneficiaryCodiceFiscale(String codiceFiscale);
|
|
||||||
|
|
||||||
boolean existsByBeneficiaryCodiceFiscale(String codiceFiscale);
|
|
||||||
|
|
||||||
UserEntity findByBeneficiaryId(Long beneficiaryId);
|
UserEntity findByBeneficiaryId(Long beneficiaryId);
|
||||||
|
|
||||||
Long countByStatusAndRoleEntityRoleType(String status, String roleName);
|
Optional<UserEntity> findByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
|
||||||
|
|
||||||
Optional<UserEntity> findByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubId);
|
|
||||||
|
|
||||||
boolean existsByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
|
boolean existsByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
|
||||||
|
|
||||||
@@ -35,4 +23,6 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
|||||||
Long countByStatusAndRoleEntityRoleTypeAndHubId(String status, String roleName, Long hubId);
|
Long countByStatusAndRoleEntityRoleTypeAndHubId(String status, String roleName, Long hubId);
|
||||||
|
|
||||||
Optional<UserEntity> findByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
Optional<UserEntity> findByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
||||||
|
|
||||||
|
boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ public interface UserWithCompanyRepository extends JpaRepository<UserWithCompany
|
|||||||
@Query("SELECT u.companyId FROM UserWithCompanyEntity u WHERE u.userId = :userId AND u.isDeleted = false")
|
@Query("SELECT u.companyId FROM UserWithCompanyEntity u WHERE u.userId = :userId AND u.isDeleted = false")
|
||||||
List<Long> findActiveCompanyIdsByUserId(@Param("userId") Long userId);
|
List<Long> findActiveCompanyIdsByUserId(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Optional<UserWithCompanyEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(Long userId, Long companyId);
|
Optional<UserWithCompanyEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(Long userId, Long companyId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.request.UpdateApplicationEvaluationRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ApplicationEvaluationService {
|
||||||
|
ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationRequest applicationEvaluationRequest,Long assignedApplicationsId);
|
||||||
|
void deleteApplicationEvaluation(HttpServletRequest request,Long id);
|
||||||
|
|
||||||
|
ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId,Long assignedApplicationId);
|
||||||
|
ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long applicationEvaluationId, ApplicationEvaluationStatusTypeEnum status);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ public interface AssignedApplicationsService {
|
|||||||
|
|
||||||
void deleteApplication(HttpServletRequest request, Long id);
|
void deleteApplication(HttpServletRequest request, Long id);
|
||||||
|
|
||||||
List<AssignedApplicationsResponse> getAllAssignedApplications(Long userId);
|
List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId);
|
||||||
AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, AssignedApplicationsRequest assignedApplicationsRequest);
|
AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, AssignedApplicationsRequest assignedApplicationsRequest);
|
||||||
AssignedApplicationsResponse getAssignedApplicationById(Long id);
|
AssignedApplicationsResponse getAssignedApplicationById(HttpServletRequest request, Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,6 @@ public interface CallService {
|
|||||||
|
|
||||||
CallEntity validateCall(Long callId);
|
CallEntity validateCall(Long callId);
|
||||||
|
|
||||||
CallEntity validatePublishedCall(Long callId);
|
CallEntity validatePublishedCall(Long callId, Long hubId);
|
||||||
byte[] downloadCallDocumentsAsZip(Long callId);
|
byte[] downloadCallDocumentsAsZip(HttpServletRequest request, Long callId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface LoginAttemptService {
|
public interface LoginAttemptService {
|
||||||
|
|
||||||
LoginAttemptPageableResponseBean<List<LoginAttemptEntity>> getLoginAttemptsList(Integer pageNo, Integer pageLimit);
|
LoginAttemptPageableResponseBean<List<LoginAttemptEntity>> getLoginAttemptsList(HttpServletRequest request, Integer pageNo, Integer pageLimit);
|
||||||
|
|
||||||
void createLoginAttempt(LoginAttemptReq loginAttemptReq, HttpServletRequest request);
|
void createLoginAttempt(LoginAttemptReq loginAttemptReq, HttpServletRequest request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.S3ConfigReq;
|
||||||
|
import net.gepafin.tendermanagement.model.response.S3ConfigBean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public interface S3ConfigService {
|
||||||
|
S3ConfigBean addS3Path(S3ConfigReq s3Path);
|
||||||
|
|
||||||
|
Optional<S3ConfigEntity> getS3PathByType(String type);
|
||||||
|
|
||||||
|
S3ConfigEntity deleteS3PathById(Long id);
|
||||||
|
|
||||||
|
S3ConfigBean updateS3PathConfiguration(S3ConfigReq s3PathConfigurationReq, Long id);
|
||||||
|
}
|
||||||
@@ -17,11 +17,11 @@ import java.util.List;
|
|||||||
public interface UserService {
|
public interface UserService {
|
||||||
JWTToken createUser(HttpServletRequest request, String tempToken, UserReq userReq);
|
JWTToken createUser(HttpServletRequest request, String tempToken, UserReq userReq);
|
||||||
|
|
||||||
UserResponseBean updateUser(Long userId, UpdateUserReq userReq);
|
UserResponseBean updateUser(HttpServletRequest request, Long userId, UpdateUserReq userReq);
|
||||||
|
|
||||||
UserResponseBean getUserById(Long userId);
|
UserResponseBean getUserById(HttpServletRequest request, Long userId);
|
||||||
|
|
||||||
void deleteUser(Long userId);
|
void deleteUser(HttpServletRequest request, Long userId);
|
||||||
|
|
||||||
JWTToken login(LoginReq loginReq,HttpServletRequest request);
|
JWTToken login(LoginReq loginReq,HttpServletRequest request);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
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.AssignedApplicationsEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.request.UpdateApplicationEvaluationRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
|
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||||
|
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
|
||||||
|
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.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationEvaluationDao applicationEvaluationDao;
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
@Autowired
|
||||||
|
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationRequest req,Long assignedApplicationsId) {
|
||||||
|
AssignedApplicationsEntity assignedApplication = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationsId).orElseThrow(()->
|
||||||
|
new ResourceNotFoundException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_MSG)));
|
||||||
|
UserEntity user=validator.validatePreInstructor(request,assignedApplication.getUserId());
|
||||||
|
return applicationEvaluationDao.createOrUpdateApplicationEvaluation(user,req,assignedApplication.getApplication().getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(
|
||||||
|
HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
|
||||||
|
|
||||||
|
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
|
||||||
|
assignedApplicationsRepository.findByApplicationIdOrId(applicationId, assignedApplicationId);
|
||||||
|
|
||||||
|
AssignedApplicationsEntity assignedApplications = assignedApplicationsOptional
|
||||||
|
.orElseThrow(() -> new CustomValidationException(
|
||||||
|
Status.BAD_REQUEST,
|
||||||
|
Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG)
|
||||||
|
));
|
||||||
|
UserEntity user = validator.validatePreInstructor(request, assignedApplications.getUserId());
|
||||||
|
return applicationEvaluationDao.getApplicationEvaluationByApplicationId(
|
||||||
|
user,
|
||||||
|
assignedApplications.getApplication().getId(),
|
||||||
|
assignedApplications.getId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void deleteApplicationEvaluation(HttpServletRequest request,Long id) {
|
||||||
|
validator.getUserIdFromToken(request);
|
||||||
|
applicationEvaluationDao.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long applicationId, ApplicationEvaluationStatusTypeEnum status) {
|
||||||
|
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId).orElse(null);
|
||||||
|
if(assignedApplications==null){
|
||||||
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG));
|
||||||
|
}
|
||||||
|
validator.validatePreInstructor(request, assignedApplications.getUserId());
|
||||||
|
return applicationEvaluationDao.updateApplicationEvaluationStatus(applicationId, status);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,6 +65,7 @@ public class ApplicationServiceImpl implements ApplicationService {
|
|||||||
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);
|
||||||
CompanyEntity companyEntity = validator.validateUserWithCompany(request, companyId);
|
CompanyEntity companyEntity = validator.validateUserWithCompany(request, companyId);
|
||||||
|
validator.validateUserWithCall(userEntity, callId);
|
||||||
return applicationDao.createApplicationByCallId(companyEntity, applicationRequest, callId, userEntity);
|
return applicationDao.createApplicationByCallId(companyEntity, applicationRequest, callId, userEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +115,6 @@ public class ApplicationServiceImpl implements ApplicationService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId) {
|
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId) {
|
||||||
return applicationDao.validateApplication(request, applicationId);
|
return applicationDao.validateApplication(request, applicationId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,32 +26,32 @@ public class AssignedApplicationsServiceImpl implements AssignedApplicationsServ
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public AssignedApplicationsResponse createAssignedApplications(HttpServletRequest request, Long applicationId, Long userId, AssignedApplicationsRequest assignedApplicationsRequest) {
|
public AssignedApplicationsResponse createAssignedApplications(HttpServletRequest request, Long applicationId, Long userId, AssignedApplicationsRequest assignedApplicationsRequest) {
|
||||||
UserEntity assignedByUser= validator.validateUser(request);
|
UserEntity assignedByUser= validator.validateUser(request);
|
||||||
|
validator.validatePreInstructor(request, userId);
|
||||||
return assignedApplicationsDao.createAssignedApplications(applicationId,userId,assignedByUser, assignedApplicationsRequest);
|
return assignedApplicationsDao.createAssignedApplications(applicationId,userId,assignedByUser, assignedApplicationsRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteApplication(HttpServletRequest request, Long id) {
|
public void deleteApplication(HttpServletRequest request, Long id) {
|
||||||
assignedApplicationsDao.deleteById(id);
|
assignedApplicationsDao.deleteById(request, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<AssignedApplicationsResponse> getAllAssignedApplications(Long userId) {
|
public List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId) {
|
||||||
return assignedApplicationsDao.getAllAssignedApplications(userId);
|
return assignedApplicationsDao.getAllAssignedApplications(request, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, AssignedApplicationsRequest updatedAssignedApplicationRequest) {
|
public AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, AssignedApplicationsRequest updatedAssignedApplicationRequest) {
|
||||||
UserEntity updatedByUser= validator.validateUser(request);
|
return assignedApplicationsDao.updateAssignedApplication(request, id, updatedAssignedApplicationRequest);
|
||||||
return assignedApplicationsDao.updateAssignedApplication(id,updatedAssignedApplicationRequest,updatedByUser);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public AssignedApplicationsResponse getAssignedApplicationById(Long id) {
|
public AssignedApplicationsResponse getAssignedApplicationById(HttpServletRequest request, Long id) {
|
||||||
return assignedApplicationsDao.getAssignedApplicationById(id);
|
return assignedApplicationsDao.getAssignedApplicationById(request, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,10 +211,11 @@ public class AuthenticationService {
|
|||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.INVALID_TOKEN_MSG));
|
Translator.toLocale(GepafinConstant.INVALID_TOKEN_MSG));
|
||||||
}
|
}
|
||||||
|
HubEntity hub = hubService.getHubByUuid(samlResponseLogEntity.getHubUuid());
|
||||||
Map<String, List<Object>> userAttributes = Utils
|
Map<String, List<Object>> userAttributes = Utils
|
||||||
.convertStringIntoMap(samlResponseLogEntity.getAuthenticationObject());
|
.convertStringIntoMap(samlResponseLogEntity.getAuthenticationObject());
|
||||||
String cf = userAttributes.get("CodiceFiscale").get(0).toString();
|
String cf = userAttributes.get("CodiceFiscale").get(0).toString();
|
||||||
if (userRepository.existsByBeneficiaryCodiceFiscale(cf)) {
|
if (userRepository.existsByBeneficiaryCodiceFiscaleAndHubId(cf, hub.getId())) {
|
||||||
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
Translator.toLocale(GepafinConstant.USER_ALREADY_EXIST_MSG));
|
Translator.toLocale(GepafinConstant.USER_ALREADY_EXIST_MSG));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
|
|||||||
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
|
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
|
||||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
|
||||||
import net.gepafin.tendermanagement.service.BeneficiaryPreferredCallService;
|
import net.gepafin.tendermanagement.service.BeneficiaryPreferredCallService;
|
||||||
import net.gepafin.tendermanagement.service.UserService;
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
@@ -17,7 +16,6 @@ import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationExceptio
|
|||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
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.validation.annotation.Validated;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -26,10 +24,10 @@ public class BeneficiaryPreferredCallServiceImpl implements BeneficiaryPreferred
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BeneficiaryPreferredCallDao beneficiaryPreferredCallDao;
|
private BeneficiaryPreferredCallDao beneficiaryPreferredCallDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Validator validator;
|
private Validator validator;
|
||||||
@Autowired
|
|
||||||
private UserRepository userRepository;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@@ -37,22 +35,22 @@ public class BeneficiaryPreferredCallServiceImpl implements BeneficiaryPreferred
|
|||||||
@Override
|
@Override
|
||||||
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest request, BeneficiaryPreferredCallReq beneficiaryPreferredCallRequest) {
|
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest request, BeneficiaryPreferredCallReq beneficiaryPreferredCallRequest) {
|
||||||
UserEntity userEntity = validator.validateUser(request);
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
return beneficiaryPreferredCallDao.createBeneficiaryPreferredCall(beneficiaryPreferredCallRequest,userEntity);
|
return beneficiaryPreferredCallDao.createBeneficiaryPreferredCall(request, beneficiaryPreferredCallRequest,userEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BeneficiaryPreferredCallResponseBean getBeneficiaryPreferredCallById(HttpServletRequest request, Long id) {
|
public BeneficiaryPreferredCallResponseBean getBeneficiaryPreferredCallById(HttpServletRequest request, Long id) {
|
||||||
return beneficiaryPreferredCallDao.getBeneficiaryPreferredCallById(id);
|
return beneficiaryPreferredCallDao.getBeneficiaryPreferredCallById(request, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteBeneficiaryPreferredCall(HttpServletRequest request, Long id) {
|
public void deleteBeneficiaryPreferredCall(HttpServletRequest request, Long id) {
|
||||||
beneficiaryPreferredCallDao.deleteBeneficiaryPreferredCallById(id);
|
beneficiaryPreferredCallDao.deleteBeneficiaryPreferredCallById(request, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BeneficiaryPreferredCallResponseBean> getAllBeneficiaryPreferredCalls(HttpServletRequest request) {
|
public List<BeneficiaryPreferredCallResponseBean> getAllBeneficiaryPreferredCalls(HttpServletRequest request) {
|
||||||
return beneficiaryPreferredCallDao.getAllBeneficiaryPreferredCalls();
|
return beneficiaryPreferredCallDao.getAllBeneficiaryPreferredCalls(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
@@ -68,6 +66,7 @@ public class BeneficiaryPreferredCallServiceImpl implements BeneficiaryPreferred
|
|||||||
@Override
|
@Override
|
||||||
public List<BeneficiaryPreferredCallResponseBean> getBeneficiaryPreferredCallByUserId(HttpServletRequest request,Long userId,Long beneficiaryId,Long companyId) {
|
public List<BeneficiaryPreferredCallResponseBean> getBeneficiaryPreferredCallByUserId(HttpServletRequest request,Long userId,Long beneficiaryId,Long companyId) {
|
||||||
UserEntity userEntity =validateGetBeneficiaryPreferredCallrequest(request,userId,beneficiaryId);
|
UserEntity userEntity =validateGetBeneficiaryPreferredCallrequest(request,userId,beneficiaryId);
|
||||||
|
validator.validateUserId(request, userEntity.getId());
|
||||||
return beneficiaryPreferredCallDao.getBeneficiaryPreferredCallByUserId(userEntity,companyId);
|
return beneficiaryPreferredCallDao.getBeneficiaryPreferredCallByUserId(userEntity,companyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,13 +91,15 @@ public class CallServiceImpl implements CallService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CallEntity validatePublishedCall(Long callId) {
|
public CallEntity validatePublishedCall(Long callId, Long hubId) {
|
||||||
return callDao.validatePublishedCall(callId);
|
return callDao.validatePublishedCall(callId, hubId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public byte[] downloadCallDocumentsAsZip(Long callId) {
|
public byte[] downloadCallDocumentsAsZip(HttpServletRequest request, Long callId) {
|
||||||
|
UserEntity user = validator.validateUser(request);
|
||||||
|
validator.validateUserWithCall(user, callId);
|
||||||
return callDao.downloadCallDocumentsAsZip(callId);
|
return callDao.downloadCallDocumentsAsZip(callId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class CompanyServiceImpl implements CompanyService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public CompanyResponse updateCompany(HttpServletRequest request, Long companyId, CompanyRequest companyRequest) {
|
public CompanyResponse updateCompany(HttpServletRequest request, Long companyId, CompanyRequest companyRequest) {
|
||||||
UserEntity userEntity =validator.validateUser(request);
|
UserEntity userEntity =validator.validateUser(request);
|
||||||
|
validator.validateUserWithCompany(request, companyId);
|
||||||
return companyDao.updateCompany(userEntity, companyId, companyRequest);
|
return companyDao.updateCompany(userEntity, companyId, companyRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,6 +57,7 @@ public class CompanyServiceImpl implements CompanyService {
|
|||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public CompanyResponse getCompany(HttpServletRequest request, Long companyId) {
|
public CompanyResponse getCompany(HttpServletRequest request, Long companyId) {
|
||||||
UserEntity userEntity =validator.validateUser(request);
|
UserEntity userEntity =validator.validateUser(request);
|
||||||
|
validator.validateUserWithCompany(request, companyId);
|
||||||
return companyDao.getCompany(userEntity, companyId);
|
return companyDao.getCompany(userEntity, companyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,13 +65,14 @@ public class CompanyServiceImpl implements CompanyService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteCompany(HttpServletRequest request, Long companyId) {
|
public void deleteCompany(HttpServletRequest request, Long companyId) {
|
||||||
UserEntity userEntity =validator.validateUser(request);
|
UserEntity userEntity =validator.validateUser(request);
|
||||||
|
validator.validateUserWithCompany(request, companyId);
|
||||||
companyDao.deleteCompany(userEntity, companyId);
|
companyDao.deleteCompany(userEntity, companyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<CompanyResponse> getCompanyByUserId(HttpServletRequest request, Long userId) {
|
public List<CompanyResponse> getCompanyByUserId(HttpServletRequest request, Long userId) {
|
||||||
validator.validateUser(request);
|
validator.validateUserId(request, userId);
|
||||||
return companyDao.getCompanyByUserId(userId);
|
return companyDao.getCompanyByUserId(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,8 +94,7 @@ public class CompanyServiceImpl implements CompanyService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public ByteArrayOutputStream downloadCompanyDelegation(HttpServletRequest request, Long companyId, CompanyDelegationRequest companyDelegationRequest) {
|
public ByteArrayOutputStream downloadCompanyDelegation(HttpServletRequest request, Long companyId, CompanyDelegationRequest companyDelegationRequest) {
|
||||||
UserEntity userEntity =validator.validateUser(request);
|
return delegationDao.downloadCompanyDelegation(request, companyId, companyDelegationRequest);
|
||||||
return delegationDao.downloadCompanyDelegation(userEntity, companyId, companyDelegationRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import net.gepafin.tendermanagement.dao.FlowDao;
|
|||||||
import net.gepafin.tendermanagement.model.request.FlowRequestBean;
|
import net.gepafin.tendermanagement.model.request.FlowRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.FlowResponseBean;
|
import net.gepafin.tendermanagement.model.response.FlowResponseBean;
|
||||||
import net.gepafin.tendermanagement.service.FlowService;
|
import net.gepafin.tendermanagement.service.FlowService;
|
||||||
|
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;
|
||||||
@@ -15,15 +17,20 @@ public class FlowServiceImpl implements FlowService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FlowDao flowDao;
|
private FlowDao flowDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public FlowResponseBean createOrUpdateFlow(HttpServletRequest httpServletRequest, FlowRequestBean flowRequestBean, Long callId) {
|
public FlowResponseBean createOrUpdateFlow(HttpServletRequest httpServletRequest, FlowRequestBean flowRequestBean, Long callId) {
|
||||||
|
validator.validateUserWithCall(validator.validateUser(httpServletRequest), callId);
|
||||||
return flowDao.createOrUpdateFlow(flowRequestBean,callId);
|
return flowDao.createOrUpdateFlow(flowRequestBean,callId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@org.springframework.transaction.annotation.Transactional(readOnly = true)
|
@org.springframework.transaction.annotation.Transactional(readOnly = true)
|
||||||
public FlowResponseBean getFlowByCallId(HttpServletRequest request, Long callId) {
|
public FlowResponseBean getFlowByCallId(HttpServletRequest request, Long callId) {
|
||||||
|
validator.validateUserWithCall(validator.validateUser(request), callId);
|
||||||
return flowDao.getFlowByCallId(callId);
|
return flowDao.getFlowByCallId(callId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,15 @@ package net.gepafin.tendermanagement.service.impl;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.dao.LoginAttemptDao;
|
import net.gepafin.tendermanagement.dao.LoginAttemptDao;
|
||||||
import net.gepafin.tendermanagement.entities.LoginAttemptEntity;
|
import net.gepafin.tendermanagement.entities.LoginAttemptEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.enums.LoginAttemptResultEnum;
|
import net.gepafin.tendermanagement.enums.LoginAttemptResultEnum;
|
||||||
import net.gepafin.tendermanagement.enums.LoginAttemptTypeEnum;
|
import net.gepafin.tendermanagement.enums.LoginAttemptTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.LoginAttemptReq;
|
import net.gepafin.tendermanagement.model.request.LoginAttemptReq;
|
||||||
import net.gepafin.tendermanagement.model.response.LoginAttemptPageableResponseBean;
|
import net.gepafin.tendermanagement.model.response.LoginAttemptPageableResponseBean;
|
||||||
import net.gepafin.tendermanagement.service.LoginAttemptService;
|
import net.gepafin.tendermanagement.service.LoginAttemptService;
|
||||||
import net.gepafin.tendermanagement.util.Utils;
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
|
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;
|
||||||
|
|
||||||
@@ -20,21 +23,29 @@ public class LoginAttemptServiceImpl implements LoginAttemptService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
LoginAttemptDao loginAttemptDao;
|
LoginAttemptDao loginAttemptDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginAttemptPageableResponseBean<List<LoginAttemptEntity>> getLoginAttemptsList(Integer pageNo, Integer pageLimit) {
|
public LoginAttemptPageableResponseBean<List<LoginAttemptEntity>> getLoginAttemptsList(HttpServletRequest request, Integer pageNo, Integer pageLimit) {
|
||||||
return loginAttemptDao.getLoginAttemptsList(pageNo, pageLimit);
|
return loginAttemptDao.getLoginAttemptsList(validator.validateUser(request), pageNo, pageLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createLoginAttempt(LoginAttemptReq loginAttemptReq, HttpServletRequest request) {
|
public void createLoginAttempt(LoginAttemptReq loginAttemptReq, HttpServletRequest request) {
|
||||||
String ipAddress = Utils.getClientIpAddress(request);
|
String ipAddress = Utils.getClientIpAddress(request);
|
||||||
String userAgent = request.getHeader("user-agent");
|
String userAgent = request.getHeader("user-agent");
|
||||||
|
|
||||||
LoginAttemptEntity loginAttemptEntity = new LoginAttemptEntity();
|
LoginAttemptEntity loginAttemptEntity = new LoginAttemptEntity();
|
||||||
loginAttemptEntity.setType(LoginAttemptTypeEnum.SWITCH.getValue());
|
loginAttemptEntity.setType(LoginAttemptTypeEnum.SWITCH.getValue());
|
||||||
loginAttemptEntity.setIpAddress(ipAddress);
|
loginAttemptEntity.setIpAddress(ipAddress);
|
||||||
loginAttemptEntity.setUserAgent(userAgent);
|
loginAttemptEntity.setUserAgent(userAgent);
|
||||||
loginAttemptEntity.setUsername(loginAttemptReq.getUserName());
|
loginAttemptEntity.setUsername(loginAttemptReq.getUserName());
|
||||||
loginAttemptEntity.setResult(LoginAttemptResultEnum.SUCCESS.getValue());
|
loginAttemptEntity.setResult(LoginAttemptResultEnum.SUCCESS.getValue());
|
||||||
|
if(loginAttemptReq.getUserId() != null) {
|
||||||
|
UserEntity userEntity = validator.validateUserId(request, loginAttemptReq.getUserId());
|
||||||
|
loginAttemptEntity.setUserId(userEntity.getId());
|
||||||
|
}
|
||||||
loginAttemptDao.createLoginAttempt(loginAttemptEntity);
|
loginAttemptDao.createLoginAttempt(loginAttemptEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import net.gepafin.tendermanagement.dao.S3ConfigDao;
|
||||||
|
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.S3ConfigReq;
|
||||||
|
import net.gepafin.tendermanagement.model.response.S3ConfigBean;
|
||||||
|
import net.gepafin.tendermanagement.service.S3ConfigService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class S3ConfigServiceImpl implements S3ConfigService {
|
||||||
|
@Autowired
|
||||||
|
S3ConfigDao s3ConfigDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public S3ConfigBean addS3Path(S3ConfigReq s3Path) {
|
||||||
|
|
||||||
|
return s3ConfigDao.addS3Path(s3Path);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Optional<S3ConfigEntity> getS3PathByType(String type) {
|
||||||
|
|
||||||
|
return s3ConfigDao.getS3PathByType(type);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public S3ConfigEntity deleteS3PathById(Long id) {
|
||||||
|
|
||||||
|
return s3ConfigDao.deleteS3PathConfigById(id);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public S3ConfigBean updateS3PathConfiguration(S3ConfigReq s3PathConfigurationReq, Long id) {
|
||||||
|
|
||||||
|
return s3ConfigDao.updateS3PathConfiguration(s3PathConfigurationReq, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import com.amazonaws.AmazonServiceException;
|
||||||
|
import com.amazonaws.SdkClientException;
|
||||||
|
import com.amazonaws.services.s3.AmazonS3;
|
||||||
|
import com.amazonaws.services.s3.AmazonS3Client;
|
||||||
|
import com.amazonaws.services.s3.model.GetObjectRequest;
|
||||||
|
import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.gepafin.tendermanagement.dao.S3PathConfig;
|
||||||
|
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.ApplicationSignedDocumentRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class S3ReUploadMigrationService {
|
||||||
|
|
||||||
|
private static final String OLD_BUCKET = "mementoresources";
|
||||||
|
|
||||||
|
private static final String SECURE_KEY = "267163962963";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DocumentRepository documentRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AmazonS3Client s3Client;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private S3PathConfig s3ConfigBean;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationRepository applicationRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationSignedDocumentRepository applicationSignedDocumentRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AmazonS3 amazonS3;
|
||||||
|
|
||||||
|
@Value("${aws.s3.url}")
|
||||||
|
private String s3Url;
|
||||||
|
|
||||||
|
private boolean migrationCompleted = false;
|
||||||
|
|
||||||
|
public String reUploadAndMigrateDocuments(String providedKey) {
|
||||||
|
|
||||||
|
if (migrationCompleted) {
|
||||||
|
return "Migration already completed.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate the provided key
|
||||||
|
if (!isValidKey(providedKey)) {
|
||||||
|
return "Invalid or missing migration key.";
|
||||||
|
}
|
||||||
|
|
||||||
|
List<DocumentEntity> documents = documentRepository.findAllByIsDeleteFalse();
|
||||||
|
|
||||||
|
if (documents.isEmpty()) {
|
||||||
|
return "No documents found to migrate.";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DocumentEntity document : documents) {
|
||||||
|
String oldUrl = document.getFilePath(); // This should contain the full URL
|
||||||
|
log.info("Processing {}", oldUrl);
|
||||||
|
|
||||||
|
try {
|
||||||
|
File localFile = downloadFileFromS3(oldUrl);
|
||||||
|
String newKey = generateNewS3Path(document); // Make sure this generates the correct new path
|
||||||
|
String uploadedPath = uploadFileToNewBucket(localFile, newKey);
|
||||||
|
updateDocumentPathAndDeleteOldEntry(document, uploadedPath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error processing document {}: {}", document.getId(), e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "Migrated Successfully.";
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidKey(String providedKey) {
|
||||||
|
|
||||||
|
return providedKey != null && providedKey.equals(SECURE_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private File downloadFileFromS3(String fileUrl) throws Exception {
|
||||||
|
|
||||||
|
String key = extractS3KeyFromUrl(fileUrl); // Get the S3 key from the URL
|
||||||
|
File localFile = new File("/tmp/" + extractFileName(key)); // Save file locally
|
||||||
|
|
||||||
|
GetObjectRequest getObjectRequest = new GetObjectRequest(OLD_BUCKET, key); // Use the key
|
||||||
|
|
||||||
|
try (InputStream s3Stream = s3Client.getObject(getObjectRequest).getObjectContent(); FileOutputStream outputStream = new FileOutputStream(localFile)) {
|
||||||
|
s3Stream.transferTo(outputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("Downloaded file from old S3 bucket: {}", key);
|
||||||
|
return localFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String extractS3KeyFromUrl(String url) {
|
||||||
|
// Assuming the URL structure is consistent
|
||||||
|
return url.replace("https://mementoresources.s3.eu-west-1.amazonaws.com/", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String uploadFileToNewBucket(File localFile, String s3Folder) {
|
||||||
|
|
||||||
|
InputStream inputStream = null; // Declare the InputStream here for cleanup
|
||||||
|
try {
|
||||||
|
// Extract file name from the local file
|
||||||
|
String fileName = extractFileName(localFile.getAbsolutePath()); // Get the file name
|
||||||
|
String path = s3Folder + "/" + fileName; // Construct the S3 path
|
||||||
|
|
||||||
|
// Create InputStream from the local file
|
||||||
|
inputStream = new FileInputStream(localFile);
|
||||||
|
|
||||||
|
// Set up object metadata
|
||||||
|
ObjectMetadata objectMetadata = new ObjectMetadata();
|
||||||
|
objectMetadata.setContentType("application/octet-stream");
|
||||||
|
objectMetadata.setContentLength(localFile.length());
|
||||||
|
|
||||||
|
// Upload to S3
|
||||||
|
s3Client.putObject(OLD_BUCKET, path, inputStream, objectMetadata);
|
||||||
|
|
||||||
|
// Construct the full S3 URL
|
||||||
|
String fullUrl = String.format("https://%s.s3.%s.amazonaws.com/%s", OLD_BUCKET, "eu-west-1", path);
|
||||||
|
log.info("File '{}' uploaded successfully to Amazon S3 with URL: {}", fileName, fullUrl);
|
||||||
|
return fullUrl;
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("IOException occurred during file upload for '{}': {}", localFile.getName(), e.getMessage());
|
||||||
|
throw new RuntimeException("Upload failed for: " + s3Folder + "/" + localFile.getName(), e);
|
||||||
|
} catch (AmazonServiceException e) {
|
||||||
|
log.error("Amazon service exception while uploading file '{}': {}", localFile.getName(), e.getMessage());
|
||||||
|
throw new RuntimeException("Upload failed for: " + s3Folder + "/" + localFile.getName(), e);
|
||||||
|
} catch (SdkClientException e) {
|
||||||
|
log.error("SDK client exception while uploading file '{}': {}", localFile.getName(), e.getMessage());
|
||||||
|
throw new RuntimeException("Upload failed for: " + s3Folder + "/" + localFile.getName(), e);
|
||||||
|
} finally {
|
||||||
|
// Close InputStream if it was opened
|
||||||
|
if (inputStream != null) {
|
||||||
|
try {
|
||||||
|
inputStream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("Failed to close InputStream for file '{}': {}", localFile.getName(), e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateNewS3Path(DocumentEntity document) {
|
||||||
|
|
||||||
|
DocumentSourceTypeEnum sourceType = DocumentSourceTypeEnum.valueOf(document.getSource());
|
||||||
|
Long callId;
|
||||||
|
|
||||||
|
if (sourceType.equals(DocumentSourceTypeEnum.CALL)) {
|
||||||
|
return s3ConfigBean.generateDocumentPath(sourceType, document.getSourceId(), 0L);
|
||||||
|
} else {
|
||||||
|
callId = applicationRepository.findCallIdById(document.getSourceId());
|
||||||
|
return s3ConfigBean.generateDocumentPath(sourceType, callId, document.getSourceId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String extractFileName(String filePath) {
|
||||||
|
|
||||||
|
String[] parts = filePath.split("/");
|
||||||
|
return parts[parts.length - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void updateDocumentPathAndDeleteOldEntry(DocumentEntity document, String newPath) {
|
||||||
|
|
||||||
|
String fileName = extractFileName(newPath);
|
||||||
|
DocumentEntity newDocument = new DocumentEntity();
|
||||||
|
newDocument.setFilePath(newPath);
|
||||||
|
newDocument.setSource(document.getSource());
|
||||||
|
newDocument.setType(document.getType());
|
||||||
|
newDocument.setIsDeleted(false);
|
||||||
|
newDocument.setSourceId(document.getSourceId());
|
||||||
|
newDocument.setFileName(fileName);
|
||||||
|
|
||||||
|
documentRepository.save(newDocument);
|
||||||
|
documentRepository.delete(document);
|
||||||
|
|
||||||
|
log.info("Migrated document ID: {} to new path: {}", document.getId(), newPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,19 +40,22 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public UserResponseBean updateUser(Long userId, UpdateUserReq userReq) {
|
public UserResponseBean updateUser(HttpServletRequest request, Long userId, UpdateUserReq userReq) {
|
||||||
|
validator.validateUserId(request, userId);
|
||||||
return userDao.updateUser(userId, userReq);
|
return userDao.updateUser(userId, userReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public UserResponseBean getUserById(Long userId) {
|
public UserResponseBean getUserById(HttpServletRequest request, Long userId) {
|
||||||
|
validator.validateUserId(request, userId);
|
||||||
return userDao.getUserById(userId);
|
return userDao.getUserById(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteUser(Long userId) {
|
public void deleteUser(HttpServletRequest request, Long userId) {
|
||||||
|
validator.validateUserId(request, userId);
|
||||||
userDao.deleteUser(userId);
|
userDao.deleteUser(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,261 @@
|
|||||||
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import com.amazonaws.AmazonServiceException;
|
||||||
|
import com.amazonaws.SdkClientException;
|
||||||
|
import com.amazonaws.services.s3.AmazonS3Client;
|
||||||
|
import com.amazonaws.services.s3.model.GetObjectRequest;
|
||||||
|
import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.gepafin.tendermanagement.dao.S3PathConfig;
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationSignedDocumentEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserCompanyDelegationEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.ApplicationSignedDocumentRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.S3ConfigRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.UserCompanyDelegationRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class UserSignedAndDelegationServiceImpl {
|
||||||
|
private static final String OLD_BUCKET = "mementoresources";
|
||||||
|
|
||||||
|
private static final String NEW_BUCKET = "mementoresources";
|
||||||
|
|
||||||
|
private static final String SECURE_KEY = "267163962963";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserCompanyDelegationRepository userCompanyDelegationRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AmazonS3Client s3Client;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private S3PathConfig s3ConfigBean;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationSignedDocumentRepository applicationSignedDocumentRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ApplicationRepository applicationRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
S3ConfigRepository s3ConfigRepository;
|
||||||
|
|
||||||
|
@Value("${aws.s3.url}")
|
||||||
|
private String s3Url;
|
||||||
|
|
||||||
|
private boolean migrationCompleted = false;
|
||||||
|
|
||||||
|
|
||||||
|
public String migrateUserDelegatedDocuments(String providedKey) {
|
||||||
|
|
||||||
|
if (migrationCompleted) {
|
||||||
|
return "Migration already completed.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate the provided key
|
||||||
|
if (isValidKey(providedKey)) {
|
||||||
|
return "Invalid or missing migration key.";
|
||||||
|
}
|
||||||
|
|
||||||
|
List<UserCompanyDelegationEntity> documents = userCompanyDelegationRepository.findAllByStatus("ACTIVE");
|
||||||
|
|
||||||
|
if (documents.isEmpty()) {
|
||||||
|
return "No documents found to migrate.";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (UserCompanyDelegationEntity document : documents) {
|
||||||
|
String oldUrl = document.getFilePath();
|
||||||
|
log.info("Processing user designated document: {}", oldUrl);
|
||||||
|
|
||||||
|
try {
|
||||||
|
File localFile = downloadFileFromS3(oldUrl);
|
||||||
|
String newKey = generateNewS3PathForDelegationDoc();
|
||||||
|
String uploadedPath = uploadFileToNewBucket(localFile, newKey);
|
||||||
|
updateDelegatedDocumentPathAndDeleteOldEntry(document, uploadedPath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error processing user designated document {}: {}", document.getId(), e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "Migrated";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String migrateUserSignedDocuments(String providedKey) {
|
||||||
|
|
||||||
|
if (migrationCompleted) {
|
||||||
|
return "Migration already completed.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate the provided key
|
||||||
|
if (isValidKey(providedKey)) {
|
||||||
|
return "Invalid or missing migration key.";
|
||||||
|
}
|
||||||
|
List<ApplicationSignedDocumentEntity> documents = applicationSignedDocumentRepository.findAllByIsStatus("ACTIVE");
|
||||||
|
|
||||||
|
if (documents.isEmpty()) {
|
||||||
|
return "No documents found to migrate.";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ApplicationSignedDocumentEntity document : documents) {
|
||||||
|
String oldUrl = document.getFilePath();
|
||||||
|
log.info("Processing user signed document: {}", oldUrl);
|
||||||
|
|
||||||
|
try {
|
||||||
|
File localFile = downloadFileFromS3(oldUrl);
|
||||||
|
String newKey = generateNewS3PathForUserSignedDoc(document);
|
||||||
|
String uploadedPath = uploadFileToNewBucket(localFile, newKey);
|
||||||
|
updateDocumentPathAndDeleteOldEntry(document, uploadedPath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error processing user signed document {}: {}", document.getId(), e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "Migrated.";
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidKey(String providedKey) {
|
||||||
|
|
||||||
|
return providedKey == null || !providedKey.equals(SECURE_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateNewS3PathForDelegationDoc() {
|
||||||
|
|
||||||
|
return s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateNewS3PathForUserSignedDoc(ApplicationSignedDocumentEntity document) {
|
||||||
|
// Fetch the list of application IDs associated with the document
|
||||||
|
List<Long> applicationIds = applicationSignedDocumentRepository.findApplicationIdIdsById(document.getId());
|
||||||
|
List<String> paths = new ArrayList<>();
|
||||||
|
|
||||||
|
// Loop through the application IDs and generate paths
|
||||||
|
for (Long applicationId : applicationIds) {
|
||||||
|
Long callId = applicationRepository.findCallIdById(applicationId);
|
||||||
|
|
||||||
|
// Construct the path for the current application and call ID
|
||||||
|
String newPath = String.format("%s/call/call_%d/application/application_%d/user_signed_document", s3ConfigRepository.getPathByTypeOther(
|
||||||
|
String.valueOf(DocOtherSourceTypeEnum.USER_SIGNED_DOCUMENT)) , callId, applicationId);
|
||||||
|
|
||||||
|
log.info("Generated new S3 path: {}", newPath);
|
||||||
|
paths.add(newPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.join(",", paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
private File downloadFileFromS3(String fileUrl) throws Exception {
|
||||||
|
|
||||||
|
String key = extractS3KeyFromUrl(fileUrl);
|
||||||
|
File localFile = new File("/tmp/" + extractFileName(key));
|
||||||
|
|
||||||
|
GetObjectRequest getObjectRequest = new GetObjectRequest(OLD_BUCKET, key);
|
||||||
|
|
||||||
|
try (InputStream s3Stream = s3Client.getObject(getObjectRequest).getObjectContent(); FileOutputStream outputStream = new FileOutputStream(localFile)) {
|
||||||
|
s3Stream.transferTo(outputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("Downloaded file from old S3 bucket: {}", key);
|
||||||
|
return localFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String extractS3KeyFromUrl(String url) {
|
||||||
|
|
||||||
|
return url.replace("https://mementoresources.s3.eu-west-1.amazonaws.com/", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String uploadFileToNewBucket(File localFile, String s3Path) {
|
||||||
|
|
||||||
|
InputStream inputStream = null;
|
||||||
|
try {
|
||||||
|
String fileName = extractFileName(localFile.getAbsolutePath()); // Extract file name
|
||||||
|
String fullPath = String.format("%s/%s", s3Path, fileName); // Construct full path
|
||||||
|
|
||||||
|
inputStream = new FileInputStream(localFile); // Create InputStream
|
||||||
|
|
||||||
|
// Set metadata for the file
|
||||||
|
ObjectMetadata objectMetadata = new ObjectMetadata();
|
||||||
|
objectMetadata.setContentLength(localFile.length());
|
||||||
|
objectMetadata.setContentType("application/octet-stream");
|
||||||
|
|
||||||
|
// Upload the file to S3 with the constructed path
|
||||||
|
s3Client.putObject(NEW_BUCKET, fullPath, inputStream, objectMetadata);
|
||||||
|
|
||||||
|
// Construct the full S3 URL for the uploaded file
|
||||||
|
String fullUrl = String.format("https://%s.s3.%s.amazonaws.com/%s", NEW_BUCKET, "eu-west-1", fullPath);
|
||||||
|
log.info("File '{}' uploaded successfully to Amazon S3 with URL: {}", fileName, fullUrl);
|
||||||
|
return fullUrl;
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("IOException occurred during file upload for '{}': {}", localFile.getName(), e.getMessage());
|
||||||
|
throw new RuntimeException("Upload failed for: " + localFile, e);
|
||||||
|
} catch (AmazonServiceException e) {
|
||||||
|
log.error("Amazon service exception while uploading file '{}': {}", localFile.getName(), e.getMessage());
|
||||||
|
throw new RuntimeException("Upload failed for: " + localFile, e);
|
||||||
|
} catch (SdkClientException e) {
|
||||||
|
log.error("SDK client exception while uploading file '{}': {}", localFile.getName(), e.getMessage());
|
||||||
|
throw new RuntimeException("Upload failed for: " + localFile, e);
|
||||||
|
} finally {
|
||||||
|
if (inputStream != null) {
|
||||||
|
try {
|
||||||
|
inputStream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("Failed to close InputStream for file '{}': {}", localFile.getName(), e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String extractFileName(String filePath) {
|
||||||
|
|
||||||
|
String[] parts = filePath.split("/");
|
||||||
|
return parts[parts.length - 1];
|
||||||
|
}
|
||||||
|
private String extractFileNameFromPath(String path) {
|
||||||
|
|
||||||
|
return path.substring(path.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDocumentPathAndDeleteOldEntry(ApplicationSignedDocumentEntity document, String newPath) {
|
||||||
|
|
||||||
|
ApplicationSignedDocumentEntity newDocument = new ApplicationSignedDocumentEntity();
|
||||||
|
String fileName = extractFileNameFromPath(newPath);
|
||||||
|
newDocument.setFilePath(newPath);
|
||||||
|
newDocument.setFileName(fileName);
|
||||||
|
newDocument.setApplication(document.getApplication());
|
||||||
|
newDocument.setStatus("ACTIVE");
|
||||||
|
|
||||||
|
applicationSignedDocumentRepository.save(newDocument);
|
||||||
|
applicationSignedDocumentRepository.delete(document);
|
||||||
|
|
||||||
|
log.info("Migrated document ID: {} to new path: {}", document.getId(), newPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDelegatedDocumentPathAndDeleteOldEntry(UserCompanyDelegationEntity document, String newPath) {
|
||||||
|
|
||||||
|
String fileName = extractFileNameFromPath(newPath);
|
||||||
|
UserCompanyDelegationEntity newDocument = new UserCompanyDelegationEntity();
|
||||||
|
newDocument.setFilePath(newPath);
|
||||||
|
newDocument.setFileName(fileName);
|
||||||
|
newDocument.setBeneficiaryId(document.getBeneficiaryId());
|
||||||
|
newDocument.setUserId(document.getUserId());
|
||||||
|
newDocument.setCompanyId(document.getCompanyId());
|
||||||
|
newDocument.setStatus("ACTIVE");
|
||||||
|
|
||||||
|
userCompanyDelegationRepository.save(newDocument);
|
||||||
|
userCompanyDelegationRepository.delete(document);
|
||||||
|
|
||||||
|
log.info("Migrated document ID: {} to new path: {}", document.getId(), newPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.gepafin.tendermanagement.util;
|
package net.gepafin.tendermanagement.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -31,6 +32,8 @@ import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientNotFoundExcep
|
|||||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientUnauthorizedException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientUnauthorizedException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientValidationException;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||||
|
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
@@ -308,6 +311,22 @@ public class Utils {
|
|||||||
|
|
||||||
return new StringTokenizer(header, ",").nextToken().trim();
|
return new StringTokenizer(header, ",").nextToken().trim();
|
||||||
}
|
}
|
||||||
|
public static <T> List<T> convertJsonToList(String json, TypeReference<List<T>> typeRef) {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
try {
|
||||||
|
return objectMapper.readValue(json, typeRef);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertObjectToJson(Object obj) {
|
||||||
|
try {
|
||||||
|
return new ObjectMapper().writeValueAsString(obj);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
log.error("Failed to convert object to JSON: {}", e.getMessage(), e);
|
||||||
|
throw new RuntimeException("Failed to convert object to JSON", e);}}
|
||||||
|
|
||||||
public static String replaceSpacesWithUnderscores(String content) {
|
public static String replaceSpacesWithUnderscores(String content) {
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
@@ -315,4 +334,57 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return content.trim().replace(" ", "_");
|
return content.trim().replace(" ", "_");
|
||||||
}
|
}
|
||||||
|
public static List<Map<String, Object>> convertJsonStringIntoJsonList(String jsonString) {
|
||||||
|
try {
|
||||||
|
if(isEmpty(jsonString))
|
||||||
|
{
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper.configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(), true);
|
||||||
|
return mapper.readValue(jsonString, List.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public static String convertToString(Object input) {
|
||||||
|
if (input == null) {
|
||||||
|
return "null"; // Return string "null" for null input
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input instanceof String) {
|
||||||
|
return (String) input; // Return the string directly if input is a string
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input instanceof Collection<?>) {
|
||||||
|
// Handle collections (List, Set, etc.)
|
||||||
|
return convertCollectionToString((Collection<?>) input);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input instanceof Map<?, ?>) {
|
||||||
|
// Handle maps
|
||||||
|
return convertMapToString((Map<?, ?>) input);
|
||||||
|
}
|
||||||
|
|
||||||
|
// For other types (like Integer, Boolean, etc.), use toString()
|
||||||
|
return input.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String convertCollectionToString(Collection<?> collection) {
|
||||||
|
try {
|
||||||
|
return mapper.writeValueAsString(collection); // Convert the collection to a JSON string
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException("Error converting collection to string", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String convertMapToString(Map<?, ?> map) {
|
||||||
|
try {
|
||||||
|
return mapper.writeValueAsString(map); // Convert the map to a JSON string
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException("Error converting map to string", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.config.jwt.TokenProvider;
|
import net.gepafin.tendermanagement.config.jwt.TokenProvider;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.dao.CallDao;
|
|
||||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
@@ -66,6 +65,20 @@ public class Validator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean checkIsPreInstructor() {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
|
||||||
|
if (authentication != null && authentication.isAuthenticated()) {
|
||||||
|
// Check if the user has the ROLE_SUPER_ADMIN authority
|
||||||
|
for (GrantedAuthority authority : authentication.getAuthorities()) {
|
||||||
|
if (RoleStatusEnum.ROLE_PRE_INSTRUCTOR.getValue().equals(authority.getAuthority())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void validateRequest(HttpServletRequest request,RoleStatusEnum role) {
|
public void validateRequest(HttpServletRequest request,RoleStatusEnum role) {
|
||||||
if (RoleStatusEnum.ROLE_SUPER_ADMIN.equals(role) && Boolean.FALSE.equals(checkIsSuperAdmin())) {
|
if (RoleStatusEnum.ROLE_SUPER_ADMIN.equals(role) && Boolean.FALSE.equals(checkIsSuperAdmin())) {
|
||||||
throw new UnauthorizedAccessException(Status.UNAUTHORIZED, Translator.toLocale(GepafinConstant.INVALID_REQUEST));
|
throw new UnauthorizedAccessException(Status.UNAUTHORIZED, Translator.toLocale(GepafinConstant.INVALID_REQUEST));
|
||||||
@@ -73,14 +86,25 @@ public class Validator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CompanyEntity validateUserWithCompany(HttpServletRequest request, Long companyId) {
|
public CompanyEntity validateUserWithCompany(HttpServletRequest request, Long companyId) {
|
||||||
|
CompanyEntity companyEntity = companyService.validateCompany(companyId);
|
||||||
|
validateHubId(request, companyEntity.getHub().getId());
|
||||||
if (checkIsSuperAdmin()) {
|
if (checkIsSuperAdmin()) {
|
||||||
return companyService.validateCompany(companyId);
|
return companyEntity;
|
||||||
}
|
}
|
||||||
Map<String, Object> userInfo = tokenProvider.getUserInfoAndUserIdFromToken(request);
|
Map<String, Object> userInfo = tokenProvider.getUserInfoAndUserIdFromToken(request);
|
||||||
companyService.validateUserWithCompny(getUserId(userInfo), companyId);
|
companyService.validateUserWithCompny(getUserId(userInfo), companyId);
|
||||||
return companyService.validateCompany(companyId);
|
return companyService.validateCompany(companyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validateHubId(HttpServletRequest request, Long hubId) {
|
||||||
|
UserEntity user = validateUser(request);
|
||||||
|
Long hubIdFromHttpRequest = user.getHub().getId();
|
||||||
|
if (Boolean.FALSE.equals(hubIdFromHttpRequest.equals(hubId))) {
|
||||||
|
throw new ForbiddenAccessException(Status.FORBIDDEN,
|
||||||
|
Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Long getUserId(Map<String, Object> userInfo) {
|
private Long getUserId(Map<String, Object> userInfo) {
|
||||||
return Long.parseLong(userInfo.get("userId").toString());
|
return Long.parseLong(userInfo.get("userId").toString());
|
||||||
}
|
}
|
||||||
@@ -100,17 +124,21 @@ public class Validator {
|
|||||||
|
|
||||||
public UserEntity validateUserId(HttpServletRequest request, Long userId) {
|
public UserEntity validateUserId(HttpServletRequest request, Long userId) {
|
||||||
UserEntity user = validateUser(request);
|
UserEntity user = validateUser(request);
|
||||||
if(user.getRoleEntity().getRoleType().equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue()) && Boolean.FALSE.equals(user.getId().equals(userId))) {
|
UserEntity requestedUser = userService.validateUser(userId);
|
||||||
throw new ForbiddenAccessException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
|
||||||
|
validateHubId(request, requestedUser.getHub().getId());
|
||||||
|
if (Boolean.FALSE.equals(user.getRoleEntity().getRoleType().equals(RoleStatusEnum.ROLE_SUPER_ADMIN.getValue()))
|
||||||
|
&& Boolean.FALSE.equals(user.getId().equals(userId))) {
|
||||||
|
throw new ForbiddenAccessException(Status.FORBIDDEN,
|
||||||
|
Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||||
}
|
}
|
||||||
return userService.validateUser(userId);
|
return requestedUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long getUserIdFromToken(HttpServletRequest request) {
|
public Long getUserIdFromToken(HttpServletRequest request) {
|
||||||
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
||||||
return Long.parseLong(userInfo.get("userId").toString());
|
return Long.parseLong(userInfo.get("userId").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CallEntity validateUserWithCall(UserEntity user, Long callId) {
|
public CallEntity validateUserWithCall(UserEntity user, Long callId) {
|
||||||
CallEntity callEntity = callService.validateCall(callId);
|
CallEntity callEntity = callService.validateCall(callId);
|
||||||
if(Boolean.FALSE.equals(user.getHub().getId().equals(callEntity.getHub().getId()))) {
|
if(Boolean.FALSE.equals(user.getHub().getId().equals(callEntity.getHub().getId()))) {
|
||||||
@@ -124,4 +152,19 @@ public class Validator {
|
|||||||
return Arrays.stream(activeProfiles).anyMatch("production"::equals);
|
return Arrays.stream(activeProfiles).anyMatch("production"::equals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserEntity validatePreInstructor(HttpServletRequest request, Long preInstructorUserId) {
|
||||||
|
UserEntity preInstructorUser = userService.validateUser(preInstructorUserId);
|
||||||
|
if (checkIsSuperAdmin()) {
|
||||||
|
if (preInstructorUserId != null) {
|
||||||
|
validateHubId(request, preInstructorUser.getHub().getId());
|
||||||
|
}
|
||||||
|
return preInstructorUser;
|
||||||
|
} else if (checkIsPreInstructor()) {
|
||||||
|
return validateUserId(request, preInstructorUserId);
|
||||||
|
} else {
|
||||||
|
throw new ForbiddenAccessException(Status.FORBIDDEN,
|
||||||
|
Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
|
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.ApplicationEvaluationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.request.UpdateApplicationEvaluationRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ApplicationEvaluationApi {
|
||||||
|
|
||||||
|
@Operation(summary = "API to create or update ApplicationEvaluation",
|
||||||
|
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 = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||||
|
})
|
||||||
|
@PutMapping(value = "/{assignedApplicationsId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
ResponseEntity<Response<ApplicationEvaluationResponse>> createOrUpdateApplicationEvaluation(
|
||||||
|
HttpServletRequest request,
|
||||||
|
@Parameter(required = true) @PathVariable("assignedApplicationsId") Long assignedApplicationsId,
|
||||||
|
@Parameter( required = true) @Valid @RequestBody ApplicationEvaluationRequest evaluationRequest);
|
||||||
|
|
||||||
|
@Operation(summary = "API to get ApplicationEvaluation data for evaluation process",
|
||||||
|
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) }))
|
||||||
|
})
|
||||||
|
@GetMapping(value = "/application", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
ResponseEntity<Response<ApplicationEvaluationResponse>> getApplicationEvaluationByApplicationId(
|
||||||
|
HttpServletRequest request,
|
||||||
|
@Parameter(description = "Application ID", required = false) @RequestParam(value = "applicationId", required = false) Long applicationId,
|
||||||
|
@Parameter(description = "Assigned Application ID", required = false) @RequestParam(value = "assignedApplicationId", required = false) Long assignedApplicationId);
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "API to delete ApplicationEvaluation",
|
||||||
|
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) }))
|
||||||
|
})
|
||||||
|
@DeleteMapping(value = "/{id}")
|
||||||
|
ResponseEntity<Response<Void>> deleteApplicationEvaluation(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The evaluation ID", required = true) @PathVariable("id") Long id);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to update application evaluation status",
|
||||||
|
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 = "/{applicationId}/status", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
ResponseEntity<Response<ApplicationEvaluationResponse>> updateApplicationEvaluationStatus(HttpServletRequest request,
|
||||||
|
@Parameter( required = true) @PathVariable("applicationId") Long applicationId,
|
||||||
|
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) ApplicationEvaluationStatusTypeEnum status);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,9 +6,7 @@ import io.swagger.v3.oas.annotations.media.ExampleObject;
|
|||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
|
||||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
|
||||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||||
import net.gepafin.tendermanagement.model.util.Response;
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||||
@@ -66,7 +64,8 @@ public interface AssignedApplicationsApi {
|
|||||||
@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) })) })
|
||||||
@GetMapping(value = "", produces = "application/json")
|
@GetMapping(value = "", produces = "application/json")
|
||||||
ResponseEntity<Response<List<AssignedApplicationsResponse>>> getAllAssignedApplications(@Parameter(description = "The User ID", required = false) @RequestParam(value = "userId",required = false) Long userId);
|
ResponseEntity<Response<List<AssignedApplicationsResponse>>> getAllAssignedApplications(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The User ID", required = false) @RequestParam(value = "userId",required = false) Long userId);
|
||||||
|
|
||||||
@Operation(summary = "Api to update assigned application",
|
@Operation(summary = "Api to update assigned application",
|
||||||
responses = {
|
responses = {
|
||||||
@@ -94,7 +93,9 @@ public interface AssignedApplicationsApi {
|
|||||||
@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) })) })
|
||||||
@GetMapping(value = "/{id}", produces = "application/json")
|
@GetMapping(value = "/{id}", produces = "application/json")
|
||||||
ResponseEntity<Response<AssignedApplicationsResponse>> getAssignedApplicationById(@Parameter(description = "The assigned application id", required = true) @PathVariable(value = "id", required = true) Long id);
|
ResponseEntity<Response<AssignedApplicationsResponse>> getAssignedApplicationById(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The assigned application id", required = true) @PathVariable(value = "id", required = true) Long id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public interface CallApi {
|
|||||||
public ResponseEntity<Response<CallResponse>> updateCallStep1(HttpServletRequest request,
|
public ResponseEntity<Response<CallResponse>> updateCallStep1(HttpServletRequest request,
|
||||||
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId,
|
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId,
|
||||||
@Parameter(description = "Call request object", required = true) @Valid @RequestBody UpdateCallRequestStep1 updateCallRequest);
|
@Parameter(description = "Call request object", required = true) @Valid @RequestBody UpdateCallRequestStep1 updateCallRequest);
|
||||||
@Operation(summary = "Api to get call by id",
|
@Operation(summary = "Api to get call by id updated today to check the bug",
|
||||||
responses = {
|
responses = {
|
||||||
@ApiResponse(responseCode = "200", description = "OK"),
|
@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 = {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public interface LoginAttemptApi {
|
|||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||||
@GetMapping(value = "/login-attempt", produces = {"application/json"})
|
@GetMapping(value = "/login-attempt", produces = {"application/json"})
|
||||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||||
default ResponseEntity<LoginAttemptPageableResponseBean<List<LoginAttemptEntity>>> getLoginAttemptsList(
|
default ResponseEntity<LoginAttemptPageableResponseBean<List<LoginAttemptEntity>>> getLoginAttemptsList(HttpServletRequest request,
|
||||||
@ApiParam(value = "page number") @RequestParam(name = "pageNo", required = false) Integer pageNo,
|
@ApiParam(value = "page number") @RequestParam(name = "pageNo", required = false) Integer pageNo,
|
||||||
@ApiParam(value = "page limit") @RequestParam(name = "pageLimit", required = false) Integer pageLimit) {
|
@ApiParam(value = "page limit") @RequestParam(name = "pageLimit", required = false) Integer pageLimit) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
|
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.S3ConfigReq;
|
||||||
|
import net.gepafin.tendermanagement.model.response.S3ConfigBean;
|
||||||
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Validated
|
||||||
|
public interface S3ConfigApi {
|
||||||
|
|
||||||
|
@Operation(summary = "Api to create S3Path structure.", 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) })) })
|
||||||
|
@PostMapping(value = "", produces = { "application/json" })
|
||||||
|
ResponseEntity<Response<S3ConfigBean>> addS3Path(@Valid @RequestBody S3ConfigReq s3pathReq);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to get S3Path structure. by type", 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) })) })
|
||||||
|
@GetMapping(value = "", produces = { "application/json" })
|
||||||
|
ResponseEntity<Response<Optional<S3ConfigEntity>>> getS3PathByType(@Valid @Param(value = "type") String type);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to delete S3Path structure. by id", 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) })) })
|
||||||
|
@DeleteMapping(value = "", produces = { "application/json" })
|
||||||
|
ResponseEntity<Response<S3ConfigEntity>> deleteS3PathConfigById(@Valid @Param(value = "id") Long id);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to update S3Path structure. by id", 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 = "", produces = { "application/json" })
|
||||||
|
ResponseEntity<Response<S3ConfigBean>> updateS3PathConfigById(@Valid @RequestBody S3ConfigReq s3PathConfigurationReq, @Param(value = "id") Long id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
|
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
|
||||||
|
@Validated
|
||||||
|
public interface S3MigrationApi {
|
||||||
|
|
||||||
|
@Operation(summary = "Api to migrate S3 doc to db and update s3 files as per specified folder.", 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 = "/{key}", produces = { "application/json" })
|
||||||
|
String reUploadAndMigrateDocuments(@Parameter(description = "The secret key", required = true) @PathVariable("key") String key);
|
||||||
|
}
|
||||||
@@ -59,7 +59,7 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/{userId}",
|
@RequestMapping(value = "/{userId}",
|
||||||
produces = {"application/json"},
|
produces = {"application/json"},
|
||||||
method = RequestMethod.PUT)
|
method = RequestMethod.PUT)
|
||||||
default ResponseEntity<Response<UserResponseBean>> updateUser(
|
default ResponseEntity<Response<UserResponseBean>> updateUser(HttpServletRequest request,
|
||||||
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
|
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
|
||||||
@Parameter(description = "User request object", required = true) @Valid @RequestBody UpdateUserReq userReq) {
|
@Parameter(description = "User request object", required = true) @Valid @RequestBody UpdateUserReq userReq) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
@@ -77,7 +77,7 @@ public interface UserApi {
|
|||||||
@RequestMapping(value = "/{userId}",
|
@RequestMapping(value = "/{userId}",
|
||||||
produces = {"application/json"},
|
produces = {"application/json"},
|
||||||
method = RequestMethod.GET)
|
method = RequestMethod.GET)
|
||||||
default ResponseEntity<Response<UserResponseBean>> getUserById(
|
default ResponseEntity<Response<UserResponseBean>> getUserById(HttpServletRequest request,
|
||||||
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId) {
|
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ public interface UserApi {
|
|||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||||
@RequestMapping(value = "/{userId}",
|
@RequestMapping(value = "/{userId}",
|
||||||
method = RequestMethod.DELETE)
|
method = RequestMethod.DELETE)
|
||||||
default ResponseEntity<Response<Void>> deleteUser(
|
default ResponseEntity<Response<Void>> deleteUser(HttpServletRequest request,
|
||||||
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId) {
|
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
|
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
@Validated
|
||||||
|
public interface UserSignedAndDelegationApi {
|
||||||
|
@Operation(summary = "Api to migrate S3 doc to db and user-delegated folder", 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) })) })
|
||||||
|
@GetMapping(value = "/{key}", produces = { "application/json" })
|
||||||
|
String migrateUserDelegatedDocuments(@Parameter(description = "The secret key", required = true) @PathVariable("key") String key);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to migrate S3 doc to user-signed.", 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) })) })
|
||||||
|
@PostMapping(value = "/{key}", produces = { "application/json" })
|
||||||
|
String migrateUserSignedDocuments(@Parameter(description = "The secret key", required = true) @PathVariable("key") String key);
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
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.ApplicationEvaluationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.request.UpdateApplicationEvaluationRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
|
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.ApplicationEvaluationApi;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
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 {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationEvaluationService applicationEvaluationService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<ApplicationEvaluationResponse>> createOrUpdateApplicationEvaluation(HttpServletRequest request,
|
||||||
|
Long assignedApplicationsId,ApplicationEvaluationRequest evaluationRequest) {
|
||||||
|
ApplicationEvaluationResponse response = applicationEvaluationService.createOrUpdateApplicationEvaluation(request,evaluationRequest,assignedApplicationsId);
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
|
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_CREATED_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<ApplicationEvaluationResponse>> getApplicationEvaluationByApplicationId(
|
||||||
|
HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
|
||||||
|
|
||||||
|
ApplicationEvaluationResponse response = null;
|
||||||
|
response = applicationEvaluationService.getApplicationEvaluationByApplicationId(request, applicationId,assignedApplicationId);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_FETCHED_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Void>> deleteApplicationEvaluation(HttpServletRequest request,
|
||||||
|
Long id) {
|
||||||
|
applicationEvaluationService.deleteApplicationEvaluation(request,id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_DELETED_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<ApplicationEvaluationResponse>> updateApplicationEvaluationStatus(HttpServletRequest request, Long applicationId,
|
||||||
|
ApplicationEvaluationStatusTypeEnum status) {
|
||||||
|
ApplicationEvaluationResponse applicationEvaluationResponse = applicationEvaluationService.updateApplicationEvaluationStatus(request, applicationId, status);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(applicationEvaluationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_EVALUATION_STATUS_UPDATED_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,9 +43,9 @@ public class AssignedApplicationsController implements AssignedApplicationsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<List<AssignedApplicationsResponse>>> getAllAssignedApplications(Long userId) {
|
public ResponseEntity<Response<List<AssignedApplicationsResponse>>> getAllAssignedApplications(HttpServletRequest request, Long userId) {
|
||||||
log.info("Get All Assigned Applications");
|
log.info("Get All Assigned Applications");
|
||||||
List<AssignedApplicationsResponse> applications = assignedApplicationsService.getAllAssignedApplications(userId);
|
List<AssignedApplicationsResponse> applications = assignedApplicationsService.getAllAssignedApplications(request, userId);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ASSIGNED_APPLICATION_SUCCESS_MSG)));
|
.body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ASSIGNED_APPLICATION_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
@@ -59,9 +59,9 @@ public class AssignedApplicationsController implements AssignedApplicationsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<AssignedApplicationsResponse>> getAssignedApplicationById(Long id) {
|
public ResponseEntity<Response<AssignedApplicationsResponse>> getAssignedApplicationById(HttpServletRequest request, Long id) {
|
||||||
log.info("Get Assigned Applications By Id");
|
log.info("Get Assigned Applications By Id");
|
||||||
AssignedApplicationsResponse application = assignedApplicationsService.getAssignedApplicationById(id);
|
AssignedApplicationsResponse application = assignedApplicationsService.getAssignedApplicationById(request, id);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(application, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ASSIGNED_APPLICATION_SUCCESS_MSG)));
|
.body(new Response<>(application, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ASSIGNED_APPLICATION_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class CallApiController implements CallApi {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<byte[]> downloadCallDocumentsAsZip(HttpServletRequest request, Long callId) {
|
public ResponseEntity<byte[]> downloadCallDocumentsAsZip(HttpServletRequest request, Long callId) {
|
||||||
byte[] zipFile = callService.downloadCallDocumentsAsZip(callId);
|
byte[] zipFile = callService.downloadCallDocumentsAsZip(request, callId);
|
||||||
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ public class LoginAttemptApiController implements LoginAttemptApi {
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<LoginAttemptPageableResponseBean<List<LoginAttemptEntity>>> getLoginAttemptsList(Integer pageNo, Integer pageLimit) {
|
public ResponseEntity<LoginAttemptPageableResponseBean<List<LoginAttemptEntity>>> getLoginAttemptsList(HttpServletRequest request, Integer pageNo, Integer pageLimit) {
|
||||||
LoginAttemptPageableResponseBean<List<LoginAttemptEntity>> response = loginAttemptService.getLoginAttemptsList(pageNo, pageLimit);
|
LoginAttemptPageableResponseBean<List<LoginAttemptEntity>> response = loginAttemptService.getLoginAttemptsList(request, pageNo, pageLimit);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.S3ConfigReq;
|
||||||
|
import net.gepafin.tendermanagement.model.response.S3ConfigBean;
|
||||||
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
|
import net.gepafin.tendermanagement.service.S3ConfigService;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.S3ConfigApi;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("${openapi.gepafin.base-path:/v1/s3-path-config}")
|
||||||
|
public class S3ConfigController implements S3ConfigApi {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(S3ConfigController.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
S3ConfigService s3PathService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<S3ConfigBean>> addS3Path(S3ConfigReq s3pathReq) {
|
||||||
|
|
||||||
|
log.info("Request Body : {}, {}, {}", s3pathReq.getPath(), s3pathReq.getType(), s3pathReq.getBucketName());
|
||||||
|
S3ConfigBean s3Path = s3PathService.addS3Path(s3pathReq);
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED).body(new Response<S3ConfigBean>(s3Path, Status.SUCCESS, Translator.toLocale(GepafinConstant.ADDED_S3_PATH_STRUCTURE)));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Optional<S3ConfigEntity>>> getS3PathByType(String type) {
|
||||||
|
|
||||||
|
log.info("Request to get S3Path by type {}", type);
|
||||||
|
Optional<S3ConfigEntity> s3Path = s3PathService.getS3PathByType(type);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<Optional<S3ConfigEntity>>(s3Path, Status.SUCCESS, Translator.toLocale(GepafinConstant.S3_PATH_STRUCTURE_BY_TYPE)));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<S3ConfigEntity>> deleteS3PathConfigById(Long id) {
|
||||||
|
log.info("Request to delete S3Path by Id {}", id);
|
||||||
|
S3ConfigEntity deletedS3PathConfig = s3PathService.deleteS3PathById(id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<S3ConfigEntity>(deletedS3PathConfig, Status.SUCCESS, Translator.toLocale(GepafinConstant.S3_PATH_DELETE_MSG)));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<S3ConfigBean>> updateS3PathConfigById(S3ConfigReq s3PathConfigurationReq, Long id) {
|
||||||
|
S3ConfigBean updatedS3PathConfiguration = s3PathService.updateS3PathConfiguration(s3PathConfigurationReq, id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<S3ConfigBean>(updatedS3PathConfiguration, Status.SUCCESS, Translator.toLocale(GepafinConstant.S3_PATH_CONFIG_UPDATE_MSG)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.service.impl.S3ReUploadMigrationService;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.S3MigrationApi;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("${openapi.gepafin.base-path:/v1/s3-migration}")
|
||||||
|
public class S3MigrationApiController implements S3MigrationApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
S3ReUploadMigrationService s3MigrationService;
|
||||||
|
@Override
|
||||||
|
public String reUploadAndMigrateDocuments(String providedKey) {
|
||||||
|
return s3MigrationService.reUploadAndMigrateDocuments(providedKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.service.impl.UserSignedAndDelegationServiceImpl;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.UserSignedAndDelegationApi;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("${openapi.gepafin.base-path:/v1/s3-user-signed-and-delegation-migration}")
|
||||||
|
public class S3UserSignedAndDelegationMigrationController implements UserSignedAndDelegationApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
UserSignedAndDelegationServiceImpl userSignedAndDelegationService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String migrateUserDelegatedDocuments(String providedKey) {
|
||||||
|
return userSignedAndDelegationService.migrateUserDelegatedDocuments(providedKey);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String migrateUserSignedDocuments(String providedKey) {
|
||||||
|
return userSignedAndDelegationService.migrateUserSignedDocuments(providedKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,29 +44,29 @@ public class UserApiController implements UserApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<UserResponseBean>> updateUser(
|
public ResponseEntity<Response<UserResponseBean>> updateUser(HttpServletRequest request,
|
||||||
@PathVariable("userId") Long userId,
|
@PathVariable("userId") Long userId,
|
||||||
@Valid @RequestBody UpdateUserReq userReq) {
|
@Valid @RequestBody UpdateUserReq userReq) {
|
||||||
log.info("Update User - User ID: {}, Request Body: {}", userId, userReq);
|
log.info("Update User - User ID: {}, Request Body: {}", userId, userReq);
|
||||||
UserResponseBean updatedUser = userService.updateUser(userId, userReq);
|
UserResponseBean updatedUser = userService.updateUser(request, userId, userReq);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(updatedUser, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_UPDATED_SUCCESS_MSG)));
|
.body(new Response<>(updatedUser, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_UPDATED_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<UserResponseBean>> getUserById(
|
public ResponseEntity<Response<UserResponseBean>> getUserById(HttpServletRequest request,
|
||||||
@PathVariable("userId") Long userId) {
|
@PathVariable("userId") Long userId) {
|
||||||
log.info("Get User by ID - User ID: {}", userId);
|
log.info("Get User by ID - User ID: {}", userId);
|
||||||
UserResponseBean user = userService.getUserById(userId);
|
UserResponseBean user = userService.getUserById(request, userId);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(user, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_USER_SUCCESS_MSG)));
|
.body(new Response<>(user, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_USER_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<Void>> deleteUser(
|
public ResponseEntity<Response<Void>> deleteUser(HttpServletRequest request,
|
||||||
@PathVariable("userId") Long userId) {
|
@PathVariable("userId") Long userId) {
|
||||||
log.info("Delete User - User ID: {}", userId);
|
log.info("Delete User - User ID: {}", userId);
|
||||||
userService.deleteUser(userId);
|
userService.deleteUser(request, userId);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_DELETED_SUCCESS_MSG)));
|
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_DELETED_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ spring.datasource.driver-class-name=org.postgresql.Driver
|
|||||||
spring.h2.console.enabled=true
|
spring.h2.console.enabled=true
|
||||||
|
|
||||||
isVatCheckGloballyDisabled = false
|
isVatCheckGloballyDisabled = false
|
||||||
|
|
||||||
isMailSendingEnabled = true
|
isMailSendingEnabled = true
|
||||||
default_System_Receiver_Email=antonio.manca@bflows.net
|
default_System_Receiver_Email=antonio.manca@bflows.net
|
||||||
gepafin_email=rinaldo.bonazzo@bflows.net
|
gepafin_email=rinaldo.bonazzo@bflows.net
|
||||||
rinaldo_email=rinaldo.bonazzo@bflows.net
|
rinaldo_email=rinaldo.bonazzo@bflows.net
|
||||||
|
carlo_email=test@test.test
|
||||||
|
default.hub.uuid=p4lk3bcx1RStqTaIVVbXs
|
||||||
|
|||||||
@@ -7,3 +7,10 @@ spring.datasource.driver-class-name=org.postgresql.Driver
|
|||||||
# JPA Configuration
|
# JPA Configuration
|
||||||
spring.jpa.show-sql=true
|
spring.jpa.show-sql=true
|
||||||
base-url=http://localhost:8080
|
base-url=http://localhost:8080
|
||||||
|
|
||||||
|
isMailSendingEnabled = false
|
||||||
|
default_System_Receiver_Email=test@test.test
|
||||||
|
gepafin_email=test@test.test
|
||||||
|
rinaldo_email=test@test.test
|
||||||
|
carlo_email=test@test.test
|
||||||
|
default.hub.uuid=p4lk3bcx1RStqTaIVVbXs
|
||||||
@@ -14,8 +14,10 @@ fe.base.url=https://bandi.gepafin.it
|
|||||||
#SPID configuration
|
#SPID configuration
|
||||||
spid.ipd.base.url=https://login.regione.umbria.it
|
spid.ipd.base.url=https://login.regione.umbria.it
|
||||||
active.profile.folder=production
|
active.profile.folder=production
|
||||||
|
|
||||||
isMailSendingEnabled = true
|
isMailSendingEnabled = true
|
||||||
default_System_Receiver_Email=antonio.manca@bflows.net
|
default_System_Receiver_Email=antonio.manca@bflows.net
|
||||||
gepafin_email=bandi@pec.gepafin.it
|
gepafin_email=bandi@pec.gepafin.it
|
||||||
rinaldo_email=rinaldo.bonazzo@bflows.net
|
rinaldo_email=rinaldo.bonazzo@bflows.net
|
||||||
carlo_email=carlo.mancosu@bflows.net
|
carlo_email=carlo.mancosu@bflows.net
|
||||||
|
default.hub.uuid=p4lk3bcx1RStqTaIVVbXs
|
||||||
|
|||||||
@@ -6,3 +6,9 @@ spring.datasource.password=sa
|
|||||||
# JPA Configuration
|
# JPA Configuration
|
||||||
spring.h2.console.enabled=true
|
spring.h2.console.enabled=true
|
||||||
base-url=http://localhost:8080
|
base-url=http://localhost:8080
|
||||||
|
isMailSendingEnabled = false
|
||||||
|
default_System_Receiver_Email=test@test.test
|
||||||
|
gepafin_email=test@test.test
|
||||||
|
rinaldo_email=test@test.test
|
||||||
|
carlo_email=test@test.test
|
||||||
|
default.hub.uuid=p4lk3bcx1RStqTaIVVbXs
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
spring.application.name=tendermanagement
|
spring.application.name=tendermanagement
|
||||||
|
|
||||||
# Multipart Configuration
|
# Multipart Configuration
|
||||||
spring.servlet.multipart.max-file-size=15MB
|
spring.servlet.multipart.max-file-size=300MB
|
||||||
spring.servlet.multipart.max-request-size=15MB
|
spring.servlet.multipart.max-request-size=300MB
|
||||||
|
|
||||||
spring.profiles.active=testing
|
spring.profiles.active=testing
|
||||||
|
|
||||||
@@ -59,10 +59,4 @@ mailGun_base_url=https://api.eu.mailgun.net/
|
|||||||
# SendinBlue API key
|
# SendinBlue API key
|
||||||
apiKey=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
|
apiKey=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
|
||||||
#senderEmail=mailer@bflows.net
|
#senderEmail=mailer@bflows.net
|
||||||
isMailSendingEnabled = false
|
|
||||||
default_System_Receiver_Email=antonio.manca@bflows.net
|
|
||||||
gepafin_email=rinaldo.bonazzo@bflows.net
|
|
||||||
rinaldo_email=rinaldo.bonazzo@bflows.net
|
|
||||||
carlo_email=rinaldo.bonazzo@bflows.net
|
|
||||||
default.hub.uuid=p4lk3bcx1RStqTaIVVbXs
|
|
||||||
|
|
||||||
|
|||||||
@@ -250,7 +250,8 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/></column>
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<createTable tableName="lookup_data">
|
<createTable tableName="lookup_data">
|
||||||
@@ -270,7 +271,8 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/></column>
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<createTable tableName="call_target_audience_checklist">
|
<createTable tableName="call_target_audience_checklist">
|
||||||
@@ -279,10 +281,12 @@
|
|||||||
primaryKeyName="call_target_audience_checklist_pkey"/>
|
primaryKeyName="call_target_audience_checklist_pkey"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="call_id" type="INTEGER">
|
<column name="call_id" type="INTEGER">
|
||||||
<constraints nullable="false" foreignKeyName="fk_call_call_target_audience_checklist" references="call(id)"/>
|
<constraints nullable="false" foreignKeyName="fk_call_call_target_audience_checklist"
|
||||||
|
references="call(id)"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="lookup_data_id" type="INTEGER">
|
<column name="lookup_data_id" type="INTEGER">
|
||||||
<constraints nullable="false" foreignKeyName="fk_lookup_data_call_target_audience_checklist" references="lookup_data(id)"/>
|
<constraints nullable="false" foreignKeyName="fk_lookup_data_call_target_audience_checklist"
|
||||||
|
references="lookup_data(id)"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="is_validated" type="BOOLEAN">
|
<column name="is_validated" type="BOOLEAN">
|
||||||
</column>
|
</column>
|
||||||
@@ -290,14 +294,16 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/></column>
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
<changeSet id="22-08-2024_1" author="Harish Bagora">
|
<changeSet id="22-08-2024_1" author="Harish Bagora">
|
||||||
<insert tableName="region">
|
<insert tableName="region">
|
||||||
<column name="region_name" value="Italy"/>
|
<column name="region_name" value="Italy"/>
|
||||||
<column name="description" value="A beautiful country in Southern Europe known for its art, culture, and history."/>
|
<column name="description"
|
||||||
|
value="A beautiful country in Southern Europe known for its art, culture, and history."/>
|
||||||
<column name="created_date" value="2024-08-14 00:00:00"/>
|
<column name="created_date" value="2024-08-14 00:00:00"/>
|
||||||
<column name="updated_date" value="2024-08-14 00:00:00"/>
|
<column name="updated_date" value="2024-08-14 00:00:00"/>
|
||||||
<column name="country" value="Italy"/>
|
<column name="country" value="Italy"/>
|
||||||
@@ -318,7 +324,8 @@
|
|||||||
<insert tableName="role">
|
<insert tableName="role">
|
||||||
<column name="role_name" value="beneficiary"/>
|
<column name="role_name" value="beneficiary"/>
|
||||||
<column name="role_type" value="ROLE_BENEFICIARY"/>
|
<column name="role_type" value="ROLE_BENEFICIARY"/>
|
||||||
<column name="description" value="Companies or individuals looking for financing opportunities. They can view, search, and apply to available calls."/>
|
<column name="description"
|
||||||
|
value="Companies or individuals looking for financing opportunities. They can view, search, and apply to available calls."/>
|
||||||
<column name="created_date" value="2024-08-14 00:00:00"/>
|
<column name="created_date" value="2024-08-14 00:00:00"/>
|
||||||
<column name="updated_date" value="2024-08-14 00:00:00"/>
|
<column name="updated_date" value="2024-08-14 00:00:00"/>
|
||||||
<column name="permissions" value="VIEW_CALLS, APPLY_CALLS"/>
|
<column name="permissions" value="VIEW_CALLS, APPLY_CALLS"/>
|
||||||
@@ -329,7 +336,8 @@
|
|||||||
<insert tableName="role">
|
<insert tableName="role">
|
||||||
<column name="role_name" value="super admin"/>
|
<column name="role_name" value="super admin"/>
|
||||||
<column name="role_type" value="ROLE_SUPER_ADMIN"/>
|
<column name="role_type" value="ROLE_SUPER_ADMIN"/>
|
||||||
<column name="description" value="Manages the creation and publication of tenders and administers internal system users."/>
|
<column name="description"
|
||||||
|
value="Manages the creation and publication of tenders and administers internal system users."/>
|
||||||
<column name="created_date" value="2024-08-14 00:00:00"/>
|
<column name="created_date" value="2024-08-14 00:00:00"/>
|
||||||
<column name="updated_date" value="2024-08-14 00:00:00"/>
|
<column name="updated_date" value="2024-08-14 00:00:00"/>
|
||||||
<column name="permissions" value="MANAGE_TENDERS, MANAGE_USERS"/>
|
<column name="permissions" value="MANAGE_TENDERS, MANAGE_USERS"/>
|
||||||
@@ -340,7 +348,8 @@
|
|||||||
<insert tableName="role">
|
<insert tableName="role">
|
||||||
<column name="role_name" value="pre instructor"/>
|
<column name="role_name" value="pre instructor"/>
|
||||||
<column name="role_type" value="ROLE_PRE_INSTRUCTOR"/>
|
<column name="role_type" value="ROLE_PRE_INSTRUCTOR"/>
|
||||||
<column name="description" value="They evaluate the applications sent by beneficiaries and manage the preliminary relief process."/>
|
<column name="description"
|
||||||
|
value="They evaluate the applications sent by beneficiaries and manage the preliminary relief process."/>
|
||||||
<column name="created_date" value="2024-08-14 00:00:00"/>
|
<column name="created_date" value="2024-08-14 00:00:00"/>
|
||||||
<column name="updated_date" value="2024-08-14 00:00:00"/>
|
<column name="updated_date" value="2024-08-14 00:00:00"/>
|
||||||
<column name="permissions" value="EVALUATE_APPLICATIONS, MANAGE_PRELIMINARY_RELIEF"/>
|
<column name="permissions" value="EVALUATE_APPLICATIONS, MANAGE_PRELIMINARY_RELIEF"/>
|
||||||
@@ -351,7 +360,8 @@
|
|||||||
<insert tableName="role">
|
<insert tableName="role">
|
||||||
<column name="role_name" value="gepafin operator"/>
|
<column name="role_name" value="gepafin operator"/>
|
||||||
<column name="role_type" value="ROLE_GEPAFIN_OPERATOR"/>
|
<column name="role_type" value="ROLE_GEPAFIN_OPERATOR"/>
|
||||||
<column name="description" value="They manage the subsequent phases of the evaluation after the pre-investigation."/>
|
<column name="description"
|
||||||
|
value="They manage the subsequent phases of the evaluation after the pre-investigation."/>
|
||||||
<column name="created_date" value="2024-08-14 00:00:00"/>
|
<column name="created_date" value="2024-08-14 00:00:00"/>
|
||||||
<column name="updated_date" value="2024-08-14 00:00:00"/>
|
<column name="updated_date" value="2024-08-14 00:00:00"/>
|
||||||
<column name="permissions" value="MANAGE_SUBSEQUENT_PHASES"/>
|
<column name="permissions" value="MANAGE_SUBSEQUENT_PHASES"/>
|
||||||
@@ -416,7 +426,8 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/></column>
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createTable tableName="form_template">
|
<createTable tableName="form_template">
|
||||||
<column name="id" type="INTEGER" autoIncrement="true">
|
<column name="id" type="INTEGER" autoIncrement="true">
|
||||||
@@ -432,7 +443,8 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/></column>
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createTable tableName="form_field">
|
<createTable tableName="form_field">
|
||||||
<column name="id" type="INTEGER" autoIncrement="true">
|
<column name="id" type="INTEGER" autoIncrement="true">
|
||||||
@@ -454,12 +466,12 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/></column>
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<changeSet id="27-08-2024_1" author="Rajesh Khore">
|
<changeSet id="27-08-2024_1" author="Rajesh Khore">
|
||||||
<dropColumn tableName="EVALUATION_CRITERIA"
|
<dropColumn tableName="EVALUATION_CRITERIA"
|
||||||
columnName="name"/>
|
columnName="name"/>
|
||||||
@@ -586,7 +598,8 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/></column>
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<createTable tableName="application_form_field">
|
<createTable tableName="application_form_field">
|
||||||
@@ -594,7 +607,8 @@
|
|||||||
<constraints nullable="false" primaryKey="true" primaryKeyName="application_form_field_pkey"/>
|
<constraints nullable="false" primaryKey="true" primaryKeyName="application_form_field_pkey"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="application_form_id" type="INTEGER">
|
<column name="application_form_id" type="INTEGER">
|
||||||
<constraints nullable="false" foreignKeyName="fk_application_form_application_form_field" references="application_form(id)"/>
|
<constraints nullable="false" foreignKeyName="fk_application_form_application_form_field"
|
||||||
|
references="application_form(id)"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="field_id" type="VARCHAR(255)"></column>
|
<column name="field_id" type="VARCHAR(255)"></column>
|
||||||
<column name="field_value" type="VARCHAR(255)"></column>
|
<column name="field_value" type="VARCHAR(255)"></column>
|
||||||
@@ -602,7 +616,8 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/></column>
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<createTable tableName="flow_edges">
|
<createTable tableName="flow_edges">
|
||||||
@@ -618,7 +633,8 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/></column>
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<createTable tableName="flow_data">
|
<createTable tableName="flow_data">
|
||||||
@@ -634,7 +650,8 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/></column>
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<addColumn tableName="call">
|
<addColumn tableName="call">
|
||||||
@@ -664,12 +681,14 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/></column>
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
<addColumn tableName="application_form">
|
<addColumn tableName="application_form">
|
||||||
<column name="application_id" type="INTEGER">
|
<column name="application_id" type="INTEGER">
|
||||||
<constraints nullable="false" foreignKeyName="fk_application_application_form" references="application(id)"/>
|
<constraints nullable="false" foreignKeyName="fk_application_application_form"
|
||||||
|
references="application(id)"/>
|
||||||
</column>
|
</column>
|
||||||
</addColumn>
|
</addColumn>
|
||||||
|
|
||||||
@@ -1226,7 +1245,8 @@
|
|||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="application_id" type="INTEGER">
|
<column name="application_id" type="INTEGER">
|
||||||
<constraints nullable="false" foreignKeyName="fk_application_assigned_applications" references="application(id)"/>
|
<constraints nullable="false" foreignKeyName="fk_application_assigned_applications"
|
||||||
|
references="application(id)"/>
|
||||||
</column>
|
</column>
|
||||||
<column name="STATUS" type="VARCHAR(50)"/>
|
<column name="STATUS" type="VARCHAR(50)"/>
|
||||||
<column name="note" type="TEXT"></column>
|
<column name="note" type="TEXT"></column>
|
||||||
@@ -1282,9 +1302,6 @@
|
|||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<changeSet id="19-10-2024_1" author="Harish Bagora">
|
<changeSet id="19-10-2024_1" author="Harish Bagora">
|
||||||
<addColumn tableName="saml_response">
|
<addColumn tableName="saml_response">
|
||||||
<column name="IN_RESPONSE_TO" type="TEXT"/>
|
<column name="IN_RESPONSE_TO" type="TEXT"/>
|
||||||
@@ -1362,10 +1379,202 @@
|
|||||||
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/>
|
<constraints nullable="true"/>
|
||||||
</column>
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
|
||||||
|
<changeSet id="24-10-2024_1" author="Rajesh Khore">
|
||||||
|
<dropUniqueConstraint
|
||||||
|
constraintName="company_vat_number_key"
|
||||||
|
tableName="company"/>
|
||||||
|
|
||||||
|
<addColumn tableName="company">
|
||||||
|
<column name="hub_id" type="INTEGER" defaultValue="1">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</addColumn>
|
||||||
|
|
||||||
|
<addUniqueConstraint
|
||||||
|
columnNames="VAT_NUMBER, hub_id"
|
||||||
|
tableName="company"
|
||||||
|
constraintName="uk_vat_hub" />
|
||||||
|
|
||||||
|
<addForeignKeyConstraint
|
||||||
|
baseTableName="company"
|
||||||
|
baseColumnNames="hub_id"
|
||||||
|
referencedTableName="hub"
|
||||||
|
referencedColumnNames="id"
|
||||||
|
constraintName="fk_company_hub" />
|
||||||
|
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="24-10-2024_2" author="Rajesh Khore">
|
||||||
|
<dropUniqueConstraint
|
||||||
|
constraintName="beneficiary_codice_fiscale_key"
|
||||||
|
tableName="beneficiary"/>
|
||||||
|
|
||||||
|
<addColumn tableName="beneficiary">
|
||||||
|
<column name="hub_id" type="INTEGER" defaultValue="1">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</addColumn>
|
||||||
|
|
||||||
|
<addUniqueConstraint
|
||||||
|
columnNames="CODICE_FISCALE, hub_id"
|
||||||
|
tableName="beneficiary"
|
||||||
|
constraintName="uk_codice_hub" />
|
||||||
|
|
||||||
|
<addForeignKeyConstraint
|
||||||
|
baseTableName="beneficiary"
|
||||||
|
baseColumnNames="hub_id"
|
||||||
|
referencedTableName="hub"
|
||||||
|
referencedColumnNames="id"
|
||||||
|
constraintName="fk_beneficiary_hub" />
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="24-10-2024_3" author="Rajesh Khore">
|
||||||
|
<addColumn tableName="application">
|
||||||
|
<column name="hub_id" type="INTEGER" defaultValue="1">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</addColumn>
|
||||||
|
|
||||||
|
<addForeignKeyConstraint
|
||||||
|
baseTableName="application"
|
||||||
|
baseColumnNames="hub_id"
|
||||||
|
referencedTableName="hub"
|
||||||
|
referencedColumnNames="id"
|
||||||
|
constraintName="fk_application_hub" />
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="25-10-2024_1" author="Piyush">
|
||||||
|
<createTable tableName="s3_path_configuration">
|
||||||
|
<column name="id" type="INTEGER" autoIncrement="true">
|
||||||
|
<constraints nullable="false" primaryKey="true" primaryKeyName="s3_path_configuration_pkey"/>
|
||||||
|
</column>
|
||||||
|
<column name="type" type="VARCHAR(100)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="bucket_name" type="VARCHAR(500)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="parent_folder" type="VARCHAR(100)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="path" type="VARCHAR(500)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
<constraints nullable="true"/>
|
<constraints nullable="true"/>
|
||||||
</column>
|
</column>
|
||||||
</createTable>
|
</createTable>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="25-10-2024_2" author="Piyush">
|
||||||
|
<insert tableName="s3_path_configuration">
|
||||||
|
<column name="type" value="CALL"/>
|
||||||
|
<column name="path" value="call/{call_id}"/>
|
||||||
|
<column name="bucket_name" value="mementoresources"/>
|
||||||
|
<column name="created_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="updated_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="parent_folder" value="gepafin/staging"/>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert tableName="s3_path_configuration">
|
||||||
|
<column name="type" value="APPLICATION"/>
|
||||||
|
<column name="path" value="call/{call_id}/application/{application_id}"/>
|
||||||
|
<column name="bucket_name" value="mementoresources"/>
|
||||||
|
<column name="created_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="updated_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="parent_folder" value="gepafin/staging"/>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert tableName="s3_path_configuration">
|
||||||
|
<column name="type" value="USER_SIGNED_DOCUMENT"/>
|
||||||
|
<column name="path" value="call/{call_id}/application/{application_id}/user_signed_document"/>
|
||||||
|
<column name="bucket_name" value="mementoresources"/>
|
||||||
|
<column name="created_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="updated_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="parent_folder" value="gepafin/staging"/>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert tableName="s3_path_configuration">
|
||||||
|
<column name="type" value="TEMPLATE"/>
|
||||||
|
<column name="path" value="template"/>
|
||||||
|
<column name="bucket_name" value="mementoresources"/>
|
||||||
|
<column name="created_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="updated_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="parent_folder" value="gepafin/staging"/>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert tableName="s3_path_configuration">
|
||||||
|
<column name="type" value="USER_DELEGATION"/>
|
||||||
|
<column name="path" value="user_delegation"/>
|
||||||
|
<column name="bucket_name" value="mementoresources"/>
|
||||||
|
<column name="created_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="updated_date" value="2024-10-25 03:00:00"/>
|
||||||
|
<column name="parent_folder" value="gepafin/staging"/>
|
||||||
|
</insert>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="26-10-2024_1" author="Harish Bagora">
|
||||||
|
<createTable tableName="application_evaluation">
|
||||||
|
<column autoIncrement="true" name="id" type="INTEGER">
|
||||||
|
<constraints nullable="false" primaryKey="true" primaryKeyName="application_evaluation_pkey"/>
|
||||||
|
</column>
|
||||||
|
<column name="assigned_applications_id" type="INTEGER">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="application_id" type="INTEGER">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="user_id" type="INTEGER">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="criteria" type="TEXT">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="checklist" type="TEXT">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="file" type="TEXT">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="note" type="TEXT">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="status" type="VARCHAR(255)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addForeignKeyConstraint
|
||||||
|
baseTableName="application_evaluation"
|
||||||
|
baseColumnNames="user_id"
|
||||||
|
referencedTableName="gepafin_user"
|
||||||
|
referencedColumnNames="id"
|
||||||
|
constraintName="fk_application_evaluation_gepafin_user"
|
||||||
|
onDelete="CASCADE" />
|
||||||
|
<addForeignKeyConstraint
|
||||||
|
baseTableName="application_evaluation"
|
||||||
|
baseColumnNames="assigned_applications_id"
|
||||||
|
referencedTableName="assigned_applications"
|
||||||
|
referencedColumnNames="id"
|
||||||
|
constraintName="fk_application_evaluation_assigned_applications"
|
||||||
|
onDelete="CASCADE" />
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
)
|
)
|
||||||
LOOP
|
LOOP
|
||||||
EXECUTE format(
|
EXECUTE format(
|
||||||
'CREATE OR REPLACE TRIGGER tg_gepafin_schema_updated_at_%I
|
'CREATE OR REPLACE TRIGGER tg_gepafin_schema_updated_date_%I
|
||||||
BEFORE UPDATE ON gepafin_schema.%I
|
BEFORE UPDATE ON gepafin_schema.%I
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
EXECUTE FUNCTION gepafin_schema.clock_timestamp_updated_date_column()',
|
EXECUTE FUNCTION gepafin_schema.clock_timestamp_updated_date_column()',
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
)
|
)
|
||||||
LOOP
|
LOOP
|
||||||
EXECUTE format(
|
EXECUTE format(
|
||||||
'CREATE OR REPLACE TRIGGER tg_gepafin_schema_created_at_%I
|
'CREATE OR REPLACE TRIGGER tg_gepafin_schema_created_date_%I
|
||||||
BEFORE INSERT ON gepafin_schema.%I
|
BEFORE INSERT ON gepafin_schema.%I
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
EXECUTE FUNCTION gepafin_schema.clock_timestamp_created_date_column()',
|
EXECUTE FUNCTION gepafin_schema.clock_timestamp_created_date_column()',
|
||||||
|
|||||||
@@ -253,7 +253,15 @@ get_login_attempt_se_msg=Login attempts fetched successfully.
|
|||||||
application.in.submit.status.cannot.delete.company=The company cannot be deleted because there are active applications in the SUBMITTED status.
|
application.in.submit.status.cannot.delete.company=The company cannot be deleted because there are active applications in the SUBMITTED status.
|
||||||
get.users.success.msg = Successfully fetched users.
|
get.users.success.msg = Successfully fetched users.
|
||||||
cannot.create.beneficiary.user = Creation of a Beneficiary user is not allowed. Please assign the appropriate role.
|
cannot.create.beneficiary.user = Creation of a Beneficiary user is not allowed. Please assign the appropriate role.
|
||||||
|
application.evaluation.not.found=Application Evaluation not found with ID: {0}
|
||||||
|
evaluation.created.successfully = Application evaluation created successfully.
|
||||||
|
evaluation.updated.successfully = Application evaluation updated successfully.
|
||||||
|
evaluation.fetched.successfully = Application evaluation fetched successfully.
|
||||||
|
evaluation.deleted.successfully = Application evaluation deleted successfully.
|
||||||
|
evaluations.fetched.successfully = All application evaluations fetched successfully.
|
||||||
|
application.evaluation.status.updated.successfully=Application evaluation status updated successfully.
|
||||||
evaluationCriteria.invalid=This evaluation criterion does not belong to the current call.
|
evaluationCriteria.invalid=This evaluation criterion does not belong to the current call.
|
||||||
|
assigned.application.not.found.with.id=Assigned application with this application ID not found
|
||||||
|
|
||||||
|
|
||||||
# Hub Messages
|
# Hub Messages
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user