Resolved Conflicts

This commit is contained in:
rajesh
2025-03-12 18:53:14 +05:30
38 changed files with 565 additions and 82 deletions

View File

@@ -485,10 +485,11 @@ public class GepafinConstant {
public static final String USAGE="usage"; public static final String USAGE="usage";
public static final String LIMIT="limit"; public static final String LIMIT="limit";
public static final String DATA="data"; public static final String DATA="data";
public static final String FILE_SELECT = "fileselect";
public static final String INVALID_LIMIT = "error.invalid.limit";
public static final String PREFERRED_CALL_ID="preferredCallId"; public static final String PREFERRED_CALL_ID="preferredCallId";
public static final String REGION_ID="regionId"; public static final String REGION_ID="regionId";
public static final String DELEGATION_TEMPLATE_CONFIDI="DELEGATION_TEMPLATE_CONFIDI";
} }

View File

@@ -181,6 +181,7 @@ public class ApplicationAmendmentRequestDao {
for (ApplicationFormEntity form : forms) { for (ApplicationFormEntity form : forms) {
String content = form.getForm().getContent(); String content = form.getForm().getContent();
List<Map<String, Object>> result = filterByName(content, "fileupload"); List<Map<String, Object>> result = filterByName(content, "fileupload");
result.addAll(filterByName(content, GepafinConstant.FILE_SELECT));
List<AmendmentFormFieldResponse> amendmentFormFieldResponses= getIdAndLabelFromResult(result); List<AmendmentFormFieldResponse> amendmentFormFieldResponses= getIdAndLabelFromResult(result);
amendmentFormFieldResponses.removeIf(amendmentFormFieldResponse -> { amendmentFormFieldResponses.removeIf(amendmentFormFieldResponse -> {
FieldRequest matchingRequest = fieldRequestMap.get(amendmentFormFieldResponse.getFieldId()); FieldRequest matchingRequest = fieldRequestMap.get(amendmentFormFieldResponse.getFieldId());
@@ -533,12 +534,15 @@ public class ApplicationAmendmentRequestDao {
} }
return response; return response;
} }
private Map<String, String> extractFieldIdToLabelMap(List<ApplicationFormEntity> forms) { private Map<String, String> extractFieldIdToLabelMap(List<ApplicationFormEntity> forms) {
return forms.stream() return forms.stream()
.flatMap(form -> { .flatMap(form -> {
String content = form.getForm().getContent(); String content = form.getForm().getContent();
return getIdAndLabelFromResult(filterByName(content, "fileupload")).stream(); List<Map<String, Object>> filteredResults = new ArrayList<>();
filteredResults.addAll(filterByName(content, "fileupload"));
filteredResults.addAll(filterByName(content, GepafinConstant.FILE_SELECT));
return getIdAndLabelFromResult(filteredResults).stream();
}) })
.collect(Collectors.toMap(AmendmentFormFieldResponse::getFieldId, AmendmentFormFieldResponse::getLabel)); .collect(Collectors.toMap(AmendmentFormFieldResponse::getFieldId, AmendmentFormFieldResponse::getLabel));
} }
@@ -678,7 +682,7 @@ public class ApplicationAmendmentRequestDao {
log.info("Updating application amendement with ID: {}", id); log.info("Updating application amendement with ID: {}", id);
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id); ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
Boolean isBeneficiary=false; Boolean isBeneficiary=false;
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) { if (Boolean.FALSE.equals(validator.checkIsBeneficiary()) && Boolean.FALSE.equals(validator.checkIsConfidi()) ) {
validator.validatePreInstructor(request, existingApplicationAmendment.getApplicationEvaluationEntity().getUserId()); validator.validatePreInstructor(request, existingApplicationAmendment.getApplicationEvaluationEntity().getUserId());
isBeneficiary=false; isBeneficiary=false;
} else { } else {
@@ -1368,10 +1372,10 @@ public class ApplicationAmendmentRequestDao {
.toList(); .toList();
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues)); predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
} }
if(Boolean.TRUE.equals(validator.checkIsBeneficiary())) { if(Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("application").get("userId").in(userId)); predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("application").get("userId").in(userId));
} }
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) { else {
predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("userId").in(userId)); predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("userId").in(userId));
} }

View File

