Resolved Conflicts.

This commit is contained in:
piyuskag
2024-10-25 15:49:28 +05:30
63 changed files with 818 additions and 544 deletions

View File

@@ -110,7 +110,7 @@ public class SamlSuccessHandler implements AuthenticationSuccessHandler {
logger.info("SAML login successful for user: " + principal.getName()); logger.info("SAML login successful for user: " + principal.getName());
String cf = userAttributes.get("CodiceFiscale").get(0).toString(); String cf = userAttributes.get("CodiceFiscale").get(0).toString();
UserEntity userEntity = userRepository.findByBeneficiaryCodiceFiscale(cf).orElse(null); UserEntity userEntity = userRepository.findByBeneficiaryCodiceFiscaleAndHubId(cf, hub.getId()).orElse(null);
if (userEntity == null) { if (userEntity == null) {
redirectUrl += "/registration?temp_token=" + token; redirectUrl += "/registration?temp_token=" + token;
} else { } else {

View File

@@ -248,6 +248,7 @@ public class GepafinConstant {
public static final String HUB_DELETE_SUCCESS = "hub_delete_success"; public static final String HUB_DELETE_SUCCESS = "hub_delete_success";
public static final String HUB_NOT_FOUND = "hub_not_found"; public static final String HUB_NOT_FOUND = "hub_not_found";
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 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 ADDED_S3_PATH_STRUCTURE ="added.s3.path.structure";
@@ -258,5 +259,6 @@ public class GepafinConstant {
public static final String S3_PATH_CONFIG_UPDATE_MSG ="s3.path.config.updated.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_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 S3_PATH_GENERATION_ERROR_MSG ="s3.path.config.already.exist.";
public static final String INVALID_APPLICATION_STATUS = "invalid.application.status";
} }

View File

@@ -138,12 +138,12 @@ public class ApplicationDao {
validateFormFields(applicationRequestBean,formEntity); validateFormFields(applicationRequestBean,formEntity);
ApplicationEntity applicationEntity = validateApplication(applicationId); ApplicationEntity applicationEntity = validateApplication(applicationId);
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId()); validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
if(Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.SUBMIT.getValue()))) { if(Boolean.FALSE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.DRAFT.getValue()))) {
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_SUBMITTED)); throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_NOT_IN_DRAFT_STATUS));
} }
formService.validateFormField(applicationRequestBean.getFormFields(),applicationEntity,formEntity); formService.validateFormField(applicationRequestBean.getFormFields(),applicationEntity,formEntity);
ApplicationFormEntity applicationFormEntity = getApplicationFormOrCreate(formEntity, applicationEntity); ApplicationFormEntity applicationFormEntity = getApplicationFormOrCreate(formEntity, applicationEntity);
createOrUpdateMultipleFormFields(applicationRequestBean.getFormFields(), applicationFormEntity,formEntity); createOrUpdateMultipleFormFields(applicationRequestBean.getFormFields(), applicationFormEntity, formEntity);
return getApplicationById(applicationEntity.getId(),formEntity.getId()); return getApplicationById(applicationEntity.getId(),formEntity.getId());
} }
public void validateDelegation(UserEntity user, CompanyEntity company) { public void validateDelegation(UserEntity user, CompanyEntity company) {
@@ -179,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;
@@ -291,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);
@@ -301,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));
@@ -317,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;
}; };
} }
@@ -603,25 +604,8 @@ public class ApplicationDao {
if(Boolean.TRUE.equals(applicationEntity.getStatus().equals(status.getValue()))){ if(Boolean.TRUE.equals(applicationEntity.getStatus().equals(status.getValue()))){
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)) { 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());
// CallEntity callEntity = applicationEntity.getCall();
// Long initialFormId = callEntity.getInitialForm();
// Long finalFormId = callEntity.getFinalForm();
//// if (initialFormId == null || finalFormId == null) {
//// throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
//// }
// ApplicationFormEntity initialApplicationForm = applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(), initialFormId);
// ApplicationFormEntity finalApplicationForm = applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(), finalFormId);
// if (initialApplicationForm == null || finalApplicationForm == null) {
// throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
// }
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
Long totalSteps=flowFormDao.calculateTotalSteps(flowEdgesList);
Integer completedSteps=flowFormDao.getCompletedSteps(applicationEntity);
if (totalSteps.intValue() != completedSteps) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
}
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);
@@ -630,7 +614,6 @@ public class ApplicationDao {
applicationEntity = saveApplicationEntity(applicationEntity); applicationEntity = saveApplicationEntity(applicationEntity);
sendMailToUserAndCompany(userEntity, applicationEntity); sendMailToUserAndCompany(userEntity, applicationEntity);
sendMailTodefaultSystemAndGepafin(userEntity, applicationEntity); sendMailTodefaultSystemAndGepafin(userEntity, applicationEntity);
} else {
applicationEntity.setStatus(status.getValue()); applicationEntity.setStatus(status.getValue());
applicationEntity = saveApplicationEntity(applicationEntity); applicationEntity = saveApplicationEntity(applicationEntity);
} }
@@ -806,8 +789,9 @@ public class ApplicationDao {
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue()); .findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
if (applicationSignedDocument != null) { if (applicationSignedDocument != null) {
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue()); throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_ASSIGNED));
applicationSignedDocumentRepository.save(applicationSignedDocument); // applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue());
// applicationSignedDocumentRepository.save(applicationSignedDocument);
} }
UploadFileOnAmazonS3Response uploadFileOnAmazonS3 = uploadFileOnAmazonS3ForUserSignedDocument(file, UploadFileOnAmazonS3Response uploadFileOnAmazonS3 = uploadFileOnAmazonS3ForUserSignedDocument(file,
applicationEntity.getCall().getId(), applicationId); applicationEntity.getCall().getId(), applicationId);
@@ -817,6 +801,8 @@ public class ApplicationDao {
applicationSignedDocument.setFilePath(uploadFileOnAmazonS3.getFilePath()); applicationSignedDocument.setFilePath(uploadFileOnAmazonS3.getFilePath());
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.ACTIVE.getValue()); applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
applicationSignedDocumentRepository.save(applicationSignedDocument); applicationSignedDocumentRepository.save(applicationSignedDocument);
applicationEntity.setStatus(ApplicationStatusTypeEnum.READY.getValue());
applicationRepository.save(applicationEntity);
return convertApplicationSignedDocumentToApplicationSignedDocumentResponse(applicationSignedDocument); return convertApplicationSignedDocumentToApplicationSignedDocumentResponse(applicationSignedDocument);
} }
private UploadFileOnAmazonS3Response uploadFileOnAmazonS3ForUserSignedDocument(MultipartFile file, Long callId, Long applicationId) { private UploadFileOnAmazonS3Response uploadFileOnAmazonS3ForUserSignedDocument(MultipartFile file, Long callId, Long applicationId) {
@@ -888,4 +874,24 @@ public class ApplicationDao {
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue()); applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue());
applicationSignedDocumentRepository.save(applicationSignedDocument); applicationSignedDocumentRepository.save(applicationSignedDocument);
} }
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId) {
ApplicationEntity applicationEntity = validateApplication(applicationId);
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
if (Boolean.FALSE.equals(ApplicationStatusTypeEnum.DRAFT.getValue().equals(applicationEntity.getStatus()))) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_NOT_IN_DRAFT_STATUS));
}
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
Long totalSteps=flowFormDao.calculateTotalSteps(flowEdgesList);
Integer completedSteps=flowFormDao.getCompletedSteps(applicationEntity);
if (totalSteps.intValue() != completedSteps) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
}
applicationEntity.setStatus(ApplicationStatusTypeEnum.AWAITING.getValue());
applicationEntity = saveApplicationEntity(applicationEntity);
return getApplicationResponse(applicationEntity);
}
} }

