Resolved conflicts
This commit is contained in:
@@ -148,6 +148,9 @@ public class ApplicationDao {
|
||||
|
||||
@Autowired
|
||||
private EmailLogDao emailLogDao;
|
||||
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
@@ -163,7 +166,7 @@ public class ApplicationDao {
|
||||
// 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));
|
||||
}
|
||||
@@ -172,12 +175,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) {
|
||||
@@ -200,13 +201,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;
|
||||
@@ -275,9 +277,11 @@ public class ApplicationDao {
|
||||
|
||||
log.info("Deleting application with ID: {}", id);
|
||||
|
||||
ApplicationEntity applicationEntity = validateApplication(id);
|
||||
ApplicationEntity applicationEntity= validateApplication(id);
|
||||
|
||||
ApplicationEntity oldApplicationDataEntity = Utils.getClonedEntityForData(applicationEntity);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
applicationEntity.setIsDeleted(true);
|
||||
applicationEntity = applicationRepository.save(applicationEntity);
|
||||
|
||||
@@ -348,9 +352,9 @@ public class ApplicationDao {
|
||||
if (callId != null) {
|
||||
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));
|
||||
}
|
||||
if (companyId != null) {
|
||||
predicate = builder.and(predicate, builder.equal(root.get("companyId"), companyId));
|
||||
}
|
||||
if (statusList != null && !statusList.isEmpty()) {
|
||||
List<String> statusNames = statusList.stream()
|
||||
.map(Enum::name)
|
||||
@@ -381,8 +385,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());
|
||||
}
|
||||
@@ -750,11 +755,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;
|
||||
}
|
||||
|
||||
@@ -771,15 +777,17 @@ 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);
|
||||
return getApplicationResponse(applicationEntity);
|
||||
}
|
||||
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));
|
||||
}
|
||||
@@ -793,7 +801,7 @@ public class ApplicationDao {
|
||||
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity);
|
||||
|
||||
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));
|
||||
}
|
||||
@@ -917,7 +925,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
|
||||
@@ -960,7 +968,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);
|
||||
}
|
||||
@@ -968,7 +976,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
|
||||
@@ -1008,14 +1016,13 @@ public class ApplicationDao {
|
||||
emailLogRequest.setRecipientEmails(rinaldoEmail);
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(rinaldoEmail),emailLogRequest);
|
||||
}
|
||||
public ApplicationSignedDocumentResponse uploadSignedDocument(HttpServletRequest request, Long applicationId,
|
||||
MultipartFile file) {
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
|
||||
public ApplicationSignedDocumentResponse uploadSignedDocument(HttpServletRequest request, Long applicationId, MultipartFile file) {
|
||||
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
//cloned entity for old data
|
||||
ApplicationEntity oldApplicationData = Utils.getClonedEntityForData(applicationEntity);
|
||||
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
validateFileTypeForCall(file, applicationEntity);
|
||||
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository.findByApplicationIdAndStatus(applicationId,
|
||||
ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
@@ -1103,7 +1110,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());
|
||||
@@ -1113,23 +1120,22 @@ public class ApplicationDao {
|
||||
}
|
||||
return convertApplicationSignedDocumentToApplicationSignedDocumentResponse(applicationSignedDocument);
|
||||
}
|
||||
|
||||
public void deleteSignedDocument(HttpServletRequest request, Long applicationId) {
|
||||
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
|
||||
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository.findByApplicationIdAndStatus(applicationId,
|
||||
ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
//cloned entity for old data
|
||||
|
||||
public void deleteSignedDocument(HttpServletRequest request, Long applicationId) {
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
|
||||
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
|
||||
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
//cloned entity for old data
|
||||
ApplicationSignedDocumentEntity oldApplicationSignedDocument = Utils.getClonedEntityForData(applicationSignedDocument);
|
||||
if (applicationSignedDocument == null) {
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.APPLICATION_SIGNED_DOCUMENT_NOT_FOUND));
|
||||
}
|
||||
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue());
|
||||
applicationSignedDocument = applicationSignedDocumentRepository.save(applicationSignedDocument);
|
||||
if(applicationSignedDocument == null) {
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.APPLICATION_SIGNED_DOCUMENT_NOT_FOUND));
|
||||
}
|
||||
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue());
|
||||
applicationSignedDocument = applicationSignedDocumentRepository.save(applicationSignedDocument);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Delete signed document" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationSignedDocument).newData(applicationSignedDocument)
|
||||
.build());
|
||||
@@ -1138,11 +1144,10 @@ public class ApplicationDao {
|
||||
public ApplicationResponse validateApplication(HttpServletRequest request, Long applicationId) {
|
||||
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
|
||||
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity);
|
||||
|
||||
userService.validateUser(applicationEntity.getUserId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||
|
||||
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.FaqEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
@@ -19,6 +21,7 @@ import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository
|
||||
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.LoggingUtil;
|
||||
@@ -59,6 +62,9 @@ public class AssignedApplicationsDao {
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationDao applicationEvaluationDao;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
@@ -161,7 +167,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);
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
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.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
||||
@@ -12,6 +13,8 @@ import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
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.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
@@ -41,6 +44,12 @@ public class BeneficiaryPreferredCallDao {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@@ -50,16 +59,16 @@ public class BeneficiaryPreferredCallDao {
|
||||
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);
|
||||
|
||||
/** This code is responsible for adding a version history log for "Create Beneficiary Preferred Call" operation. **/
|
||||
@@ -69,7 +78,7 @@ public class BeneficiaryPreferredCallDao {
|
||||
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());
|
||||
@@ -77,7 +86,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;
|
||||
}
|
||||
@@ -142,6 +152,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());
|
||||
|
||||
@@ -160,8 +171,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());
|
||||
|
||||
@@ -99,6 +99,9 @@ public class CallDao {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@@ -476,8 +479,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
|
||||
@@ -735,8 +739,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());
|
||||
@@ -764,10 +769,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,10 +1,14 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserCompanyDelegationStatusEnum;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
@@ -19,8 +23,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;
|
||||
|
||||
@@ -41,6 +43,15 @@ public class CompanyDao {
|
||||
private ApplicationRepository applicationRepository;
|
||||
@Autowired
|
||||
private FaqRepository faqRepository;
|
||||
|
||||
@Autowired
|
||||
private BeneficiaryPreferredCallRepository beneficiaryPreferredCallRepository;
|
||||
|
||||
@Autowired
|
||||
private UserCompanyDelegationRepository userCompanyDelegationRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
@@ -245,40 +256,67 @@ public class CompanyDao {
|
||||
}
|
||||
|
||||
public UserWithCompanyEntity getUserWithCompany(Long userId, Long compnayId) {
|
||||
return userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userId, compnayId).orElseThrow(
|
||||
() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.USER_COMPANY_RELATION_NOT_FOUND)));
|
||||
}
|
||||
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()))) {
|
||||
return userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userId, compnayId).orElseThrow(
|
||||
() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.USER_COMPANY_RELATION_NOT_FOUND)));
|
||||
}
|
||||
public void removeCompanyFromList(UserEntity userEntity, Long companyId) {
|
||||
CompanyEntity companyEntity = validateCompany(companyId);
|
||||
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()))) {
|
||||
|
||||
//cloned entity for old data
|
||||
ApplicationEntity oldApplicationData = Utils.getClonedEntityForData(application);
|
||||
for(ApplicationEntity application:userApplications){
|
||||
ApplicationEntity oldApplication = Utils.getClonedEntityForData(application);
|
||||
application.setIsDeleted(Boolean.TRUE);
|
||||
applicationRepository.save(application);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldApplicationData).newData(application).build());
|
||||
/** This code is responsible for adding a version history log for the "Soft delete application" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldApplication).newData(application).build());
|
||||
|
||||
}
|
||||
}
|
||||
for (FaqEntity faq : faqs) {
|
||||
//cloned for old data
|
||||
FaqEntity oldFaqEntityData = Utils.getClonedEntityForData(faq);
|
||||
faq.setIsDeleted(Boolean.TRUE);
|
||||
faqRepository.save(faq);
|
||||
applicationRepository.saveAll(userApplications);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "soft deleting faq" operation. **/
|
||||
for(FaqEntity faq:faqs){
|
||||
FaqEntity oldFaq = Utils.getClonedEntityForData(faq);
|
||||
faq.setIsDeleted(Boolean.TRUE);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Soft delete Faq" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldFaq).newData(faq).build());
|
||||
}
|
||||
faqRepository.saveAll(faqs);
|
||||
|
||||
for(BeneficiaryPreferredCallEntity beneficiaryPreferredCall:preferredCallEntities){
|
||||
BeneficiaryPreferredCallEntity oldPreferredCall = Utils.getClonedEntityForData(beneficiaryPreferredCall);
|
||||
beneficiaryPreferredCall.setIsDeleted(Boolean.TRUE);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Soft Delete BeneficiaryPreferredCall" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldPreferredCall).newData(beneficiaryPreferredCall).build());
|
||||
|
||||
}
|
||||
beneficiaryPreferredCallRepository.saveAll(preferredCallEntities);
|
||||
|
||||
if(userCompanyDelegationEntity!=null){
|
||||
UserCompanyDelegationEntity oldUserWithCompanyDelegation = Utils.getClonedEntityForData(userCompanyDelegationEntity);
|
||||
userCompanyDelegationEntity.setStatus( UserCompanyDelegationStatusEnum.INACTIVE.getValue());
|
||||
userCompanyDelegationRepository.save(userCompanyDelegationEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update UserWithCompanyDelegation" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldFaqEntityData).newData(faq).build());
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldUserWithCompanyDelegation).newData(userCompanyDelegationEntity).build());
|
||||
}
|
||||
UserWithCompanyEntity oldUserWithCompanyData = Utils.getClonedEntityForData(existingRelation);
|
||||
existingRelation.setIsDeleted(Boolean.TRUE);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -31,6 +33,9 @@ public class DashboardDao {
|
||||
|
||||
@Autowired
|
||||
private CompanyRepository companyRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
public SuperAdminWidgetResponseBean getDashboardWidget(UserEntity requestedUserEntity) {
|
||||
SuperAdminWidgetResponseBean widgetResponseBean = new SuperAdminWidgetResponseBean();
|
||||
@@ -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 net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
@@ -21,10 +25,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;
|
||||
@@ -70,6 +70,12 @@ public class DelegationDao {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@@ -191,8 +197,11 @@ public class DelegationDao {
|
||||
companyDao.validateCompany(companyId);
|
||||
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||
validateFileType(file);
|
||||
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository.findByUserIdAndCompanyIdAndStatus(userEntity.getId(), companyId,
|
||||
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyId);
|
||||
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
|
||||
.findByUserIdAndUserWithCompanyIdAndStatus(userEntity.getId(), userWithCompanyEntity.getId(),
|
||||
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||
|
||||
UserCompanyDelegationEntity oldUserCompanyDelegationEntity = Utils.getClonedEntityForData(userCompanyDelegationEntity);
|
||||
if (userCompanyDelegationEntity != null) {
|
||||
userCompanyDelegationEntity.setStatus(UserCompanyDelegationStatusEnum.INACTIVE.getValue());
|
||||
@@ -204,7 +213,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());
|
||||
@@ -254,8 +264,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) {
|
||||
@@ -266,9 +277,10 @@ public class DelegationDao {
|
||||
}
|
||||
|
||||
public void deleteCompanyDelegation(UserEntity userEntity, Long companyId) {
|
||||
|
||||
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository.findByUserIdAndCompanyIdAndStatus(userEntity.getId(), companyId,
|
||||
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyId);
|
||||
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
|
||||
.findByUserIdAndUserWithCompanyIdAndStatus(userEntity.getId(), userWithCompanyEntity.getId(),
|
||||
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||
//cloned entity for old data
|
||||
UserCompanyDelegationEntity oldUserCompanyDelegation = Utils.getClonedEntityForData(userCompanyDelegationEntity);
|
||||
|
||||
@@ -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;
|
||||
@@ -58,6 +55,9 @@ public class EmailNotificationDao {
|
||||
|
||||
@Autowired
|
||||
private EmailLogRepository emailLogRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
|
||||
private void sendEmail(ApplicationEntity applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType,
|
||||
@@ -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);
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.dao;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||
import net.gepafin.tendermanagement.entities.FaqEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
@@ -13,6 +14,7 @@ import net.gepafin.tendermanagement.model.request.FaqReq;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
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;
|
||||
@@ -30,6 +32,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 {
|
||||
@@ -48,6 +51,9 @@ public class FaqDao {
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
|
||||
@Autowired
|
||||
HttpServletRequest request;
|
||||
@@ -63,10 +69,15 @@ public class FaqDao {
|
||||
if (validator.checkIsBeneficiary() && companyId == null) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.COMPANY_ID_MANDATORY));
|
||||
}
|
||||
if (companyId != null) {
|
||||
companyService.validateCompany(companyId);
|
||||
entity.setCompanyId(companyId);
|
||||
UserWithCompanyEntity userWithCompanyEntity=null;
|
||||
if(companyId!=null) {
|
||||
userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyId);
|
||||
companyService.validateCompany(userWithCompanyEntity.getCompanyId());
|
||||
entity.setCompanyId(userWithCompanyEntity.getCompanyId());
|
||||
|
||||
}
|
||||
|
||||
entity.setUserWithCompany(userWithCompanyEntity);
|
||||
faqRepository.save(entity);
|
||||
|
||||
if (entity.getCompanyId() != null) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user