@@ -389,7 +389,7 @@ public class ApplicationDao {
return (root, query, builder) -> { return (root, query, builder) -> {
Boolean isBeneficiary = validator.checkIsBeneficiary(); Boolean isBeneficiary = validator.checkIsBeneficiary();
Predicate predicate = builder.isFalse(root.get("isDeleted")); Predicate predicate = builder.isFalse(root.get("isDeleted"));
if (isBeneficiary) { if (Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
predicate = builder.and(predicate, builder.equal(root.get("userId"), userEntity.getId())); predicate = builder.and(predicate, builder.equal(root.get("userId"), userEntity.getId()));
} }
if (callId != null) { if (callId != null) {
@@ -742,7 +742,7 @@ public class ApplicationDao {
List<FormApplicationResponse> formApplicationResponses = new ArrayList<>(); List<FormApplicationResponse> formApplicationResponses = new ArrayList<>();
List<FormEntity> formEntities = new ArrayList<>(); List<FormEntity> formEntities = new ArrayList<>();
UserEntity userEntity = validator.validateUser(request); UserEntity userEntity = validator.validateUser(request);
boolean isBeneficiary = isBeneficiary(userEntity); boolean isBeneficiary = Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi());
ApplicationEntity applicationEntity = isBeneficiary ApplicationEntity applicationEntity = isBeneficiary
? applicationRepository.findByIdAndUserIdAndIsDeletedFalse(applicationId, userEntity.getId()) ? applicationRepository.findByIdAndUserIdAndIsDeletedFalse(applicationId, userEntity.getId())
.orElseThrow(() -> new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG))) .orElseThrow(() -> new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG)))
@@ -1530,8 +1530,8 @@ public class ApplicationDao {
} }
List<Predicate> predicates = new ArrayList<>(); List<Predicate> predicates = new ArrayList<>();
Boolean isBeneficiary = validator.checkIsBeneficiary(); // Boolean isBeneficiary = validator.checkIsBeneficiary();
if (isBeneficiary) { if (Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_ID), userEntity.getId())); predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_ID), userEntity.getId()));
} }
if (year != null && year > 0) { if (year != null && year > 0) {

View File

@@ -378,6 +378,9 @@ public class ApplicationEvaluationDao {
case "fileupload": case "fileupload":
mapFileFieldDetails(mappedField, formFieldId, applicationForm.getId(), applicationId); mapFileFieldDetails(mappedField, formFieldId, applicationForm.getId(), applicationId);
break; break;
case "fileselect":
mapFileFieldDetails(mappedField, formFieldId, applicationForm.getId(), applicationId);
break;
case "checkboxes": case "checkboxes":
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentBean); populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentBean);
break; break;
@@ -516,7 +519,7 @@ public class ApplicationEvaluationDao {
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
contentResponseBeans.forEach(contentResponseBean -> { contentResponseBeans.forEach(contentResponseBean -> {
// Check if this is a file upload field that matches the current field response // Check if this is a file upload field that matches the current field response
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) { if (("fileupload".equals(contentResponseBean.getName()) || GepafinConstant.FILE_SELECT.equals(contentResponseBean.getName())) && contentResponseBean.getId().equals(fieldResponse.getId())) {
String label = null; String label = null;
// Set the label if available // Set the label if available
if (contentResponseBean.getSettings() != null) { if (contentResponseBean.getSettings() != null) {
@@ -742,7 +745,7 @@ public class ApplicationEvaluationDao {
applicationAmendmentRequestEntities.forEach(applicationAmendmentRequestEntity->{ applicationAmendmentRequestEntities.forEach(applicationAmendmentRequestEntity->{
ApplicationAmendmentRequestEntity oldEntity = Utils.getClonedEntityForData(applicationAmendmentRequestEntity); ApplicationAmendmentRequestEntity oldEntity = Utils.getClonedEntityForData(applicationAmendmentRequestEntity);
updateAmendment(applicationAmendmentRequestEntity, amendmentFormFieldsMap.get(applicationAmendmentRequestEntity.getId())); updateAmendment(applicationAmendmentRequestEntity, amendmentFormFieldsMap.get(applicationAmendmentRequestEntity.getId()));
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().actionType(VersionActionTypeEnum.UPDATE).oldData(oldEntity).newData(applicationAmendmentRequestEntity).build()); loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldEntity).newData(applicationAmendmentRequestEntity).build());
}); });
applicationAmendmentRequestRepository.saveAll(applicationAmendmentRequestEntities); applicationAmendmentRequestRepository.saveAll(applicationAmendmentRequestEntities);
@@ -1252,7 +1255,9 @@ public class ApplicationEvaluationDao {
case "fileupload": case "fileupload":
populateFileDetailsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId); populateFileDetailsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId);
break; break;
case "fileselect":
populateFileDetailsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId);
break;
case "checkboxes": case "checkboxes":
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentResponseBean); populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentResponseBean);
break; break;
@@ -1402,7 +1407,7 @@ public class ApplicationEvaluationDao {
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class); // List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
contentResponseBeans.forEach(contentResponseBean -> { contentResponseBeans.forEach(contentResponseBean -> {
if ("fileupload".equals(contentResponseBean.getName()) && contentResponseBean.getId().equals(fieldResponse.getId())) { if (("fileupload".equals(contentResponseBean.getName()) || GepafinConstant.FILE_SELECT.equals(contentResponseBean.getName())) && contentResponseBean.getId().equals(fieldResponse.getId())) {
String label = null; String label = null;
if (contentResponseBean.getSettings() != null) { if (contentResponseBean.getSettings() != null) {
for (SettingResponseBean setting : contentResponseBean.getSettings()) { for (SettingResponseBean setting : contentResponseBean.getSettings()) {
@@ -1564,9 +1569,10 @@ public class ApplicationEvaluationDao {
mappedField.setFieldName(contentResponseBean.getName()); mappedField.setFieldName(contentResponseBean.getName());
boolean isCheckbox = "checkboxes".equals(contentResponseBean.getName()); boolean isCheckbox = "checkboxes".equals(contentResponseBean.getName());
boolean isFileUpload = "fileupload".equals(contentResponseBean.getName()); boolean isFileUpload = "fileupload".equals(contentResponseBean.getName());
boolean isFileSelect = GepafinConstant.FILE_SELECT.equals(contentResponseBean.getName());
boolean isParagraph = "paragraph".equals(contentResponseBean.getName()); boolean isParagraph = "paragraph".equals(contentResponseBean.getName());
boolean isTable = "table".equals(contentResponseBean.getName()); boolean isTable = "table".equals(contentResponseBean.getName());
if (isFileUpload) { if (isFileUpload || isFileSelect ) {
handleFileUpload(applicationId, criteriaFormField, mappedField); handleFileUpload(applicationId, criteriaFormField, mappedField);
} else if (isCheckbox) { } else if (isCheckbox) {
handleCheckbox(applicationId, criteriaFormField, contentResponseBean, mappedField); handleCheckbox(applicationId, criteriaFormField, contentResponseBean, mappedField);
@@ -1773,7 +1779,7 @@ public class ApplicationEvaluationDao {
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent(); List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
for (ContentResponseBean contentResponseBean : contentResponseBeans) { for (ContentResponseBean contentResponseBean : contentResponseBeans) {
if ("fileupload".equals(contentResponseBean.getName())) { if ("fileupload".equals(contentResponseBean.getName()) || GepafinConstant.FILE_SELECT.equals(contentResponseBean.getName())) {
String fieldId = contentResponseBean.getId(); String fieldId = contentResponseBean.getId();
Long applicationFormId = applicationForm.getId(); Long applicationFormId = applicationForm.getId();
@@ -2103,7 +2109,8 @@ public class ApplicationEvaluationDao {
List<ContentResponseBean> contentResponseBeans=evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent(); List<ContentResponseBean> contentResponseBeans=evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent();
for (ContentResponseBean contentResponseBean:contentResponseBeans){ for (ContentResponseBean contentResponseBean:contentResponseBeans){
if(Boolean.TRUE.equals(contentResponseBean.getName().equals("fileupload"))) { if(Boolean.TRUE.equals(contentResponseBean.getName().equals("fileupload")) ||
Boolean.TRUE.equals(contentResponseBean.getName().equals(GepafinConstant.FILE_SELECT))){
if (contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())) { if (contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())) {
Object fieldValueObject = applicationFormFieldRequestBean.getFieldValue(); Object fieldValueObject = applicationFormFieldRequestBean.getFieldValue();
if (fieldValueObject instanceof String) { if (fieldValueObject instanceof String) {
@@ -2128,7 +2135,8 @@ public class ApplicationEvaluationDao {
for (ApplicationEvaluationFormFieldEntity applicationEvaluationFormFieldEntity : evaluationFormFieldEntities) { for (ApplicationEvaluationFormFieldEntity applicationEvaluationFormFieldEntity : evaluationFormFieldEntities) {
Optional<ContentResponseBean> fileUploadContent = contentResponseBeans.stream() Optional<ContentResponseBean> fileUploadContent = contentResponseBeans.stream()
.filter(contentResponseBean -> "fileupload".equals(contentResponseBean.getName()) && .filter(contentResponseBean -> ("fileupload".equals(contentResponseBean.getName()) ||
GepafinConstant.FILE_SELECT.equals(contentResponseBean.getName())) &&
contentResponseBean.getId().equals(applicationEvaluationFormFieldEntity.getFieldId())) contentResponseBean.getId().equals(applicationEvaluationFormFieldEntity.getFieldId()))
.findFirst(); .findFirst();

View File

@@ -15,6 +15,10 @@ import java.util.stream.Collectors;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.Expression;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.persistence.criteria.*; import jakarta.persistence.criteria.*;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.entities.*; import net.gepafin.tendermanagement.entities.*;
@@ -781,30 +785,45 @@ public class CallDao {
return createCallResponseBean; return createCallResponseBean;
} }
public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,UserEntity user, Long companyId,Boolean onlyPreferredCall) { public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,UserEntity user, Long companyId,Boolean onlyPreferredCall,Boolean onlyConfidiCall) {
String type = user.getRoleEntity().getRoleType(); String type = user.getRoleEntity().getRoleType();
List<String> callStatusList = CallStatusEnum.getStatusValues(); List<String> callStatusList = CallStatusEnum.getStatusValues();
if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) { if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) {
callStatusList = List.of(CallStatusEnum.PUBLISH.getValue()); callStatusList = List.of(CallStatusEnum.PUBLISH.getValue());
} }
List<CallEntity> calls; // List<CallEntity> calls = List.of();
if (Boolean.TRUE.equals(onlyPreferredCall) && companyId == null) { if (Boolean.TRUE.equals(onlyPreferredCall) && companyId == null) {
throw new CustomValidationException(Status.VALIDATION_ERROR, throw new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL)); Translator.toLocale(GepafinConstant.COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL));
} }
Specification<CallEntity> spec = buildCallSpecification(request, user, companyId, onlyPreferredCall, onlyConfidiCall, callStatusList);
if (Boolean.TRUE.equals(onlyPreferredCall)) { List<CallEntity> calls = callRepository.findAll(spec);
validator.validateUserWithCompany(request, companyId);
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(),companyId); LocalDateTime now = LocalDateTime.now();
List<BeneficiaryPreferredCallEntity> preferredCalls = beneficiaryPreferredCallRepository for (CallEntity call : calls) {
.findByUserIdAndUserWithCompanyIdAndIsDeletedFalse(user.getId(), userWithCompanyEntity.getId()); CallEntity oldCallEntity = Utils.getClonedEntityForData(call);
List<Long> preferredCallIds = preferredCalls.stream() if (CallStatusEnum.PUBLISH.getValue().equals(call.getStatus()) &&
.map(BeneficiaryPreferredCallEntity::getCallId) call.getEndDate() != null && call.getEndTime() != null) {
.collect(Collectors.toList()); LocalDateTime callEndDateTime = LocalDateTime.of(LocalDate.from(call.getEndDate()), call.getEndTime());
calls = callRepository.findByIdInAndStatusIn(preferredCallIds, callStatusList); if (callEndDateTime.isBefore(now)) {
} else { call.setStatus(CallStatusEnum.EXPIRED.getValue());
calls = callRepository.findByStatusInAndHubId(callStatusList, user.getHub().getId()); callRepository.save(call);
}
if (Boolean.FALSE.equals(oldCallEntity.getStatus().equals(call.getStatus()))) {
loggingUtil.logUserAction(UserActionRequest.builder()
.request(request)
.actionType(UserActionLogsEnum.UPDATE)
.actionContext(UserActionContextEnum.UPDATE_EXPIRED_CALL)
.build());
/** This code is responsible for adding a version history log for the "update call status to EXPIRED" operation **/
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCallEntity).newData(call).build());
}
}
} }
List<Long> callIds = calls.stream().map(CallEntity::getId).collect(Collectors.toList()); List<Long> callIds = calls.stream().map(CallEntity::getId).collect(Collectors.toList());
Map<String, BeneficiaryPreferredCallEntity> preferredCallsMap = Map<String, BeneficiaryPreferredCallEntity> preferredCallsMap =
getBeneficiaryPreferredCallsForUser(request,user, callIds, companyId); getBeneficiaryPreferredCallsForUser(request,user, callIds, companyId);
@@ -825,7 +844,7 @@ public class CallDao {
public Map<String, BeneficiaryPreferredCallEntity> getBeneficiaryPreferredCallsForUser(HttpServletRequest request, UserEntity user, List<Long> callIds, Long companyId) { public Map<String, BeneficiaryPreferredCallEntity> getBeneficiaryPreferredCallsForUser(HttpServletRequest request, UserEntity user, List<Long> callIds, Long companyId) {
List<BeneficiaryPreferredCallEntity> beneficiaryPreferredCalls; List<BeneficiaryPreferredCallEntity> beneficiaryPreferredCalls;
if (companyId != null && Boolean.TRUE.equals(validator.checkIsBeneficiary())) { if (companyId != null && (Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi()))) {
validator.validateUserWithCompany(request, companyId); validator.validateUserWithCompany(request, companyId);
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(),companyId); UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(),companyId);
beneficiaryPreferredCalls = beneficiaryPreferredCallRepository beneficiaryPreferredCalls = beneficiaryPreferredCallRepository
@@ -981,7 +1000,7 @@ public class CallDao {
Translator.toLocale(GepafinConstant.COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL) Translator.toLocale(GepafinConstant.COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL)
); );
} }
Specification<CallEntity> spec = search(user, callPageableRequestBean); Specification<CallEntity> spec = search(request,user, callPageableRequestBean);
Page<CallEntity> entityPage; Page<CallEntity> entityPage;
if (Boolean.TRUE.equals(onlyPreferredCall)) { if (Boolean.TRUE.equals(onlyPreferredCall)) {
validator.validateUserWithCompany(request, companyId); validator.validateUserWithCompany(request, companyId);
@@ -994,7 +1013,10 @@ public class CallDao {
// Add preferredCallIds filtering to the specification // Add preferredCallIds filtering to the specification
spec = spec.and((root, query, criteriaBuilder) -> spec = spec.and((root, query, criteriaBuilder) ->
root.get(GepafinConstant.ID).in(preferredCallIds) criteriaBuilder.and(
root.get(GepafinConstant.ID).in(preferredCallIds),
criteriaBuilder.isTrue(root.get("confidi"))
)
); );
} }
entityPage = callRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit)); entityPage = callRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
@@ -1028,10 +1050,10 @@ public class CallDao {
return pageableResponseBean; return pageableResponseBean;
} }
public Specification<CallEntity> search(UserEntity userEntity, CallPageableRequestBean callPageableRequestBean) { public Specification<CallEntity> search(HttpServletRequest request,UserEntity userEntity, CallPageableRequestBean callPageableRequestBean) {
return (root, query, criteriaBuilder) -> { return (root, query, criteriaBuilder) -> {
List<Predicate> predicates = getPredicates(callPageableRequestBean, criteriaBuilder, root, userEntity); List<Predicate> predicates = getPredicates(request,callPageableRequestBean, criteriaBuilder, root, userEntity);
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true); SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
if (callPageableRequestBean.getGlobalFilters() != null if (callPageableRequestBean.getGlobalFilters() != null
@@ -1054,9 +1076,9 @@ public class CallDao {
} }
private List<Predicate> getPredicates(CallPageableRequestBean callPageableRequestBean, private List<Predicate> getPredicates(HttpServletRequest request,CallPageableRequestBean callPageableRequestBean,
CriteriaBuilder criteriaBuilder, Root<CallEntity> root, UserEntity userEntity) { CriteriaBuilder criteriaBuilder, Root<CallEntity> root, UserEntity userEntity) {
expirePublishedCalls(request);
Integer year = null; Integer year = null;
String search = null; String search = null;
Map<String, FilterCriteria> filters = new HashMap<>(); Map<String, FilterCriteria> filters = new HashMap<>();
@@ -1110,13 +1132,84 @@ public class CallDao {
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues)); predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
} }
applyFilters(root, criteriaBuilder, predicates, filters); applyFilters(root, criteriaBuilder, predicates, filters);
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB).get(GepafinConstant.ID), userEntity.getHub().getId())); Boolean isConfidi = callPageableRequestBean.getConfidi();
if (validator.checkIsConfidi()) {
if (isConfidi == null || isConfidi.equals(Boolean.FALSE)) {
// Ensure no records are returned
return List.of(criteriaBuilder.disjunction());
}
if (isConfidi.equals(Boolean.TRUE)) {
predicates.add(criteriaBuilder.isTrue(root.get("confidi")));
}
} else if (Boolean.TRUE.equals(validator.checkIsBeneficiary())) {
predicates.add(criteriaBuilder.isFalse(root.get("confidi")));
} else if( Boolean.FALSE.equals(validator.checkIsConfidi()) && isConfidi!=null){
if (isConfidi.equals(Boolean.TRUE)) {
predicates.add(criteriaBuilder.isTrue(root.get("confidi")));
}
if (isConfidi.equals(Boolean.FALSE)) {
predicates.add(criteriaBuilder.isFalse(root.get("confidi")));
}
}
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB).get(GepafinConstant.ID), userEntity.getHub().getId()));
return predicates; return predicates;
} }
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) {
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)
.actionType(VersionActionTypeEnum.UPDATE)
.oldData(oldCallEntity)
.newData(call)
.build());
}
}
callRepository.saveAll(expiredCalls); // Save all modified calls at once
}
}
private void applyFilters(Root<?> root, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Map<String, FilterCriteria> filters) { private void applyFilters(Root<?> root, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Map<String, FilterCriteria> filters) {
if (Boolean.FALSE.equals(filters.isEmpty())) { if (Boolean.FALSE.equals(filters.isEmpty())) {
for (Map.Entry<String, FilterCriteria> entry : filters.entrySet()) { for (Map.Entry<String, FilterCriteria> entry : filters.entrySet()) {
@@ -1251,4 +1344,47 @@ public class CallDao {
createCallResponseBean.setCurrentStep(GepafinConstant.EVALUATION_V2_STEP_2); createCallResponseBean.setCurrentStep(GepafinConstant.EVALUATION_V2_STEP_2);
return createCallResponseBean; return createCallResponseBean;
} }
private Specification<CallEntity> buildCallSpecification(HttpServletRequest request, UserEntity user, Long companyId, Boolean onlyPreferredCall, Boolean onlyConfidiCall, List<String> callStatusList) {
return (root, query, criteriaBuilder) -> {
List<Predicate> predicates = new ArrayList<>();
predicates.add(root.get("status").in(callStatusList));
if (Boolean.TRUE.equals(onlyPreferredCall)) {
validator.validateUserWithCompany(request, companyId);
UserWithCompanyEntity userWithCompanyEntity = companyService.getUserWithCompany(user.getId(), companyId);
List<BeneficiaryPreferredCallEntity> preferredCalls = beneficiaryPreferredCallRepository
.findByUserIdAndUserWithCompanyIdAndIsDeletedFalse(user.getId(), userWithCompanyEntity.getId());
List<Long> preferredCallIds = preferredCalls.stream()
.map(BeneficiaryPreferredCallEntity::getCallId)
.collect(Collectors.toList());
predicates.add(root.get("id").in(preferredCallIds));
} else {
predicates.add(criteriaBuilder.equal(root.get("hub").get("id"), user.getHub().getId()));
}
if (validator.checkIsConfidi()) {
if (onlyConfidiCall==null || Boolean.FALSE.equals(onlyConfidiCall)) {
return criteriaBuilder.disjunction(); // Returns an empty predicate (no results)
}
if (onlyConfidiCall!=null && Boolean.TRUE.equals(onlyConfidiCall)) {
predicates.add(criteriaBuilder.isTrue(root.get("confidi")));
}
} else if (Boolean.TRUE.equals(validator.checkIsBeneficiary())) {
predicates.add(criteriaBuilder.isFalse(root.get("confidi")));
} else {
if(onlyConfidiCall!=null) {
if (Boolean.TRUE.equals(onlyConfidiCall)) {
predicates.add(criteriaBuilder.isTrue(root.get("confidi")));
}
if (Boolean.FALSE.equals(onlyConfidiCall)) {
predicates.add(criteriaBuilder.isFalse(root.get("confidi")));
}
}
}
return criteriaBuilder.and(predicates.toArray(new Predicate[0]));
};
}
} }

View File

@@ -138,7 +138,7 @@ public class CommunicationDao {
if(validator.checkIsPreInstructor()){ if(validator.checkIsPreInstructor()){
communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId()); communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId());
communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId()); communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
} else if(validator.checkIsBeneficiary()) { } else if(Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId()); communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId()); communicationEntity.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId());
} }

View File

@@ -1,23 +1,33 @@
package net.gepafin.tendermanagement.dao; 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.EnumSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.log4j.Log4j2;
import net.gepafin.tendermanagement.entities.*; import net.gepafin.tendermanagement.entities.*;
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum; import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
import net.gepafin.tendermanagement.enums.UserCompanyDelegationStatusEnum; import net.gepafin.tendermanagement.enums.UserCompanyDelegationStatusEnum;
import net.gepafin.tendermanagement.model.request.LimitRequest;
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
import net.gepafin.tendermanagement.repositories.*; import net.gepafin.tendermanagement.repositories.*;
import net.gepafin.tendermanagement.service.CompanyService; import net.gepafin.tendermanagement.service.CompanyService;
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum; import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest; import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
import net.gepafin.tendermanagement.repositories.ApplicationRepository; import net.gepafin.tendermanagement.repositories.ApplicationRepository;
import net.gepafin.tendermanagement.repositories.FaqRepository; import net.gepafin.tendermanagement.repositories.FaqRepository;
import net.gepafin.tendermanagement.service.feignClient.VatCheckService;
import net.gepafin.tendermanagement.util.LoggingUtil; import net.gepafin.tendermanagement.util.LoggingUtil;
import net.gepafin.tendermanagement.web.rest.api.errors.*; import net.gepafin.tendermanagement.web.rest.api.errors.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import net.gepafin.tendermanagement.config.Translator; import net.gepafin.tendermanagement.config.Translator;
@@ -27,9 +37,11 @@ import net.gepafin.tendermanagement.model.response.CompanyResponse;
import net.gepafin.tendermanagement.service.UserService; import net.gepafin.tendermanagement.service.UserService;
import net.gepafin.tendermanagement.util.Utils; import net.gepafin.tendermanagement.util.Utils;
import static net.gepafin.tendermanagement.util.Utils.convertObjectToJsonString;
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated; import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
@Component @Component
@Log4j2
public class CompanyDao { public class CompanyDao {
@Autowired @Autowired
@@ -60,6 +72,13 @@ public class CompanyDao {
@Autowired @Autowired
private HttpServletRequest request; 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) { public CompanyResponse createCompany(UserEntity userEntity, CompanyRequest companyRequest) {
CompanyEntity existingCompany = companyRepository.findByVatNumberAndHubId(companyRequest.getVatNumber(), userEntity.getHub().getId()); CompanyEntity existingCompany = companyRepository.findByVatNumberAndHubId(companyRequest.getVatNumber(), userEntity.getHub().getId());
@@ -410,4 +429,123 @@ public class CompanyDao {
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldUserWithCompanyData).newData(existingRelation).build()); VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldUserWithCompanyData).newData(existingRelation).build());
} }
public void updateMissingVatCheckResponses(HttpServletRequest request, LimitRequest limitRequest) {
long limit = limitRequest.getLimit();
if (limit <= 0 || limit > 3000) {
log.error("Invalid limit: {}. Limit should be between 1 and 3000.", limit);
throw new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.INVALID_LIMIT));
}
int successfulUpdates = 0;
int failedUpdates = 0;
int invalidVatNumbers = 0;
Pageable pageable = PageRequest.of(0, (int) limit, Sort.by("id").ascending());
Page<CompanyEntity> companyPage = companyRepository.findCompaniesWithMissingVatCheck(pageable);
List<CompanyEntity> companies = companyPage.getContent();
if (companies.isEmpty()) {
log.info("No companies found with missing VAT check responses.");
return;
}
log.info("Processing {} companies with missing VAT check responses...", companies.size());
for (CompanyEntity company : companies) {
try {
log.info("Processing company ID: {} with VAT number: {}", company.getId(), company.getVatNumber());
VatCheckResponseBean vatResponse = companyService.checkVatNumber(request, company.getVatNumber());
CompanyEntity oldCompanyData = Utils.getClonedEntityForData(company);
if (vatResponse != null && vatResponse.getVatCheckResponse() != null) {
// Convert response to JSON and update the JSON field
String jsonResponse = Utils.convertMapIntoJsonString(vatResponse.getVatCheckResponse());
company.setJson(jsonResponse);
log.info("Company ID {}: JSON field updated successfully.", company.getId());
// Extract and set codiceAteco field
updateCodiceAtecoField(company);
successfulUpdates++;
} else {
company.setJson(NOT_FOUND_JSON);
invalidVatNumbers++;
log.warn("Company ID {}: Invalid or null VAT check response. JSON set to '{}'", company.getId(), NOT_FOUND_JSON);
}
// Adding version history log
/** This code is responsible for adding a version history log for the "Update MissingVatCheckResponses" operation. **/
loggingUtil.addVersionHistory(
VersionHistoryRequest.builder()
.request(request)
.actionType(VersionActionTypeEnum.UPDATE)
.oldData(oldCompanyData)
.newData(company)
.build());
} catch (Exception e) {
failedUpdates++;
log.error("Error updating VAT check response for company ID {}: {}", company.getId(), e.getMessage(), e);
}
}
companyRepository.saveAll(companies);
log.info("VAT check update completed. Limit: {} | Successful: {} | Invalid VAT numbers: {} | Failed: {}",
limit, successfulUpdates, invalidVatNumbers, failedUpdates);
}
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());
}
}
} }