View File

@@ -1,17 +1,21 @@
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;
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity; import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
import net.gepafin.tendermanagement.entities.UserEntity; import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
import net.gepafin.tendermanagement.enums.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;
@@ -30,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);
@@ -46,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;
@@ -59,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.ASSIGNED.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()));
@@ -72,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;
} }
@@ -92,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());
@@ -131,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;
} }

View File

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

View File

@@ -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,

View File

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

View File

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

View File

@@ -15,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;
@@ -32,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;
@@ -39,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;
@@ -62,6 +64,9 @@ public class DelegationDao {
@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 {
@@ -93,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);

View File

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

View File

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

View File

@@ -10,11 +10,15 @@ import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.*; import com.itextpdf.text.pdf.*;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import net.gepafin.tendermanagement.entities.*; 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.
@@ -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 {
@@ -75,56 +80,11 @@ public class PdfDao {
addColoredLines(writer,document,greyColor); addColoredLines(writer,document,greyColor);
document.add(new Paragraph(" ")); document.add(new Paragraph(" "));
// Application ID section (Centered)
// pageEvent.setTotalPages(writer.getPageNumber());
String protocolNumber="XX00";
if(applicationEntity.getProtocol()!=null) {
protocolNumber= String.valueOf(applicationEntity.getProtocol().getProtocolNumber());
}
Paragraph appId = new Paragraph("ID domanda :" +protocolNumber);
appId.setAlignment(Element.ALIGN_RIGHT);
document.add(appId);
document.add(new Paragraph(" "));
addColoredLines(writer,document,greenColor);
document.add(new Paragraph(" "));
document.add(new Paragraph("\n")); // Add line break
// String companyName= companyEntity.getCompanyName();
// String vatNumber=companyEntity.getVatNumber();
// String address=companyEntity.getAddress();
// // Section: Dati Anagrafici Azienda
// document.add(new Paragraph("Dati Anagrafici Azienda", sectionFont));
// addLabelValuePair(document, "Codice ATECO", "SEZIONE C “ATTIVITÀ MANUFATTURIERE”", regularFont);
// addLabelValuePair(document, "Ragione Sociale", companyName, regularFont);
// addLabelValuePair(document, "Partita IVA", vatNumber, regularFont);
// addLabelValuePair(document, "Indirizzo sede Legale", address, regularFont);
//
// document.add(new Paragraph("\n")); // Add line break
//
// // Section: Domanda presentata da
// document.add(new Paragraph("Domanda presentata da:", sectionFont));
// addLabelValuePair(document, "Nome e cognome", userEntity.getBeneficiary().getFirstName()+" "+userEntity.getBeneficiary().getLastName(), regularFont);
// addLabelValuePair(document, "Codice fiscale", userEntity.getBeneficiary().getCodiceFiscale(), regularFont);
// addLabelValuePair(document, "Telefono", userEntity.getBeneficiary().getPhoneNumber(), regularFont);
// addLabelValuePair(document, "Email", userEntity.getBeneficiary().getEmail(), regularFont);
// addLabelValuePair(document, "Con il titolo di", "Rappresentante legale", regularFont);
document.add(new Paragraph(" "));
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)); document.add(new Paragraph(formApplicationResponse.getLabel(),sectionFont));
document.add(new Paragraph(" ")); // Add line break document.add(new Paragraph(" ")); // Add line break
List<FieldLabelValuePairRequest> fieldLabelValuePairRequests = getFormFieldsToLabels(formApplicationResponse); List<FieldLabelValuePairRequest> fieldLabelValuePairRequests = getFormFieldsToLabels(formApplicationResponse,writer,document);
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
} }
@@ -200,15 +160,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
@@ -221,12 +172,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
@@ -240,8 +192,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
@@ -271,44 +221,13 @@ 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);
// Handle based on the number of keys in the map
if (Boolean.FALSE.equals(containsThreeValues) && keys.size() == 2) {
// Treat the first key as the "key" and second key as the "value"
String heading = (String) entry.get(keys.get(0)); // Get value of first key
String value1 = (String) entry.get(keys.get(1)); // Get value of second key
extractedMap.put(heading,value1); // Store the first key's value as "heading"
} if (Boolean.TRUE.equals(containsThreeValues) ) {
String amount="";
// Treat the first as number, second as description, third as amount
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
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
String combinedValue = number + "; " + description + "; " + amount; // Concatenate them as a single value
extractedMap.put("combined", combinedValue); // Store as a single entry, key as "combined"
}
extractedData.add(extractedMap); // Add each extracted map to the list
}
document=createPdfTable(extractedData,document);
} }
} }
else { else {
@@ -325,150 +244,89 @@ public class PdfDao {
} }
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<>();
// 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);
}
});
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);
// Iterate through extracted data to populate the table
for (Map<String, Object> row : extractedData) {
// Add headers once
if (!headersAdded) {
for (Map.Entry<String, String> stateField : stateFieldMap.entrySet()) {
String headerValue = stateField.getValue(); // Header text
// Add table header PdfPCell headerCell = new PdfPCell(new Phrase(headerValue)); // Create a new PdfPCell for the header
// Populate the table with extracted data and style rows headerCell.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
for (Map<String, String> row : extractedData) { headerCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
for (Map.Entry<String, String> entry : row.entrySet()) { headerCell.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
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 table.addCell(headerCell); // Add the header cell to the table
if ("combined".equals(key)) { }
// Ensure the combined header is added only once headersAdded = true; // Prevent headers from being added again
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 // Add data rows matching stateFieldMap keys
String[] combinedValues = value.split("; "); for (Map.Entry<String, String> stateField : stateFieldMap.entrySet()) {
String stateKey = stateField.getKey(); // Get the key from stateFieldMap
if (row.containsKey(stateKey)) { // If row contains the stateKey
Object value = row.get(stateKey); // Get the value from the row map
// Check if we have 3 parts (number, description, amount) PdfPCell dynamicCell = new PdfPCell(new Phrase(value != null ? value.toString() : "", textFont));
String number = combinedValues[0]; // 1st part (number) dynamicCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for the cell
String description = combinedValues[1]; // 2nd part (description) dynamicCell.setMinimumHeight(rowHeight);
String amount = ""; dynamicCell.setPadding(7f);
if (combinedValues.length == 3) {
amount = combinedValues[2]; // 3rd part (amount) table.addCell(dynamicCell); // Add the dynamically created cell to the table
}
} }
// Create PDF cells using the split values // Check if adding another row would exceed max height
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);
} else {
if (!combinedHeaderAdded) {
// 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);
}
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,
@@ -489,83 +347,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();

View File

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

View File

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

View File

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

View File

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

View File

@@ -6,7 +6,10 @@ public enum ApplicationStatusTypeEnum {
DRAFT("DRAFT"), DRAFT("DRAFT"),
SUBMIT("SUBMIT"), SUBMIT("SUBMIT"),
DISCARD("DISCARD"); AWAITING("AWAITING"),
READY("READY"),
DISCARD("DISCARD"),
EVALUATION("EVALUATION");
private String value; private String value;

View File

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

View File

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

View File

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

View File

@@ -5,8 +5,10 @@ import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data; import lombok.Data;
import net.gepafin.tendermanagement.enums.CallStatusEnum; import net.gepafin.tendermanagement.enums.CallStatusEnum;
import net.gepafin.tendermanagement.util.DynamicLocalTimeSerializer;
@Data @Data
public class CallResponse { public class CallResponse {
@@ -47,8 +49,10 @@ public class CallResponse {
private String phoneNumber; private String phoneNumber;
@JsonSerialize(using = DynamicLocalTimeSerializer.class)
private LocalTime startTime; private LocalTime startTime;
@JsonSerialize(using = DynamicLocalTimeSerializer.class)
private LocalTime endTime; private LocalTime endTime;
private LocalDateTime createdDate; private LocalDateTime createdDate;

View File

@@ -32,14 +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") @Query("SELECT a.call.id FROM ApplicationEntity a WHERE a.id = :id")
Long findCallIdById(@Param("id") Long id); Long findCallIdById(@Param("id") Long id);
} }

View File

@@ -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,30 @@ 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 c.name, COUNT(a.id) " + // @Query("SELECT COALESCE(SUM(c.amount), 0) FROM CallEntity c WHERE c.status = 'PUBLISH'")
"FROM CallEntity c LEFT JOIN ApplicationEntity a ON c.id = a.call.id " + // BigDecimal findTotalAmountOfPublishedCalls();
"GROUP BY c.name")
List<Object[]> findApplicationsPerCall(); // @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);
} }

View File

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

View File

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

View File

@@ -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);
@@ -33,4 +21,8 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
List<UserEntity> findByHubId(Long hubId); List<UserEntity> findByHubId(Long hubId);
Long countByStatusAndRoleEntityRoleTypeAndHubId(String status, String roleName, Long hubId); Long countByStatusAndRoleEntityRoleTypeAndHubId(String status, String roleName, Long hubId);
Optional<UserEntity> findByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
} }

