Resolved Conflicts.

This commit is contained in:
piyushkag
2024-12-06 14:26:09 +05:30
14 changed files with 84 additions and 30 deletions

View File

@@ -305,6 +305,7 @@ public class GepafinConstant {
public static final String USER_ID = "userId";
public static final String LOGIN_ATTEMPT_ID = "loginAttemptId";
public static final String USER_ACTION_ID = "userActionId";
public static final String ATLEAST_ONE_ID_REQUIRED="atleast.one.id.required";
//Appointment
public static final String NDG_IN_PROGRESS = "IN_PROGRESS";

View File

@@ -14,6 +14,7 @@ import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
import net.gepafin.tendermanagement.model.response.*;
import net.gepafin.tendermanagement.repositories.*;
import net.gepafin.tendermanagement.service.AmazonS3Service;
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
import net.gepafin.tendermanagement.service.CallService;
import net.gepafin.tendermanagement.service.CompanyService;
import net.gepafin.tendermanagement.service.DocumentService;
@@ -159,7 +160,7 @@ public class ApplicationDao {
private HttpServletRequest request;
@Autowired
private TokenProvider tokenProvider;
private ApplicationEvaluationService applicationEvaluationService;
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
FormEntity formEntity = formService.validateForm(formId);
@@ -1113,7 +1114,14 @@ public class ApplicationDao {
public ApplicationSignedDocumentResponse getSignedDocument(HttpServletRequest request, Long applicationId) {
ApplicationEntity applicationEntity = validateApplication(applicationId);
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
// validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
if (validator.checkIsPreInstructor()) {
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluationByApplicationId(applicationId);
validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId());
} else {
validator.validateUserId(request, applicationEntity.getUserId());
}
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());

View File

@@ -1396,5 +1396,12 @@ public class ApplicationEvaluationDao {
}
return null;
}
public ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId) {
return applicationEvaluationRepository
.findByApplicationIdAndIsDeletedFalse(applicationId)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_EVALUATION_NOT_FOUND)));
}
}

View File