View File

@@ -136,8 +136,8 @@ public class DashboardDao {
} }
private void setRegisteredUsers(Widget1 widget1, UserEntity requestedUserEntity) { private void setRegisteredUsers(Widget1 widget1, UserEntity requestedUserEntity) {
Long activeUsers = userRepository.countByStatusAndRoleEntityRoleTypeAndHubId(UserStatusEnum.ACTIVE.getValue(), Long activeUsers = userRepository.countByStatusAndRoleEntityRoleTypeInAndHubId(UserStatusEnum.ACTIVE.getValue(),
RoleStatusEnum.ROLE_BENEFICIARY.getValue(), requestedUserEntity.getHub().getId()); List.of(RoleStatusEnum.ROLE_BENEFICIARY.getValue(),RoleStatusEnum.ROLE_CONFIDI.getValue()), requestedUserEntity.getHub().getId());
if (activeUsers != null) { if (activeUsers != null) {
widget1.setNumberOfResgisteredUsers(activeUsers); widget1.setNumberOfResgisteredUsers(activeUsers);
} }
@@ -183,10 +183,21 @@ public class DashboardDao {
.map(BeneficiaryPreferredCallEntity::getCallId) .map(BeneficiaryPreferredCallEntity::getCallId)
.collect(Collectors.toList()); .collect(Collectors.toList());
List<CallEntity> callEntities = callRepository.findByIdIn(callIds); List<CallEntity> callEntities = callRepository.findByIdIn(callIds);
long activeCallsCount = callEntities.stream() long activeCallsCount=0;
.filter(call -> CallStatusEnum.PUBLISH.getValue().equals(call.getStatus()) if(Boolean.TRUE.equals(validator.checkIsBeneficiary())) {
&& userEntity.getHub().getId().equals(call.getHub().getId())) activeCallsCount = callEntities.stream()
.count(); .filter(call -> CallStatusEnum.PUBLISH.getValue().equals(call.getStatus())
&& userEntity.getHub().getId().equals(call.getHub().getId()))
.count();
}
if(Boolean.TRUE.equals(validator.checkIsConfidi())) {
activeCallsCount = callEntities.stream()
.filter(call -> CallStatusEnum.PUBLISH.getValue().equals(call.getStatus())
&& userEntity.getHub().getId().equals(call.getHub().getId())
&& call.getConfidi()) // Add this condition for confidi
.count();
}
beneficiaryWidgetResponseBean.setNumberOfCalls(activeCallsCount); beneficiaryWidgetResponseBean.setNumberOfCalls(activeCallsCount);
} }

View File

@@ -128,7 +128,12 @@ public class DelegationDao {
CompanyEntity companyEntity = companyDao.validateCompany(companyId); CompanyEntity companyEntity = companyDao.validateCompany(companyId);
companyDao.getUserWithCompany(userEntity.getId(), companyId); companyDao.getUserWithCompany(userEntity.getId(), companyId);
updatePlaceholdersForDelegation(user, companyEntity, placeholders, companyDelegationRequest); updatePlaceholdersForDelegation(user, companyEntity, placeholders, companyDelegationRequest);
DocumentEntity documentEntity = documentRepository.findBySource(GepafinConstant.DELEGATION_TEMPLATE).get(0); DocumentEntity documentEntity =null;
if(Boolean.TRUE.equals(validator.checkIsConfidi())){
documentEntity = documentRepository.findBySource(GepafinConstant.DELEGATION_TEMPLATE_CONFIDI).get(0);
}else {
documentEntity = documentRepository.findBySource(GepafinConstant.DELEGATION_TEMPLATE).get(0);
}
return generateDocument(placeholders, documentEntity.getFilePath()); return generateDocument(placeholders, documentEntity.getFilePath());
} }
@@ -293,7 +298,7 @@ public class DelegationDao {
if (validator.checkIsPreInstructor()) { if (validator.checkIsPreInstructor()) {
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluationByApplicationId(applicationId); ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluationByApplicationId(applicationId);
validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId()); validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId());
} else if (validator.checkIsBeneficiary()) { } else if (Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
userId = validator.validateUser(request).getId(); userId = validator.validateUser(request).getId();
} }
return companyService.getUserWithCompany(userId, companyId); return companyService.getUserWithCompany(userId, companyId);