View File

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

View File

@@ -40,4 +40,6 @@ public interface ApplicationService {
public void deleteSignedDocument(HttpServletRequest request, Long applicationId); public void deleteSignedDocument(HttpServletRequest request, Long applicationId);
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId);
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -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);
} }
@@ -110,6 +111,11 @@ public class ApplicationServiceImpl implements ApplicationService {
applicationDao.deleteSignedDocument(request, applicationId); applicationDao.deleteSignedDocument(request, applicationId);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId) {
return applicationDao.validateApplication(request, applicationId);
}
} }

View File

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

View File

@@ -8,6 +8,7 @@ import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.dao.CompanyDao; import net.gepafin.tendermanagement.dao.CompanyDao;
import net.gepafin.tendermanagement.dao.LoginAttemptDao; import net.gepafin.tendermanagement.dao.LoginAttemptDao;
import net.gepafin.tendermanagement.dao.RoleDao; import net.gepafin.tendermanagement.dao.RoleDao;
import net.gepafin.tendermanagement.entities.HubEntity;
import net.gepafin.tendermanagement.entities.LoginAttemptEntity; import net.gepafin.tendermanagement.entities.LoginAttemptEntity;
import net.gepafin.tendermanagement.entities.SamlResponseEntity; import net.gepafin.tendermanagement.entities.SamlResponseEntity;
import net.gepafin.tendermanagement.entities.UserEntity; import net.gepafin.tendermanagement.entities.UserEntity;
@@ -22,6 +23,7 @@ import net.gepafin.tendermanagement.model.response.UserSamlResponse;
import net.gepafin.tendermanagement.model.util.JWTToken; import net.gepafin.tendermanagement.model.util.JWTToken;
import net.gepafin.tendermanagement.repositories.SamlResponseRepository; import net.gepafin.tendermanagement.repositories.SamlResponseRepository;
import net.gepafin.tendermanagement.repositories.UserRepository; import net.gepafin.tendermanagement.repositories.UserRepository;
import net.gepafin.tendermanagement.service.HubService;
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.web.rest.api.errors.CustomValidationException; import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
@@ -64,6 +66,9 @@ public class AuthenticationService {
@Autowired @Autowired
private LoginAttemptDao loginAttemptDao; private LoginAttemptDao loginAttemptDao;
@Autowired
private HubService hubService;
@Autowired @Autowired
public AuthenticationService(TokenProvider tokenProvider, AuthenticationManager authenticationManager) { public AuthenticationService(TokenProvider tokenProvider, AuthenticationManager authenticationManager) {
this.tokenProvider = tokenProvider; this.tokenProvider = tokenProvider;
@@ -186,10 +191,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();
UserEntity userEntity = userRepository.findByBeneficiaryCodiceFiscale(cf) UserEntity userEntity = userRepository.findByBeneficiaryCodiceFiscaleAndHubId(cf, hub.getId())
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, .orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG))); Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
//samlResponseLogRepository.delete(samlResponseLogEntity); //samlResponseLogRepository.delete(samlResponseLogEntity);
@@ -205,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));
} }

