Done ticket GEPAFINBE-104
This commit is contained in:
@@ -146,12 +146,15 @@ public class ApplicationDao {
|
||||
@Autowired
|
||||
private EmailLogDao emailLogDao;
|
||||
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
|
||||
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
||||
FormEntity formEntity = formService.validateForm(formId);
|
||||
// callService.validatePublishedCall(formEntity.getCall().getId());
|
||||
validateFormFields(applicationRequestBean,formEntity);
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
if(Boolean.FALSE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.DRAFT.getValue()))) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_NOT_IN_DRAFT_STATUS));
|
||||
}
|
||||
@@ -160,11 +163,10 @@ public class ApplicationDao {
|
||||
createOrUpdateMultipleFormFields(applicationRequestBean.getFormFields(), applicationFormEntity, formEntity);
|
||||
return getApplicationById(applicationEntity.getId(),formEntity.getId());
|
||||
}
|
||||
public void validateDelegation(UserEntity user, CompanyEntity company) {
|
||||
UserWithCompanyEntity userWithCompany = companyService.getUserWithCompanyEntity(user.getId(), company.getId());
|
||||
public void validateDelegation(UserEntity user, UserWithCompanyEntity userWithCompany) {
|
||||
|
||||
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
|
||||
.findByUserIdAndCompanyIdAndStatus(user.getId(), company.getId(),
|
||||
.findByUserIdAndUserWithCompanyIdAndStatus(user.getId(), userWithCompany.getId(),
|
||||
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||
|
||||
if (!userWithCompany.getIsLegalRepresentant() && userCompanyDelegationEntity == null) {
|
||||
@@ -187,13 +189,14 @@ public class ApplicationDao {
|
||||
return applicationFormEntity;
|
||||
}
|
||||
|
||||
public ApplicationEntity createApplicationEntity(UserEntity user, CallEntity call, CompanyEntity companyEntity) {
|
||||
validateDelegation(user,companyEntity);
|
||||
public ApplicationEntity createApplicationEntity(UserEntity user, CallEntity call, UserWithCompanyEntity userWithCompany) {
|
||||
validateDelegation(user,userWithCompany);
|
||||
ApplicationEntity entity = new ApplicationEntity();
|
||||
entity.setUserId(user.getId());
|
||||
entity.setCompany(companyEntity);
|
||||
entity.setCompanyId(userWithCompany.getCompanyId());
|
||||
entity.setCall(call);
|
||||
entity.setHubId(call.getHub().getId());
|
||||
entity.setUserWithCompany(userWithCompany);
|
||||
entity.setIsDeleted(false);
|
||||
entity.setStatus(ApplicationStatusTypeEnum.DRAFT.getValue());
|
||||
return entity;
|
||||
@@ -262,7 +265,7 @@ public class ApplicationDao {
|
||||
log.info("Deleting application with ID: {}", id);
|
||||
|
||||
ApplicationEntity applicationEntity= validateApplication(id);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
applicationEntity.setIsDeleted(true);
|
||||
applicationEntity=saveApplicationEntity(applicationEntity);
|
||||
log.info("Application deleted with ID: {}", id);
|
||||
@@ -329,7 +332,7 @@ public class ApplicationDao {
|
||||
predicate = builder.and(predicate, builder.equal(root.get("call").get("id"), callId));
|
||||
}
|
||||
if (companyId != null) {
|
||||
predicate = builder.and(predicate, builder.equal(root.get("company").get("id"), companyId));
|
||||
predicate = builder.and(predicate, builder.equal(root.get("companyId"), companyId));
|
||||
}
|
||||
if (statusList != null && !statusList.isEmpty()) {
|
||||
List<String> statusNames = statusList.stream()
|
||||
@@ -361,8 +364,9 @@ public class ApplicationDao {
|
||||
responseBean.setSubmissionDate(applicationEntity.getSubmissionDate());
|
||||
responseBean.setStatus(applicationEntity.getStatus());
|
||||
responseBean.setComments(applicationEntity.getComments());
|
||||
responseBean.setCompanyId(applicationEntity.getCompany().getId());
|
||||
responseBean.setCompanyName(applicationEntity.getCompany().getCompanyName());
|
||||
responseBean.setCompanyId(applicationEntity.getCompanyId());
|
||||
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
responseBean.setCompanyName(company.getCompanyName());
|
||||
if(applicationEntity.getProtocol() != null) {
|
||||
responseBean.setProtocolNumber(applicationEntity.getProtocol().getProtocolNumber());
|
||||
}
|
||||
@@ -701,11 +705,12 @@ public class ApplicationDao {
|
||||
applicationGetResponseBean.setSubmissionDate(applicationEntity.getSubmissionDate());
|
||||
applicationGetResponseBean.setCallId(applicationEntity.getCall().getId());
|
||||
applicationGetResponseBean.setCallTitle(applicationEntity.getCall().getName());
|
||||
applicationGetResponseBean.setCompanyId(applicationEntity.getCompany().getId());
|
||||
applicationGetResponseBean.setCompanyId(applicationEntity.getCompanyId());
|
||||
if(applicationEntity.getProtocol() != null) {
|
||||
applicationGetResponseBean.setProtocolNumber(applicationEntity.getProtocol().getProtocolNumber());
|
||||
}
|
||||
applicationGetResponseBean.setCompanyName(applicationEntity.getCompany().getCompanyName());
|
||||
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
applicationGetResponseBean.setCompanyName(company.getCompanyName());
|
||||
return applicationGetResponseBean;
|
||||
}
|
||||
|
||||
@@ -722,16 +727,18 @@ public class ApplicationDao {
|
||||
public ApplicationResponse createApplicationByCallId(CompanyEntity companyEntity,
|
||||
ApplicationRequest applicationRequest, Long callId, UserEntity userEntity) {
|
||||
CallEntity call = callService.validateCall(callId);
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyEntity.getId());
|
||||
|
||||
// call = callService.validatePublishedCall(call.getId());
|
||||
checkIfApplicationExists(call, companyEntity, userEntity);
|
||||
ApplicationEntity applicationEntity = createApplicationEntity(userEntity, call, companyEntity);
|
||||
checkIfApplicationExists(call, userWithCompanyEntity, userEntity);
|
||||
ApplicationEntity applicationEntity = createApplicationEntity(userEntity, call, userWithCompanyEntity);
|
||||
applicationEntity.setComments(applicationRequest.getComments());
|
||||
applicationEntity = saveApplicationEntity(applicationEntity);
|
||||
ApplicationResponse applicationResponse = getApplicationResponse(applicationEntity);
|
||||
return applicationResponse;
|
||||
}
|
||||
public void checkIfApplicationExists(CallEntity call, CompanyEntity companyEntity, UserEntity userEntity){
|
||||
Optional<ApplicationEntity> applicationEntity=applicationRepository.findByUserIdAndCompanyIdAndCallIdAndIsDeletedFalse(userEntity.getId(), companyEntity.getId(),call.getId());
|
||||
public void checkIfApplicationExists(CallEntity call, UserWithCompanyEntity userWithCompanyEntity, UserEntity userEntity){
|
||||
Optional<ApplicationEntity> applicationEntity=applicationRepository.findByUserIdAndUserWithCompanyIdAndCallIdAndIsDeletedFalse(userEntity.getId(), userWithCompanyEntity.getId(),call.getId());
|
||||
if(applicationEntity.isPresent()){
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_EXISTS));
|
||||
}
|
||||
@@ -740,7 +747,7 @@ public class ApplicationDao {
|
||||
public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) {
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
if (ApplicationStatusTypeEnum.SUBMIT.getValue().equals(applicationEntity.getStatus())) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_SUBMITTED_CANNOT_CHANGE));
|
||||
}
|
||||
@@ -846,7 +853,7 @@ public class ApplicationDao {
|
||||
|
||||
private void sendMailToUserAndCompany(UserEntity userEntity, ApplicationEntity applicationEntity) {
|
||||
CallEntity call =applicationEntity.getCall();
|
||||
CompanyEntity company = applicationEntity.getCompany();
|
||||
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
ProtocolEntity protocol = applicationEntity.getProtocol();
|
||||
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
|
||||
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService
|
||||
@@ -889,7 +896,7 @@ public class ApplicationDao {
|
||||
recipientEmails.add(contactEmail);
|
||||
}
|
||||
if(Boolean.FALSE.equals(recipientEmails.isEmpty())){
|
||||
emailLogRequest.setRecipientId(applicationEntity.getCompany().getId());
|
||||
emailLogRequest.setRecipientId(applicationEntity.getCompanyId());
|
||||
emailLogRequest.setRecipientType(RecipientTypeEnum.COMPANY);
|
||||
emailLogRequest.setRecipientEmails(companyEmail);
|
||||
}
|
||||
@@ -897,7 +904,7 @@ public class ApplicationDao {
|
||||
}
|
||||
private void sendMailTodefaultSystemAndGepafin(UserEntity userEntity, ApplicationEntity applicationEntity) {
|
||||
CallEntity call = applicationEntity.getCall();
|
||||
CompanyEntity company = applicationEntity.getCompany();
|
||||
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
ProtocolEntity protocol = applicationEntity.getProtocol();
|
||||
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
|
||||
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService
|
||||
@@ -941,7 +948,7 @@ public class ApplicationDao {
|
||||
public ApplicationSignedDocumentResponse uploadSignedDocument(HttpServletRequest request, Long applicationId,
|
||||
MultipartFile file) {
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
validateFileTypeForCall(file, applicationEntity);
|
||||
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
|
||||
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
@@ -1017,7 +1024,7 @@ public class ApplicationDao {
|
||||
public ApplicationSignedDocumentResponse getSignedDocument(HttpServletRequest request, Long applicationId) {
|
||||
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
|
||||
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
|
||||
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
@@ -1030,7 +1037,7 @@ public class ApplicationDao {
|
||||
|
||||
public void deleteSignedDocument(HttpServletRequest request, Long applicationId) {
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
|
||||
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
|
||||
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
@@ -1045,7 +1052,7 @@ public class ApplicationDao {
|
||||
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId) {
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
if (Boolean.FALSE.equals(ApplicationStatusTypeEnum.DRAFT.getValue().equals(applicationEntity.getStatus()))) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_NOT_IN_DRAFT_STATUS));
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
@@ -14,6 +15,7 @@ import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
@@ -51,6 +53,9 @@ public class AssignedApplicationsDao {
|
||||
@Autowired
|
||||
private ApplicationEvaluationDao applicationEvaluationDao;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
public AssignedApplicationsResponse createAssignedApplications(Long applicationId, Long userId, UserEntity assignedByUser, AssignedApplicationsRequest assignedApplicationsRequest){
|
||||
log.info("Assigning application to pre-Instructor with details: {}", applicationId,userId);
|
||||
|
||||
@@ -131,7 +136,8 @@ public class AssignedApplicationsDao {
|
||||
assignedApplicationsResponse.setAssignedAt(assignedApplications.getAssignedAt());
|
||||
assignedApplicationsResponse.setProtocolNumber(protocolNumber);
|
||||
assignedApplicationsResponse.setCallName(callName);
|
||||
assignedApplicationsResponse.setCompanyName(application.getCompany().getCompanyName());
|
||||
CompanyEntity company=companyService.validateCompany(application.getCompanyId());
|
||||
assignedApplicationsResponse.setCompanyName(company.getCompanyName());
|
||||
assignedApplicationsResponse.setBeneficiaryName(beneficiaryName);
|
||||
assignedApplicationsResponse.setSubmissionDate(submissionDate);
|
||||
assignedApplicationsResponse.setCallEndDate(callEndDate);
|
||||
|
||||
@@ -4,11 +4,14 @@ import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.BeneficiaryPreferredCallEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
|
||||
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
||||
|
||||
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.BeneficiaryPreferredCallRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
@@ -36,26 +39,32 @@ public class BeneficiaryPreferredCallDao {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
|
||||
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest httpServletRequest, BeneficiaryPreferredCallReq request, UserEntity user) {
|
||||
log.info("Creating new beneficiary preferred call with details: {}", request);
|
||||
validator.validateUserWithCompany(httpServletRequest, request.getCompanyId());
|
||||
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(), request.getCompanyId());
|
||||
Optional<BeneficiaryPreferredCallEntity> existingCall = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndCallIdAndCompanyIdAndIsDeletedFalse(user.getId(), request.getCallId(), request.getCompanyId());
|
||||
.findByUserIdAndCallIdAndUserWithCompanyIdAndIsDeletedFalse(user.getId(), request.getCallId(), userWithCompanyEntity.getId());
|
||||
|
||||
if (existingCall.isPresent()) {
|
||||
log.warn("Duplicate beneficiary preferred call detected: {}", existingCall.get());
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.DUPLICATE_BENEFICIARY_CALL));
|
||||
}
|
||||
|
||||
BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request, user);
|
||||
BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request, user,userWithCompanyEntity);
|
||||
entity = beneficiaryPreferredCallRepository.save(entity);
|
||||
log.info("Beneficiary preferred call created with ID: {}", entity.getId());
|
||||
return convertEntityToResponse(entity);
|
||||
}
|
||||
|
||||
private BeneficiaryPreferredCallEntity convertRequestToEntity(BeneficiaryPreferredCallReq request,UserEntity userEntity) {
|
||||
private BeneficiaryPreferredCallEntity convertRequestToEntity(BeneficiaryPreferredCallReq request,UserEntity userEntity,UserWithCompanyEntity userWithCompanyEntity) {
|
||||
BeneficiaryPreferredCallEntity entity = new BeneficiaryPreferredCallEntity();
|
||||
if (userEntity.getBeneficiary()!=null) {
|
||||
entity.setBeneficiaryId(userEntity.getBeneficiary().getId());
|
||||
@@ -63,7 +72,8 @@ public class BeneficiaryPreferredCallDao {
|
||||
entity.setStatus(BeneficiaryCallStatus.ENABLED.getValue());
|
||||
entity.setCallId(request.getCallId());
|
||||
entity.setUserId(userEntity.getId());
|
||||
entity.setCompanyId(request.getCompanyId());
|
||||
entity.setCompanyId(userWithCompanyEntity.getCompanyId());
|
||||
entity.setUserWithCompany(userWithCompanyEntity);
|
||||
entity.setIsDeleted( false);
|
||||
return entity;
|
||||
}
|
||||
@@ -122,6 +132,7 @@ public class BeneficiaryPreferredCallDao {
|
||||
response.setCallId(entity.getCallId());
|
||||
response.setUserId(entity.getUserId());
|
||||
response.setCompanyId(entity.getCompanyId());
|
||||
response.setUserWithCompanyId(entity.getUserWithCompany().getId());
|
||||
response.setCreatedDate(entity.getCreatedDate());
|
||||
response.setUpdatedDate(entity.getUpdatedDate());
|
||||
|
||||
@@ -135,8 +146,8 @@ public class BeneficiaryPreferredCallDao {
|
||||
log.info("Beneficiary preferred call status updated with ID: {}", existingEntity.getId());
|
||||
}
|
||||
public List<BeneficiaryPreferredCallResponseBean> getBeneficiaryPreferredCallByUserId(UserEntity userEntity, Long companyId) {
|
||||
|
||||
List<BeneficiaryPreferredCallEntity> calls = beneficiaryPreferredCallRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), companyId);
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyId);
|
||||
List<BeneficiaryPreferredCallEntity> calls = beneficiaryPreferredCallRepository.findByUserIdAndUserWithCompanyIdAndIsDeletedFalse(userEntity.getId(), userWithCompanyEntity.getId());
|
||||
return calls.stream()
|
||||
.map(this::convertEntityToResponse)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -95,6 +95,9 @@ public class CallDao {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
|
||||
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
|
||||
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
|
||||
@@ -433,8 +436,9 @@ public class CallDao {
|
||||
BeneficiaryPreferredCallEntity preferredCall;
|
||||
if (companyId != null) {
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(),companyId);
|
||||
preferredCall = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndCallIdAndCompanyIdAndIsDeletedFalse(userId, callId, companyId)
|
||||
.findByUserIdAndCallIdAndUserWithCompanyIdAndIsDeletedFalse(userId, callId, userWithCompanyEntity.getId())
|
||||
.orElse(null);
|
||||
} else {
|
||||
preferredCall = beneficiaryPreferredCallRepository
|
||||
@@ -670,8 +674,9 @@ public class CallDao {
|
||||
|
||||
if (Boolean.TRUE.equals(onlyPreferredCall)) {
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(),companyId);
|
||||
List<BeneficiaryPreferredCallEntity> preferredCalls = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndCompanyIdAndIsDeletedFalse(user.getId(), companyId);
|
||||
.findByUserIdAndUserWithCompanyIdAndIsDeletedFalse(user.getId(), userWithCompanyEntity.getId());
|
||||
List<Long> preferredCallIds = preferredCalls.stream()
|
||||
.map(BeneficiaryPreferredCallEntity::getCallId)
|
||||
.collect(Collectors.toList());
|
||||
@@ -699,10 +704,11 @@ public class CallDao {
|
||||
public Map<String, BeneficiaryPreferredCallEntity> getBeneficiaryPreferredCallsForUser(HttpServletRequest request, UserEntity user, List<Long> callIds, Long companyId) {
|
||||
List<BeneficiaryPreferredCallEntity> beneficiaryPreferredCalls;
|
||||
|
||||
if (companyId != null) {
|
||||
if (companyId != null && Boolean.TRUE.equals(validator.checkIsBeneficiary())) {
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(),companyId);
|
||||
beneficiaryPreferredCalls = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndCallIdInAndCompanyIdAndIsDeletedFalse(user.getId(), callIds, companyId);
|
||||
.findByUserIdAndCallIdInAndUserWithCompanyIdAndIsDeletedFalse(user.getId(), callIds, userWithCompanyEntity.getId());
|
||||
} else {
|
||||
beneficiaryPreferredCalls = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndCallIdInAndIsDeletedFalse(user.getId(), callIds);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.FaqRepository;
|
||||
import net.gepafin.tendermanagement.enums.UserCompanyDelegationStatusEnum;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -15,8 +17,6 @@ import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
||||
import net.gepafin.tendermanagement.repositories.CompanyRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
|
||||
@@ -38,6 +38,15 @@ public class CompanyDao {
|
||||
@Autowired
|
||||
private FaqRepository faqRepository;
|
||||
|
||||
@Autowired
|
||||
private BeneficiaryPreferredCallRepository beneficiaryPreferredCallRepository;
|
||||
|
||||
@Autowired
|
||||
private UserCompanyDelegationRepository userCompanyDelegationRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
|
||||
public CompanyResponse createCompany(UserEntity userEntity, CompanyRequest companyRequest) {
|
||||
CompanyEntity existingCompany = companyRepository.findByVatNumberAndHubId(companyRequest.getVatNumber(), userEntity.getHub().getId());
|
||||
@@ -205,22 +214,33 @@ public class CompanyDao {
|
||||
}
|
||||
public void removeCompanyFromList(UserEntity userEntity, Long companyId) {
|
||||
CompanyEntity companyEntity = validateCompany(companyId);
|
||||
UserWithCompanyEntity existingRelation = userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), companyEntity.getId())
|
||||
.orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.USER_ALREADY_CONNECTED_TO_COMPANY)));
|
||||
List<ApplicationEntity> userApplications = applicationRepository.findByCompanyIdAndUserIdAndIsDeletedFalse(companyEntity.getId(), userEntity.getId());
|
||||
List<FaqEntity> faqs = faqRepository.findByCompanyIdAndUserIdAndIsDeletedFalse(companyEntity.getId(), userEntity.getId());
|
||||
for (ApplicationEntity application : userApplications) {
|
||||
if(Boolean.TRUE.equals(application.getStatus().equals(ApplicationStatusTypeEnum.SUBMIT.getValue()))) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.CANNOT_DELETE_COMPANY_WITH_APPLICATION_SUBMITT));
|
||||
UserWithCompanyEntity existingRelation=companyService.getUserWithCompany(userEntity.getId(),companyEntity.getId());
|
||||
List<ApplicationEntity> userApplications = applicationRepository.findByUserWithCompanyIdAndUserIdAndIsDeletedFalse(existingRelation.getId(), userEntity.getId());
|
||||
List<FaqEntity> faqs = faqRepository.findByUserWithCompanyIdAndIsDeletedFalse(existingRelation.getId());
|
||||
List<BeneficiaryPreferredCallEntity> preferredCallEntities= beneficiaryPreferredCallRepository.findByUserIdAndUserWithCompanyIdAndIsDeletedFalse(userEntity.getId(),existingRelation.getId());
|
||||
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository.findByUserIdAndUserWithCompanyIdAndStatus(userEntity.getId(),existingRelation.getId(), UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||
List<String> applicationStatusAllowed = List.of(
|
||||
ApplicationStatusTypeEnum.DRAFT.getValue(),
|
||||
ApplicationStatusTypeEnum.AWAITING.getValue(),
|
||||
ApplicationStatusTypeEnum.READY.getValue()
|
||||
);
|
||||
boolean notAllowedStatus = userApplications.stream()
|
||||
.anyMatch(application -> !applicationStatusAllowed.contains(application.getStatus()));
|
||||
if (notAllowedStatus) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.CANNOT_DELETE_COMPANY_WITH_APPLICATION_SUBMITT));
|
||||
}
|
||||
if(Boolean.TRUE.equals(application.getStatus().equals(ApplicationStatusTypeEnum.DRAFT.getValue()))) {
|
||||
application.setIsDeleted(Boolean.TRUE);
|
||||
applicationRepository.save(application);
|
||||
}
|
||||
}
|
||||
for(FaqEntity faq:faqs) {
|
||||
faq.setIsDeleted(Boolean.TRUE);
|
||||
faqRepository.save(faq);
|
||||
userApplications
|
||||
.forEach(application -> application.setIsDeleted(Boolean.TRUE));
|
||||
applicationRepository.saveAll(userApplications);
|
||||
faqs.forEach(faq -> faq.setIsDeleted(Boolean.TRUE));
|
||||
faqRepository.saveAll(faqs);
|
||||
|
||||
preferredCallEntities.forEach(preferredCall -> preferredCall.setIsDeleted(Boolean.TRUE));
|
||||
beneficiaryPreferredCallRepository.saveAll(preferredCallEntities);
|
||||
|
||||
if(userCompanyDelegationEntity!=null){
|
||||
userCompanyDelegationEntity.setStatus( UserCompanyDelegationStatusEnum.INACTIVE.getValue());
|
||||
userCompanyDelegationRepository.save(userCompanyDelegationEntity);
|
||||
}
|
||||
existingRelation.setIsDeleted(Boolean.TRUE);
|
||||
userWithCompanyRepository.save(existingRelation);
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
@@ -12,6 +13,7 @@ import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.CallRepository;
|
||||
import net.gepafin.tendermanagement.repositories.CompanyRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -32,6 +34,9 @@ public class DashboardDao {
|
||||
@Autowired
|
||||
private CompanyRepository companyRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
public SuperAdminWidgetResponseBean getDashboardWidget(UserEntity requestedUserEntity) {
|
||||
SuperAdminWidgetResponseBean widgetResponseBean = new SuperAdminWidgetResponseBean();
|
||||
widgetResponseBean.setWidget1(createWidget1(requestedUserEntity));
|
||||
@@ -108,8 +113,9 @@ public class DashboardDao {
|
||||
if (activeCalls != null) {
|
||||
beneficiaryWidgetResponseBean.setNumberOfCalls(activeCalls);
|
||||
}
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),company.getId());
|
||||
Long activeApplication = applicationRepository.countSubmittedApplicationsByUserId(userEntity.getId(),
|
||||
company.getId());
|
||||
userWithCompanyEntity.getId());
|
||||
if (activeApplication != null) {
|
||||
beneficiaryWidgetResponseBean.setNumberOfApplications(activeApplication);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,14 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
||||
|
||||
import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -18,10 +22,6 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserCompanyDelegationEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.UserCompanyDelegationStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyDelegationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDelegationResponse;
|
||||
@@ -67,6 +67,12 @@ public class DelegationDao {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
public ByteArrayOutputStream generateDocument(Map<String, String> placeholders, String templateName) {
|
||||
try {
|
||||
String s3Folder = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.TEMPLATE, 0L, 0L);
|
||||
@@ -182,8 +188,9 @@ public class DelegationDao {
|
||||
companyDao.validateCompany(companyId);
|
||||
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||
validateFileType(file);
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyId);
|
||||
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
|
||||
.findByUserIdAndCompanyIdAndStatus(userEntity.getId(), companyId,
|
||||
.findByUserIdAndUserWithCompanyIdAndStatus(userEntity.getId(), userWithCompanyEntity.getId(),
|
||||
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||
if (userCompanyDelegationEntity != null) {
|
||||
userCompanyDelegationEntity.setStatus(UserCompanyDelegationStatusEnum.INACTIVE.getValue());
|
||||
@@ -191,7 +198,8 @@ public class DelegationDao {
|
||||
}
|
||||
UploadFileOnAmazonS3Response uploadFileOnAmazonS3Response = uploadFileOnAmazonS3ForCompanyDelegation(file);
|
||||
userCompanyDelegationEntity = new UserCompanyDelegationEntity();
|
||||
userCompanyDelegationEntity.setCompanyId(companyId);
|
||||
userCompanyDelegationEntity.setUserWithCompany(userWithCompanyEntity);
|
||||
userCompanyDelegationEntity.setCompanyId(userWithCompanyEntity.getCompanyId());
|
||||
userCompanyDelegationEntity.setUserId(userEntity.getId());
|
||||
if (userEntity.getBeneficiary() != null) {
|
||||
userCompanyDelegationEntity.setBeneficiaryId(userEntity.getBeneficiary().getId());
|
||||
@@ -235,8 +243,9 @@ public class DelegationDao {
|
||||
}
|
||||
|
||||
public CompanyDelegationResponse getCompanyDelegation(UserEntity userEntity, Long companyId) {
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyId);
|
||||
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
|
||||
.findByUserIdAndCompanyIdAndStatus(userEntity.getId(), companyId,
|
||||
.findByUserIdAndUserWithCompanyIdAndStatus(userEntity.getId(), userWithCompanyEntity.getId(),
|
||||
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||
if(userCompanyDelegationEntity == null) {
|
||||
@@ -247,8 +256,9 @@ public class DelegationDao {
|
||||
}
|
||||
|
||||
public void deleteCompanyDelegation(UserEntity userEntity, Long companyId) {
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyId);
|
||||
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
|
||||
.findByUserIdAndCompanyIdAndStatus(userEntity.getId(), companyId,
|
||||
.findByUserIdAndUserWithCompanyIdAndStatus(userEntity.getId(), userWithCompanyEntity.getId(),
|
||||
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||
if(userCompanyDelegationEntity == null) {
|
||||
|
||||
@@ -14,10 +14,7 @@ import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
|
||||
import net.gepafin.tendermanagement.repositories.EmailLogRepository;
|
||||
import net.gepafin.tendermanagement.repositories.HubRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.HubService;
|
||||
import net.gepafin.tendermanagement.service.SystemEmailTemplatesService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.service.*;
|
||||
import net.gepafin.tendermanagement.service.impl.EmailService;
|
||||
import net.gepafin.tendermanagement.service.impl.EmailServiceFactory;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
@@ -59,6 +56,9 @@ public class EmailNotificationDao {
|
||||
@Autowired
|
||||
private EmailLogRepository emailLogRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
|
||||
private void sendEmail(ApplicationEntity applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType,
|
||||
Map<String, String> bodyPlaceholders, List<String> additionalRecipients,Long amendmentId) {
|
||||
@@ -69,8 +69,9 @@ public class EmailNotificationDao {
|
||||
|
||||
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(templateType, hubEntity, null);
|
||||
Map<String, String> subjectPlaceholders = new HashMap<>();
|
||||
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
subjectPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
||||
subjectPlaceholders.put("{{company_name}}", applicationEntity.getCompany().getCompanyName());
|
||||
subjectPlaceholders.put("{{company_name}}", company.getCompanyName());
|
||||
bodyPlaceholders.put("{{legal_mail}}", legalMail);
|
||||
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
||||
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
||||
@@ -82,8 +83,9 @@ public class EmailNotificationDao {
|
||||
}
|
||||
private List<String> getRecipientEmails(ApplicationEntity applicationEntity, UserEntity userEntity, List<String> additionalRecipients) {
|
||||
List<String> recipientEmails = new ArrayList<>();
|
||||
String companyEmail = applicationEntity.getCompany().getEmail();
|
||||
String contactEmail = applicationEntity.getCompany().getContactEmail();
|
||||
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
String companyEmail = company.getEmail();
|
||||
String contactEmail = company.getContactEmail();
|
||||
|
||||
if (companyEmail != null && !companyEmail.isEmpty()) {
|
||||
recipientEmails.add(companyEmail);
|
||||
|
||||
@@ -2,15 +2,13 @@ package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||
import net.gepafin.tendermanagement.entities.FaqEntity;
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.FaqReq;
|
||||
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.FaqRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
|
||||
import net.gepafin.tendermanagement.service.CallService;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.service.LookUpDataService;
|
||||
@@ -26,6 +24,7 @@ import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
public class FaqDao {
|
||||
@@ -45,6 +44,9 @@ public class FaqDao {
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
|
||||
public FaqResponseBean createFaq(FaqReq faqRequest, UserEntity userEntity, Long callId, Long companyId) {
|
||||
CallEntity callEntity = callService.validateCall(callId);
|
||||
FaqEntity entity = createOrUpdateFaqEntity(faqRequest, callEntity, userEntity,
|
||||
@@ -53,10 +55,15 @@ public class FaqDao {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.COMPANY_ID_MANDATORY));
|
||||
}
|
||||
UserWithCompanyEntity userWithCompanyEntity=null;
|
||||
if(companyId!=null) {
|
||||
companyService.validateCompany(companyId);
|
||||
entity.setCompanyId(companyId);
|
||||
userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyId);
|
||||
companyService.validateCompany(userWithCompanyEntity.getCompanyId());
|
||||
entity.setCompanyId(userWithCompanyEntity.getCompanyId());
|
||||
|
||||
}
|
||||
|
||||
entity.setUserWithCompany(userWithCompanyEntity);
|
||||
faqRepository.save(entity);
|
||||
return convertToFaqResponseBean(entity);
|
||||
}
|
||||
|
||||
@@ -3,19 +3,15 @@ package net.gepafin.tendermanagement.dao;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationFormEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationFormFieldEntity;
|
||||
import net.gepafin.tendermanagement.entities.FlowDataEntity;
|
||||
import net.gepafin.tendermanagement.entities.FlowEdgesEntity;
|
||||
import net.gepafin.tendermanagement.entities.FormEntity;
|
||||
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
||||
import net.gepafin.tendermanagement.service.FormService;
|
||||
@@ -44,6 +40,8 @@ public class FlowFormDao {
|
||||
private FormService formService;
|
||||
@Autowired
|
||||
private FormDao formDao;
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
|
||||
|
||||
@@ -290,6 +288,7 @@ public class FlowFormDao {
|
||||
private NextOrPreviousFormResponse setNextOrPreviousResponse(Long calculatedFormId, ApplicationEntity applicationEntity) {
|
||||
NextOrPreviousFormResponse nextOrPreviousFormResponse = new NextOrPreviousFormResponse();
|
||||
Integer completedSteps=0;
|
||||
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
FormEntity formEntity = formService.validateForm(calculatedFormId);
|
||||
nextOrPreviousFormResponse.setFormId(calculatedFormId);
|
||||
nextOrPreviousFormResponse.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(applicationEntity.getStatus()));
|
||||
@@ -297,8 +296,8 @@ public class FlowFormDao {
|
||||
applicationDao.processForm(formEntity, applicationEntity));
|
||||
nextOrPreviousFormResponse.setCallId(applicationEntity.getCall().getId());
|
||||
nextOrPreviousFormResponse.setCallTitle(applicationEntity.getCall().getName());
|
||||
nextOrPreviousFormResponse.setCompanyId(applicationEntity.getCompany().getId());
|
||||
nextOrPreviousFormResponse.setCompanyName(applicationEntity.getCompany().getCompanyName());
|
||||
nextOrPreviousFormResponse.setCompanyId(applicationEntity.getCompanyId());
|
||||
nextOrPreviousFormResponse.setCompanyName(company.getCompanyName());
|
||||
|
||||
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
|
||||
Long totalFormSteps = calculateTotalSteps(flowEdgesList);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class PdfDao {
|
||||
try {
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
ApplicationEntity applicationEntity = applicationDao.validateApplication(applicationId);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
CallEntity call=callService.validateCall(applicationEntity.getCall().getId());
|
||||
|
||||
// Create a byte stream to hold the PDF
|
||||
|
||||
@@ -13,9 +13,8 @@ public class ApplicationEntity extends BaseEntity {
|
||||
@Column(name = "USER_ID")
|
||||
private Long userId;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "COMPANY_ID", nullable = false)
|
||||
private CompanyEntity company;
|
||||
@Column(name = "COMPANY_ID")
|
||||
private Long companyId;
|
||||
|
||||
@Column(name = "SUBMISSION_DATE")
|
||||
private LocalDateTime submissionDate;
|
||||
@@ -39,4 +38,8 @@ public class ApplicationEntity extends BaseEntity {
|
||||
|
||||
@Column(name = "HUB_ID")
|
||||
private Long hubId;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "USER_WITH_COMPANY_ID")
|
||||
private UserWithCompanyEntity userWithCompany;
|
||||
}
|
||||
@@ -34,6 +34,11 @@ public class BeneficiaryPreferredCallEntity extends BaseEntity{
|
||||
|
||||
@Column(name = "STATUS", length = 255)
|
||||
private String status;
|
||||
|
||||
@Column(name="IS_DELETED")
|
||||
private Boolean isDeleted;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "USER_WITH_COMPANY_ID")
|
||||
private UserWithCompanyEntity userWithCompany;
|
||||
}
|
||||
|
||||
@@ -45,5 +45,9 @@ public class FaqEntity extends BaseEntity {
|
||||
@Column(name ="COMPANY_ID")
|
||||
private Long companyId;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "USER_WITH_COMPANY_ID")
|
||||
private UserWithCompanyEntity userWithCompany;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@@ -28,4 +26,7 @@ public class UserCompanyDelegationEntity extends BaseEntity{
|
||||
@Column(name="STATUS")
|
||||
private String status;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "USER_WITH_COMPANY_ID")
|
||||
private UserWithCompanyEntity userWithCompany;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public class BeneficiaryPreferredCallResponseBean {
|
||||
private BeneficiaryCallStatus status;
|
||||
private LocalDateTime createdDate;
|
||||
private LocalDateTime updatedDate;
|
||||
private Long userWithCompanyId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,15 +24,17 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
||||
|
||||
public Optional<ApplicationEntity> findByIdAndUserIdAndIsDeletedFalse(Long id,Long userId);
|
||||
|
||||
Optional<ApplicationEntity> findByUserIdAndCompanyIdAndCallIdAndIsDeletedFalse(Long userId, Long companyId, Long callId);
|
||||
Optional<ApplicationEntity> findByUserIdAndUserWithCompanyIdAndCallIdAndIsDeletedFalse(Long userId, Long userWithCompanyId, Long callId);
|
||||
|
||||
public Optional<ApplicationEntity> findByIdAndUserIdAndCallIdAndIsDeletedFalse(Long applicationId, Long userId,
|
||||
Long callId);
|
||||
|
||||
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.userId = :userId AND a.company.id = :companyId AND a.status = 'SUBMIT' AND a.isDeleted = false")
|
||||
Long countSubmittedApplicationsByUserId(@Param("userId") Long userId, @Param("companyId") Long companyId);
|
||||
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.userId = :userId AND a.userWithCompany.id = :userWithCompanyId AND a.status = 'SUBMIT' AND a.isDeleted = false")
|
||||
Long countSubmittedApplicationsByUserId(@Param("userId") Long userId, @Param("userWithCompanyId") Long userWithCompanyId);
|
||||
|
||||
|
||||
List<ApplicationEntity> findByUserWithCompanyIdAndUserIdAndIsDeletedFalse(Long userWithCompanyId, Long userId);
|
||||
|
||||
List<ApplicationEntity> findByCompanyIdAndUserIdAndIsDeletedFalse(Long companyId,Long userId);
|
||||
|
||||
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.status = 'SUBMIT' And a.hubId = :hubId AND a.isDeleted = false")
|
||||
public Long countSubmittedApplicationsByHubId(@Param("hubId") Long hubId);
|
||||
|
||||
@@ -13,12 +13,17 @@ public interface BeneficiaryPreferredCallRepository extends JpaRepository<Benefi
|
||||
List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndIsDeletedFalse(Long beneficiaryId);
|
||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndIsDeletedFalse(Long userId);
|
||||
|
||||
@Query("SELECT preferredCall FROM BeneficiaryPreferredCallEntity preferredCall where preferredCall.userId=:userId AND (:companyId is null OR preferredCall.companyId=:companyId) AND isDeleted=false")
|
||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(@Param("userId") Long userId, @Param("companyId") Long companyId);
|
||||
@Query("SELECT preferredCall FROM BeneficiaryPreferredCallEntity preferredCall WHERE preferredCall.userId = :userId AND (:userWithCompanyId IS NULL OR preferredCall.userWithCompany.id = :userWithCompanyId) AND isDeleted = false")
|
||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndUserWithCompanyIdAndIsDeletedFalse(@Param("userId") Long userId, @Param("userWithCompanyId") Long userWithCompanyId);
|
||||
|
||||
List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndCompanyId(Long beneficiaryId,Long companyId);
|
||||
|
||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdInAndIsDeletedFalse(Long userId, List<Long> callIds);
|
||||
|
||||
Optional<BeneficiaryPreferredCallEntity> findByIdAndIsDeletedFalse(Long id);
|
||||
Optional<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdAndCompanyIdAndIsDeletedFalse(Long userId, Long callId, Long companyId);
|
||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdInAndCompanyIdAndIsDeletedFalse(Long userId, List<Long> callIds,Long companyId);
|
||||
|
||||
Optional<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdAndUserWithCompanyIdAndIsDeletedFalse(Long userId, Long callId, Long userWithCompanyId);
|
||||
|
||||
List<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdInAndUserWithCompanyIdAndIsDeletedFalse(Long userId, List<Long> callIds, Long userWithCompanyId);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ public interface FaqRepository extends JpaRepository<FaqEntity, Long> {
|
||||
List<FaqEntity> findByCallIdAndIsDeletedFalse(Long callId);
|
||||
|
||||
Optional<FaqEntity> findByIdAndCallIdAndIsDeletedFalse(Long id, Long callId);
|
||||
List<FaqEntity> findByCompanyIdAndUserIdAndIsDeletedFalse(Long companyId,Long userId);
|
||||
|
||||
List<FaqEntity> findByUserWithCompanyIdAndIsDeletedFalse(Long userWithCompanyId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
|
||||
public interface UserCompanyDelegationRepository extends JpaRepository<UserCompanyDelegationEntity, Long> {
|
||||
|
||||
UserCompanyDelegationEntity findByUserIdAndCompanyIdAndStatus(Long userId, Long companyId, String status);
|
||||
UserCompanyDelegationEntity findByUserIdAndUserWithCompanyIdAndStatus(Long userId, Long userWithCompanyId, String status);
|
||||
|
||||
@Query("SELECT d FROM UserCompanyDelegationEntity d where d.status = :status")
|
||||
List<UserCompanyDelegationEntity> findAllByStatus(@Param("status") String status);
|
||||
|
||||
@@ -32,6 +32,8 @@ public interface CompanyService {
|
||||
|
||||
UserWithCompanyEntity validateUserWithCompny(Long userId, Long companyId);
|
||||
|
||||
UserWithCompanyEntity getUserWithCompany(Long userId, Long companyId);
|
||||
|
||||
ByteArrayOutputStream downloadCompanyDelegation(HttpServletRequest request, Long companyId, CompanyDelegationRequest companyDelegationRequest);
|
||||
|
||||
CompanyDelegationResponse uploadCompanyDelegation(HttpServletRequest request, Long companyId, MultipartFile file);
|
||||
|
||||
@@ -80,7 +80,7 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId,
|
||||
FormActionEnum action) {
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
return flowFormDao.getNextOrPreviousForm(applicationEntity, formId, action);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,10 @@ public class CompanyServiceImpl implements CompanyService {
|
||||
public UserWithCompanyEntity validateUserWithCompny(Long userId, Long companyId) {
|
||||
return companyDao.validateUserWithCompny(userId, companyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserWithCompanyEntity getUserWithCompany(Long userId, Long companyId) {
|
||||
return companyDao.getUserWithCompany(userId, companyId);
|
||||
}
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ByteArrayOutputStream downloadCompanyDelegation(HttpServletRequest request, Long companyId, CompanyDelegationRequest companyDelegationRequest) {
|
||||
|
||||
@@ -1798,4 +1798,27 @@
|
||||
<where>role_type = 'ROLE_PRE_INSTRUCTOR'</where>
|
||||
</update>
|
||||
</changeSet>
|
||||
<changeSet id="26-11-2024_1" author="Rajesh Khore">
|
||||
<addColumn tableName="APPLICATION">
|
||||
<column name="USER_WITH_COMPANY_ID" type="INTEGER">
|
||||
<constraints foreignKeyName="fk_USER_WITH_COMPANY_APPLICATION" references="user_with_company(id)"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
<dropForeignKeyConstraint baseTableName="APPLICATION" constraintName="fk_COMPANY_APPLICATION"/>
|
||||
<addColumn tableName="faq">
|
||||
<column name="USER_WITH_COMPANY_ID" type="INTEGER">
|
||||
<constraints foreignKeyName="fk_USER_WITH_COMPANY_faq" references="user_with_company(id)"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
<addColumn tableName="beneficiary_preferred_call">
|
||||
<column name="USER_WITH_COMPANY_ID" type="INTEGER">
|
||||
<constraints foreignKeyName="fk_USER_WITH_COMPANY_beneficiary_preferred_call" references="user_with_company(id)"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
<addColumn tableName="user_company_delegation">
|
||||
<column name="USER_WITH_COMPANY_ID" type="INTEGER">
|
||||
<constraints foreignKeyName="fk_USER_WITH_COMPANY_user_company_delegation" references="user_with_company(id)"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
|
||||
Reference in New Issue
Block a user