View File

@@ -184,8 +184,11 @@ public class EmailNotificationDao {
// Extract data from forms // Extract data from forms
for (ApplicationFormEntity form : forms) { for (ApplicationFormEntity form : forms) {
String content = form.getForm().getContent(); String content = form.getForm().getContent();
List<Map<String, Object>> result = filterByName(content, "fileupload"); List<Map<String, Object>> fileUploadResult = filterByName(content, "fileupload");
allFormFields.addAll(getIdAndLabelFromResult(result)); allFormFields.addAll(getIdAndLabelFromResult(fileUploadResult));
List<Map<String, Object>> fileSelectResult = filterByName(content,GepafinConstant.FILE_SELECT);
allFormFields.addAll(getIdAndLabelFromResult(fileSelectResult));
} }
// Process allFormFields and generate bullet points // Process allFormFields and generate bullet points

View File

@@ -66,7 +66,7 @@ public class FaqDao {
CallEntity callEntity = callService.validateCall(callId); CallEntity callEntity = callService.validateCall(callId);
FaqEntity entity = createOrUpdateFaqEntity(faqRequest, callEntity, userEntity, LookUpDataTypeEnum.FAQ); FaqEntity entity = createOrUpdateFaqEntity(faqRequest, callEntity, userEntity, LookUpDataTypeEnum.FAQ);
FaqEntity oldFaqEntity = Utils.getClonedEntityForData(entity); FaqEntity oldFaqEntity = Utils.getClonedEntityForData(entity);
if (validator.checkIsBeneficiary() && companyId == null) { if ((Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) && companyId == null) {
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.COMPANY_ID_MANDATORY)); throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.COMPANY_ID_MANDATORY));
} }
UserWithCompanyEntity userWithCompanyEntity=null; UserWithCompanyEntity userWithCompanyEntity=null;
@@ -132,7 +132,7 @@ public class FaqDao {
oldFaqEntity = Utils.getClonedEntityForData(faqEntity); oldFaqEntity = Utils.getClonedEntityForData(faqEntity);
actionType = VersionActionTypeEnum.UPDATE; actionType = VersionActionTypeEnum.UPDATE;
} else { } else {
if (Boolean.FALSE.equals(userEntity.getRoleEntity().getRoleType().equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue()))) { if (Boolean.FALSE.equals(userEntity.getRoleEntity().getRoleType().equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue())) && Boolean.FALSE.equals(userEntity.getRoleEntity().getRoleType().equals(RoleStatusEnum.ROLE_CONFIDI.getValue()))) {
lookUpDataService.getOrCreateLookUpDataEntity(faqReq, type); lookUpDataService.getOrCreateLookUpDataEntity(faqReq, type);
} }
faqEntity = new FaqEntity(); faqEntity = new FaqEntity();