View File

@@ -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);
} }
@@ -81,7 +80,7 @@ public class BeneficiaryPreferredCallServiceImpl implements BeneficiaryPreferred
} }
if(beneficiaryId!=null){ if(beneficiaryId!=null){
UserEntity user = userService.getUserByBeneficiaryId(beneficiaryId); UserEntity user = userService.getUserByBeneficiaryId(beneficiaryId);
return validator.validateUserId(request,user.getId()); return validator.validateUserId(request, user.getId());
} }
else{ else{
return validator.validateUserId(request, userId); return validator.validateUserId(request, userId);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,26 @@
package net.gepafin.tendermanagement.util;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
public class DynamicLocalTimeSerializer extends JsonSerializer<LocalTime> {
private static final DateTimeFormatter HH_MM_FORMAT = DateTimeFormatter.ofPattern("HH:mm");
private static final DateTimeFormatter HH_MM_SS_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss");
@Override
public void serialize(LocalTime time, JsonGenerator gen, SerializerProvider serializers) throws IOException {
// Use HH:mm if seconds are 00, otherwise use HH:mm:ss
String formattedTime = (time.getSecond() == 0)
? time.format(HH_MM_FORMAT)
: time.format(HH_MM_SS_FORMAT);
gen.writeString(formattedTime);
}
}

View File

@@ -31,6 +31,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 {
@@ -315,4 +317,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);
}
}
} }