@@ -265,7 +265,7 @@ public class AppointmentDao {
}
// Wait before the next polling attempt
Thread.sleep(TimeUnit.MINUTES.toMillis(1));
Thread.sleep(TimeUnit.MINUTES.toMillis(15));
} catch (InterruptedException e) {
log.warn("Polling task interrupted for applicationId: {}", application.getId());

View File

@@ -5,13 +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.ApplicationEvaluationRepository;
import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
import net.gepafin.tendermanagement.service.ApplicationService;
import net.gepafin.tendermanagement.service.CompanyService;
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
@@ -33,6 +34,7 @@ import net.gepafin.tendermanagement.model.response.UserResponseBean;
import net.gepafin.tendermanagement.repositories.DocumentRepository;
import net.gepafin.tendermanagement.repositories.UserCompanyDelegationRepository;
import net.gepafin.tendermanagement.service.AmazonS3Service;
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
import net.gepafin.tendermanagement.service.UserService;
import net.gepafin.tendermanagement.util.DateTimeUtil;
import net.gepafin.tendermanagement.util.Utils;
@@ -82,6 +84,12 @@ public class DelegationDao {
@Autowired
private HttpServletRequest request;
@Autowired
private ApplicationService applicationService;
@Autowired
private ApplicationEvaluationService applicationEvaluationService;
public ByteArrayOutputStream generateDocument(Map<String, String> placeholders, String templateName) {
try {
String s3Folder = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.TEMPLATE, 0L, 0L,0L);
@@ -257,12 +265,12 @@ public class DelegationDao {
}
}
public CompanyDelegationResponse getCompanyDelegation(UserEntity userEntity, Long companyId) {
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyId);
public CompanyDelegationResponse getCompanyDelegation(HttpServletRequest request, Long companyId, Long applicationId) {
UserWithCompanyEntity userWithCompanyEntity= validateUserAndGetUserWithCompany(request, companyId, applicationId);
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
.findByUserIdAndUserWithCompanyIdAndStatus(userEntity.getId(), userWithCompanyEntity.getId(),
.findByUserIdAndUserWithCompanyIdAndStatus(userWithCompanyEntity.getUserId(), userWithCompanyEntity.getId(),
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
companyDao.getUserWithCompany(userEntity.getId(), companyId);
if(userCompanyDelegationEntity == null) {
throw new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.DELEGATION_NOT_FOUND));
@@ -270,6 +278,27 @@ public class DelegationDao {
return convertUserCompanyDelegationToCompanyDelegationResponse(userCompanyDelegationEntity);
}
private UserWithCompanyEntity validateUserAndGetUserWithCompany(HttpServletRequest request, Long companyId,
Long applicationId) {
Long userId = null;
if (companyId == null && applicationId == null) {
throw new CustomValidationException(Status.BAD_REQUEST,
Translator.toLocale(GepafinConstant.ATLEAST_ONE_ID_REQUIRED));
}
if (applicationId != null) {
ApplicationEntity application = applicationService.validateApplication(applicationId);
userId = application.getUserId();
companyId = application.getCompanyId();
}
if (validator.checkIsPreInstructor()) {
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluationByApplicationId(applicationId);
validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId());
} else if (validator.checkIsBeneficiary()) {
userId = validator.validateUser(request).getId();
}
return companyService.getUserWithCompany(userId, companyId);
}
public void deleteCompanyDelegation(UserEntity userEntity, Long companyId) {
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyId);
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository

View File

@@ -152,9 +152,9 @@ public class EmailNotificationDao {
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationAmendmentRequestEntity.getApplicationId());
Map<String, String> bodyPlaceholders = new HashMap<>();
bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
bodyPlaceholders.put("{{protocol_number}}", applicationAmendmentRequestEntity.getProtocol().getProtocolNumber().toString());
bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatLocalDateTime(applicationAmendmentRequestEntity.getProtocol().getCreatedDate(), GepafinConstant.DD_MM_YYYY));
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationAmendmentRequestEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
bodyPlaceholders.put("{{protocol_number}}", applicationEntity.getProtocol().getProtocolNumber().toString());
bodyPlaceholders.put("{{protocol_date}}", DateTimeUtil.formatLocalDateTime(applicationEntity.getProtocol().getCreatedDate(), GepafinConstant.DD_MM_YYYY));
bodyPlaceholders.put("{{protocol_time}}", DateTimeUtil.parseLocalTimeToString(applicationEntity.getProtocol().getTime(), GepafinConstant.HH_MM_SS));
bodyPlaceholders.put("{{response_days}}", applicationAmendmentRequestEntity.getResponseDays().toString());
try {

View File

@@ -16,4 +16,6 @@ public interface ApplicationEvaluationService {
ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId,Long assignedApplicationId);
ApplicationEvaluationEntity validateApplicationEvaluation(Long applicationEvaluationId);
ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId);
}

View File

@@ -38,7 +38,7 @@ public interface CompanyService {
CompanyDelegationResponse uploadCompanyDelegation(HttpServletRequest request, Long companyId, MultipartFile file);
CompanyDelegationResponse getCompanyDelegation(HttpServletRequest request, Long companyId);
CompanyDelegationResponse getCompanyDelegation(HttpServletRequest request, Long companyId,Long applicationId);
void deleteCompanyDelegation(HttpServletRequest request, Long companyId);
UserWithCompanyEntity getUserWithCompanyEntity(Long userId,Long companyId);

View File

@@ -93,4 +93,9 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
public ApplicationEvaluationEntity validateApplicationEvaluation(Long applicationEvaluationId) {
return applicationEvaluationDao.validateApplicationEvaluation(applicationEvaluationId);
}
@Override
public ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId) {
return applicationEvaluationDao.validateApplicationEvaluationByApplicationId(applicationId);
}
}

View File