View File

@@ -169,7 +169,7 @@ public class UserDao {
} }
private BeneficiaryEntity createBeneficiary(RoleEntity roleEntity, UserReq userReq, HubEntity hub) { private BeneficiaryEntity createBeneficiary(RoleEntity roleEntity, UserReq userReq, HubEntity hub) {
BeneficiaryEntity beneficiaryEntity = null; BeneficiaryEntity beneficiaryEntity = null;
if (RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleEntity.getRoleType())) { if (RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleEntity.getRoleType()) || RoleStatusEnum.ROLE_CONFIDI.getValue().equals(roleEntity.getRoleType())) {
beneficiaryEntity = new BeneficiaryEntity(); beneficiaryEntity = new BeneficiaryEntity();
beneficiaryEntity.setAddress(userReq.getAddress()); beneficiaryEntity.setAddress(userReq.getAddress());
beneficiaryEntity.setCity(userReq.getCity()); beneficiaryEntity.setCity(userReq.getCity());
@@ -765,7 +765,7 @@ public class UserDao {
HubEntity hubEntity = hubService.valdateHub(userEntity.getHub().getId()); HubEntity hubEntity = hubService.valdateHub(userEntity.getHub().getId());
String beneficiaryRoleType = RoleStatusEnum.ROLE_BENEFICIARY.getValue(); String beneficiaryRoleType = RoleStatusEnum.ROLE_BENEFICIARY.getValue();
if (validator.checkIsBeneficiary()) { if (Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())) {
// Validate if the new email already exists for another beneficiary in the same hub // Validate if the new email already exists for another beneficiary in the same hub
boolean emailExistsForBeneficiary = userRepository.existsByEmailIgnoreCaseForBeneficiaries( boolean emailExistsForBeneficiary = userRepository.existsByEmailIgnoreCaseForBeneficiaries(
userReq.getEmail(), hubEntity.getUniqueUuid(), beneficiaryRoleType); userReq.getEmail(), hubEntity.getUniqueUuid(), beneficiaryRoleType);

View File

@@ -4,14 +4,14 @@ import com.fasterxml.jackson.annotation.JsonValue;
public enum MatchModeEnum { public enum MatchModeEnum {
STARTSWITH("Starts with"), STARTSWITH("startsWith"),
ENDSWITH("Ends with"), ENDSWITH("endsWith"),
CONTAINS("Contains"), CONTAINS("contains"),
EQUALS("Equals"), EQUALS("equals"),
DATEIS("Date is"), DATEIS("dateIs"),
DATEISNOT("Date is not"), DATEISNOT("dateIsNot"),
BEFORE("Date is before"), BEFORE("dateBefore"),
AFTER("Date is after"); AFTER("dateAfter");
private String value; private String value;

View File

@@ -8,7 +8,8 @@ public enum RoleStatusEnum {
ROLE_SUPER_ADMIN("ROLE_SUPER_ADMIN"), ROLE_SUPER_ADMIN("ROLE_SUPER_ADMIN"),
ROLE_PRE_INSTRUCTOR("ROLE_PRE_INSTRUCTOR"), ROLE_PRE_INSTRUCTOR("ROLE_PRE_INSTRUCTOR"),
ROLE_GEPAFIN_OPERATOR("ROLE_GEPAFIN_OPERATOR"), ROLE_GEPAFIN_OPERATOR("ROLE_GEPAFIN_OPERATOR"),
ROLE_INSTRUCTOR_MANAGER("ROLE_INSTRUCTOR_MANAGER"); ROLE_INSTRUCTOR_MANAGER("ROLE_INSTRUCTOR_MANAGER"),
ROLE_CONFIDI("ROLE_CONFIDI");
private String value; private String value;

View File

@@ -65,6 +65,7 @@ public enum UserActionContextEnum {
CHECK_COMPANY_VAT_NUMBER("CHECK_COMPANY_VAT_NUMBER"), CHECK_COMPANY_VAT_NUMBER("CHECK_COMPANY_VAT_NUMBER"),
GET_COMPANY_BY_USER("GET_COMPANY_BY_USER"), GET_COMPANY_BY_USER("GET_COMPANY_BY_USER"),
REMOVE_COMPANY_FROM_USER("REMOVE_COMPANY_FROM_USER"), REMOVE_COMPANY_FROM_USER("REMOVE_COMPANY_FROM_USER"),
UPDATE_COMPANY_JSON("UPDATE_COMPANY_JSON"),
/** LookUpData action context **/ /** LookUpData action context **/
CREATE_LOOKUP_DATA("CREATE_LOOKUP_DATA"), CREATE_LOOKUP_DATA("CREATE_LOOKUP_DATA"),
@@ -213,7 +214,8 @@ public enum UserActionContextEnum {
GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION("GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION"), GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION("GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION"),
GET_ALL_USER_ACTION_BY_PAGINATION("GET_ALL_USER_ACTION_BY_PAGINATION"), GET_ALL_USER_ACTION_BY_PAGINATION("GET_ALL_USER_ACTION_BY_PAGINATION"),
GET_ALL_USER_BY_PAGINATION("GET_ALL_USER_BY_PAGINATION"), GET_ALL_USER_BY_PAGINATION("GET_ALL_USER_BY_PAGINATION"),
UPDATE_CALL_END_DATE_AND_TIME("UPDATE_CALL_END_DATE_AND_TIME"); UPDATE_CALL_END_DATE_AND_TIME("UPDATE_CALL_END_DATE_AND_TIME"),
UPDATE_EXPIRED_CALL("UPDATE_EXPIRED_CALL") ;
private final String value; private final String value;

View File

@@ -14,4 +14,6 @@ public class CallPageableRequestBean {
private List<CallStatusEnum> status; private List<CallStatusEnum> status;
private Map<String, FilterCriteria> filters; private Map<String, FilterCriteria> filters;
private Boolean confidi;
} }

View File

@@ -0,0 +1,8 @@
package net.gepafin.tendermanagement.model.request;
import lombok.Data;
@Data
public class LimitRequest {
private Long limit;
}

View File

@@ -54,4 +54,9 @@ public interface CallRepository extends JpaRepository<CallEntity, Long>, JpaSpec
List<CallEntity> findByIdIn(@Param("ids") List<Long> ids); List<CallEntity> findByIdIn(@Param("ids") List<Long> ids);
@Query("SELECT c FROM CallEntity c WHERE c.id IN :ids AND c.status IN :status AND c.confidi= :confidi")
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);
} }

View File

@@ -1,7 +1,10 @@
package net.gepafin.tendermanagement.repositories; package net.gepafin.tendermanagement.repositories;
import org.springframework.data.domain.Pageable;
import java.util.List; import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
@@ -21,5 +24,12 @@ public interface CompanyRepository extends JpaRepository<CompanyEntity, Long> {
CompanyEntity findByVatNumberAndHubId(String vatNumber, Long hubId); CompanyEntity findByVatNumberAndHubId(String vatNumber, Long hubId);
@Query("""
SELECT c FROM CompanyEntity c
WHERE c.vatNumber IS NOT NULL
AND (c.json IS NULL OR c.json = '')
""")
Page<CompanyEntity> findCompaniesWithMissingVatCheck(Pageable pageable);
} }

View File

@@ -1,6 +1,7 @@
package net.gepafin.tendermanagement.repositories; package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.UserEntity; import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@@ -32,6 +33,10 @@ public interface UserRepository extends JpaRepository<UserEntity, Long>, JpaSpec
Long countByStatusAndRoleEntityRoleTypeAndHubId(String status, String roleName, Long hubId); Long countByStatusAndRoleEntityRoleTypeAndHubId(String status, String roleName, Long hubId);
Long countByStatusAndRoleEntityRoleTypeInAndHubId(String status,List<String> roleName, Long hubId);
Optional<UserEntity> findByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId); Optional<UserEntity> findByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
// Boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId); // Boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);

View File

@@ -21,7 +21,7 @@ public interface CallService {
CallResponse getCallById (HttpServletRequest request, Long callId,Long companyId); CallResponse getCallById (HttpServletRequest request, Long callId,Long companyId);
List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall); List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall,Boolean onlyConfidiCall);
CallResponse validateCallData(HttpServletRequest request, Long callId); CallResponse validateCallData(HttpServletRequest request, Long callId);

View File

@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.gepafin.tendermanagement.model.request.LimitRequest;
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean; import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -45,4 +46,6 @@ public interface CompanyService {
UserWithCompanyEntity getUserWithCompanyEntity(Long userId,Long companyId); UserWithCompanyEntity getUserWithCompanyEntity(Long userId,Long companyId);
void removeCompanyFromList(HttpServletRequest request, Long companyId); void removeCompanyFromList(HttpServletRequest request, Long companyId);
void updateMissingVatCheckResponses(HttpServletRequest request, LimitRequest limitRequest);
} }

View File

@@ -81,7 +81,7 @@ public class ApplicationServiceImpl implements ApplicationService {
validator.validateUserWithCompany(request, companyId); validator.validateUserWithCompany(request, companyId);
} }
ApplicationEntity applicationEntity =null; ApplicationEntity applicationEntity =null;
if(validator.checkIsBeneficiary()){ if(Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi())){
if(companyId==null){ if(companyId==null){
throw new ForbiddenAccessException(Status.FORBIDDEN,Translator.toLocale(GepafinConstant.COMPANY_ID_MANDATORY)); throw new ForbiddenAccessException(Status.FORBIDDEN,Translator.toLocale(GepafinConstant.COMPANY_ID_MANDATORY));
} }

View File

@@ -61,10 +61,10 @@ public class CallServiceImpl implements CallService {
} }
@Override @Override
@Transactional(readOnly = true) @Transactional(rollbackFor = Exception.class)
public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall) { public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall,Boolean onlyConfidiCall) {
UserEntity user = validator.validateUser(request); UserEntity user = validator.validateUser(request);
return callDao.getAllCalls(request,user,companyId,onlyPreferredCall); return callDao.getAllCalls(request,user,companyId,onlyPreferredCall,onlyConfidiCall);
} }
@@ -104,6 +104,7 @@ public class CallServiceImpl implements CallService {
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public PageableResponseBean<List<CallDetailsResponseBean>> getAllCallsByPagination(HttpServletRequest request,Long companyId , Boolean onlyPreferredCall, CallPageableRequestBean callPageableRequestBean) { public PageableResponseBean<List<CallDetailsResponseBean>> getAllCallsByPagination(HttpServletRequest request,Long companyId , Boolean onlyPreferredCall, CallPageableRequestBean callPageableRequestBean) {
UserEntity user = validator.validateUser(request); UserEntity user = validator.validateUser(request);
return callDao.getAllCallsByPagination(request,user,companyId,onlyPreferredCall,callPageableRequestBean); return callDao.getAllCallsByPagination(request,user,companyId,onlyPreferredCall,callPageableRequestBean);

View File

@@ -31,7 +31,7 @@ public class CommunicationServiceImpl implements CommunicationService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request ,CommunicationRequestBean communicationRequestBean, Long amendmentId) { public CommunicationResponseBean addCommentToAmendmentRequest(HttpServletRequest request ,CommunicationRequestBean communicationRequestBean, Long amendmentId) {
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId); ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId);
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) { if (Boolean.FALSE.equals(validator.checkIsBeneficiary()) && Boolean.FALSE.equals(validator.checkIsConfidi())) {
validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId()); validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId());
} else { } else {
validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId()); validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
@@ -43,7 +43,7 @@ public class CommunicationServiceImpl implements CommunicationService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String deleteComment(HttpServletRequest request ,Long amendmentId, Long commentId) { public String deleteComment(HttpServletRequest request ,Long amendmentId, Long commentId) {
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId); ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(amendmentId);
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) { if (Boolean.FALSE.equals(validator.checkIsBeneficiary()) && Boolean.FALSE.equals(validator.checkIsConfidi())) {
validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId()); validator.validatePreInstructor(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getUserId());
} else { } else {
validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId()); validator.validateUserId(request, applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());