View File

@@ -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,10 +124,15 @@ 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) { private Long getUserIdFromToken(HttpServletRequest request) {
@@ -124,4 +153,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));
}
}
} }

View File

@@ -176,16 +176,29 @@ public interface ApplicationApi {
ResponseEntity<Response<ApplicationSignedDocumentResponse>> getSignedDocument(HttpServletRequest request, ResponseEntity<Response<ApplicationSignedDocumentResponse>> getSignedDocument(HttpServletRequest request,
@Parameter(description = "The applicationId id", required = true) @PathVariable("applicationId") Long applicationId); @Parameter(description = "The applicationId id", required = true) @PathVariable("applicationId") Long applicationId);
@Operation(summary = "Api to delete signed document", responses = { @ApiResponse(responseCode = "200", description = "OK"), // @Operation(summary = "Api to delete signed document", 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 = "{applicationId}/signedDocument", produces = "application/json")
// ResponseEntity<Response<Void>> deleteSignedDocument(HttpServletRequest request,
// @Parameter(description = "The applicationId id", required = true) @PathVariable("applicationId") Long applicationId);
@Operation(summary = "Api to validate application",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })), @ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })), @ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@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) })) })
@DeleteMapping(value = "{applicationId}/signedDocument", produces = "application/json") @PostMapping(value = "/{applicationId}/validate", produces = { "application/json" })
ResponseEntity<Response<Void>> deleteSignedDocument(HttpServletRequest request, ResponseEntity<Response<ApplicationResponse>> validateApplication(HttpServletRequest request,
@Parameter(description = "The applicationId id", required = true) @PathVariable("applicationId") Long applicationId); @Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId);
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -133,13 +133,20 @@ public class ApplicationApiController implements ApplicationApi {
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_SIGNED_DOCUMENT_FILE_SUCCESS))); .body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_SIGNED_DOCUMENT_FILE_SUCCESS)));
} }
// @Override
// public ResponseEntity<Response<Void>> deleteSignedDocument(HttpServletRequest request,
// Long applicationId) {
// applicationService.deleteSignedDocument(request, applicationId);
// log.info("delete signed document applicationId: {}", applicationId);
// return ResponseEntity.status(HttpStatus.OK)
// .body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_SIGNED_DOCUMENT_FILE_SUCCESS)));
// }
@Override @Override
public ResponseEntity<Response<Void>> deleteSignedDocument(HttpServletRequest request, public ResponseEntity<Response<ApplicationResponse>> validateApplication(HttpServletRequest request, Long applicationId) {
Long applicationId) { ApplicationResponse applicationResponse = applicationService.validateApplication(request, applicationId);
applicationService.deleteSignedDocument(request, applicationId);
log.info("delete signed document applicationId: {}", applicationId);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_SIGNED_DOCUMENT_FILE_SUCCESS))); .body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_STATUS_UPDATED_SUCCESSFULLY)));
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1345,6 +1345,71 @@
referencedColumnNames="id"/> referencedColumnNames="id"/>
</changeSet> </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"> <changeSet id="25-10-2024_1" author="Piyush">
<createTable tableName="s3_path_configuration"> <createTable tableName="s3_path_configuration">
<column name="id" type="INTEGER" autoIncrement="true"> <column name="id" type="INTEGER" autoIncrement="true">
@@ -1418,4 +1483,6 @@
</insert> </insert>
</changeSet> </changeSet>
</databaseChangeLog> </databaseChangeLog>