@@ -110,9 +110,8 @@ public class CompanyServiceImpl implements CompanyService {
@Override
@Transactional
public CompanyDelegationResponse getCompanyDelegation(HttpServletRequest request, Long companyId) {
UserEntity userEntity =validator.validateUser(request);
return delegationDao.getCompanyDelegation(userEntity, companyId);
public CompanyDelegationResponse getCompanyDelegation(HttpServletRequest request, Long companyId,Long applicationId) {
return delegationDao.getCompanyDelegation(request, companyId,applicationId);
}
@Override
@Transactional(rollbackFor = Exception.class)

View File

@@ -128,9 +128,10 @@ public interface CompanyApi {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "{companyId}/delegation", produces = { "application/json" })
@GetMapping(value = "delegation", produces = { "application/json" })
ResponseEntity<Response<CompanyDelegationResponse>> getCompanyDelegation(HttpServletRequest request,
@Parameter(description = "The company id", required = true) @PathVariable("companyId") Long companyId);
@Parameter(description = "The company ID") @RequestParam(value = "companyId", required = false) Long companyId,
@Parameter(description = "The application ID") @RequestParam(value = "applicationId", required = false) Long applicationId);
@Operation(summary = "Api to delete company delegation", responses = { @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {

View File

@@ -8,6 +8,7 @@ import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
import net.gepafin.tendermanagement.model.request.UserActionRequest;
import net.gepafin.tendermanagement.util.LoggingUtil;
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -152,13 +153,13 @@ public class CompanyApiController implements CompanyApi{
@Override
public ResponseEntity<Response<CompanyDelegationResponse>> getCompanyDelegation(HttpServletRequest request,
Long companyId) {
Long companyId,Long applicationId) {
log.info("get company delegation with companyId: {}", companyId);
/** This code is responsible for creating user action logs for the "Get company delegation" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_COMPANY_DELEGATION).build());
CompanyDelegationResponse companyDelegationResponse = companyService.getCompanyDelegation(request, companyId);
CompanyDelegationResponse companyDelegationResponse = companyService.getCompanyDelegation(request, companyId,applicationId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(companyDelegationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELEGATION_FETCH_SUCCESS)));
}

View File

@@ -314,6 +314,8 @@ company.id.required.for.preferred.call=Company ID is required when requesting on
response.days.not.null=Response days should not be null and greater than zero.
application.cannot.approved.or.rejected=Application cannot be approved and rejected because amendment is active.
atleast.one.id.required=At least one of companyId or applicationId must be provided
#Appointment flow messages
ndg.generated = NDG Generated.
ndg.available = NDG Available.

View File

@@ -197,8 +197,6 @@ invalid.vatnumber=Numero di partita IVA non valido.
vatnumber.mandatory=Il numero di partita IVA � obbligatorio.
vatnumber.already.exists=Il numero di partita IVA esiste gi�.
invalid.email=Email non valida.
company.id.mandatory=L'ID dell'azienda <20> obbligatorio.
user.already.connected.to.company=L'utente <20> gi<67> collegato a questa azienda.
validation.error.missing.firstName=Il nome � obbligatorio.
validation.error.missing.lastName=Il cognome � obbligatorio.
validation.error.missing.codiceFiscale=Il Codice Fiscale � obbligatorio.
@@ -306,22 +304,23 @@ beneficiary.call.duplicate = Una chiamata preferita con questo ID di chiamata e
user.must.be.associated.with.company.to.create.application=Devi essere associato a un'azienda per poter presentare domanda per questa applicazione.
company.id.required.for.preferred.call=ID azienda obbligatorio quando si richiedono solo chiamate preferite.
response.days.not.null=I giorni di risposta non devono essere nulli e maggiori di zero.
application.cannot.approved.or.rejected=La domanda non pu<EFBFBD> essere approvata o rifiutata perch<EFBFBD> l'emendamento <EFBFBD> attivo.
application.cannot.approved.or.rejected=La domanda non può essere approvata o rifiutata perché l'emendamento è attivo.
atleast.one.id.required=Almeno uno tra companyId o applicationId deve essere fornito.
#Appointment flow messages
ndg.available = NDG disponibile.
ndg.generation.in.progress = La generazione NDG <EFBFBD> in corso.
ndg.generation.in.progress = La generazione NDG ? in corso.
ndg.fetch.successfully = Recupero NDG riuscito.
appointment.already.created = Appuntamento gi<EFBFBD> creato.
appointment.already.created = Appuntamento gi? creato.
ndg.not.found.for.this.application.or.invalid = NDG non trovato per questa applicazione o non valido.
provide.valid.application.document.id = Fornisci un ID documento applicativo valido.
document.uploaded.successfully.to.external.system = Documento caricato con successo nel sistema esterno.
error.in.uploading.document.check.input = Errore nel caricamento del documento. Controlla i dati inseriti o riprova.
document.already.uploaded = Documento gi<EFBFBD> caricato.
document.already.uploaded = Documento gi? caricato.
document.not.uploaded.to.external.system.please.try.again = Documento non caricato nel sistema esterno, riprova.
ndg.not.found.or.not.matched = L'NDG fornito non corrisponde all'NDG dell'applicazione o non <EFBFBD> stato generato.
ndg.generation.is.only.for.gepafin = La generazione dell'NDG <EFBFBD> disponibile solo per GEPAFIN.
appointment.creation.is.only.for.gepafin = La creazione degli appuntamenti <EFBFBD> consentita solo per GEPAFIN.
upload.document.is.only.for.gepafin = Il documento non pu<EFBFBD> essere caricato, questa operazione <EFBFBD> disponibile solo per il Hub GEPAFIN.
ndg.not.found.or.not.matched = L'NDG fornito non corrisponde all'NDG dell'applicazione o non ? stato generato.
ndg.generation.is.only.for.gepafin = La generazione dell'NDG ? disponibile solo per GEPAFIN.
appointment.creation.is.only.for.gepafin = La creazione degli appuntamenti ? consentita solo per GEPAFIN.
upload.document.is.only.for.gepafin = Il documento non pu? essere caricato, questa operazione ? disponibile solo per il Hub GEPAFIN.
appointment.created.successfully = Appuntamento creato con successo.
error.try.again = Errore di chiamata di servizio durante l'esecuzione dell'operazione. Riprovare.