View File

@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.gepafin.tendermanagement.model.request.LimitRequest;
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean; import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -130,4 +131,10 @@ public class CompanyServiceImpl implements CompanyService {
UserEntity userEntity =validator.validateUser(request); UserEntity userEntity =validator.validateUser(request);
companyDao.removeCompanyFromList(userEntity, companyId); companyDao.removeCompanyFromList(userEntity, companyId);
} }
@Override
public void updateMissingVatCheckResponses(HttpServletRequest request, LimitRequest limitRequest) {
UserEntity userEntity =validator.validateUser(request);
companyDao.updateMissingVatCheckResponses(request, limitRequest);
}
} }

View File

@@ -63,8 +63,8 @@ public class FieldValidator {
if (value != null) { if (value != null) {
if(min!=null) { if(min!=null) {
if(contentResponseBean.getName().equals(GepafinConstant.NUMBER_INPUT)) { if(contentResponseBean.getName().equals(GepafinConstant.NUMBER_INPUT)) {
long numericValue = Long.parseLong(value); // Convert String to Long double numericValue = Double.parseDouble(value); // Use double instead of long
if (numericValue < min) { if (numericValue < min.doubleValue()) {
errors.add(MessageFormat.format( errors.add(MessageFormat.format(
Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MIN), fieldLabel, min)); Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MIN), fieldLabel, min));
} }
@@ -90,8 +90,8 @@ public class FieldValidator {
if (value != null) { if (value != null) {
if (max != null) { if (max != null) {
if(contentResponseBean.getName().equals(GepafinConstant.NUMBER_INPUT)) { if(contentResponseBean.getName().equals(GepafinConstant.NUMBER_INPUT)) {
long numericValue = Long.parseLong(value); // Convert String to Long double numericValue = Double.parseDouble(value); // Convert String to Long
if (numericValue > max) { if (numericValue > max.doubleValue()) {
errors.add(MessageFormat.format( errors.add(MessageFormat.format(
Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MAX), fieldLabel, max)); Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MAX), fieldLabel, max));
} }

View File

@@ -788,4 +788,12 @@ public class Utils {
public static boolean isValidBoolean(String value) { public static boolean isValidBoolean(String value) {
return "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value); return "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
} }
public static Map<String, Object> convertJsonStringToMap(String jsonString) {
try {
return mapper.readValue(jsonString, Map.class);
} catch (Exception e) {
e.printStackTrace(); // Handle the exception
return null;
}
}
} }

View File

@@ -195,4 +195,15 @@ public class Validator {
} }
return false; return false;
} }
public Boolean checkIsConfidi() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null && authentication.isAuthenticated()) {
for (GrantedAuthority authority : authentication.getAuthorities()) {
if (RoleStatusEnum.ROLE_CONFIDI.getValue().equals(authority.getAuthority())) {
return true;
}
}
}
return false;
}
} }

View File

@@ -101,7 +101,7 @@ public interface CallApi {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "", @GetMapping(value = "",
produces = { "application/json" }) produces = { "application/json" })
ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,@RequestParam(value = "companyId", required = false) Long companyId , @RequestParam(value = "onlyPreferredCall", required = false, defaultValue = "false") Boolean onlyPreferredCall); ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,@RequestParam(value = "companyId", required = false) Long companyId , @RequestParam(value = "onlyPreferredCall", required = false, defaultValue = "false") Boolean onlyPreferredCall,@RequestParam(value = "onlyConfidiCall", required = false) Boolean onlyConfidiCall);
@Operation(summary = "Api to validate call", @Operation(summary = "Api to validate call",

View File

@@ -33,7 +33,7 @@ public interface CommunicationApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@PostMapping(value = "/{amendmentId}", produces = { "application/json" }) @PostMapping(value = "/{amendmentId}", produces = { "application/json" })
@PreAuthorize("hasRole('ROLE_PRE_INSTRUCTOR') || hasRole('ROLE_BENEFICIARY') || hasRole('ROLE_INSTRUCTOR_MANAGER')") @PreAuthorize("hasRole('ROLE_PRE_INSTRUCTOR') || hasRole('ROLE_BENEFICIARY') || hasRole('ROLE_INSTRUCTOR_MANAGER') || hasRole('ROLE_CONFIDI')")
ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request, ResponseEntity<Response<CommunicationResponseBean>> addCommentToAmendmentRequest(HttpServletRequest request,
@RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId); @RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId);
@@ -55,7 +55,7 @@ public interface CommunicationApi {
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@PutMapping(value = "/{amendmentId}/{commentId}", produces = { "application/json" }) @PutMapping(value = "/{amendmentId}/{commentId}", produces = { "application/json" })
@PreAuthorize("hasRole('ROLE_PRE_INSTRUCTOR') || hasRole('ROLE_BENEFICIARY') || hasRole('ROLE_INSTRUCTOR_MANAGER')") @PreAuthorize("hasRole('ROLE_PRE_INSTRUCTOR') || hasRole('ROLE_BENEFICIARY') || hasRole('ROLE_INSTRUCTOR_MANAGER') || hasRole('ROLE_CONFIDI')")
ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request, ResponseEntity<Response<CommunicationResponseBean>> updateCommunicationAmendment(HttpServletRequest request,
@RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId, @PathVariable(value = "commentId") Long commentId); @RequestBody @Parameter CommunicationRequestBean communicationResponseBean, @PathVariable(value = "amendmentId") Long amendmentId, @PathVariable(value = "commentId") Long commentId);

View File

@@ -3,9 +3,11 @@ package net.gepafin.tendermanagement.web.rest.api;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.gepafin.tendermanagement.model.request.LimitRequest;
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean; import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@@ -155,4 +157,16 @@ public interface CompanyApi {
ResponseEntity<Response<Void>> removeCompanyFromList(HttpServletRequest request, ResponseEntity<Response<Void>> removeCompanyFromList(HttpServletRequest request,
@Parameter(description = "The company id", required = true) @PathVariable("companyId") Long companyId); @Parameter(description = "The company id", required = true) @PathVariable("companyId") Long companyId);
@Operation(summary = "Api to update company with no data through script", 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) })) })
@PostMapping(value = "/updateCompanyJson", produces = { "application/json" })
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN') ")
ResponseEntity<Response<Void>> updateMissingVatCheckResponses(HttpServletRequest request,
@Parameter(description = "Limit request object ", required = true) @RequestBody LimitRequest limitRequest);
} }