View File

@@ -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()',

View File

@@ -264,6 +264,8 @@ hub_get_all_success=Hubs retrieved successfully
hub_delete_success=Hub deleted successfully hub_delete_success=Hub deleted successfully
hub_not_found=Hub not found hub_not_found=Hub not found
application.not.in.draft.status=Application is not in DRAFT status.
application.assigned.success.msg = Application assigned successfully. application.assigned.success.msg = Application assigned successfully.
@@ -273,4 +275,4 @@ assigned.application.deleted.success=Assigned Application successfully deleted.
assigned.application.get.success=Assigned Application details fetched successfully. assigned.application.get.success=Assigned Application details fetched successfully.
assigned.application.update.successfully=Assigned Application updated successfully. assigned.application.update.successfully=Assigned Application updated successfully.
get.error.s3=Failed to fetch the file from S3. get.error.s3=Failed to fetch the file from S3.
invalid.application.status = Invalid Application status.

View File

@@ -259,6 +259,7 @@ aasigned.application.not.found = Applicazione assegnata non trovata con l'ID spe
assigned.application.deleted.success =Applicazione assegnata eliminata con successo. assigned.application.deleted.success =Applicazione assegnata eliminata con successo.
assigned.application.get.success =Dettagli dell'applicazione assegnata recuperati correttamente. assigned.application.get.success =Dettagli dell'applicazione assegnata recuperati correttamente.
assigned.application.update.successfully = Applicazione assegnata aggiornata correttamente. assigned.application.update.successfully = Applicazione assegnata aggiornata correttamente.
invalid.application.status = Stato della domanda non valido.
# Hub Messages # Hub Messages
hub_create_success=Hub creato con successo hub_create_success=Hub creato con successo
@@ -267,4 +268,6 @@ hub_get_success=Hub recuperato con successo
hub_get_all_success=Hub recuperati con successo hub_get_all_success=Hub recuperati con successo
hub_delete_success=Hub eliminato con successo hub_delete_success=Hub eliminato con successo
hub_not_found=Hub non trovato hub_not_found=Hub non trovato
application.not.in.draft.status=La domanda non <20> in stato DRAFT.
get.error.s3=Impossibile recuperare il file da S3. get.error.s3=Impossibile recuperare il file da S3.