Merge branch 'develop' of https://github.com/Kitzanos/GEPAFIN-BE into feature/GEPAFINBE-199
This commit is contained in:
@@ -101,6 +101,7 @@ public class GepafinConstant {
|
||||
public static final String STATUS_SAME_ERROR = "status.same.error";
|
||||
public static final String INVALID_STATUS_CHANGE_FROM_DRAFT = "invalid.status.change.from.draft";
|
||||
public static final String INVALID_STATUS_CHANGE_FROM_PUBLISH = "invalid.status.change.from.publish";
|
||||
public static final String INVALID_STATUS_CHANGE_FROM_PUBLISH_TO_DRAFT = "invalid.status.change.from.publish.to.draft";
|
||||
public static final String STATUS_CANNOT_BE_CHANGED = "status.cannot.be.changed";
|
||||
public static final String PUBLISHED_CALL_NOT_UPDATE = "published.call.not.update";
|
||||
public static final String INVALID_USER = "invalid_user";
|
||||
@@ -136,8 +137,9 @@ public class GepafinConstant {
|
||||
public static final String UPDATING_FORM_VALUE_IMPACT_ON_FLOW = "updating.form.value.impact.on.flow";
|
||||
public static final String APPLICATION_IS_INCOMPLETE_MSG = "application.is.incomplete";
|
||||
public static final String AUTHORIZATION = "Authorization";
|
||||
public static final String CHECK_VATNUMBER_V2_NEW_URL = "https://imprese.openapi.it/advance";
|
||||
public static final String CHECK_VATNUMBER_V2_NEW_URL_IT_ADVANCE = "https://company.openapi.com/IT-advanced";
|
||||
public static final String CHECK_VATNUMBER_URL_V1 = "https://imprese.openapi.it/advance";
|
||||
public static final String CHECK_VATNUMBER_URL_V2 = "https://company.openapi.com/IT-advanced";
|
||||
public static final String VAT_CHECK_API_VERSION = "VAT_CHECK_API_VERSION";
|
||||
public static final String VALIDATION_FIELD_CUSTOM = "validation.field.custom";
|
||||
public static final String VALIDATION_CODICE_FISCALE = "validation.codice.fiscale";
|
||||
public static final String VALIDATION_CAP = "validation.cap";
|
||||
@@ -504,6 +506,35 @@ public class GepafinConstant {
|
||||
public static final String APPLICATION="application";
|
||||
public static final String APPLICATION_ID="applicationId";
|
||||
public static final String USER_WITH_COMPANY_ID="userWithCompanyId";
|
||||
public static final String ASSIGNED_USER_ID="assignedUserId";
|
||||
public static final String APPLICATION_USER_ID="applicationUserId";
|
||||
public static final String INVALID_USER_ID="invalid.user";
|
||||
public static final String COMPANY_NAME="companyName";
|
||||
public static final String TABLE_COLUMNS="table_columns";
|
||||
public static final String PREDEFINED="predefined";
|
||||
public static final String EBABLE_CSV="enableCsv";
|
||||
public static final String LABEL_CSV="labelCsv";
|
||||
public static final String GET="get";
|
||||
public static final String REPORT_COLUMNS="reportColumns";
|
||||
public static final String FIELD_TYPE="fieldtype";
|
||||
public static final String ENABLE_FORMULA="enableFormula";
|
||||
public static final String STATE_FIELD_DATA="stateFieldData";
|
||||
public static final String REPORT_ENABLE="reportEnable";
|
||||
public static final String TABLE="table";
|
||||
public static final String GET_FIELD_TYPE="getFieldType";
|
||||
public static final String GET_APPLICATION_FORM_ID="getApplicationFormId";
|
||||
public static final String GET_APPLICATION_ID="getApplicationId";
|
||||
public static final String GET_ID="getId";
|
||||
public static final String GET_CLASS="getClass";
|
||||
public static final String GET_FORM_ID="getFormId";
|
||||
public static final String GET_FIELD_ID="getFieldId";
|
||||
public static final String GET_FIELD_LABEL="getFieldLabel";
|
||||
public static final String GET_FIELD_VALUE="getFieldValue";
|
||||
public static final String GET_REPORT_ENABLE="getReportEnable";
|
||||
public static final String GET_REPORT_HEADER="getReportHeader";
|
||||
|
||||
public static final String APPOINTMENT_ID="appointmentId";
|
||||
public static final String APPLICATION_STATUS="applicationStatus";
|
||||
|
||||
public static final String RINALDO_EMAIL = "rinaldo.bonazzo@bflows.net";
|
||||
}
|
||||
|
||||
@@ -134,6 +134,12 @@ public class ApplicationAmendmentRequestDao {
|
||||
@Autowired
|
||||
private ApplicationEvaluationFormRepository applicationEvaluationFormRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationAmendmentRequestViewRepository applicationAmendmentRequestViewRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationDao applicationDao;
|
||||
|
||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
|
||||
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
||||
@@ -1268,7 +1274,122 @@ public class ApplicationAmendmentRequestDao {
|
||||
documentService.deleteFile(documentId);
|
||||
}
|
||||
|
||||
public PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(Long userId, ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||
// public PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(Long userId, ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||
// Integer pageNo = null;
|
||||
// Integer pageLimit = null;
|
||||
// if (applicationAmendmentPaginationRequestBean.getGlobalFilters() != null) {
|
||||
// pageNo = applicationAmendmentPaginationRequestBean.getGlobalFilters().getPage();
|
||||
// pageLimit = applicationAmendmentPaginationRequestBean.getGlobalFilters().getLimit();
|
||||
// }
|
||||
// if (pageLimit == null || pageLimit <= 0) {
|
||||
// pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||
// }
|
||||
// if (pageNo == null || pageNo <= 0) {
|
||||
// pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
// }
|
||||
// Specification<ApplicationAmendmentRequestEntity> spec = searchPagination(userId,applicationAmendmentPaginationRequestBean);
|
||||
// Page<ApplicationAmendmentRequestEntity> entityPage = applicationAmendmentRequestRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
//
|
||||
//
|
||||
// List<ApplicationAmendmentRequestResponse> applicationResponses = entityPage.getContent().stream()
|
||||
// .map(application -> {
|
||||
// ApplicationAmendmentRequestResponse response = convertEntityToResponse(application,false);
|
||||
// return response;
|
||||
// })
|
||||
// .collect(Collectors.toList());
|
||||
//
|
||||
//
|
||||
// PageableResponseBean<List<ApplicationAmendmentRequestResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||
// pageableResponseBean.setBody(applicationResponses);
|
||||
// pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||
// pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||
// pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||
// pageableResponseBean.setPageSize(entityPage.getSize());
|
||||
//
|
||||
// return pageableResponseBean;
|
||||
// }
|
||||
//
|
||||
// public Specification<ApplicationAmendmentRequestEntity> searchPagination(Long userId,ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||
// return (root, query, criteriaBuilder) -> {
|
||||
//
|
||||
// List<Predicate> predicates = getPredicates(applicationAmendmentPaginationRequestBean, criteriaBuilder, root,userId);
|
||||
// SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||
//
|
||||
// if (applicationAmendmentPaginationRequestBean .getGlobalFilters() != null
|
||||
// && applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy() != null &&
|
||||
// applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName() != null && Boolean.FALSE.equals(
|
||||
// isEmpty(applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName()))) {
|
||||
// sortBy.setColumnName(applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName());
|
||||
// sortBy.setSortDesc(true);
|
||||
// if (applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getSortDesc() != null) {
|
||||
// sortBy.setSortDesc(applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// query.orderBy(criteriaBuilder.desc(root.get(sortBy.getColumnName())));
|
||||
// if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||
// query.orderBy(criteriaBuilder.asc(root.get(sortBy.getColumnName())));
|
||||
// }
|
||||
// return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||
// };
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private List<Predicate> getPredicates(ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean,
|
||||
// CriteriaBuilder criteriaBuilder, Root<ApplicationAmendmentRequestEntity> root,Long userId) {
|
||||
//
|
||||
// Integer year = null;
|
||||
// String search = null;
|
||||
// if (amendmentPaginationRequestBean.getGlobalFilters() != null) {
|
||||
// year = amendmentPaginationRequestBean.getGlobalFilters().getYear();
|
||||
// search = amendmentPaginationRequestBean.getGlobalFilters().getSearch();
|
||||
// }
|
||||
// List<Predicate> predicates = new ArrayList<>();
|
||||
//
|
||||
// if (year != null && year > 0) {
|
||||
// int filterYear = amendmentPaginationRequestBean.getGlobalFilters().getYear();
|
||||
//
|
||||
//// Create LocalDateTime boundaries for the start and end of the year
|
||||
// LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
|
||||
// LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
|
||||
//
|
||||
//// Add the range comparison to filter records within the year
|
||||
// predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||
//
|
||||
// }
|
||||
// // Search in `title` and `message` (if search term is provided)
|
||||
// if (search != null && !search.isEmpty()) {
|
||||
// Predicate notePredicate = criteriaBuilder.like(
|
||||
// criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
||||
// "%" + search.toUpperCase() + "%"
|
||||
// );
|
||||
// predicates.add(criteriaBuilder.or(notePredicate));
|
||||
// Predicate internalNotePredicate = criteriaBuilder.like(
|
||||
// criteriaBuilder.upper(root.get(GepafinConstant.INTERNAL_NOTE)),
|
||||
// "%" + search.toUpperCase() + "%"
|
||||
// );
|
||||
// predicates.add(criteriaBuilder.or(internalNotePredicate));
|
||||
// }
|
||||
//
|
||||
// // Filter by `status` (if status list is provided)
|
||||
// if (amendmentPaginationRequestBean.getStatus() != null && !amendmentPaginationRequestBean.getStatus().isEmpty()) {
|
||||
// List<String> statusValues = amendmentPaginationRequestBean.getStatus().stream()
|
||||
// .map(ApplicationAmendmentRequestEnum::name) // Convert enum to string
|
||||
// .toList();
|
||||
// predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||
// }
|
||||
// if(Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
||||
// predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("application").get("userId").in(userId));
|
||||
// }
|
||||
// else {
|
||||
// predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("userId").in(userId));
|
||||
// }
|
||||
//
|
||||
// return predicates;
|
||||
//
|
||||
// }
|
||||
|
||||
public PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> getApplicationAmendmentByPaginationByView(Long userId, ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||
Integer pageNo = null;
|
||||
Integer pageLimit = null;
|
||||
if (applicationAmendmentPaginationRequestBean.getGlobalFilters() != null) {
|
||||
@@ -1281,20 +1402,20 @@ public class ApplicationAmendmentRequestDao {
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
}
|
||||
Specification<ApplicationAmendmentRequestEntity> spec = searchPagination(userId,applicationAmendmentPaginationRequestBean);
|
||||
Page<ApplicationAmendmentRequestEntity> entityPage = applicationAmendmentRequestRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
Specification<ApplicationAmendmentRequestView> spec = searchPaginationByView(userId,applicationAmendmentPaginationRequestBean);
|
||||
Page<ApplicationAmendmentRequestView> entityPage = applicationAmendmentRequestViewRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
|
||||
|
||||
List<ApplicationAmendmentRequestResponse> applicationResponses = entityPage.getContent().stream()
|
||||
.map(application -> {
|
||||
ApplicationAmendmentRequestResponse response = convertEntityToResponse(application,false);
|
||||
List<ApplicationAmendmentRequestViewResponse> applicationAmendmentRequestViewResponses = entityPage.getContent().stream()
|
||||
.map(amendmentRequestView -> {
|
||||
ApplicationAmendmentRequestViewResponse response = convertAmendmentEntityToApplicationAmendmentRequestViewResponse(amendmentRequestView);
|
||||
return response;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
PageableResponseBean<List<ApplicationAmendmentRequestResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||
pageableResponseBean.setBody(applicationResponses);
|
||||
PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||
pageableResponseBean.setBody(applicationAmendmentRequestViewResponses);
|
||||
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||
@@ -1302,11 +1423,10 @@ public class ApplicationAmendmentRequestDao {
|
||||
|
||||
return pageableResponseBean;
|
||||
}
|
||||
|
||||
public Specification<ApplicationAmendmentRequestEntity> searchPagination(Long userId,ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||
public Specification<ApplicationAmendmentRequestView> searchPaginationByView(Long userId,ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
|
||||
List<Predicate> predicates = getPredicates(applicationAmendmentPaginationRequestBean, criteriaBuilder, root,userId);
|
||||
List<Predicate> predicates = getPredicatesByView(applicationAmendmentPaginationRequestBean, criteriaBuilder, root,userId);
|
||||
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||
|
||||
if (applicationAmendmentPaginationRequestBean .getGlobalFilters() != null
|
||||
@@ -1329,15 +1449,19 @@ public class ApplicationAmendmentRequestDao {
|
||||
}
|
||||
|
||||
|
||||
private List<Predicate> getPredicates(ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean,
|
||||
CriteriaBuilder criteriaBuilder, Root<ApplicationAmendmentRequestEntity> root,Long userId) {
|
||||
private List<Predicate> getPredicatesByView(ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean,
|
||||
CriteriaBuilder criteriaBuilder, Root<ApplicationAmendmentRequestView> root,Long userId) {
|
||||
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
Map<String, FilterCriteria> filters = new HashMap<>();
|
||||
if (amendmentPaginationRequestBean.getGlobalFilters() != null) {
|
||||
year = amendmentPaginationRequestBean.getGlobalFilters().getYear();
|
||||
search = amendmentPaginationRequestBean.getGlobalFilters().getSearch();
|
||||
}
|
||||
if (amendmentPaginationRequestBean.getFilters() != null) {
|
||||
filters = amendmentPaginationRequestBean.getFilters();
|
||||
}
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
if (year != null && year > 0) {
|
||||
@@ -1351,19 +1475,37 @@ public class ApplicationAmendmentRequestDao {
|
||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||
|
||||
}
|
||||
// Search in `title` and `message` (if search term is provided)
|
||||
|
||||
if (search != null && !search.isEmpty()) {
|
||||
Predicate notePredicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
||||
List<Predicate> searchPredicates = new ArrayList<>();
|
||||
|
||||
searchPredicates.add(criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.CALL_NAME)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(notePredicate));
|
||||
Predicate internalNotePredicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.INTERNAL_NOTE)),
|
||||
));
|
||||
|
||||
searchPredicates.add(criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.COMPANY_NAME)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(internalNotePredicate));
|
||||
));
|
||||
|
||||
// Uncomment these if needed
|
||||
// searchPredicates.add(criteriaBuilder.like(
|
||||
// criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
||||
// "%" + search.toUpperCase() + "%"
|
||||
// ));
|
||||
//
|
||||
// searchPredicates.add(criteriaBuilder.like(
|
||||
// criteriaBuilder.upper(root.get(GepafinConstant.INTERNAL_NOTE)),
|
||||
// "%" + search.toUpperCase() + "%"
|
||||
// ));
|
||||
|
||||
Predicate finalPredicate = criteriaBuilder.or(searchPredicates.toArray(new Predicate[0]));
|
||||
|
||||
predicates.add(finalPredicate);
|
||||
}
|
||||
Utils.applyFiltersByPagination(root, criteriaBuilder, predicates, filters);
|
||||
|
||||
|
||||
// Filter by `status` (if status list is provided)
|
||||
if (amendmentPaginationRequestBean.getStatus() != null && !amendmentPaginationRequestBean.getStatus().isEmpty()) {
|
||||
@@ -1372,14 +1514,33 @@ public class ApplicationAmendmentRequestDao {
|
||||
.toList();
|
||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||
}
|
||||
if(Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
||||
predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("application").get("userId").in(userId));
|
||||
}
|
||||
else {
|
||||
predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("userId").in(userId));
|
||||
boolean isBeneficiaryOrConfidi = validator.checkIsBeneficiary() || validator.checkIsConfidi();
|
||||
boolean isPreInstructor = validator.checkIsPreInstructor();
|
||||
boolean isInstructorManagerWithPersonalRecords = validator.checkIsInstructorManager() &&
|
||||
Boolean.TRUE.equals(amendmentPaginationRequestBean.getPersonalRecords());
|
||||
|
||||
if (isBeneficiaryOrConfidi) {
|
||||
predicates.add(root.get(GepafinConstant.APPLICATION_USER_ID).in(userId));
|
||||
} else if (isPreInstructor || isInstructorManagerWithPersonalRecords) {
|
||||
predicates.add(root.get(GepafinConstant.ASSIGNED_USER_ID).in(userId));
|
||||
}
|
||||
|
||||
return predicates;
|
||||
|
||||
}
|
||||
public ApplicationAmendmentRequestViewResponse convertAmendmentEntityToApplicationAmendmentRequestViewResponse(ApplicationAmendmentRequestView applicationAmendmentRequestView){
|
||||
ApplicationAmendmentRequestViewResponse applicationAmendmentRequestViewResponse=new ApplicationAmendmentRequestViewResponse();
|
||||
applicationAmendmentRequestViewResponse.setId(applicationAmendmentRequestView.getId());
|
||||
applicationAmendmentRequestViewResponse.setApplicationId(applicationAmendmentRequestView.getApplicationId());
|
||||
applicationAmendmentRequestViewResponse.setProtocolNumber(applicationAmendmentRequestView.getProtocolNumber());
|
||||
applicationAmendmentRequestViewResponse.setCallName(applicationAmendmentRequestView.getCallName());
|
||||
applicationAmendmentRequestViewResponse.setCompanyName(applicationAmendmentRequestView.getCompanyName());
|
||||
applicationAmendmentRequestViewResponse.setStartDate(applicationAmendmentRequestView.getStartDate());
|
||||
applicationAmendmentRequestViewResponse.setExpirationDate(applicationAmendmentRequestView.getExpirationDate());
|
||||
applicationAmendmentRequestViewResponse.setAssigendUserName(applicationAmendmentRequestView.getAssigendUserName());
|
||||
applicationAmendmentRequestViewResponse.setStatus(applicationAmendmentRequestView.getStatus());
|
||||
return applicationAmendmentRequestViewResponse;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,15 +21,14 @@ import net.gepafin.tendermanagement.service.FormService;
|
||||
import net.gepafin.tendermanagement.service.HubService;
|
||||
import net.gepafin.tendermanagement.service.SystemEmailTemplatesService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.FieldValidator;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.util.*;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
import org.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVPrinter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.h2.util.IOUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
@@ -47,9 +46,14 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -185,6 +189,11 @@ public class ApplicationDao {
|
||||
@Autowired
|
||||
private ApplicationViewRepository applicationViewRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationFormViewRepository applicationFormViewRepository;
|
||||
|
||||
@Autowired
|
||||
private FormRepository formRepository;
|
||||
|
||||
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
||||
FormEntity formEntity = formService.validateForm(formId);
|
||||
@@ -1438,185 +1447,6 @@ public class ApplicationDao {
|
||||
}
|
||||
}
|
||||
|
||||
public PageableResponseBean<List<ApplicationResponse>> getAllApplicationByPagination(UserEntity userEntity, Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean) {
|
||||
Integer pageNo = null;
|
||||
Integer pageLimit = null;
|
||||
|
||||
UserWithCompanyEntity userWithCompany= userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), companyId).orElse(null);
|
||||
Long userWithCompanyId = userWithCompany!=null?userWithCompany.getId():null;
|
||||
if (applicationPageableRequestBean.getGlobalFilters() != null) {
|
||||
pageNo = applicationPageableRequestBean.getGlobalFilters().getPage();
|
||||
pageLimit = applicationPageableRequestBean.getGlobalFilters().getLimit();
|
||||
}
|
||||
if (pageLimit == null || pageLimit <= 0) {
|
||||
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||
}
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
}
|
||||
Specification<ApplicationEntity> spec = search(callId,companyId, userWithCompanyId, applicationPageableRequestBean, userEntity);
|
||||
Page<ApplicationEntity> entityPage = applicationRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
// Prepare the response
|
||||
|
||||
|
||||
List<ApplicationResponse> applicationResponses = entityPage.getContent().stream()
|
||||
.map(application -> {
|
||||
ApplicationResponse response = getApplicationResponse(application);
|
||||
return response;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
PageableResponseBean<List<ApplicationResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||
pageableResponseBean.setBody(applicationResponses);
|
||||
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||
pageableResponseBean.setPageSize(entityPage.getSize());
|
||||
|
||||
return pageableResponseBean;
|
||||
}
|
||||
|
||||
public Specification<ApplicationEntity> search(Long callId, Long companyId, Long userWithCompanyId, ApplicationPageableRequestBean applicationPageableRequestBean, UserEntity userEntity) {
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
|
||||
List<Predicate> predicates = getPredicates(applicationPageableRequestBean, criteriaBuilder, root, callId,companyId, userWithCompanyId, userEntity);
|
||||
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||
|
||||
if (applicationPageableRequestBean.getGlobalFilters() != null
|
||||
&& applicationPageableRequestBean.getGlobalFilters().getSortBy() != null &&
|
||||
applicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName() != null && Boolean.FALSE.equals(
|
||||
isEmpty(applicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName()))) {
|
||||
sortBy.setColumnName(applicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName());
|
||||
sortBy.setSortDesc(true);
|
||||
if (applicationPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc() != null) {
|
||||
sortBy.setSortDesc(applicationPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
||||
}
|
||||
}
|
||||
|
||||
query.orderBy(criteriaBuilder.desc(root.get(sortBy.getColumnName())));
|
||||
if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||
query.orderBy(criteriaBuilder.asc(root.get(sortBy.getColumnName())));
|
||||
}
|
||||
return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private List<Predicate> getPredicates(ApplicationPageableRequestBean applicationPageableRequestBean,
|
||||
CriteriaBuilder criteriaBuilder, Root<ApplicationEntity> root, Long callId,Long companyId, Long userWithCompanyId, UserEntity userEntity) {
|
||||
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
Integer daysRange = null;
|
||||
Map<String, FilterCriteria> filters = new HashMap<>();
|
||||
if (applicationPageableRequestBean.getGlobalFilters() != null) {
|
||||
year = applicationPageableRequestBean.getGlobalFilters().getYear();
|
||||
search = applicationPageableRequestBean.getGlobalFilters().getSearch();
|
||||
daysRange = applicationPageableRequestBean.getDaysRange();
|
||||
}
|
||||
if (applicationPageableRequestBean.getFilters() != null) {
|
||||
filters = applicationPageableRequestBean.getFilters();
|
||||
}
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
// Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||
if (Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_ID), userEntity.getId()));
|
||||
}
|
||||
if (year != null && year > 0) {
|
||||
int filterYear = applicationPageableRequestBean.getGlobalFilters().getYear();
|
||||
|
||||
// Create LocalDateTime boundaries for the start and end of the year
|
||||
LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
|
||||
LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
|
||||
|
||||
// Add the range comparison to filter records within the year
|
||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||
|
||||
}
|
||||
// Search in `title` and `message` (if search term is provided)
|
||||
if (search != null && !search.isEmpty()) {
|
||||
Predicate titlePredicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.COMMENTS)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
// Predicate protocolPredicate = criteriaBuilder.like(
|
||||
// criteriaBuilder.function(
|
||||
// "TO_CHAR",
|
||||
// String.class,
|
||||
// criteriaBuilder.function("CAST", String.class, root.get(GepafinConstant.PROTOCOL).get(GepafinConstant.PROTOCOL_NUMBER))
|
||||
// ),
|
||||
// "%" + search + "%"
|
||||
// );
|
||||
|
||||
Predicate callNamePredicate =criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.CALL).get(GepafinConstant.NAME)), // Adjust field name
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
|
||||
// predicates.add(criteriaBuilder.or(protocolPredicate));
|
||||
predicates.add(criteriaBuilder.or(callNamePredicate));
|
||||
predicates.add(criteriaBuilder.or(titlePredicate));
|
||||
}
|
||||
|
||||
// Filter by `status` (if status list is provided)
|
||||
if (applicationPageableRequestBean.getStatus() != null && !applicationPageableRequestBean.getStatus().isEmpty()) {
|
||||
List<String> statusValues = applicationPageableRequestBean.getStatus().stream()
|
||||
.map(ApplicationStatusTypeEnum::name) // Convert enum to string
|
||||
.toList();
|
||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||
}
|
||||
|
||||
if (callId != null) {
|
||||
CallEntity call = callService.validateCall(callId);
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.CALL).get(GepafinConstant.ID), callId));
|
||||
}
|
||||
|
||||
// Optional companyId filter
|
||||
if (userWithCompanyId != null) {
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_WITH_COMPANY).get(GepafinConstant.ID), userWithCompanyId));
|
||||
}
|
||||
if (companyId != null) {
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.COMPANY_ID), companyId));
|
||||
}
|
||||
|
||||
if (daysRange != null && daysRange >= 0) {
|
||||
LocalDateTime today = LocalDateTime.now();
|
||||
LocalDateTime pastDate = today.minusDays(daysRange);
|
||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), pastDate, today));
|
||||
}
|
||||
applyFilters(root, criteriaBuilder, predicates, filters);
|
||||
|
||||
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
||||
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB_ID), userEntity.getHub().getId()));
|
||||
|
||||
|
||||
return predicates;
|
||||
}
|
||||
private void applyFilters(Root<?> root, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Map<String, FilterCriteria> filters) {
|
||||
if (Boolean.FALSE.equals(filters.isEmpty())) {
|
||||
for (Map.Entry<String, FilterCriteria> entry : filters.entrySet()) {
|
||||
String fieldName = entry.getKey();
|
||||
FilterCriteria filterCriteria = entry.getValue();
|
||||
Object value = filterCriteria.getValue();
|
||||
MatchModeEnum matchMode = filterCriteria.getMatchMode();
|
||||
|
||||
if (value != null && matchMode != null) {
|
||||
Path<?> fieldPath = root.get(fieldName);
|
||||
if (fieldPath != null) {
|
||||
Utils.applyStringFilter(fieldPath, criteriaBuilder, predicates, value, matchMode);
|
||||
Utils.applyNumberFilter(fieldPath, criteriaBuilder, predicates, value, matchMode);
|
||||
Utils.applyDateFilter(fieldPath, criteriaBuilder, predicates, value, matchMode,root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// private Path<?> getFieldPath(Root<?> root, String fieldName) {
|
||||
// try {
|
||||
@@ -1889,27 +1719,29 @@ public class ApplicationDao {
|
||||
}
|
||||
// Search in `title` and `message` (if search term is provided)
|
||||
if (search != null && !search.isEmpty()) {
|
||||
String searchPattern = "%" + search.toUpperCase() + "%";
|
||||
|
||||
Predicate titlePredicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.COMMENTS)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
// Predicate protocolPredicate = criteriaBuilder.like(
|
||||
// criteriaBuilder.function(
|
||||
// "TO_CHAR",
|
||||
// String.class,
|
||||
// criteriaBuilder.function("CAST", String.class, root.get(GepafinConstant.PROTOCOL).get(GepafinConstant.PROTOCOL_NUMBER))
|
||||
// ),
|
||||
// "%" + search + "%"
|
||||
// );
|
||||
|
||||
Predicate callNamePredicate =criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.CALL_TITLE)), // Adjust field name
|
||||
"%" + search.toUpperCase() + "%"
|
||||
searchPattern
|
||||
);
|
||||
|
||||
// predicates.add(criteriaBuilder.or(protocolPredicate));
|
||||
predicates.add(criteriaBuilder.or(callNamePredicate));
|
||||
predicates.add(criteriaBuilder.or(titlePredicate));
|
||||
Predicate callTitlePredicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.CALL_TITLE)),
|
||||
searchPattern
|
||||
);
|
||||
Predicate callNamePredicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.CALL_NAME)),
|
||||
searchPattern
|
||||
);
|
||||
Predicate companyName = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.COMPANY_NAME)),
|
||||
searchPattern
|
||||
);
|
||||
|
||||
// Combine them using a single `or()`
|
||||
Predicate finalPredicate = criteriaBuilder.or(titlePredicate, callTitlePredicate,callNamePredicate,companyName);
|
||||
predicates.add(finalPredicate);
|
||||
}
|
||||
|
||||
// Filter by `status` (if status list is provided)
|
||||
@@ -1938,7 +1770,7 @@ public class ApplicationDao {
|
||||
LocalDateTime pastDate = today.minusDays(daysRange);
|
||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), pastDate, today));
|
||||
}
|
||||
applyFilters(root, criteriaBuilder, predicates, filters);
|
||||
Utils.applyFiltersByPagination(root, criteriaBuilder, predicates, filters);
|
||||
|
||||
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
||||
|
||||
@@ -1952,7 +1784,7 @@ public class ApplicationDao {
|
||||
ApplicationResponse responseBean = new ApplicationResponse();
|
||||
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationView.getCallId());
|
||||
Long totalFormSteps = flowFormDao.calculateTotalSteps(flowEdgesList);
|
||||
Long completedSteps= Long.valueOf(flowFormDao.getCompletedStepsByView(applicationView.getId(), false));
|
||||
Long completedSteps = Long.valueOf(flowFormDao.getCompletedStepsByView(applicationView.getId(), false));
|
||||
Integer progress = calculateProgress(totalFormSteps, completedSteps);
|
||||
responseBean.setId(applicationView.getId());
|
||||
responseBean.setProgress(progress);
|
||||
@@ -1966,23 +1798,326 @@ public class ApplicationDao {
|
||||
responseBean.setEvaluationVersion(EvaluationVersionEnum.valueOf(applicationView.getEvaluationVersion()));
|
||||
responseBean.setComments(applicationView.getComments());
|
||||
responseBean.setCompanyId(applicationView.getCompanyId());
|
||||
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
|
||||
assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationView.getId());
|
||||
if(assignedApplicationsOptional.isPresent()){
|
||||
responseBean.setAssignedUserId(assignedApplicationsOptional.get().getUserId());
|
||||
UserEntity user = userService.validateUser(assignedApplicationsOptional.get().getUserId());
|
||||
String firstName = user.getFirstName() != null ? user.getFirstName() : "";
|
||||
String lastName = user.getLastName() != null ? user.getLastName() : "";
|
||||
String userName = String.join(" ", firstName, lastName).trim();
|
||||
responseBean.setAssignedUserName(userName);
|
||||
}
|
||||
CompanyEntity company=companyService.validateCompany(applicationView.getCompanyId());
|
||||
responseBean.setCompanyName(company.getCompanyName());
|
||||
responseBean.setProtocolNumber(applicationView.getProtocolNumber());
|
||||
responseBean.setAssignedUserId(applicationView.getAssignedUserId());
|
||||
responseBean.setAssignedUserName(applicationView.getAssignedUserName());
|
||||
responseBean.setCompanyName(applicationView.getCompanyName());
|
||||
responseBean.setProtocolNumber(applicationView.getProtocolNumber());
|
||||
responseBean.setAmountAccepted(applicationView.getAmountAccepted());
|
||||
responseBean.setAmountRequested(applicationView.getAmountRequested());
|
||||
responseBean.setDateAccepted(applicationView.getDateAccepted());
|
||||
responseBean.setDateRejected(applicationView.getDateRejected());
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
public List<ApplicationFormView> getApplicationFormData(Long callId) {
|
||||
List<ApplicationFormView> applicationFormViews=new ArrayList<>();
|
||||
|
||||
applicationFormViews= applicationFormViewRepository.findByCallId(callId);
|
||||
|
||||
return applicationFormViews;
|
||||
}
|
||||
|
||||
private List<Method> getStaticGetterMethods() {
|
||||
List<String> excluded = Arrays.asList(
|
||||
GepafinConstant.GET_FIELD_TYPE,GepafinConstant.GET_APPLICATION_FORM_ID,GepafinConstant.GET_ID,GepafinConstant.GET_CLASS,GepafinConstant.GET_FORM_ID,GepafinConstant.GET_FIELD_ID,GepafinConstant.GET_FIELD_LABEL,GepafinConstant.GET_FIELD_VALUE,GepafinConstant.GET_REPORT_HEADER,GepafinConstant.GET_REPORT_ENABLE
|
||||
);
|
||||
|
||||
Method applicationIdMethod = null;
|
||||
|
||||
List<Method> methods = new ArrayList<>();
|
||||
|
||||
for (Method m : ApplicationFormView.class.getMethods()) {
|
||||
if (m.getName().equals(GepafinConstant.GET_APPLICATION_ID)) {
|
||||
applicationIdMethod = m;
|
||||
} else if (m.getName().startsWith(GepafinConstant.GET) && m.getParameterCount() == 0 && !excluded.contains(m.getName())) {
|
||||
methods.add(m);
|
||||
}
|
||||
}
|
||||
|
||||
methods.sort(Comparator.comparing(Method::getName)); // Sort remaining
|
||||
|
||||
if (applicationIdMethod != null) {
|
||||
methods.add(0, applicationIdMethod); // Add it to the beginning
|
||||
}
|
||||
|
||||
return methods;
|
||||
|
||||
}
|
||||
|
||||
private String methodToHeader(Method method) {
|
||||
String name = method.getName().substring(3); // strip "get"
|
||||
return Arrays.stream(name.split("(?=[A-Z])"))
|
||||
.map(String::toLowerCase)
|
||||
.map(word -> Character.toUpperCase(word.charAt(0)) + word.substring(1))
|
||||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
private String invokeGetter(ApplicationFormView view, Method method) {
|
||||
try {
|
||||
Object value = method.invoke(view);
|
||||
if (value == null) return "";
|
||||
|
||||
String stringValue;
|
||||
|
||||
if (value instanceof LocalDate) {
|
||||
stringValue = ((LocalDate) value).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
} else if (value instanceof LocalDateTime) {
|
||||
stringValue = ((LocalDateTime) value).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
} else if (value instanceof Date) {
|
||||
stringValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) value);
|
||||
} else {
|
||||
stringValue = value.toString();
|
||||
}
|
||||
|
||||
// Wrap it in ="..." to make Excel treat it as a literal string
|
||||
return "=\"" + stringValue.replace("\"", "\"\"") + "\"";
|
||||
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public byte[] exportCsv(Long callId) {
|
||||
|
||||
List<ApplicationFormView> results = getApplicationFormData(callId);
|
||||
|
||||
|
||||
Map<Long, ApplicationFormView> appInfo = new HashMap<>();
|
||||
Map<Long, Map<String, String>> appFieldValues = new LinkedHashMap<>();
|
||||
Set<String> tableFieldIds = new HashSet<>();
|
||||
Map<String, String> fieldIdToLabel = new LinkedHashMap<>();
|
||||
|
||||
for (ApplicationFormView row : results) {
|
||||
appInfo.putIfAbsent(row.getApplicationId(), row);
|
||||
String label=row.getReportHeader();
|
||||
if(Boolean.TRUE.equals(StringUtils.isEmpty(label))){
|
||||
label=row.getFieldLabel();
|
||||
}
|
||||
fieldIdToLabel.putIfAbsent(row.getFieldId(), label);
|
||||
|
||||
if (GepafinConstant.TABLE.equalsIgnoreCase(row.getFieldType())) {
|
||||
tableFieldIds.add(row.getFieldId());
|
||||
continue;
|
||||
}
|
||||
|
||||
String value = Optional.ofNullable(row.getFieldValue())
|
||||
.map(v -> v.startsWith("\"") && v.endsWith("\"") ? v.substring(1, v.length() - 1) : v)
|
||||
.orElse("");
|
||||
|
||||
appFieldValues
|
||||
.computeIfAbsent(row.getApplicationId(), k -> new LinkedHashMap<>())
|
||||
.merge(row.getFieldId(), value, (v1, v2) -> v1.equals(v2) ? v1 : String.join(", ", v1, v2));
|
||||
}
|
||||
|
||||
Map<String, List<String>> tableHeadersByFieldId = new LinkedHashMap<>();
|
||||
Map<Long, Map<String, String>> tableDataByApp = new HashMap<>();
|
||||
prepareTableFieldData(results, tableFieldIds, tableHeadersByFieldId, tableDataByApp);
|
||||
|
||||
// Final header construction
|
||||
List<Method> staticMethods = getStaticGetterMethods();
|
||||
List<String> staticHeaders = staticMethods.stream().map(this::methodToHeader).toList();
|
||||
|
||||
List<String> dynamicHeaders = new ArrayList<>();
|
||||
for (String fieldId : fieldIdToLabel.keySet()) {
|
||||
if (tableHeadersByFieldId.containsKey(fieldId)) {
|
||||
dynamicHeaders.addAll(tableHeadersByFieldId.get(fieldId));
|
||||
} else {
|
||||
dynamicHeaders.add(fieldIdToLabel.get(fieldId));
|
||||
}
|
||||
}
|
||||
|
||||
List<String> allHeaders = new ArrayList<>(staticHeaders);
|
||||
allHeaders.addAll(dynamicHeaders);
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
try (CSVPrinter printer = new CSVPrinter(new OutputStreamWriter(out), CSVFormat.DEFAULT.withHeader(allHeaders.toArray(new String[0])))) {
|
||||
for (Long appId : appFieldValues.keySet()) {
|
||||
ApplicationFormView appRow = appInfo.get(appId);
|
||||
Map<String, String> flatFieldVals = appFieldValues.get(appId);
|
||||
Map<String, String> tableVals = tableDataByApp.getOrDefault(appId, Collections.emptyMap());
|
||||
|
||||
List<String> row = new ArrayList<>();
|
||||
for (Method method : staticMethods) {
|
||||
row.add(invokeGetter(appRow, method));
|
||||
}
|
||||
|
||||
for (String fieldId : fieldIdToLabel.keySet()) {
|
||||
if (tableHeadersByFieldId.containsKey(fieldId)) {
|
||||
for (String header : tableHeadersByFieldId.get(fieldId)) {
|
||||
row.add(tableVals.getOrDefault(header, ""));
|
||||
}
|
||||
} else {
|
||||
row.add(flatFieldVals.getOrDefault(fieldId, ""));
|
||||
}
|
||||
}
|
||||
|
||||
printer.printRecord(row);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("CSV generation failed", e);
|
||||
}
|
||||
|
||||
return out.toByteArray();
|
||||
}
|
||||
private Map<String, String> extractTableData(String fieldType,
|
||||
ContentResponseBean content, String fieldValue) {
|
||||
|
||||
if (content == null) return Map.of();
|
||||
|
||||
Map<String, String> result = new LinkedHashMap<>();
|
||||
|
||||
List<Map<String, Object>> rows = null;
|
||||
try {
|
||||
rows = GepafinConstant.CRITERIA_TABLE_COLUMNS.equals(fieldType)
|
||||
? Utils.convertJsonToListMap(String.valueOf(PdfUtils.extractRows(fieldValue)))
|
||||
: Utils.convertJsonToListMap(fieldValue);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Map<String, String> fieldLabelMap = new LinkedHashMap<>();
|
||||
Set<String> predefinedIds = new LinkedHashSet<>();
|
||||
Set<String> dynamicIds = new LinkedHashSet<>();
|
||||
Set<String> numericFormulaIds = new LinkedHashSet<>();
|
||||
|
||||
for (SettingResponseBean setting : content.getSettings()) {
|
||||
String settingName = setting.getName();
|
||||
if(settingName.equals(GepafinConstant.REPORT_ENABLE)){
|
||||
Boolean enable= (Boolean) setting.getValue();
|
||||
if(Boolean.FALSE.equals(enable)){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(GepafinConstant.TABLE_COLUMNS.equals(settingName)) || Boolean.TRUE.equals(GepafinConstant.CRITERIA_TABLE_COLUMNS.equals(settingName))) {
|
||||
Map<String, Object> valueMap = (Map<String, Object>) setting.getValue();
|
||||
if (valueMap == null) continue;
|
||||
|
||||
List<Map<String, Object>> columns = (List<Map<String, Object>>) valueMap.get(GepafinConstant.STATE_FIELD_DATA);
|
||||
if (columns != null) {
|
||||
for (Map<String, Object> col : columns) {
|
||||
String id = String.valueOf(col.get(GepafinConstant.NAME));
|
||||
if (Boolean.FALSE.equals(col.get(GepafinConstant.PREDEFINED))) {
|
||||
if (GepafinConstant.NUMERIC.equals(col.get(GepafinConstant.FIELD_TYPE)) && Boolean.TRUE.equals(col.get(GepafinConstant.ENABLE_FORMULA))) {
|
||||
numericFormulaIds.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(GepafinConstant.REPORT_COLUMNS.equals(settingName))) {
|
||||
List<Map<String, Object>> reportColumns = (List<Map<String, Object>>) setting.getValue();
|
||||
if (reportColumns != null) {
|
||||
for (Map<String, Object> col : reportColumns) {
|
||||
Boolean enableCsv = (Boolean) col.get(GepafinConstant.EBABLE_CSV);
|
||||
if (Boolean.TRUE.equals(enableCsv)) {
|
||||
String id = String.valueOf(col.get(GepafinConstant.NAME));
|
||||
|
||||
String fieldCsvLabel = col.get(GepafinConstant.LABEL_CSV) != null
|
||||
? String.valueOf(col.get(GepafinConstant.LABEL_CSV))
|
||||
: String.valueOf(col.get(GepafinConstant.LABEL));
|
||||
|
||||
fieldLabelMap.put(id, fieldCsvLabel);
|
||||
|
||||
if (Boolean.TRUE.equals(col.get(GepafinConstant.PREDEFINED))) {
|
||||
predefinedIds.add(id);
|
||||
} else {
|
||||
dynamicIds.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (predefinedIds.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (Map<String, Object> row : rows) {
|
||||
String prefix = predefinedIds.stream()
|
||||
.map(id -> String.valueOf(row.getOrDefault(id, "")))
|
||||
.filter(s -> !s.isBlank())
|
||||
.findFirst().orElse("");
|
||||
|
||||
|
||||
for (String dynId : dynamicIds) {
|
||||
String dynLabel = fieldLabelMap.get(dynId);
|
||||
for (String preId : predefinedIds.isEmpty() ? List.of("") : predefinedIds) {
|
||||
String preLabel = fieldLabelMap.get(preId);
|
||||
String key = dynLabel + " " + (preLabel != null ? preLabel + " " : "") + prefix;
|
||||
result.put(key, String.valueOf(row.getOrDefault(dynId, "")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add totals for numeric formula-enabled columns
|
||||
for (String dynId : numericFormulaIds) {
|
||||
double sum = rows.stream()
|
||||
.mapToDouble(r -> {
|
||||
try {
|
||||
return Double.parseDouble(String.valueOf(r.getOrDefault(dynId, "0")));
|
||||
} catch (NumberFormatException e) {
|
||||
return 0.0;
|
||||
}
|
||||
}).sum();
|
||||
String dynLabel = fieldLabelMap.get(dynId);
|
||||
result.put("TOTAL " + dynLabel, String.valueOf(sum));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
private void prepareTableFieldData(
|
||||
List<ApplicationFormView> results,
|
||||
Set<String> tableFieldIds,
|
||||
Map<String, List<String>> tableHeadersByFieldId,
|
||||
Map<Long, Map<String, String>> tableDataByApp) {
|
||||
|
||||
if (tableFieldIds.isEmpty()) return;
|
||||
|
||||
Map<Long, List<ApplicationFormView>> groupedByApp = results.stream()
|
||||
.filter(r -> tableFieldIds.contains(r.getFieldId()))
|
||||
.collect(Collectors.groupingBy(ApplicationFormView::getApplicationId));
|
||||
|
||||
for (Map.Entry<Long, List<ApplicationFormView>> entry : groupedByApp.entrySet()) {
|
||||
Long appId = entry.getKey();
|
||||
Map<String, String> flattenedAll = new LinkedHashMap<>();
|
||||
|
||||
for (ApplicationFormView row : entry.getValue()) {
|
||||
formRepository.findById(row.getFormId()).ifPresent(form -> {
|
||||
List<ContentResponseBean> contentList = Utils.convertJsonStringToList(form.getContent(), ContentResponseBean.class);
|
||||
ContentResponseBean content = contentList.stream()
|
||||
.filter(c -> c.getId().equals(row.getFieldId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (content == null) return;
|
||||
|
||||
content.getSettings().stream()
|
||||
.filter(setting -> GepafinConstant.TABLE_COLUMNS.equals(setting.getName())
|
||||
|| GepafinConstant.CRITERIA_TABLE_COLUMNS.equals(setting.getName()))
|
||||
.findFirst()
|
||||
.ifPresent(setting -> {
|
||||
Map<String, String> flattened = extractTableData(
|
||||
row.getFieldType(),
|
||||
content,
|
||||
row.getFieldValue()
|
||||
);
|
||||
if (flattened != null) {
|
||||
tableHeadersByFieldId.putIfAbsent(row.getFieldId(), new ArrayList<>(flattened.keySet()));
|
||||
flattenedAll.putAll(flattened);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
tableDataByApp.put(appId, flattenedAll);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1665,7 +1665,7 @@ public class ApplicationEvaluationDao {
|
||||
});
|
||||
}
|
||||
|
||||
private String getLabelFromSettings(ContentResponseBean contentResponseBean) {
|
||||
public String getLabelFromSettings(ContentResponseBean contentResponseBean) {
|
||||
String label = contentResponseBean.getLabel();
|
||||
if (contentResponseBean.getSettings() != null) {
|
||||
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||
|
||||
@@ -96,9 +96,6 @@ public class AppointmentDao {
|
||||
@Value("${aws.s3.bucket.name}")
|
||||
private String OLD_BUCKET;
|
||||
|
||||
@Value("${flagDaFirmare}")
|
||||
private Boolean flagDaFirmare;
|
||||
|
||||
@Autowired
|
||||
private HubRepository hubRepository;
|
||||
|
||||
@@ -963,7 +960,7 @@ public class AppointmentDao {
|
||||
UploadDocToExternalSystemRequest.Input input = new UploadDocToExternalSystemRequest.Input();
|
||||
input.setIdTipoProtocollo(docToExternalSystemRequest.getInput().getIdTipoProtocollo());
|
||||
input.setIdClassificazione(docToExternalSystemRequest.getInput().getIdClassificazione());
|
||||
input.setFlagDaFirmare(flagDaFirmare);
|
||||
input.setFlagDaFirmare(docToExternalSystemRequest.getInput().getFlagDaFirmare());
|
||||
input.setDescrizione(docToExternalSystemRequest.getInput().getDescrizione());
|
||||
|
||||
UploadDocToExternalSystemRequest.Input.Attributes attributes = new UploadDocToExternalSystemRequest.Input.Attributes();
|
||||
|
||||
@@ -14,12 +14,14 @@ import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationViewResponse;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.SortBy;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsViewRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
@@ -77,6 +79,9 @@ public class AssignedApplicationsDao {
|
||||
@Autowired
|
||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||
|
||||
@Autowired
|
||||
private AssignedApplicationsViewRepository assignedApplicationsViewRepository;
|
||||
|
||||
public AssignedApplicationsResponse createAssignedApplications(Long applicationId, Long userId, UserEntity assignedByUser, AssignedApplicationsRequest assignedApplicationsRequest) {
|
||||
log.info("Assigning application to pre-Instructor with details: {}", applicationId, userId);
|
||||
|
||||
@@ -297,7 +302,7 @@ public class AssignedApplicationsDao {
|
||||
log.info("Assigned application fetched successfully: {}", response);
|
||||
return response;
|
||||
}
|
||||
public PageableResponseBean<List<AssignedApplicationsResponse>> getAllAssignedApplicationsByPagination(UserEntity user, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean,Long userId) {
|
||||
public PageableResponseBean<List<AssignedApplicationViewResponse>> getAllAssignedApplicationsByPagination(UserEntity user, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean,Long userId) {
|
||||
Integer pageNo = null;
|
||||
Integer pageLimit = null;
|
||||
if (assignedApplicationPageableRequestBean.getGlobalFilters() != null) {
|
||||
@@ -310,21 +315,15 @@ public class AssignedApplicationsDao {
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
}
|
||||
Specification<AssignedApplicationsEntity> spec = searchByPagination( assignedApplicationPageableRequestBean, user,userId);
|
||||
Page<AssignedApplicationsEntity> entityPage = assignedApplicationsRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
Specification<AssignedApplicationsView> spec = searchByPagination( assignedApplicationPageableRequestBean, user,userId);
|
||||
Page<AssignedApplicationsView> entityPage = assignedApplicationsViewRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
// Prepare the response
|
||||
|
||||
|
||||
List<AssignedApplicationsResponse> assignedApplicationsResponses = entityPage.getContent().stream()
|
||||
.map(application -> {
|
||||
AssignedApplicationsResponse response = convertEntityToResponse(application);
|
||||
return response;
|
||||
})
|
||||
List<AssignedApplicationViewResponse> assignedApplicationsResponses = entityPage.getContent().stream()
|
||||
.map(this::getAssignedApplicationResponseByView)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
|
||||
PageableResponseBean<List<AssignedApplicationsResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||
PageableResponseBean<List<AssignedApplicationViewResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||
pageableResponseBean.setBody(assignedApplicationsResponses);
|
||||
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1);
|
||||
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||
@@ -334,7 +333,7 @@ public class AssignedApplicationsDao {
|
||||
return pageableResponseBean;
|
||||
}
|
||||
|
||||
public Specification<AssignedApplicationsEntity> searchByPagination(AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean, UserEntity userEntity,Long userId) {
|
||||
public Specification<AssignedApplicationsView> searchByPagination(AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean, UserEntity userEntity,Long userId) {
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
|
||||
List<Predicate> predicates = getPredicates(assignedApplicationPageableRequestBean, criteriaBuilder, root, userEntity,userId);
|
||||
@@ -350,30 +349,35 @@ public class AssignedApplicationsDao {
|
||||
sortBy.setSortDesc(assignedApplicationPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
||||
}
|
||||
}
|
||||
Path<?> sortPath;
|
||||
Join<AssignedApplicationsEntity, ApplicationEntity> applicationJoin = root.join(GepafinConstant.APPLICATION, JoinType.LEFT);
|
||||
// Path<?> sortPath;
|
||||
// Join<AssignedApplicationsEntity, ApplicationEntity> applicationJoin = root.join(GepafinConstant.APPLICATION, JoinType.LEFT);
|
||||
//
|
||||
// if (GepafinConstant.APPLICATION_ID.equals(sortBy.getColumnName())) {
|
||||
// sortPath = root.join(GepafinConstant.APPLICATION, JoinType.LEFT).get(GepafinConstant.ID); // Join ApplicationEntity and sort by application.id
|
||||
// }
|
||||
// else if (GepafinConstant.PROTOCOL_NUMBER.equals(sortBy.getColumnName())) {
|
||||
// Join<ApplicationEntity, ProtocolEntity> protocolJoin = applicationJoin.join(GepafinConstant.PROTOCOL, JoinType.LEFT);
|
||||
// sortPath = protocolJoin.get(GepafinConstant.PROTOCOL_NUMBER);
|
||||
// }
|
||||
// else {
|
||||
// sortPath = root.get(sortBy.getColumnName()); // Sorting by a field in AmendmentEntity
|
||||
// }
|
||||
// query.orderBy(criteriaBuilder.desc(sortPath));
|
||||
// if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||
// query.orderBy(criteriaBuilder.asc(sortPath));
|
||||
// }
|
||||
// return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||
|
||||
Path<?> sortPath = root.get(sortBy.getColumnName()); // All fields are accessible directly in the view
|
||||
query.orderBy(sortBy.getSortDesc() ? criteriaBuilder.desc(sortPath) : criteriaBuilder.asc(sortPath));
|
||||
|
||||
if (GepafinConstant.APPLICATION_ID.equals(sortBy.getColumnName())) {
|
||||
sortPath = root.join(GepafinConstant.APPLICATION, JoinType.LEFT).get(GepafinConstant.ID); // Join ApplicationEntity and sort by application.id
|
||||
}
|
||||
else if (GepafinConstant.PROTOCOL_NUMBER.equals(sortBy.getColumnName())) {
|
||||
Join<ApplicationEntity, ProtocolEntity> protocolJoin = applicationJoin.join(GepafinConstant.PROTOCOL, JoinType.LEFT);
|
||||
sortPath = protocolJoin.get(GepafinConstant.PROTOCOL_NUMBER);
|
||||
}
|
||||
else {
|
||||
sortPath = root.get(sortBy.getColumnName()); // Sorting by a field in AmendmentEntity
|
||||
}
|
||||
query.orderBy(criteriaBuilder.desc(sortPath));
|
||||
if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||
query.orderBy(criteriaBuilder.asc(sortPath));
|
||||
}
|
||||
return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private List<Predicate> getPredicates(AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean,
|
||||
CriteriaBuilder criteriaBuilder, Root<AssignedApplicationsEntity> root, UserEntity userEntity,Long userId) {
|
||||
CriteriaBuilder criteriaBuilder, Root<AssignedApplicationsView> root, UserEntity userEntity,Long userId) {
|
||||
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
@@ -404,12 +408,35 @@ public class AssignedApplicationsDao {
|
||||
|
||||
}
|
||||
// Search in `title` and `message` (if search term is provided)
|
||||
if (search != null && !search.isEmpty()) {
|
||||
Predicate titlePredicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(titlePredicate));
|
||||
// if (search != null && !search.isEmpty()) {
|
||||
// Predicate titlePredicate = criteriaBuilder.like(
|
||||
// criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
||||
// "%" + search.toUpperCase() + "%"
|
||||
// );
|
||||
// predicates.add(criteriaBuilder.or(titlePredicate));
|
||||
// }
|
||||
|
||||
if (search != null && !search.trim().isEmpty()) {
|
||||
String pattern = "%" + search.toUpperCase() + "%";
|
||||
List<Predicate> searchPredicates = new ArrayList<>();
|
||||
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.CALL_NAME)), pattern));
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.COMPANY_NAME)), pattern));
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.STATUS)), pattern));
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.NDG_STRING)), pattern));
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.APPOINTMENT_ID)), pattern));
|
||||
searchPredicates.add(criteriaBuilder.like(criteriaBuilder.upper(root.get(GepafinConstant.APPLICATION_STATUS)), pattern));
|
||||
|
||||
// Convert numeric fields to string for search (optional and DB-specific; otherwise exact match)
|
||||
try {
|
||||
Long searchLong = Long.parseLong(search);
|
||||
searchPredicates.add(criteriaBuilder.equal(root.get(GepafinConstant.APPLICATION_ID), searchLong));
|
||||
searchPredicates.add(criteriaBuilder.equal(root.get(GepafinConstant.PROTOCOL_NUMBER), searchLong));
|
||||
} catch (NumberFormatException ignored) {
|
||||
// Ignore if search is not a number
|
||||
}
|
||||
|
||||
predicates.add(criteriaBuilder.or(searchPredicates.toArray(new Predicate[0])));
|
||||
}
|
||||
|
||||
// Filter by `status` (if status list is provided)
|
||||
@@ -421,12 +448,31 @@ public class AssignedApplicationsDao {
|
||||
}
|
||||
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
||||
|
||||
applyFilters(root, criteriaBuilder, predicates, filters);
|
||||
|
||||
Utils.applyFiltersByPagination(root, criteriaBuilder, predicates, filters);
|
||||
|
||||
return predicates;
|
||||
|
||||
}
|
||||
|
||||
private AssignedApplicationViewResponse getAssignedApplicationResponseByView(AssignedApplicationsView view) {
|
||||
AssignedApplicationViewResponse response = new AssignedApplicationViewResponse();
|
||||
response.setId(view.getId());
|
||||
response.setUserId(view.getUserId());
|
||||
response.setStatus(AssignedApplicationEnum.valueOf(view.getStatus()));
|
||||
response.setApplicationId(view.getApplicationId());
|
||||
response.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(view.getApplicationStatus()));
|
||||
response.setSubmissionDate(view.getSubmissionDate());
|
||||
response.setEvaluationEndDate(view.getEvaluationEndDate());
|
||||
response.setNdg(view.getNdg());
|
||||
response.setAppointmentId(view.getAppointmentId());
|
||||
response.setProtocolNumber(view.getProtocolNumber());
|
||||
response.setCallName(view.getCallName());
|
||||
response.setCompanyName(view.getCompanyName());
|
||||
response.setCreatedDate(view.getCreatedDate());
|
||||
response.setUpdatedDate(view.getUpdatedDate());
|
||||
return response;
|
||||
}
|
||||
|
||||
public AssignedApplicationsResponse updateAssignedApplicationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedApplicationEnum status) {
|
||||
|
||||
AssignedApplicationsEntity assignedApplication = validateAssignedApplication(assignedApplicationId);
|
||||
|
||||
@@ -124,6 +124,9 @@ public class CallDao {
|
||||
@Autowired
|
||||
private EvaluationFormDao evalualtionFormDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationRepository applicationRepository;
|
||||
|
||||
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
|
||||
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
|
||||
CallEntity callEntity = convertToCallEntity(createCallRequest, userEntity);
|
||||
@@ -598,8 +601,8 @@ public class CallDao {
|
||||
if (!requestEndDate.equals(storedEndDate)) { // Check if dates are different
|
||||
|
||||
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
|
||||
callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
callRepository.save(callEntity);
|
||||
// callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
// callRepository.save(callEntity);
|
||||
isEndDateUpdated = true;
|
||||
}
|
||||
}
|
||||
@@ -611,13 +614,13 @@ public class CallDao {
|
||||
|
||||
if (!requestEndTime.equals(storedEndTime)) {
|
||||
setIfUpdated(callEntity::getEndTime, callEntity::setEndTime, DateTimeUtil.parseTime(updateCallRequest.getEndTime()));
|
||||
callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
callRepository.save(callEntity);
|
||||
// callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
// callRepository.save(callEntity);
|
||||
isEndTimeUpdated = true;
|
||||
}
|
||||
}
|
||||
if (isEndDateUpdated || isEndTimeUpdated) {
|
||||
|
||||
callRepository.save(callEntity);
|
||||
loggingUtil.logUserAction(UserActionRequest.builder()
|
||||
.request(request)
|
||||
.actionType(UserActionLogsEnum.UPDATE)
|
||||
@@ -796,6 +799,7 @@ public class CallDao {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL));
|
||||
}
|
||||
expirePublishedCalls(request);
|
||||
Specification<CallEntity> spec = buildCallSpecification(request, user, companyId, onlyPreferredCall, onlyConfidiCall, callStatusList);
|
||||
|
||||
List<CallEntity> calls = callRepository.findAll(spec);
|
||||
@@ -901,7 +905,7 @@ public class CallDao {
|
||||
public CallResponse updateCallStatus(CallEntity callEntity, CallStatusEnum statusReq) {
|
||||
CallEntity oldCallEntity = Utils.getClonedEntityForData(callEntity);
|
||||
CallStatusEnum currentStatus = CallStatusEnum.valueOf(callEntity.getStatus());
|
||||
validateStatusChange(currentStatus, statusReq);
|
||||
validateStatusChange(currentStatus, statusReq, callEntity.getId());
|
||||
callEntity.setStatus(statusReq.getValue());
|
||||
callEntity = callRepository.save(callEntity);
|
||||
|
||||
@@ -921,36 +925,37 @@ public class CallDao {
|
||||
return convertToCallResponseBean(callEntity);
|
||||
}
|
||||
|
||||
private void validateStatusChange(CallStatusEnum currentStatus, CallStatusEnum newStatus) {
|
||||
private void validateStatusChange(CallStatusEnum currentStatus, CallStatusEnum newStatus, Long callId) {
|
||||
|
||||
if (currentStatus == newStatus) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.STATUS_SAME_ERROR));
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.STATUS_SAME_ERROR));
|
||||
}
|
||||
|
||||
switch (currentStatus) {
|
||||
case DRAFT:
|
||||
if (newStatus == CallStatusEnum.READY_TO_PUBLISH || newStatus == CallStatusEnum.PUBLISH) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.INVALID_STATUS_CHANGE_FROM_DRAFT));
|
||||
}
|
||||
break;
|
||||
case PUBLISH:
|
||||
if (newStatus == CallStatusEnum.READY_TO_PUBLISH || newStatus == CallStatusEnum.DRAFT) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.INVALID_STATUS_CHANGE_FROM_PUBLISH));
|
||||
}
|
||||
break;
|
||||
case DRAFT:
|
||||
if (newStatus == CallStatusEnum.READY_TO_PUBLISH || newStatus == CallStatusEnum.PUBLISH) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_STATUS_CHANGE_FROM_DRAFT));
|
||||
}
|
||||
break;
|
||||
|
||||
case EXPIRED:
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.STATUS_CANNOT_BE_CHANGED));
|
||||
case READY_TO_PUBLISH:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case PUBLISH:
|
||||
if (newStatus == CallStatusEnum.READY_TO_PUBLISH) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_STATUS_CHANGE_FROM_PUBLISH));
|
||||
}
|
||||
if (newStatus == CallStatusEnum.DRAFT && Boolean.TRUE.equals(applicationRepository.existsByCallId(callId))) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_STATUS_CHANGE_FROM_PUBLISH_TO_DRAFT));
|
||||
}
|
||||
break;
|
||||
|
||||
case EXPIRED:
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.STATUS_CANNOT_BE_CHANGED));
|
||||
|
||||
case READY_TO_PUBLISH:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public CallEntity validatePublishedCall(Long callId, Long hubId) {
|
||||
CallEntity callEntity= callRepository
|
||||
.findByIdAndStatusAndHubId(callId, CallStatusEnum.PUBLISH.getValue(), hubId);
|
||||
@@ -959,7 +964,7 @@ public class CallDao {
|
||||
Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_PUBLISHED));
|
||||
}
|
||||
LocalDate currentDate = DateTimeUtil.LocalDateServerToEurope(LocalDate.now());
|
||||
LocalDate currentDate = DateTimeUtil.DateServerToUTC(LocalDateTime.now()).toLocalDate();
|
||||
LocalTime currentTime = DateTimeUtil.LocalTimeServerToEurope(LocalTime.now());
|
||||
|
||||
if (currentDate.isBefore(callEntity.getStartDate().toLocalDate()) ||
|
||||
@@ -1000,6 +1005,7 @@ public class CallDao {
|
||||
Translator.toLocale(GepafinConstant.COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL)
|
||||
);
|
||||
}
|
||||
expirePublishedCalls(request);
|
||||
Specification<CallEntity> spec = search(request,user, callPageableRequestBean);
|
||||
Page<CallEntity> entityPage;
|
||||
if (Boolean.TRUE.equals(onlyPreferredCall)) {
|
||||
@@ -1078,7 +1084,6 @@ public class CallDao {
|
||||
|
||||
private List<Predicate> getPredicates(HttpServletRequest request,CallPageableRequestBean callPageableRequestBean,
|
||||
CriteriaBuilder criteriaBuilder, Root<CallEntity> root, UserEntity userEntity) {
|
||||
expirePublishedCalls(request);
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
Map<String, FilterCriteria> filters = new HashMap<>();
|
||||
@@ -1162,42 +1167,24 @@ public class CallDao {
|
||||
}
|
||||
|
||||
public void expirePublishedCalls(HttpServletRequest request) {
|
||||
List<CallEntity> expiredCalls = callRepository.findAll((root, query, criteriaBuilder) -> {
|
||||
Predicate isPublished = criteriaBuilder.equal(root.get(GepafinConstant.STATUS), CallStatusEnum.PUBLISH.name());
|
||||
|
||||
// Concatenate date and time as a single string
|
||||
Expression<String> dateTimeString = criteriaBuilder.concat(
|
||||
root.get(GepafinConstant.END_DATE),
|
||||
criteriaBuilder.literal(" ") // Space between date and time
|
||||
);
|
||||
Expression<String> fullDateTimeString = criteriaBuilder.concat(dateTimeString, root.get(GepafinConstant.END_TIME));
|
||||
|
||||
// Convert the concatenated string into TIMESTAMP
|
||||
Expression<LocalDateTime> endDateTime = criteriaBuilder.function(
|
||||
"to_timestamp",
|
||||
LocalDateTime.class,
|
||||
fullDateTimeString,
|
||||
criteriaBuilder.literal("YYYY-MM-DD HH24:MI:SS")
|
||||
);
|
||||
|
||||
Predicate isExpired = criteriaBuilder.lessThan(endDateTime, LocalDateTime.now());
|
||||
|
||||
return criteriaBuilder.and(isPublished, isExpired);
|
||||
});
|
||||
|
||||
if (!expiredCalls.isEmpty()) {
|
||||
for (CallEntity call : expiredCalls) {
|
||||
|
||||
|
||||
LocalDate currentDate = DateTimeUtil.DateServerToUTC(LocalDateTime.now()).toLocalDate();
|
||||
LocalTime currentTime = DateTimeUtil.LocalTimeServerToEurope(LocalTime.now());
|
||||
|
||||
List<CallEntity> expirdedCallList = callRepository.findExpiredCallsWhichIsPublished(CallStatusEnum.PUBLISH.getValue(), currentDate, currentTime);
|
||||
|
||||
if (!expirdedCallList.isEmpty()) {
|
||||
|
||||
loggingUtil.logUserAction(UserActionRequest.builder()
|
||||
.request(request)
|
||||
.actionType(UserActionLogsEnum.UPDATE)
|
||||
.actionContext(UserActionContextEnum.UPDATE_EXPIRED_CALL)
|
||||
.build());
|
||||
for (CallEntity call : expirdedCallList) {
|
||||
CallEntity oldCallEntity = Utils.getClonedEntityForData(call); // Clone before modification
|
||||
call.setStatus(CallStatusEnum.EXPIRED.getValue());
|
||||
|
||||
if (!oldCallEntity.getStatus().equals(call.getStatus())) {
|
||||
// Log user action
|
||||
loggingUtil.logUserAction(UserActionRequest.builder()
|
||||
.request(request)
|
||||
.actionType(UserActionLogsEnum.UPDATE)
|
||||
.actionContext(UserActionContextEnum.UPDATE_EXPIRED_CALL)
|
||||
.build());
|
||||
|
||||
// Add version history log
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder()
|
||||
.request(request)
|
||||
@@ -1205,9 +1192,8 @@ public class CallDao {
|
||||
.oldData(oldCallEntity)
|
||||
.newData(call)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
callRepository.saveAll(expiredCalls); // Save all modified calls at once
|
||||
callRepository.saveAll(expirdedCallList); // Save all modified calls at once
|
||||
}
|
||||
}
|
||||
private void applyFilters(Root<?> root, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Map<String, FilterCriteria> filters) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.data.domain.Pageable; // Correct package
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -20,7 +18,6 @@ import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.FaqRepository;
|
||||
import net.gepafin.tendermanagement.service.feignClient.VatCheckService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -37,7 +34,6 @@ import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.convertObjectToJsonString;
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Component
|
||||
@@ -73,10 +69,6 @@ public class CompanyDao {
|
||||
private HttpServletRequest request;
|
||||
|
||||
|
||||
@Autowired
|
||||
private VatCheckService vatCheckService; // Service to call VAT API
|
||||
|
||||
|
||||
private static final String NOT_FOUND_JSON = "{\"data\": \"not found\"}";
|
||||
|
||||
public CompanyResponse createCompany(UserEntity userEntity, CompanyRequest companyRequest) {
|
||||
@@ -146,8 +138,6 @@ public class CompanyDao {
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(userWithCompany).build());
|
||||
if (StringUtils.isEmpty(companyEntity.getJson())) {
|
||||
companyEntity.setJson(Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()));
|
||||
Map<String, Object> vatCheckResponse = companyRequest.getVatCheckResponse();
|
||||
Map<String, Object> data = (Map<String, Object>) vatCheckResponse.get("data");
|
||||
updateCodiceAtecoFieldWithNewJson(companyEntity);
|
||||
companyEntity = companyRepository.save(companyEntity);
|
||||
|
||||
@@ -178,7 +168,7 @@ public class CompanyDao {
|
||||
entity.setAnnualRevenue(request.getAnnualRevenue());
|
||||
entity.setHub(userEntity.getHub());
|
||||
entity.setJson(Utils.convertMapIntoJsonString(request.getVatCheckResponse()));
|
||||
updateCodiceAtecoFieldWithNewJson(entity);
|
||||
updateCodiceAtecoFieldWithNewJson(entity);
|
||||
|
||||
return entity;
|
||||
}
|
||||
@@ -437,7 +427,6 @@ public class CompanyDao {
|
||||
log.info("Company ID {}: JSON field updated successfully.", company.getId());
|
||||
|
||||
// Extract and set codiceAteco field
|
||||
// updateCodiceAtecoField(company);
|
||||
updateCodiceAtecoFieldWithNewJson(company);
|
||||
|
||||
successfulUpdates++;
|
||||
@@ -472,50 +461,38 @@ public class CompanyDao {
|
||||
private void updateCodiceAtecoField(CompanyEntity company) {
|
||||
Map<String, Object> vatCheckResponse = Utils.convertJsonStringToMap(company.getJson());
|
||||
|
||||
if (vatCheckResponse != null && vatCheckResponse.containsKey("data")) {
|
||||
Object dataObj = vatCheckResponse.get("data");
|
||||
|
||||
if (dataObj instanceof Map) {
|
||||
Map<String, Object> dataMap = (Map<String, Object>) dataObj;
|
||||
log.info("Company ID {}: Available keys inside 'data' -> {}", company.getId(), dataMap.keySet());
|
||||
|
||||
if (dataMap.containsKey("dettaglio")) {
|
||||
Object dettaglioObj = dataMap.get("dettaglio");
|
||||
|
||||
if (dettaglioObj instanceof Map) {
|
||||
Map<String, Object> dettaglio = (Map<String, Object>) dettaglioObj;
|
||||
|
||||
if (dettaglio.containsKey("codice_ateco")) {
|
||||
Object codiceAtecoObj = dettaglio.get("codice_ateco");
|
||||
|
||||
if (codiceAtecoObj instanceof String) {
|
||||
String codiceAteco = (String) codiceAtecoObj;
|
||||
|
||||
if (codiceAteco != null && !codiceAteco.isEmpty()) {
|
||||
company.setCodiceAteco(codiceAteco);
|
||||
log.info("Company ID {}: codiceAteco updated to {}", company.getId(), codiceAteco);
|
||||
} else {
|
||||
log.warn("Company ID {}: codiceAteco is null or empty in the response.", company.getId());
|
||||
}
|
||||
} else {
|
||||
log.warn("Company ID {}: 'codice_ateco' is not a string, actual type: {}", company.getId(), codiceAtecoObj.getClass());
|
||||
}
|
||||
} else {
|
||||
log.warn("Company ID {}: 'dettaglio' does not contain 'codice_ateco' key.", company.getId());
|
||||
}
|
||||
} else {
|
||||
log.warn("Company ID {}: 'dettaglio' is not a Map, actual type: {}", company.getId(), dettaglioObj.getClass());
|
||||
}
|
||||
} else {
|
||||
log.warn("Company ID {}: 'dettaglio' section is missing inside 'data'!", company.getId());
|
||||
}
|
||||
} else {
|
||||
log.warn("Company ID {}: 'data' is not a Map, actual type: {}", company.getId(), dataObj.getClass());
|
||||
}
|
||||
} else {
|
||||
log.warn("Company ID {}: 'data' section missing in the JSON response.", company.getId());
|
||||
if (vatCheckResponse == null) {
|
||||
log.warn("Company ID {}: Invalid JSON response.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
Object dataObj = vatCheckResponse.get("data");
|
||||
if (!(dataObj instanceof Map<?, ?> dataMap)) {
|
||||
log.warn("Company ID {}: 'data' is missing or not a valid object.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dataMap.containsKey("dettaglio")) {
|
||||
log.warn("Company ID {}: 'dettaglio' not present inside 'data'. Skipping codiceAteco update.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
Object dettaglioObj = dataMap.get("dettaglio");
|
||||
if (!(dettaglioObj instanceof Map<?, ?> dettaglio)) {
|
||||
log.warn("Company ID {}: 'dettaglio' is not a valid object.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
Object codiceAtecoObj = dettaglio.get("codice_ateco");
|
||||
if (!(codiceAtecoObj instanceof String codiceAteco) || codiceAteco.isEmpty()) {
|
||||
log.warn("Company ID {}: 'codice_ateco' is missing, empty, or not a string.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
company.setCodiceAteco(codiceAteco);
|
||||
logCodiceAtecoUpdate(company, codiceAteco);
|
||||
}
|
||||
|
||||
private void updateCodiceAtecoFieldWithNewJson(CompanyEntity company) {
|
||||
if (company == null || company.getJson() == null || company.getJson().isEmpty()) {
|
||||
log.warn("Company is null or JSON data is empty.");
|
||||
@@ -530,32 +507,43 @@ public class CompanyDao {
|
||||
|
||||
// Extract 'data' section
|
||||
Map<String, Object> dataMap = Utils.extractMap(companyDataMap, "data");
|
||||
Object dataObj = companyDataMap.get("data");
|
||||
|
||||
if (dataMap == null) {
|
||||
log.warn("Company ID {}: 'data' section is missing or invalid in the JSON.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract 'atecoClassification' section
|
||||
Map<String, Object> atecoClassificationMap = Utils.extractMap(dataMap, "atecoClassification");
|
||||
if (atecoClassificationMap == null) {
|
||||
log.warn("Company ID {}: 'atecoClassification' section is missing or invalid.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract 'ateco' section
|
||||
Map<String, Object> atecoMap = Utils.extractMap(atecoClassificationMap, "ateco");
|
||||
if (atecoMap == null) {
|
||||
log.warn("Company ID {}: 'ateco' section is missing or invalid.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract and set 'code'
|
||||
String atecoCode = Utils.extractString(atecoMap, "code");
|
||||
if (atecoCode != null && !atecoCode.isEmpty()) {
|
||||
company.setCodiceAteco(atecoCode);
|
||||
log.info("Company ID {}: codiceAteco updated to {}", company.getId(), atecoCode);
|
||||
if (dataObj instanceof Map<?, ?>) {
|
||||
// if data is a single object
|
||||
updateCodiceAtecoField(company);
|
||||
} else {
|
||||
log.warn("Company ID {}: 'code' inside 'ateco' is empty or missing.", company.getId());
|
||||
// Extract 'atecoClassification' section
|
||||
Map<String, Object> atecoClassificationMap = Utils.extractMap(dataMap, "atecoClassification");
|
||||
if (atecoClassificationMap == null) {
|
||||
log.warn("Company ID {}: 'atecoClassification' section is missing or invalid.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract 'ateco' section
|
||||
Map<String, Object> atecoMap = Utils.extractMap(atecoClassificationMap, "ateco");
|
||||
if (atecoMap == null) {
|
||||
log.warn("Company ID {}: 'ateco' section is missing or invalid.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract and set 'code'
|
||||
String atecoCode = Utils.extractString(atecoMap, "code");
|
||||
if (atecoCode != null && !atecoCode.isEmpty()) {
|
||||
company.setCodiceAteco(atecoCode);
|
||||
logCodiceAtecoUpdate(company, atecoCode);
|
||||
} else {
|
||||
log.warn("Company ID {}: 'code' inside 'ateco' is empty or missing.", company.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void logCodiceAtecoUpdate(CompanyEntity company, String atecoCode) {
|
||||
|
||||
log.info("Company ID {}: codiceAteco updated to {}", company.getId(), atecoCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,6 @@ public class DelegationDao {
|
||||
|
||||
companyDao.validateCompany(companyId);
|
||||
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||
validateFileType(file);
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyId);
|
||||
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
|
||||
.findByUserIdAndUserWithCompanyIdAndStatus(userEntity.getId(), userWithCompanyEntity.getId(),
|
||||
|
||||
@@ -511,7 +511,7 @@ public class FormDao {
|
||||
// Map<String, Object> customData=null;
|
||||
try {
|
||||
// Map<String, Object> vatCheckResponse = vatCheckDao.checkVatNumberApi(value);
|
||||
vatCheckDao.checkVatNumberApi(value);
|
||||
vatCheckDao.checkVatNumber(value);
|
||||
// if (Boolean.FALSE.equals(CollectionUtils.isEmpty(vatCheckResponse))) {
|
||||
// customData = vatCheckResponse;
|
||||
// }
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import feign.FeignException;
|
||||
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.enums.VatCheckVersionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
|
||||
import net.gepafin.tendermanagement.service.feignClient.VatCheckService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.repositories.GlobalConfigRepository;
|
||||
import net.gepafin.tendermanagement.service.feignClient.VatCheckV1Service;
|
||||
import net.gepafin.tendermanagement.service.feignClient.VatCheckV2Service;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,8 +21,8 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -30,104 +31,103 @@ import java.util.Map;
|
||||
public class VatCheckDao {
|
||||
|
||||
@Autowired
|
||||
private VatCheckService vatCheckService;
|
||||
private VatCheckV2Service vatCheckV2Service;
|
||||
|
||||
@Value("${vatCheckNewToken}")
|
||||
public String vatCheckNewToken;
|
||||
@Autowired
|
||||
private VatCheckV1Service vatCheckV1Service;
|
||||
|
||||
@Value("${vatCheckTokenV2}")
|
||||
public String vatCheckTokenV2;
|
||||
|
||||
@Value("${vatCheckTokenV1}")
|
||||
public String vatCheckTokenV1;
|
||||
|
||||
@Value("${isVatCheckGloballyDisabled}")
|
||||
public String isVatCheckGloballyDisabled;
|
||||
|
||||
@Autowired
|
||||
private GlobalConfigRepository globalConfigRepository;
|
||||
|
||||
public final Logger log = LoggerFactory.getLogger(VatCheckDao.class);
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
public VatCheckResponseBean checkVatNumberV1(String vatNumber) {
|
||||
VatCheckResponseBean vatCheckResponseBean = new VatCheckResponseBean();
|
||||
vatCheckResponseBean.setValid(false);
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
if (Boolean.TRUE.equals(Boolean.parseBoolean(isVatCheckGloballyDisabled))) {
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
return vatCheckResponseBean;
|
||||
}
|
||||
try {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set(GepafinConstant.AUTHORIZATION, "Bearer " + vatCheckTokenV1);
|
||||
headers.add(org.apache.http.HttpHeaders.USER_AGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0");
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
URI baseUrl = URI.create(GepafinConstant.CHECK_VATNUMBER_URL_V1);
|
||||
ResponseEntity<Map<String, Object>> response = vatCheckV1Service.checkVatNumber(baseUrl, vatNumber, headers);
|
||||
|
||||
// public VatCheckResponseBean checkVatNumberApi(String vatNumber) {
|
||||
// VatCheckResponseBean vatCheckResponseBean = new VatCheckResponseBean();
|
||||
// vatCheckResponseBean.setValid(false);
|
||||
// vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
// if (Boolean.TRUE.equals(Boolean.parseBoolean(isVatCheckGloballyDisabled))) {
|
||||
// vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
// return vatCheckResponseBean;
|
||||
// }
|
||||
// Map<String, Object> responseBody = new HashMap<>();
|
||||
// try {
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
// headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
// headers.set(GepafinConstant.AUTHORIZATION, "Bearer " + vatCheckNewToken);
|
||||
// headers.add(org.apache.http.HttpHeaders.USER_AGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0");
|
||||
//
|
||||
// URI baseUrl = URI.create(GepafinConstant.CHECK_VATNUMBER_V2_NEW_URL);
|
||||
// ResponseEntity<Map<String, Object>> response = vatCheckService.checkVatNumber(baseUrl, vatNumber, headers);
|
||||
//
|
||||
//
|
||||
// if (response.getStatusCode() == HttpStatus.OK && response.hasBody()) {
|
||||
// log.info("Successfully checked vat number");
|
||||
// Map<String, Object> responseMap = response.getBody();
|
||||
// processValidResponse(responseMap, vatCheckResponseBean);
|
||||
// }
|
||||
// } catch (FeignException ex) {
|
||||
// if (ex.status() == 406) {
|
||||
// try {
|
||||
// Map<String, Object> errorResponse = Utils.parseErrorResponse(ex.contentUTF8());
|
||||
// processValidResponse(errorResponse, vatCheckResponseBean);
|
||||
// } catch (Exception parseEx) {
|
||||
// log.error("Failed to parse 406 error response: {0}", parseEx);
|
||||
// }
|
||||
// } else {
|
||||
// log.error("Exception occurred while checking vat number: {0}", ex);
|
||||
// Utils.callException(ex.status(), ex);
|
||||
// }
|
||||
// }
|
||||
// return vatCheckResponseBean;
|
||||
// }
|
||||
// public static void processValidResponse(Map<String, Object> responseMap, VatCheckResponseBean vatCheckResponseBean) {
|
||||
// if (responseMap != null && responseMap.containsKey("data")) {
|
||||
// Map<String, Object> responseBody = (Map<String, Object>) responseMap.get("data");
|
||||
//
|
||||
// if (responseBody != null) {
|
||||
// responseBody.remove("timestamp_creation");
|
||||
// responseBody.remove("timestamp_last_update");
|
||||
// responseBody.remove("data_iscrizione");
|
||||
// responseBody.remove("id");
|
||||
//
|
||||
// Map<String, Object> data = new LinkedHashMap<>();
|
||||
// data.put("data", responseBody);
|
||||
//
|
||||
// vatCheckResponseBean.setValid(true);
|
||||
// vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.VALID_VATNUMBER_MSG));
|
||||
// vatCheckResponseBean.setVatCheckResponse(data);
|
||||
// } else {
|
||||
// vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
// }
|
||||
// } else {
|
||||
// vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public VatCheckResponseBean checkVatNumber(String vatNumber) {
|
||||
// try {
|
||||
// return checkVatNumberApi(vatNumber);
|
||||
// } catch (Exception e) {
|
||||
// log.error("Error in checkVatNumber: {}", e.getMessage());
|
||||
// VatCheckResponseBean vatCheckResponseBean = new VatCheckResponseBean();
|
||||
// vatCheckResponseBean.setValid(false);
|
||||
// vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
// return vatCheckResponseBean;
|
||||
// }
|
||||
// }
|
||||
if (response.getStatusCode() == HttpStatus.OK && response.hasBody()) {
|
||||
logSuccess();
|
||||
Map<String, Object> responseMap = response.getBody();
|
||||
if (responseMap != null) {
|
||||
processValidResponseV1(responseMap, vatCheckResponseBean);
|
||||
} else {
|
||||
log.warn("Response map or vatCheckResponseBean is null.");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (FeignException ex) {
|
||||
if (ex.status() == 406) {
|
||||
try {
|
||||
Map<String, Object> errorResponse = Utils.parseErrorResponse(ex.contentUTF8());
|
||||
processValidResponseV1(errorResponse, vatCheckResponseBean);
|
||||
} catch (Exception parseEx) {
|
||||
log.error("Failed to parse 406 error response: {0}", parseEx);
|
||||
}
|
||||
} else {
|
||||
log.error("Exception occurred while checking vat number: {0}", ex);
|
||||
Utils.callException(ex.status(), ex);
|
||||
}
|
||||
}
|
||||
return vatCheckResponseBean;
|
||||
}
|
||||
|
||||
public static void processValidResponseV1(Map<String, Object> responseMap, VatCheckResponseBean vatCheckResponseBean) {
|
||||
Object dataObj = responseMap.get("data");
|
||||
if (dataObj instanceof Map<?, ?> rawDataMap) {
|
||||
Map<String, Object> responseBody = new LinkedHashMap<>();
|
||||
rawDataMap.forEach((k, v) -> {
|
||||
if (k instanceof String strKey) {
|
||||
responseBody.put(strKey, v);
|
||||
}
|
||||
});
|
||||
|
||||
List.of("timestamp_creation", "timestamp_last_update", "id", "data_iscrizione").forEach(responseBody.keySet()::remove);
|
||||
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("data", responseBody);
|
||||
|
||||
vatCheckResponseBean.setValid(true);
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.VALID_VATNUMBER_MSG));
|
||||
vatCheckResponseBean.setVatCheckResponse(data);
|
||||
} else {
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public VatCheckResponseBean checkVatNumber(String vatNumber) {
|
||||
|
||||
try {
|
||||
return checkVatNumberApi(vatNumber);
|
||||
String vatApiVersion = getVatCheckVersion();
|
||||
if(!isVatCheckApiV2(vatApiVersion)){
|
||||
return checkVatNumberV1(vatNumber);
|
||||
}
|
||||
return checkVatNumberV2(vatNumber);
|
||||
} catch (Exception e) {
|
||||
log.error("Error in checkVatNumber: {}", e.getMessage());
|
||||
logErrorMessage(e);
|
||||
VatCheckResponseBean vatCheckResponseBean = new VatCheckResponseBean();
|
||||
vatCheckResponseBean.setValid(false);
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
@@ -135,7 +135,7 @@ public class VatCheckDao {
|
||||
}
|
||||
}
|
||||
|
||||
public VatCheckResponseBean checkVatNumberApi(String vatNumber) {
|
||||
public VatCheckResponseBean checkVatNumberV2(String vatNumber) {
|
||||
|
||||
VatCheckResponseBean vatCheckResponseBean = new VatCheckResponseBean();
|
||||
vatCheckResponseBean.setValid(false);
|
||||
@@ -147,13 +147,13 @@ public class VatCheckDao {
|
||||
try {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
headers.set(GepafinConstant.AUTHORIZATION, "Bearer " + vatCheckNewToken);
|
||||
headers.set(GepafinConstant.AUTHORIZATION, "Bearer " + vatCheckTokenV2);
|
||||
|
||||
URI baseUrl = URI.create(GepafinConstant.CHECK_VATNUMBER_V2_NEW_URL_IT_ADVANCE);
|
||||
ResponseEntity<Map<String, Object>> response = vatCheckService.checkVatNumber(baseUrl, vatNumber, headers);
|
||||
URI baseUrl = URI.create(GepafinConstant.CHECK_VATNUMBER_URL_V2);
|
||||
ResponseEntity<Map<String, Object>> response = vatCheckV2Service.checkVatNumber(baseUrl, vatNumber, headers);
|
||||
|
||||
if (response.getStatusCode() == HttpStatus.OK && response.hasBody()) {
|
||||
log.info("Successfully checked vat number");
|
||||
logSuccess();
|
||||
Map<String, Object> responseMap = response.getBody();
|
||||
processValidResponse(responseMap, vatCheckResponseBean);
|
||||
}
|
||||
@@ -172,33 +172,65 @@ public class VatCheckDao {
|
||||
}
|
||||
return vatCheckResponseBean;
|
||||
}
|
||||
|
||||
public static void processValidResponse(Map<String, Object> responseMap, VatCheckResponseBean vatCheckResponseBean) {
|
||||
|
||||
if (responseMap != null && responseMap.containsKey("data")) {
|
||||
Object dataObject = responseMap.get("data");
|
||||
|
||||
if (dataObject instanceof List && !((List<?>) dataObject).isEmpty()) {
|
||||
dataObject = ((List<?>) dataObject).get(0);
|
||||
}
|
||||
|
||||
if (dataObject instanceof Map) {
|
||||
Map<String, Object> responseBody = (Map<String, Object>) dataObject;
|
||||
|
||||
responseBody.remove("creationTimestamp");
|
||||
responseBody.remove("lastUpdateTimestamp");
|
||||
responseBody.remove("id");
|
||||
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("data", responseBody);
|
||||
|
||||
vatCheckResponseBean.setValid(true);
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.VALID_VATNUMBER_MSG));
|
||||
vatCheckResponseBean.setVatCheckResponse(data);
|
||||
} else {
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
}
|
||||
} else {
|
||||
if (responseMap == null || !responseMap.containsKey("data")) {
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
return;
|
||||
}
|
||||
|
||||
Object dataObject = responseMap.get("data");
|
||||
if (!(dataObject instanceof List<?> dataList) || dataList.isEmpty()) {
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
return;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> processedList = new ArrayList<>();
|
||||
|
||||
for (Object item : dataList) {
|
||||
if (item instanceof Map<?, ?> mapItem) {
|
||||
Map<String, Object> responseBody = new LinkedHashMap<>();
|
||||
mapItem.forEach((key, value) -> {
|
||||
if (key instanceof String strKey) {
|
||||
responseBody.put(strKey, value);
|
||||
}
|
||||
});
|
||||
|
||||
List.of("creationTimestamp", "lastUpdateTimestamp", "id").forEach(responseBody.keySet()::remove);
|
||||
|
||||
processedList.add(responseBody);
|
||||
}
|
||||
}
|
||||
|
||||
if (processedList.isEmpty()) {
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
return;
|
||||
}
|
||||
|
||||
vatCheckResponseBean.setValid(true);
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.VALID_VATNUMBER_MSG));
|
||||
vatCheckResponseBean.setVatCheckResponse(Map.of("data", processedList));
|
||||
}
|
||||
|
||||
private void logSuccess() {
|
||||
|
||||
log.info("Successfully checked vat number");
|
||||
}
|
||||
|
||||
private static boolean isVatCheckApiV2(String vatApiVersion) {
|
||||
boolean isNotBlank = StringUtils.isNotBlank(vatApiVersion);
|
||||
boolean isNotEmpty = StringUtils.isNotEmpty(vatApiVersion);
|
||||
return isNotBlank && isNotEmpty && Boolean.TRUE.equals(vatApiVersion.equals(VatCheckVersionTypeEnum.V2.getValue()));
|
||||
}
|
||||
|
||||
private String getVatCheckVersion() {
|
||||
|
||||
return globalConfigRepository.findContentByTypeAndIsDeletedFalse(GepafinConstant.VAT_CHECK_API_VERSION);
|
||||
}
|
||||
|
||||
private void logErrorMessage(Exception e) {
|
||||
|
||||
log.error("Error in checkVatNumber: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Immutable
|
||||
@Table(name = "application_amendment_request_view")
|
||||
@Getter
|
||||
@Setter
|
||||
@IdClass(ApplicationAmendmentRequestViewId.class)
|
||||
public class ApplicationAmendmentRequestView {
|
||||
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "APPLICATION_ID")
|
||||
private Long applicationId;
|
||||
|
||||
@Column(name = "PROTOCOL_NUMBER")
|
||||
private Long protocolNumber;
|
||||
|
||||
@Column(name = "CALL_NAME")
|
||||
private String callName;
|
||||
|
||||
@Column(name = "COMPANY_NAME")
|
||||
private String companyName;
|
||||
|
||||
@Column(name = "START_DATE")
|
||||
private LocalDateTime startDate;
|
||||
|
||||
@Column(name = "EXPIRATION_DATE")
|
||||
private LocalDateTime expirationDate;
|
||||
|
||||
@Column(name = "ASSIGNED_USER_NAME")
|
||||
private String assigendUserName;
|
||||
|
||||
@Column(name = "ASSIGNED_USER_ID")
|
||||
private Long assignedUserId;
|
||||
|
||||
@Column(name = "STATUS")
|
||||
private String status;
|
||||
|
||||
@Column(name = "NOTE")
|
||||
private String note;
|
||||
|
||||
@Column(name = "INTERNAL_NOTE")
|
||||
private String internalNote;
|
||||
|
||||
@Column(name = "APPLICATION_USER_ID")
|
||||
private Long applicationUserId;
|
||||
|
||||
@Column(name = "CREATED_DATE")
|
||||
private String createdDate;
|
||||
|
||||
@Column(name = "UPDATED_DATE")
|
||||
private String updatedDate;
|
||||
|
||||
@Column(name = "IS_DELETED")
|
||||
private Boolean isDeleted;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
public class ApplicationAmendmentRequestViewId {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Long id;
|
||||
|
||||
public ApplicationAmendmentRequestViewId() {
|
||||
}
|
||||
|
||||
public ApplicationAmendmentRequestViewId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
@Entity
|
||||
@Immutable
|
||||
@Table(name = "application_form_view")
|
||||
@Getter
|
||||
@Setter
|
||||
@IdClass(ApplicationFormViewId.class)
|
||||
public class ApplicationFormView {
|
||||
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "application_id")
|
||||
private Long applicationId;
|
||||
|
||||
@Column(name = "call_id")
|
||||
private Long callId;
|
||||
|
||||
@Column(name = "form_id")
|
||||
private Long formId;
|
||||
|
||||
@Column(name = "application_form_id")
|
||||
private Long applicationFormId;
|
||||
|
||||
@Column(name = "field_id")
|
||||
private String fieldId;
|
||||
|
||||
@Column(name = "field_label")
|
||||
private String fieldLabel;
|
||||
|
||||
@Column(name = "field_type")
|
||||
private String fieldType;
|
||||
|
||||
@Column(name = "field_value")
|
||||
private String fieldValue;
|
||||
|
||||
@Column(name = "report_enable")
|
||||
private Boolean reportEnable;
|
||||
|
||||
@Column(name = "report_header")
|
||||
private String reportHeader;
|
||||
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
|
||||
@Column(name = "amount_requested")
|
||||
private BigDecimal amountRequested;
|
||||
|
||||
@Column(name = "amount_accepted")
|
||||
private BigDecimal amountAccepted;
|
||||
|
||||
@Column(name = "is_deleted")
|
||||
private boolean isDeleted;
|
||||
|
||||
@Column(name = "hub_id")
|
||||
private Long hubId;
|
||||
|
||||
@Column(name = "user_id")
|
||||
private Long userId;
|
||||
|
||||
@Column(name = "evaluation_version")
|
||||
private String evaluationVersion;
|
||||
|
||||
@Column(name = "company_id")
|
||||
private Long companyId;
|
||||
|
||||
@Column(name = "company_name")
|
||||
private String companyName;
|
||||
|
||||
@Column(name = "company_vat_number")
|
||||
private String companyVatNumber;
|
||||
|
||||
@Column(name = "codice_ateco")
|
||||
private String codiceAteco;
|
||||
|
||||
@Column(name = "company_codice_fiscale")
|
||||
private String companyCodiceFiscale;
|
||||
|
||||
@Column(name = "protocol_number")
|
||||
private Long protocolNumber;
|
||||
|
||||
@Column(name = "user_codice_fiscale")
|
||||
private String userCodiceFiscale;
|
||||
|
||||
@Column(name = "user_name")
|
||||
private String userName;
|
||||
|
||||
@Column(name = "legal_representative")
|
||||
private Boolean legalRepresentative;
|
||||
|
||||
@Column(name = "call_title")
|
||||
private String callTitle;
|
||||
|
||||
@Column(name = "call_end_date")
|
||||
private LocalDate callEndDate;
|
||||
|
||||
@Column(name = "call_end_time")
|
||||
private LocalTime callEndTime;
|
||||
|
||||
@Column(name = "call_start_date")
|
||||
private LocalDate callStartDate;
|
||||
|
||||
@Column(name = "call_start_time")
|
||||
private LocalTime callStartTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
public class ApplicationFormViewId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Long id;
|
||||
|
||||
public ApplicationFormViewId() {
|
||||
}
|
||||
|
||||
public ApplicationFormViewId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class ApplicationView implements Serializable {
|
||||
private Long protocolNumber;
|
||||
|
||||
@Column(name = "ASSIGNED_USER_ID")
|
||||
private Long assigned_user_id;
|
||||
private Long assignedUserId;
|
||||
|
||||
@Column(name = "ASSIGNED_USER_NAME")
|
||||
private String assignedUserName;
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Immutable
|
||||
@Data
|
||||
@Table(name = "assigned_applications_view")
|
||||
@IdClass(AssignedApplicationsViewId.class)
|
||||
public class AssignedApplicationsView{
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "APPLICATION_ID")
|
||||
private Long applicationId;
|
||||
|
||||
@Column(name = "USER_ID")
|
||||
private Long userId;
|
||||
|
||||
@Column(name = "PROTOCOL_NUMBER")
|
||||
private Long protocolNumber;
|
||||
|
||||
@Column(name = "CALL_NAME")
|
||||
private String callName;
|
||||
|
||||
@Column(name = "COMPANY_NAME")
|
||||
private String companyName;
|
||||
|
||||
@Column(name = "STATUS")
|
||||
private String status;
|
||||
|
||||
@Column(name = "NDG")
|
||||
private String ndg;
|
||||
|
||||
@Column(name = "APPOINTMENT_ID")
|
||||
private String appointmentId;
|
||||
|
||||
@Column(name = "APPLICATION_STATUS")
|
||||
private String applicationStatus;
|
||||
|
||||
@Column(name = "SUBMISSION_DATE")
|
||||
private LocalDateTime submissionDate;
|
||||
|
||||
@Column(name = "EVALUATION_END_DATE")
|
||||
private LocalDateTime evaluationEndDate;
|
||||
|
||||
@Column(name = "CREATED_DATE")
|
||||
private LocalDateTime createdDate;
|
||||
|
||||
@Column(name = "UPDATED_DATE")
|
||||
private LocalDateTime updatedDate;
|
||||
|
||||
@Column(name = "IS_DELETED")
|
||||
private Boolean isDeleted;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class AssignedApplicationsViewId implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Long id;
|
||||
|
||||
public AssignedApplicationsViewId() {}
|
||||
|
||||
public AssignedApplicationsViewId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "GLOBAL_CONFIG")
|
||||
public class GlobalConfigEntity extends BaseEntity{
|
||||
|
||||
@Column(name = "CONTENT")
|
||||
private String content;
|
||||
|
||||
@Column(name = "TYPE")
|
||||
private String type;
|
||||
|
||||
@Column(name = "IS_DELETED")
|
||||
private Boolean isDeleted = false;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum VatCheckVersionTypeEnum {
|
||||
V1("V1"),
|
||||
V2("V2");
|
||||
private String value;
|
||||
|
||||
VatCheckVersionTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class ApplicationAmendmentPaginationRequestBean {
|
||||
@@ -11,4 +12,9 @@ public class ApplicationAmendmentPaginationRequestBean {
|
||||
private GlobalFilters globalFilters;
|
||||
|
||||
private List<ApplicationAmendmentRequestEnum> status;
|
||||
|
||||
private Map<String, FilterCriteria> filters;
|
||||
|
||||
private Boolean personalRecords;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class ApplicationAmendmentRequestViewResponse {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long applicationId;
|
||||
|
||||
private Long protocolNumber;
|
||||
|
||||
private String callName;
|
||||
|
||||
private String companyName;
|
||||
|
||||
private LocalDateTime startDate;
|
||||
|
||||
private LocalDateTime expirationDate;
|
||||
|
||||
private String assigendUserName;
|
||||
|
||||
private String status;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class AssignedApplicationViewResponse extends BaseBean {
|
||||
private Long userId;
|
||||
private Long applicationId;
|
||||
private AssignedApplicationEnum status;
|
||||
private LocalDateTime submissionDate;
|
||||
private ApplicationStatusTypeEnum applicationStatus;
|
||||
private LocalDateTime evaluationEndDate;
|
||||
private String ndg;
|
||||
private String appointmentId;
|
||||
private Long protocolNumber;
|
||||
private String callName;
|
||||
private String companyName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestView;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
public interface ApplicationAmendmentRequestViewRepository extends JpaRepository<ApplicationAmendmentRequestView,Long> , JpaSpecificationExecutor<ApplicationAmendmentRequestView> {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.ApplicationFormView;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ApplicationFormViewRepository extends JpaRepository<ApplicationFormView,Long>, JpaSpecificationExecutor<ApplicationFormView> {
|
||||
|
||||
@Query("SELECT v FROM ApplicationFormView v WHERE v.callId = :callId AND v.reportEnable = true")
|
||||
List<ApplicationFormView> findByCallId(Long callId);
|
||||
|
||||
}
|
||||
@@ -177,4 +177,5 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
||||
@Query("UPDATE ApplicationEntity a SET a.ndgStatus = NULL WHERE a.ndgStatus = :status")
|
||||
void resetNdgStatusForInProgress(@Param("status") String status);
|
||||
|
||||
boolean existsByCallId(Long callId);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package net.gepafin.tendermanagement.repositories;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationView;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ApplicationViewRepository extends JpaRepository<ApplicationView,Long> , JpaSpecificationExecutor<ApplicationView> {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsView;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
public interface AssignedApplicationsViewRepository extends JpaRepository<AssignedApplicationsView,Long> , JpaSpecificationExecutor<AssignedApplicationsView> {
|
||||
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
@@ -58,5 +60,8 @@ public interface CallRepository extends JpaRepository<CallEntity, Long>, JpaSpec
|
||||
List<CallEntity> findByIdInAndStatusInAndConfidi(@Param("ids") List<Long> ids, @Param("status") List<String> status,Boolean confidi);
|
||||
|
||||
public List<CallEntity> findByStatusInAndHubIdAndConfidi(List<String> callStatus, Long hubId,Boolean onlyConfidiCall);
|
||||
|
||||
@Query("SELECT c FROM CallEntity c WHERE c.status = :status AND (FUNCTION('DATE', c.endDate) < :endDate OR (FUNCTION('DATE', c.endDate) = :endDate AND c.endTime <= :endTime))")
|
||||
List<CallEntity> findExpiredCallsWhichIsPublished(@Param("status") String status, @Param("endDate") LocalDate endDate, @Param("endTime") LocalTime endTime);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.GlobalConfigEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
public interface GlobalConfigRepository extends JpaRepository<GlobalConfigEntity, Long> {
|
||||
|
||||
@Query("SELECT gc.content FROM GlobalConfigEntity gc WHERE gc.type = :vatCheckApiVersion AND gc.isDeleted = false")
|
||||
String findContentByTypeAndIsDeletedFalse(String vatCheckApiVersion);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestViewResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||
|
||||
@@ -29,5 +30,5 @@ public interface ApplicationAmendmentRequestService {
|
||||
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(HttpServletRequest request, Long applicationAmendmentId, ApplicationAmendmentRequestEnum status);
|
||||
|
||||
void sendReminderEmail(HttpServletRequest request,Long amendmentId);
|
||||
PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean);
|
||||
PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationPageableRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||
@@ -46,4 +47,7 @@ public interface ApplicationService {
|
||||
PageableResponseBean<List<ApplicationResponse>> getAllApplicationByPagination(HttpServletRequest request, Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean);
|
||||
|
||||
public ApplicationEntity validateApplicationWithCompany(Long applicationId,Long companyId);
|
||||
|
||||
public byte[] exportCsv(HttpServletRequest request, Long callId);
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationViewResponse;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
|
||||
@@ -23,6 +24,6 @@ public interface AssignedApplicationsService {
|
||||
AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, UpdateAssignedApplicationRequest assignedApplicationsRequest);
|
||||
AssignedApplicationsResponse getAssignedApplicationById(HttpServletRequest request, Long id);
|
||||
AssignedApplicationsEntity validateAssignedApplication(Long assignedApplicationId);
|
||||
PageableResponseBean<List<AssignedApplicationsResponse>> getAllAssignedApplicationsByPagination(HttpServletRequest request, Long userId, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean);
|
||||
PageableResponseBean<List<AssignedApplicationViewResponse>> getAllAssignedApplicationsByPagination(HttpServletRequest request, Long userId, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean);
|
||||
AssignedApplicationsResponse updateAssignedApplicationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedApplicationEnum status);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.gepafin.tendermanagement.service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.gepafin.tendermanagement.model.request.LimitRequest;
|
||||
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
|
||||
|
||||
@@ -11,13 +11,9 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(value = "vat-check-service", url = GepafinConstant.CHECK_VATNUMBER_V2_NEW_URL_IT_ADVANCE)
|
||||
public interface VatCheckService {
|
||||
|
||||
@FeignClient(value = "vat-check-v1-service", url = GepafinConstant.CHECK_VATNUMBER_URL_V1)
|
||||
public interface VatCheckV1Service {
|
||||
|
||||
@GetMapping("/{vatNumber}")
|
||||
ResponseEntity<Map<String, Object>> checkVatNumber(URI baseUrl,
|
||||
@PathVariable("vatNumber") String vatNumber,
|
||||
@RequestHeader HttpHeaders headers
|
||||
);
|
||||
ResponseEntity<Map<String, Object>> checkVatNumber(URI baseUrl, @PathVariable("vatNumber") String vatNumber, @RequestHeader HttpHeaders headers);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.gepafin.tendermanagement.service.feignClient;
|
||||
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(value = "vat-check-v2-service", url = GepafinConstant.CHECK_VATNUMBER_URL_V2)
|
||||
public interface VatCheckV2Service {
|
||||
|
||||
@GetMapping("/{vatNumber}")
|
||||
ResponseEntity<Map<String, Object>> checkVatNumber(URI baseUrl, @PathVariable("vatNumber") String vatNumber, @RequestHeader HttpHeaders headers);
|
||||
}
|
||||
@@ -13,12 +13,15 @@ import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestViewResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -41,6 +44,9 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
@Autowired
|
||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(HttpServletRequest request, Long applicationEvaluationId) {
|
||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(applicationEvaluationId);
|
||||
@@ -153,8 +159,16 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean) {
|
||||
UserEntity user=validator.validateUser(request);
|
||||
return applicationAmendmentRequestDao.getApplicationAmendmentByPaginnation(userId,amendmentPaginationRequestBean);
|
||||
public PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean) {
|
||||
boolean isSpecialUser = validator.checkIsBeneficiary() ||
|
||||
validator.checkIsConfidi() ||
|
||||
validator.checkIsPreInstructor() ||
|
||||
validator.checkIsInstructorManager();
|
||||
|
||||
if (isSpecialUser && Boolean.TRUE.equals(validator.checkRequestedUserWithUserId(request,userId))) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_USER_ID));
|
||||
}
|
||||
|
||||
return applicationAmendmentRequestDao.getApplicationAmendmentByPaginationByView(userId,amendmentPaginationRequestBean);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.dao.ApplicationDao;
|
||||
import net.gepafin.tendermanagement.dao.FlowFormDao;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationPageableRequestBean;
|
||||
@@ -15,6 +17,8 @@ import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CallService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||
@@ -38,6 +42,9 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private CallService callService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationResponseBean createApplication(HttpServletRequest request,
|
||||
@@ -112,6 +119,7 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationSignedDocumentResponse uploadSignedDocument(HttpServletRequest request, Long applicationId, MultipartFile file) {
|
||||
Utils.validateFileType(file);
|
||||
return applicationDao.uploadSignedDocument(request, applicationId, file);
|
||||
}
|
||||
|
||||
@@ -152,4 +160,15 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
public ApplicationEntity validateApplicationWithCompany(Long applicationId,Long companyId) {
|
||||
return applicationDao.validateApplicationWithCompany(applicationId,companyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] exportCsv(HttpServletRequest request, Long callId) {
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
CallEntity call=callService.validateCall(callId);
|
||||
validator.validateHubId(request,call.getHub().getId());
|
||||
byte[] csvBytes= applicationDao.exportCsv(callId);
|
||||
|
||||
return csvBytes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationViewResponse;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||
@@ -66,7 +67,7 @@ public class AssignedApplicationsServiceImpl implements AssignedApplicationsServ
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableResponseBean<List<AssignedApplicationsResponse>> getAllAssignedApplicationsByPagination(HttpServletRequest request, Long userId, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean) {
|
||||
public PageableResponseBean<List<AssignedApplicationViewResponse>> getAllAssignedApplicationsByPagination(HttpServletRequest request, Long userId, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean) {
|
||||
UserEntity user=validator.validateUser(request);
|
||||
return assignedApplicationsDao.getAllAssignedApplicationsByPagination(user,assignedApplicationPageableRequestBean,userId);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.gepafin.tendermanagement.model.request.CompanyDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.service.CompanyDocumentService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -31,6 +32,7 @@ public class CompanyDocumentServiceImpl implements CompanyDocumentService {
|
||||
public List<CompanyDocumentResponseBean> uploadFileForCompany(HttpServletRequest request, List<MultipartFile> files, Long companyId, Long documentCategoryId , CompanyDocumentTypeEnum documentSourceTypeEnum, LocalDateTime expirationDate,String name) {
|
||||
Map<String, Object> userInfo = validator.getUserInfoFromToken(request);
|
||||
Long userId = validator.getUserId(userInfo);
|
||||
files.forEach(Utils::validateFileType);
|
||||
return companyDocumentDao.uploadFileForCompany(request,userId,files,companyId,documentCategoryId,documentSourceTypeEnum,expirationDate,name);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jdk.jshell.execution.Util;
|
||||
import net.gepafin.tendermanagement.model.request.LimitRequest;
|
||||
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -107,6 +109,7 @@ public class CompanyServiceImpl implements CompanyService {
|
||||
public CompanyDelegationResponse uploadCompanyDelegation(HttpServletRequest request, Long companyId, MultipartFile file) {
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
Utils.validateFileType(file);
|
||||
return delegationDao.uploadCompanyDelegation(userEntity, companyId, file);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.service.DocumentService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -31,6 +32,7 @@ public class DocumentServiceImpl implements DocumentService {
|
||||
public List<DocumentResponseBean> uploadFile(HttpServletRequest request,List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
|
||||
Map<String, Object> userInfo = validator.getUserInfoFromToken(request);
|
||||
Long userId = validator.getUserId(userInfo);
|
||||
files.forEach(Utils::validateFileType);
|
||||
return documentDao.uploadFiles(userId,files,sourceId,sourceType,fileType);
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -28,11 +28,6 @@ public class DateTimeUtil {
|
||||
LocalDateTime localDatetime = ldtZoned.withZoneSameInstant(ZoneId.of("Europe/Rome")).toLocalDateTime();
|
||||
return localDatetime;
|
||||
}
|
||||
|
||||
public static LocalDate LocalDateServerToEurope(LocalDate systemDate) {
|
||||
ZonedDateTime zonedDateTime = systemDate.atStartOfDay(ZoneId.systemDefault());
|
||||
return zonedDateTime.withZoneSameInstant(ZoneId.of("Europe/Rome")).toLocalDate();
|
||||
}
|
||||
|
||||
public static LocalTime LocalTimeServerToEurope(LocalTime systemTime) {
|
||||
ZonedDateTime zonedDateTime = systemTime.atDate(LocalDate.now()).atZone(ZoneId.systemDefault());
|
||||
|
||||
@@ -37,7 +37,9 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.MatchModeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.FilterCriteria;
|
||||
import net.gepafin.tendermanagement.model.request.GlobalFilters;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.*;
|
||||
import net.objecthunter.exp4j.Expression;
|
||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
@@ -55,13 +57,10 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
|
||||
import feign.FeignException;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientForbiddenException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientUnauthorizedException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.FeignClientValidationException;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.Mac;
|
||||
@@ -113,6 +112,7 @@ public class Utils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String extractFileName(String filePath) {
|
||||
if (filePath == null || filePath.isEmpty()) {
|
||||
return null;
|
||||
@@ -125,6 +125,7 @@ public class Utils {
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
|
||||
public static String decodeBase64String(String decodedString) {
|
||||
if (StringUtils.isBlank(decodedString)) {
|
||||
return decodedString;
|
||||
@@ -132,18 +133,20 @@ public class Utils {
|
||||
byte[] decode = Base64.getDecoder().decode(decodedString.getBytes(StandardCharsets.UTF_8));
|
||||
return new String(decode, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static <T> void setIfNotNull(Consumer<T> setter, T value) {
|
||||
if (value != null) {
|
||||
setter.accept(value);
|
||||
}
|
||||
}
|
||||
public static <T> void setIfUpdated(Supplier<T> getter, Consumer<T> setter, T newValue) {
|
||||
T currentValue = getter.get();
|
||||
if (newValue != null && !newValue.equals(currentValue)) {
|
||||
setter.accept(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void setIfNotNull(Consumer<T> setter, T value) {
|
||||
if (value != null) {
|
||||
setter.accept(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void setIfUpdated(Supplier<T> getter, Consumer<T> setter, T newValue) {
|
||||
T currentValue = getter.get();
|
||||
if (newValue != null && !newValue.equals(currentValue)) {
|
||||
setter.accept(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> String convertListToJsonString(List<T> list) {
|
||||
try {
|
||||
return mapper.writeValueAsString(list);
|
||||
@@ -153,6 +156,7 @@ public class Utils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> List<T> convertJsonStringToList(String jsonString, Class<T> clazz) {
|
||||
try {
|
||||
TypeReference<List<T>> typeRef = new TypeReference<List<T>>() {
|
||||
@@ -168,6 +172,7 @@ public class Utils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String convertMapIntoJsonString(Map<String, Object> map) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@@ -182,6 +187,7 @@ public class Utils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Map<String, Object> convertIntoJson(String jsonString) {
|
||||
if (jsonString != null && !jsonString.isEmpty()) {
|
||||
try {
|
||||
@@ -194,6 +200,7 @@ public class Utils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T, U> U convertSourceObjectToDestinationObject(T source, Class<U> destinationClass) {
|
||||
try {
|
||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
@@ -204,6 +211,7 @@ public class Utils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> void retainOnlySpecificFields(T requestObject, List<T> retainFields) throws IllegalAccessException {
|
||||
// Get all declared fields of the request object's class
|
||||
Field[] fields = requestObject.getClass().getDeclaredFields();
|
||||
@@ -219,22 +227,23 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String encodeData(String data) {
|
||||
return Base64.getEncoder().encodeToString(data.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
return Base64.getEncoder().encodeToString(data.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public static String decodeData(String token) {
|
||||
byte[] decodedBytes = Base64.getDecoder().decode(token);
|
||||
return new String(decodedBytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
public static String decodeData(String token) {
|
||||
byte[] decodedBytes = Base64.getDecoder().decode(token);
|
||||
return new String(decodedBytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static String generateSecureSamlToken() {
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
byte[] tokenBytes = new byte[24];
|
||||
secureRandom.nextBytes(tokenBytes);
|
||||
String token = Base64.getUrlEncoder().withoutPadding().encodeToString(tokenBytes);
|
||||
log.debug("Generated secure token: {}", token);
|
||||
return token;
|
||||
}
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
byte[] tokenBytes = new byte[24];
|
||||
secureRandom.nextBytes(tokenBytes);
|
||||
String token = Base64.getUrlEncoder().withoutPadding().encodeToString(tokenBytes);
|
||||
log.debug("Generated secure token: {}", token);
|
||||
return token;
|
||||
}
|
||||
|
||||
public static String generateSecureToken() {
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
byte[] tokenBytes = new byte[5];
|
||||
@@ -243,6 +252,7 @@ public class Utils {
|
||||
log.debug("Generated secure token: {}", token);
|
||||
return token;
|
||||
}
|
||||
|
||||
public static Map<String, List<Object>> convertStringIntoMap(String jsonString) {
|
||||
try {
|
||||
return mapper.readValue(jsonString, new TypeReference<Map<String, List<Object>>>() {
|
||||
@@ -252,26 +262,26 @@ public class Utils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void callException(Integer staus, FeignException ex) {
|
||||
switch (staus) {
|
||||
case 400:
|
||||
throw new FeignClientValidationException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||
case 400:
|
||||
throw new FeignClientValidationException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||
|
||||
case 401:
|
||||
throw new FeignClientUnauthorizedException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||
case 401:
|
||||
throw new FeignClientUnauthorizedException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||
|
||||
case 403:
|
||||
throw new FeignClientForbiddenException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||
case 403:
|
||||
throw new FeignClientForbiddenException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||
|
||||
case 404:
|
||||
throw new FeignClientNotFoundException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||
default:
|
||||
log.error("Exception occured :- {0}", ex);
|
||||
throw ex;
|
||||
case 404:
|
||||
throw new FeignClientNotFoundException(HttpStatus.valueOf(staus), ex.getMessage());
|
||||
default:
|
||||
log.error("Exception occured :- {0}", ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Boolean isValidEmail(String email) {
|
||||
String EMAIL_REGEX = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+$";
|
||||
if (email == null || email.isEmpty()) {
|
||||
@@ -285,7 +295,7 @@ public class Utils {
|
||||
String data = String.valueOf(System.currentTimeMillis());
|
||||
return data.substring(data.length() - range);
|
||||
}
|
||||
|
||||
|
||||
public static String convertObjectToJsonString(Object object) {
|
||||
try {
|
||||
// Check if the object is a string
|
||||
@@ -329,7 +339,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Map<String, String>> parseJsonContent(String jsonContent) {
|
||||
public static Map<String, Map<String, String>> parseJsonContent(String jsonContent) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
return mapper.readValue(jsonContent, HashMap.class);
|
||||
@@ -338,22 +348,23 @@ public class Utils {
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
// Utility method to replace placeholders with their values, handling nulls
|
||||
public static String replacePlaceholders(String text, Map<String, String> placeholders) {
|
||||
if (text == null) {
|
||||
return "";
|
||||
}
|
||||
for (Map.Entry<String, String> entry : placeholders.entrySet()) {
|
||||
text = replaceNull(text, entry.getKey(), entry.getValue());
|
||||
}
|
||||
return text;
|
||||
if (text == null) {
|
||||
return "";
|
||||
}
|
||||
for (Map.Entry<String, String> entry : placeholders.entrySet()) {
|
||||
text = replaceNull(text, entry.getKey(), entry.getValue());
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
// Method to safely replace nulls with an empty string or a default value
|
||||
private static String replaceNull(String text, String target, String replacement) {
|
||||
return text.replace(target, replacement != null ? replacement : "");
|
||||
return text.replace(target, replacement != null ? replacement : "");
|
||||
}
|
||||
|
||||
public static String getClientIpAddress(HttpServletRequest request) {
|
||||
String header = request.getHeader("X-Forwarded-For");
|
||||
if (org.apache.commons.lang3.StringUtils.isBlank(header)) {
|
||||
@@ -362,6 +373,7 @@ public class Utils {
|
||||
|
||||
return new StringTokenizer(header, ",").nextToken().trim();
|
||||
}
|
||||
|
||||
public static <T> List<T> convertJsonToList(String json, TypeReference<List<T>> typeRef) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
@@ -374,11 +386,15 @@ public class Utils {
|
||||
|
||||
public static String convertObjectToJson(Object obj) {
|
||||
try {
|
||||
if(obj == null){return null;}
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
return new ObjectMapper().writeValueAsString(obj);
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Failed to convert object to JSON: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("Failed to convert object to JSON", e);}}
|
||||
throw new RuntimeException("Failed to convert object to JSON", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String replaceSpacesWithUnderscores(String content) {
|
||||
if (content == null) {
|
||||
@@ -386,10 +402,10 @@ public class Utils {
|
||||
}
|
||||
return content.trim().replace(" ", "_");
|
||||
}
|
||||
|
||||
public static List<Map<String, Object>> convertJsonStringIntoJsonList(String jsonString) {
|
||||
try {
|
||||
if(isEmpty(jsonString))
|
||||
{
|
||||
if (isEmpty(jsonString)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@@ -400,6 +416,7 @@ public class Utils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String convertToString(Object input) {
|
||||
if (input == null) {
|
||||
return "null"; // Return string "null" for null input
|
||||
@@ -461,6 +478,7 @@ public class Utils {
|
||||
throw new RuntimeException("Error converting map to string", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isValidDateString(String dateStr) {
|
||||
Pattern datePattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}");
|
||||
return datePattern.matcher(dateStr).matches();
|
||||
@@ -478,7 +496,7 @@ public class Utils {
|
||||
|
||||
return targetFormat.format(date);
|
||||
} catch (ParseException e) {
|
||||
log.error("error while prcoessing date formate");
|
||||
log.error("error while prcoessing date formate");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -524,6 +542,7 @@ public class Utils {
|
||||
return "Invalid amount format";
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isItalianFormattedAmount(String input) {
|
||||
// Regular expression to match Italian-style amounts (e.g., 41.003,00 or 123,45)
|
||||
String sanitizedInput = input.replace(",", "");
|
||||
@@ -536,7 +555,7 @@ public class Utils {
|
||||
|
||||
public static String encryptCredential(String value) {
|
||||
try {
|
||||
if(Boolean.FALSE.equals(isEmpty(value))) {
|
||||
if (Boolean.FALSE.equals(isEmpty(value))) {
|
||||
|
||||
IvParameterSpec iv = new IvParameterSpec(GepafinConstant.ENCRYPT_INIT_VECTOR.getBytes("UTF-8"));
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(Base64.getDecoder().decode(GepafinConstant.ENCRYPT_KEY), "AES");
|
||||
@@ -557,7 +576,7 @@ public class Utils {
|
||||
|
||||
public static String decryptCredential(String encrypted) {
|
||||
try {
|
||||
if(Boolean.FALSE.equals(isEmpty(encrypted))) {
|
||||
if (Boolean.FALSE.equals(isEmpty(encrypted))) {
|
||||
|
||||
IvParameterSpec iv = new IvParameterSpec(GepafinConstant.ENCRYPT_INIT_VECTOR.getBytes("UTF-8"));
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(Base64.getDecoder().decode(GepafinConstant.ENCRYPT_KEY), "AES");
|
||||
@@ -620,19 +639,19 @@ public class Utils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setHttpServletRequestForScheduler() {
|
||||
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
|
||||
mockRequest.setRequestURI("/scheduled");
|
||||
mockRequest.setMethod("POST");
|
||||
ServletRequestAttributes attributes = new ServletRequestAttributes(mockRequest);
|
||||
RequestContextHolder.setRequestAttributes(attributes);
|
||||
}
|
||||
|
||||
public static void clearHttpServletRequest() {
|
||||
// Clear the RequestContextHolder after task execution
|
||||
RequestContextHolder.resetRequestAttributes();
|
||||
}
|
||||
public static void setHttpServletRequestForScheduler() {
|
||||
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
|
||||
mockRequest.setRequestURI("/scheduled");
|
||||
mockRequest.setMethod("POST");
|
||||
ServletRequestAttributes attributes = new ServletRequestAttributes(mockRequest);
|
||||
RequestContextHolder.setRequestAttributes(attributes);
|
||||
}
|
||||
|
||||
public static void clearHttpServletRequest() {
|
||||
// Clear the RequestContextHolder after task execution
|
||||
RequestContextHolder.resetRequestAttributes();
|
||||
}
|
||||
|
||||
public static String generateAuthTokenForLoginToOdessa() {
|
||||
|
||||
@@ -741,7 +760,8 @@ public class Utils {
|
||||
public static String createChannelForUserAndCompany(Long userId, Long companyId) {
|
||||
return GepafinConstant.COMMON_SINGLE_CHANNEL_PREFIX + userId + GepafinConstant.COMPANY_PREFIX + companyId;
|
||||
}
|
||||
public static GlobalFilters setPageNumberAndLimit(GlobalFilters globalFilters){
|
||||
|
||||
public static GlobalFilters setPageNumberAndLimit(GlobalFilters globalFilters) {
|
||||
if (globalFilters == null) {
|
||||
if (globalFilters.getLimit() == null || globalFilters.getLimit() <= 0) {
|
||||
globalFilters.setLimit(GepafinConstant.DEFAULT_PAGE_LIMIT);
|
||||
@@ -769,6 +789,7 @@ public class Utils {
|
||||
private static Map<String, Object> defaultErrorResponse() {
|
||||
return Collections.singletonMap("message", Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
}
|
||||
|
||||
public static List<String> extractValues(String input) {
|
||||
List<String> extractedValues = new ArrayList<>();
|
||||
Pattern pattern = Pattern.compile("\\{(.*?)\\}"); // Regex to match {value}
|
||||
@@ -779,6 +800,7 @@ public class Utils {
|
||||
}
|
||||
return extractedValues;
|
||||
}
|
||||
|
||||
public static double evaluateExpression(String expression) {
|
||||
try {
|
||||
Expression exp = new ExpressionBuilder(expression).build();
|
||||
@@ -788,6 +810,7 @@ public class Utils {
|
||||
return Double.NaN; // Return NaN if the expression is invalid
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isNumeric(String input) {
|
||||
if (input == null || input.trim().isEmpty()) {
|
||||
return false;
|
||||
@@ -795,9 +818,11 @@ public class Utils {
|
||||
|
||||
return input.matches("-?\\d+(\\.\\d+)?");
|
||||
}
|
||||
|
||||
public static boolean isValidBoolean(String value) {
|
||||
return "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
|
||||
}
|
||||
|
||||
public static Map<String, Object> convertJsonStringToMap(String jsonString) {
|
||||
try {
|
||||
return mapper.readValue(jsonString, Map.class);
|
||||
@@ -826,20 +851,48 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static void applyNumberFilter(Path<?> fieldPath, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Object value, MatchModeEnum matchMode) {
|
||||
|
||||
if (Number.class.isAssignableFrom(fieldPath.getJavaType())) {
|
||||
Number numberValue = null;
|
||||
if (value instanceof Number) {
|
||||
numberValue = (Number) value;
|
||||
|
||||
if (value instanceof String stringValue) {
|
||||
if (isInteger(stringValue)) {
|
||||
numberValue = Long.parseLong(stringValue);
|
||||
} else if (isDecimal(stringValue)) {
|
||||
numberValue = Double.parseDouble(stringValue);
|
||||
}
|
||||
} else if (value instanceof Number number) {
|
||||
numberValue = number;
|
||||
}
|
||||
MatchModeEnum mode = MatchModeEnum.fromObject(matchMode.getValue());
|
||||
switch (mode) {
|
||||
case EQUALS -> predicates.add(criteriaBuilder.equal(fieldPath, numberValue));
|
||||
if (numberValue != null) {
|
||||
MatchModeEnum mode = MatchModeEnum.fromObject(matchMode.getValue());
|
||||
|
||||
if (mode == MatchModeEnum.EQUALS) {
|
||||
predicates.add(criteriaBuilder.equal(fieldPath, numberValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isInteger(String value) {
|
||||
|
||||
try {
|
||||
Long.parseLong(value);
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isDecimal(String value) {
|
||||
|
||||
try {
|
||||
Double.parseDouble(value);
|
||||
return value.contains(".");
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyDateFilter(Path<?> fieldPath, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Object value, MatchModeEnum matchMode, Root<?> root) {
|
||||
if (fieldPath.getJavaType().equals(LocalDateTime.class)) {
|
||||
@@ -879,8 +932,10 @@ public class Utils {
|
||||
switch (mode) {
|
||||
case DATEIS -> predicates.add(criteriaBuilder.equal(dateField, dateValue));
|
||||
case DATEISNOT -> predicates.add(criteriaBuilder.notEqual(dateField, dateValue));
|
||||
case BEFORE -> predicates.add(criteriaBuilder.lessThan(fieldPath.as(Timestamp.class), Timestamp.valueOf(dateTimeValue)));
|
||||
case AFTER -> predicates.add(criteriaBuilder.greaterThan(fieldPath.as(Timestamp.class), Timestamp.valueOf(dateTimeValue)));
|
||||
case BEFORE ->
|
||||
predicates.add(criteriaBuilder.lessThan(fieldPath.as(Timestamp.class), Timestamp.valueOf(dateTimeValue)));
|
||||
case AFTER ->
|
||||
predicates.add(criteriaBuilder.greaterThan(fieldPath.as(Timestamp.class), Timestamp.valueOf(dateTimeValue)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -904,4 +959,57 @@ public class Utils {
|
||||
Object obj = parentMap.get(key);
|
||||
return (obj instanceof String str) ? str : null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void validateFileType(MultipartFile file) {
|
||||
if (file.isEmpty()) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.VALIDATION_ERROR_FILE_EMPTY));
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyFiltersByPagination(Root<?> root, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Map<String, FilterCriteria> filters) {
|
||||
if (Boolean.FALSE.equals(filters.isEmpty())) {
|
||||
for (Map.Entry<String, FilterCriteria> entry : filters.entrySet()) {
|
||||
String fieldName = entry.getKey();
|
||||
FilterCriteria filterCriteria = entry.getValue();
|
||||
Object value = filterCriteria.getValue();
|
||||
MatchModeEnum matchMode = filterCriteria.getMatchMode();
|
||||
|
||||
if (value != null && matchMode != null) {
|
||||
Path<?> fieldPath = root.get(fieldName);
|
||||
if (fieldPath != null) {
|
||||
Utils.applyStringFilter(fieldPath, criteriaBuilder, predicates, value, matchMode);
|
||||
Utils.applyNumberFilter(fieldPath, criteriaBuilder, predicates, value, matchMode);
|
||||
Utils.applyDateFilter(fieldPath, criteriaBuilder, predicates, value, matchMode, root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static List<Map<String, Object>> convertJsonToListMap(String jsonString) {
|
||||
try {
|
||||
if (jsonString == null || jsonString.trim().isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String unescaped;
|
||||
|
||||
// First try: parse as if it's double-encoded (escaped string containing a JSON array)
|
||||
try {
|
||||
unescaped = objectMapper.readValue(jsonString, String.class);
|
||||
} catch (Exception e) {
|
||||
// If that fails, assume it's already a proper JSON array
|
||||
unescaped = jsonString;
|
||||
}
|
||||
|
||||
// Now parse the actual JSON array
|
||||
return objectMapper.readValue(unescaped, new TypeReference<List<Map<String, Object>>>() {});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -206,4 +206,12 @@ public class Validator {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Boolean checkRequestedUserWithUserId(HttpServletRequest request,Long userId){
|
||||
UserEntity user=validateUser(request);
|
||||
UserEntity requestedUser=userService.validateUser(userId);
|
||||
if( Boolean.FALSE.equals(user.getId().equals(requestedUser.getId()))){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,7 @@ import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -201,7 +197,7 @@ public interface ApplicationAmendmentRequestApi {
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@PostMapping(value = "/user/{userId}/pagination", produces = { "application/json" })
|
||||
ResponseEntity<Response<PageableResponseBean<List<ApplicationAmendmentRequestResponse>>>> getApplicationAmendmentByPaginnation(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
|
||||
@RequestBody ApplicationAmendmentPaginationRequestBean userActionPaginationRequest);
|
||||
ResponseEntity<Response<PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>>>> getApplicationAmendmentByPaginnation(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
|
||||
@RequestBody ApplicationAmendmentPaginationRequestBean userActionPaginationRequest);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationPageableRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationRequestBean;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -18,10 +19,8 @@ import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
|
||||
@@ -224,5 +223,21 @@ public interface ApplicationApi {
|
||||
ResponseEntity<Response<PageableResponseBean<List<ApplicationResponse>>>> getAllApplicationByPagination(HttpServletRequest request,@Parameter(description = "The call id", required = false) @RequestParam(value = "callId", required = false) Long callId,
|
||||
@Parameter(description = "The company id", required = false) @RequestParam(value = "companyId", required = false) Long companyId, @RequestBody ApplicationPageableRequestBean applicationPageableRequestBean);
|
||||
|
||||
@Operation(summary = "Api to download application data as a CSV file using the call ID",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))
|
||||
})
|
||||
@GetMapping(value = "/call/{callId}/csv")
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
public ResponseEntity<byte[]> exportCsv(
|
||||
HttpServletRequest request, @Parameter(description = "The call id", required = true) @PathVariable(value = "callId", required = true) Long callId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationViewResponse;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
@@ -128,8 +129,8 @@ public interface AssignedApplicationsApi {
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@PostMapping(value = "/pagination", produces = "application/json")
|
||||
ResponseEntity<Response<PageableResponseBean<List<AssignedApplicationsResponse>>>> getAllAssignedApplicationsByPagination(HttpServletRequest request,
|
||||
@Parameter(description = "The User ID", required = false) @RequestParam(value = "userId",required = false) Long userId, @RequestBody AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean);
|
||||
ResponseEntity<Response<PageableResponseBean<List<AssignedApplicationViewResponse>>>> getAllAssignedApplicationsByPagination(HttpServletRequest request,
|
||||
@Parameter(description = "The User ID", required = false) @RequestParam(value = "userId",required = false) Long userId, @RequestBody AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestViewResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
@@ -187,11 +188,11 @@ public class ApplicationAmendmentRequestController implements ApplicationAmendme
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<PageableResponseBean<List<ApplicationAmendmentRequestResponse>>>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean) {
|
||||
public ResponseEntity<Response<PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>>>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean) {
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION).build());
|
||||
|
||||
PageableResponseBean<List<ApplicationAmendmentRequestResponse>> listPageableResponseBean=applicationAmendmentRequestService.getApplicationAmendmentByPaginnation(request,userId,amendmentPaginationRequestBean);
|
||||
PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> listPageableResponseBean=applicationAmendmentRequestService.getApplicationAmendmentByPaginnation(request,userId,amendmentPaginationRequestBean);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(listPageableResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_DATA_FOR_AMENDMENT_SUCCESS_MSG)));
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationPageableRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
@@ -236,5 +234,13 @@ public class ApplicationApiController implements ApplicationApi {
|
||||
.getAllApplicationByPagination(request, callId,companyId,applicationPageableRequestBean);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(pageableResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<byte[]> exportCsv(HttpServletRequest request, Long callId) {
|
||||
byte[] csvBytes =applicationService.exportCsv(request,callId);
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=applications.csv")
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.body(csvBytes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,10 +12,7 @@ import net.gepafin.tendermanagement.model.request.AssignedApplicationPageableReq
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
@@ -96,11 +93,11 @@ public class AssignedApplicationsController implements AssignedApplicationsApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<PageableResponseBean<List<AssignedApplicationsResponse>>>> getAllAssignedApplicationsByPagination(HttpServletRequest request, Long userId, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean) {
|
||||
public ResponseEntity<Response<PageableResponseBean<List<AssignedApplicationViewResponse>>>> getAllAssignedApplicationsByPagination(HttpServletRequest request, Long userId, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean) {
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_ALL_ASSIGNED_APPLICATION_BY_PAGINATION).build());
|
||||
|
||||
PageableResponseBean<List<AssignedApplicationsResponse>> assigenedApplicationResponses=assignedApplicationsService.getAllAssignedApplicationsByPagination(request, userId,assignedApplicationPageableRequestBean);
|
||||
PageableResponseBean<List<AssignedApplicationViewResponse>> assigenedApplicationResponses=assignedApplicationsService.getAllAssignedApplicationsByPagination(request, userId,assignedApplicationPageableRequestBean);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(assigenedApplicationResponses, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ASSIGNED_APPLICATION_SUCCESS_MSG)));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user