View File

@@ -93,13 +93,13 @@ public class CallApiController implements CallApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall) { public ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall,Boolean onlyConfidiCall) {
/** This code is responsible for creating user action logs for the "get all Calls" operation. **/ /** This code is responsible for creating user action logs for the "get all Calls" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW) loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
.actionContext(UserActionContextEnum.GET_CALL).build()); .actionContext(UserActionContextEnum.GET_CALL).build());
List<CallDetailsResponseBean> calls = callService.getAllCalls(request, companyId, onlyPreferredCall); List<CallDetailsResponseBean> calls = callService.getAllCalls(request, companyId, onlyPreferredCall,onlyConfidiCall);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(calls, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG))); .body(new Response<>(calls, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));

View File

@@ -6,6 +6,7 @@ import java.util.Map;
import net.gepafin.tendermanagement.enums.UserActionContextEnum; import net.gepafin.tendermanagement.enums.UserActionContextEnum;
import net.gepafin.tendermanagement.enums.UserActionLogsEnum; import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
import net.gepafin.tendermanagement.model.request.LimitRequest;
import net.gepafin.tendermanagement.model.request.UserActionRequest; import net.gepafin.tendermanagement.model.request.UserActionRequest;
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean; import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
import net.gepafin.tendermanagement.util.LoggingUtil; import net.gepafin.tendermanagement.util.LoggingUtil;
@@ -188,4 +189,16 @@ public class CompanyApiController implements CompanyApi{
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_DELETE_SUCCESS_MSG))); .body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_DELETE_SUCCESS_MSG)));
} }
@Override
public ResponseEntity<Response<Void>> updateMissingVatCheckResponses(HttpServletRequest request, LimitRequest limitRequest) {
log.info("Api to update company json field");
/** This code is responsible for creating user action logs for the "Update company json field" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE).actionContext(UserActionContextEnum.UPDATE_COMPANY_JSON).build());
companyService.updateMissingVatCheckResponses(request, limitRequest);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_UPDATED_SUCCESS_MSG)));
}
} }

View File

@@ -2561,5 +2561,84 @@
<sqlFile dbms="postgresql" <sqlFile dbms="postgresql"
path="db/dump/update_form_field_data_03-03-2025.sql"/> path="db/dump/update_form_field_data_03-03-2025.sql"/>
</changeSet> </changeSet>
<changeSet id="05-03-2025_NK_190115" author="Nisha Kashyap">
<sql dbms="postgresql">select
setval('gepafin_schema.role_id_seq', (select
max(id)+1
from gepafin_schema.role), false)
</sql>
<sql dbms="postgresql">select
setval('gepafin_schema.beneficiary_id_seq', (select
max(id)+1
from gepafin_schema.beneficiary), false)
</sql>
<insert tableName="role">
<column name="role_name" value="confidi"/>
<column name="role_type" value="ROLE_CONFIDI"/>
<column name="description"
value="Companies or individuals looking for financing opportunities. They can view, search, and apply to available confidi calls."/>
<column name="created_date" value="2025-03-05 00:00:00"/>
<column name="updated_date" value="2025-03-05 00:00:00"/>
<column name="permissions" value="VIEW_CONFIDI_CALLS, APPLY_CONFIDI_CALLS"/>
<column name="region_id" valueComputed="1"/>
</insert>
<insert tableName="BENEFICIARY">
<column name="EMAIL" value="confidi@test.test"/>
<column name="FIRST_NAME" value="Test"/>
<column name="LAST_NAME" value="Confidi"/>
<column name="PHONE_NUMBER" value="1234567890"/>
<column name="ORGANIZATION" value="ConfidiOrg"/>
<column name="ADDRESS" value="789 Victory Road"/>
<column name="CITY" value="Naples"/>
<column name="COUNTRY" value="Italy"/>
<column name="CODICE_FISCALE" value="0123456789"/>
<column name="DATE_OF_BIRTH" value="1985-06-15T00:00:00"/>
<column name="PRIVACY" value="true"/>
<column name="TERMS" value="true"/>
<column name="MARKETING" value="false"/>
<column name="OFFERS" value="true"/>
<column name="THIRD_PARTY" value="false"/>
<column name="HUB_ID" value="1"/>
</insert>
<insert tableName="GEPAFIN_USER">
<column name="email" value="confidi@test.test"/>
<column name="password" value="$2a$10$doUyOcEm8WPuFfpFT5y18.1DvZzF7exbqgy9X0P27cUBK7YWbfzzS"/>
<column name="first_name" value="Test"/>
<column name="last_name" value="Confidi"/>
<column name="last_login" value="2024-03-05T12:00:00"/>
<column name="organization" value="ConfidiOrg"/>
<column name="role_id" valueComputed="(SELECT id FROM role WHERE role_type = 'ROLE_CONFIDI')"/>
<column name="status" value="ACTIVE"/>
<column name="last_login" value="2024-12-19 00:00:00"/>
<column name="organization" value="ConfidiOrg"/>
<column name="address" value="789 Victory Road"/>
<column name="city" value="Naples"/>
<column name="country" value="Italy"/>
<column name="hub_id" value="1"/>
<column name="beneficiary_id" valueComputed="(SELECT id FROM BENEFICIARY WHERE EMAIL = 'confidi@test.test' ORDER BY id DESC LIMIT 1)"/>
</insert>
</changeSet>
<changeSet id="06-03-2025_NK_190111" author="Nisha Kashyap">
<update tableName="role">
<column name="permissions" value="VIEW_CONFIDI_CALLS,APPLY_CONFIDI_CALLS"/>
<where>role_type = 'ROLE_CONFIDI'</where>
</update>
</changeSet>
<changeSet id="10-03-2025_NK_180430" author="Nisha Kashyap">
<insert tableName="document">
<column name="file_name" value="PROCURA_BANDI_TEMPLATE_CONFIDI.DOCX"></column>
<column name="file_path" value="https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/local/template/PROCURA_BANDI_TEMPLATE_CONFIDI.docx"></column>
<column name="type" value="DOCUMENT"></column>
<column name="source" value="DELEGATION_TEMPLATE_CONFIDI"></column>
</insert>
</changeSet>
<changeSet id="12-03-2025_NK_180530" author="Nisha Kashyap">
<sqlFile dbms="postgresql"
path="db/dump/update_form_field_data_12-03-2025.sql"/>
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View File

@@ -0,0 +1,6 @@
UPDATE FORM_FIELD
SET LABEL = 'Seleziona File',
SETTINGS = '[{"name": "label", "value": "Seleziona File"},{"name": "documentCategories", "value": []},{"name": "isDelegation", "value": false}]',
UPDATED_DATE = CURRENT_TIMESTAMP
WHERE NAME = 'fileselect';

View File

@@ -394,4 +394,5 @@ appointment.cannot.be.created = Appointment cannot be created because call doesn
appointment.not.created = Appointment not created please try again. appointment.not.created = Appointment not created please try again.
validation.failed.checklist=Validation failed for checklist. validation.failed.checklist=Validation failed for checklist.
error.invalid.limit=Limit should be between 1 and 3000.
insufficient.score.msg = Insufficient score to pass to the technical and economic-financial evaluation insufficient.score.msg = Insufficient score to pass to the technical and economic-financial evaluation

View File

@@ -385,4 +385,5 @@ appointment.cannot.be.created = Impossibile creare l'appuntamento perch<63> la ch
appointment.not.created = Appuntamento non creato, riprova appointment.not.created = Appuntamento non creato, riprova
validation.failed.checklist=Convalida fallita per la checklist. validation.failed.checklist=Convalida fallita per la checklist.
error.invalid.limit=Il limite dovrebbe essere compreso tra 1 e 3000.
insufficient.score.msg = Punteggio non sufficiente per passaggio alla valutazione tecnica ed economico finanziaria insufficient.score.msg = Punteggio non sufficiente per passaggio alla valutazione tecnica ed economico finanziaria