Resolved Conflicts
This commit is contained in:
@@ -181,6 +181,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
for (ApplicationFormEntity form : forms) {
|
||||
String content = form.getForm().getContent();
|
||||
List<Map<String, Object>> result = filterByName(content, "fileupload");
|
||||
result.addAll(filterByName(content, GepafinConstant.FILE_SELECT));
|
||||
List<AmendmentFormFieldResponse> amendmentFormFieldResponses= getIdAndLabelFromResult(result);
|
||||
amendmentFormFieldResponses.removeIf(amendmentFormFieldResponse -> {
|
||||
FieldRequest matchingRequest = fieldRequestMap.get(amendmentFormFieldResponse.getFieldId());
|
||||
@@ -533,12 +534,15 @@ public class ApplicationAmendmentRequestDao {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, String> extractFieldIdToLabelMap(List<ApplicationFormEntity> forms) {
|
||||
return forms.stream()
|
||||
.flatMap(form -> {
|
||||
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));
|
||||
}
|
||||
@@ -678,7 +682,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
log.info("Updating application amendement with ID: {}", id);
|
||||
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
||||
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());
|
||||
isBeneficiary=false;
|
||||
} else {
|
||||
@@ -1368,10 +1372,10 @@ public class ApplicationAmendmentRequestDao {
|
||||
.toList();
|
||||
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));
|
||||
}
|
||||
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||
else {
|
||||
predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("userId").in(userId));
|
||||
}
|
||||
|
||||
|
||||
@@ -389,7 +389,7 @@ public class ApplicationDao {
|
||||
return (root, query, builder) -> {
|
||||
Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||
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()));
|
||||
}
|
||||
if (callId != null) {
|
||||
@@ -742,7 +742,7 @@ public class ApplicationDao {
|
||||
List<FormApplicationResponse> formApplicationResponses = new ArrayList<>();
|
||||
List<FormEntity> formEntities = new ArrayList<>();
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
boolean isBeneficiary = isBeneficiary(userEntity);
|
||||
boolean isBeneficiary = Boolean.TRUE.equals(validator.checkIsBeneficiary()) || Boolean.TRUE.equals(validator.checkIsConfidi());
|
||||
ApplicationEntity applicationEntity = isBeneficiary
|
||||
? applicationRepository.findByIdAndUserIdAndIsDeletedFalse(applicationId, userEntity.getId())
|
||||
.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<>();
|
||||
|
||||
Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||
if (isBeneficiary) {
|
||||
// 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) {
|
||||
|
||||
@@ -378,6 +378,9 @@ public class ApplicationEvaluationDao {
|
||||
case "fileupload":
|
||||
mapFileFieldDetails(mappedField, formFieldId, applicationForm.getId(), applicationId);
|
||||
break;
|
||||
case "fileselect":
|
||||
mapFileFieldDetails(mappedField, formFieldId, applicationForm.getId(), applicationId);
|
||||
break;
|
||||
case "checkboxes":
|
||||
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentBean);
|
||||
break;
|
||||
@@ -516,7 +519,7 @@ public class ApplicationEvaluationDao {
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
contentResponseBeans.forEach(contentResponseBean -> {
|
||||
// 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;
|
||||
// Set the label if available
|
||||
if (contentResponseBean.getSettings() != null) {
|
||||
@@ -742,7 +745,7 @@ public class ApplicationEvaluationDao {
|
||||
applicationAmendmentRequestEntities.forEach(applicationAmendmentRequestEntity->{
|
||||
ApplicationAmendmentRequestEntity oldEntity = Utils.getClonedEntityForData(applicationAmendmentRequestEntity);
|
||||
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);
|
||||
|
||||
@@ -884,7 +887,9 @@ public class ApplicationEvaluationDao {
|
||||
amendmentFormField.setValid(amendmentDetailsRequest.getValid());
|
||||
}
|
||||
});
|
||||
applicationAmendmentRequestEntity.setFormFields(Utils.convertListToJsonString(formFieldsMap.values().stream().toList()));
|
||||
if(Boolean.FALSE.equals(CollectionUtils.isEmpty(formFieldsMap))) {
|
||||
applicationAmendmentRequestEntity.setFormFields(Utils.convertListToJsonString(formFieldsMap.values().stream().toList()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1252,7 +1257,9 @@ public class ApplicationEvaluationDao {
|
||||
case "fileupload":
|
||||
populateFileDetailsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId);
|
||||
break;
|
||||
|
||||
case "fileselect":
|
||||
populateFileDetailsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId);
|
||||
break;
|
||||
case "checkboxes":
|
||||
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentResponseBean);
|
||||
break;
|
||||
@@ -1402,7 +1409,7 @@ public class ApplicationEvaluationDao {
|
||||
// List<ContentResponseBean> contentResponseBeans = Utils.convertJsonStringToList(formEntity.getContent(), ContentResponseBean.class);
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
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;
|
||||
if (contentResponseBean.getSettings() != null) {
|
||||
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||
@@ -1564,9 +1571,10 @@ public class ApplicationEvaluationDao {
|
||||
mappedField.setFieldName(contentResponseBean.getName());
|
||||
boolean isCheckbox = "checkboxes".equals(contentResponseBean.getName());
|
||||
boolean isFileUpload = "fileupload".equals(contentResponseBean.getName());
|
||||
boolean isFileSelect = GepafinConstant.FILE_SELECT.equals(contentResponseBean.getName());
|
||||
boolean isParagraph = "paragraph".equals(contentResponseBean.getName());
|
||||
boolean isTable = "table".equals(contentResponseBean.getName());
|
||||
if (isFileUpload) {
|
||||
if (isFileUpload || isFileSelect ) {
|
||||
handleFileUpload(applicationId, criteriaFormField, mappedField);
|
||||
} else if (isCheckbox) {
|
||||
handleCheckbox(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||
@@ -1773,7 +1781,7 @@ public class ApplicationEvaluationDao {
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
|
||||
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
|
||||
if ("fileupload".equals(contentResponseBean.getName())) {
|
||||
if ("fileupload".equals(contentResponseBean.getName()) || GepafinConstant.FILE_SELECT.equals(contentResponseBean.getName())) {
|
||||
String fieldId = contentResponseBean.getId();
|
||||
Long applicationFormId = applicationForm.getId();
|
||||
|
||||
@@ -2103,7 +2111,8 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
List<ContentResponseBean> contentResponseBeans=evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity).getContent();
|
||||
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())) {
|
||||
Object fieldValueObject = applicationFormFieldRequestBean.getFieldValue();
|
||||
if (fieldValueObject instanceof String) {
|
||||
@@ -2128,7 +2137,8 @@ public class ApplicationEvaluationDao {
|
||||
for (ApplicationEvaluationFormFieldEntity applicationEvaluationFormFieldEntity : evaluationFormFieldEntities) {
|
||||
|
||||
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()))
|
||||
.findFirst();
|
||||
|
||||
|
||||
@@ -214,6 +214,7 @@ public class AssignedApplicationsDao {
|
||||
assignedApplicationsResponse.setAppointmentTemplateId(application.getCall().getAppointmentTemplateId());
|
||||
assignedApplicationsResponse.setNdg(application.getNdg());
|
||||
assignedApplicationsResponse.setAppointmentId(application.getAppointmentId());
|
||||
assignedApplicationsResponse.setApplicationStatus(ApplicationStatusTypeEnum.valueOf(application.getStatus()));
|
||||
return assignedApplicationsResponse;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@ import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
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.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
@@ -781,30 +785,45 @@ public class CallDao {
|
||||
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();
|
||||
List<String> callStatusList = CallStatusEnum.getStatusValues();
|
||||
if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) {
|
||||
callStatusList = List.of(CallStatusEnum.PUBLISH.getValue());
|
||||
}
|
||||
List<CallEntity> calls;
|
||||
// List<CallEntity> calls = List.of();
|
||||
if (Boolean.TRUE.equals(onlyPreferredCall) && companyId == null) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL));
|
||||
}
|
||||
Specification<CallEntity> spec = buildCallSpecification(request, user, companyId, onlyPreferredCall, onlyConfidiCall, 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());
|
||||
calls = callRepository.findByIdInAndStatusIn(preferredCallIds, callStatusList);
|
||||
} else {
|
||||
calls = callRepository.findByStatusInAndHubId(callStatusList, user.getHub().getId());
|
||||
List<CallEntity> calls = callRepository.findAll(spec);
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
for (CallEntity call : calls) {
|
||||
CallEntity oldCallEntity = Utils.getClonedEntityForData(call);
|
||||
if (CallStatusEnum.PUBLISH.getValue().equals(call.getStatus()) &&
|
||||
call.getEndDate() != null && call.getEndTime() != null) {
|
||||
LocalDateTime callEndDateTime = LocalDateTime.of(LocalDate.from(call.getEndDate()), call.getEndTime());
|
||||
if (callEndDateTime.isBefore(now)) {
|
||||
call.setStatus(CallStatusEnum.EXPIRED.getValue());
|
||||
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());
|
||||
Map<String, BeneficiaryPreferredCallEntity> preferredCallsMap =
|
||||
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) {
|
||||
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);
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(),companyId);
|
||||
beneficiaryPreferredCalls = beneficiaryPreferredCallRepository
|
||||
@@ -981,7 +1000,7 @@ public class CallDao {
|
||||
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;
|
||||
if (Boolean.TRUE.equals(onlyPreferredCall)) {
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
@@ -994,7 +1013,10 @@ public class CallDao {
|
||||
|
||||
// Add preferredCallIds filtering to the specification
|
||||
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));
|
||||
@@ -1028,10 +1050,10 @@ public class CallDao {
|
||||
return pageableResponseBean;
|
||||
}
|
||||
|
||||
public Specification<CallEntity> search(UserEntity userEntity, CallPageableRequestBean callPageableRequestBean) {
|
||||
public Specification<CallEntity> search(HttpServletRequest request,UserEntity userEntity, CallPageableRequestBean callPageableRequestBean) {
|
||||
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);
|
||||
|
||||
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) {
|
||||
|
||||
expirePublishedCalls(request);
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
Map<String, FilterCriteria> filters = new HashMap<>();
|
||||
@@ -1110,13 +1132,84 @@ public class CallDao {
|
||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||
}
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
if (Boolean.FALSE.equals(filters.isEmpty())) {
|
||||
for (Map.Entry<String, FilterCriteria> entry : filters.entrySet()) {
|
||||
@@ -1251,4 +1344,47 @@ public class CallDao {
|
||||
createCallResponseBean.setCurrentStep(GepafinConstant.EVALUATION_V2_STEP_2);
|
||||
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]));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class CommunicationDao {
|
||||
if(validator.checkIsPreInstructor()){
|
||||
communicationEntity.setSenderUserId(amendmentRequest.getApplicationEvaluationEntity().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.setReceiverUserId(amendmentRequest.getApplicationEvaluationEntity().getUserId());
|
||||
}
|
||||
|
||||
@@ -1,23 +1,33 @@
|
||||
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;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
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.service.CompanyService;
|
||||
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;
|
||||
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 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.util.Utils;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.convertObjectToJsonString;
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Component
|
||||
@Log4j2
|
||||
public class CompanyDao {
|
||||
|
||||
@Autowired
|
||||
@@ -60,6 +72,13 @@ public class CompanyDao {
|
||||
@Autowired
|
||||
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) {
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -258,30 +258,29 @@ public class CompanyDocumentDao {
|
||||
return userActionContext;
|
||||
}
|
||||
|
||||
public DocumentResponseBean validateAndDuplicateCompanyDocument(HttpServletRequest request , Long userId ,Long companyDocumentId , Long applicationId , DocumentTypeEnum documentTypeEnum){
|
||||
public DocumentResponseBean createDuplicateCompanyDocument(HttpServletRequest request , Long userId ,Long companyDocumentId , Long applicationId , DocumentTypeEnum documentTypeEnum){
|
||||
ApplicationEntity applicationEntity = applicationService.validateApplication(applicationId);
|
||||
CompanyDocumentEntity companyDocumentEntity = validateCompanyDocument(companyDocumentId);
|
||||
validator.validateUserWithCompany(request,companyDocumentEntity.getCompanyId());
|
||||
|
||||
String oldS3Path = companyDocumentEntity.getFilePath();
|
||||
String newS3Path = s3ConfigBean.generateDocumentPath(DocumentSourceTypeEnum.APPLICATION,applicationEntity.getCall().getId(),applicationId,0L);
|
||||
String companyDocumentPath = companyDocumentEntity.getFilePath();
|
||||
String documentPath = s3ConfigBean.generateDocumentPath(DocumentSourceTypeEnum.APPLICATION,applicationEntity.getCall().getId(),applicationId,0L);
|
||||
|
||||
log.info("Original Paths - oldPath: {}, newPath: {}", oldS3Path, newS3Path);
|
||||
log.info("Original Paths - oldPath: {}, newPath: {}", companyDocumentPath, documentPath);
|
||||
|
||||
oldS3Path = amazonS3ServiceImpl.decodeS3Key(amazonS3ServiceImpl.cleanOldPath(oldS3Path));
|
||||
newS3Path = amazonS3ServiceImpl.cleanNewPath(oldS3Path, newS3Path);
|
||||
log.info("Moving file from {} to {} in bucket {}", oldS3Path, newS3Path, bucketName);
|
||||
UploadFileOnAmazonS3Response response;
|
||||
try {
|
||||
response = amazonS3ServiceImpl.copyFile(companyDocumentEntity.getName(), companyDocumentPath, documentPath);
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while uploading file from Amazon S3: {}", e);
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
||||
}
|
||||
|
||||
CopyObjectRequest copyRequest = new CopyObjectRequest(bucketName, oldS3Path, bucketName, newS3Path);
|
||||
s3Client.copyObject(copyRequest);
|
||||
log.info("File copied successfully from {} to {}", oldS3Path, newS3Path);
|
||||
|
||||
URL amazonS3Url = amazonS3.getUrl(bucketName, newS3Path);
|
||||
String fileUrl = amazonS3Url.toString();
|
||||
|
||||
DocumentEntity entity = new DocumentEntity();
|
||||
entity.setFilePath(fileUrl);
|
||||
entity.setFileName(companyDocumentEntity.getFileName());
|
||||
entity.setFilePath(response.getFilePath());
|
||||
entity.setFileName(response.getFileName());
|
||||
entity.setSource(DocumentSourceTypeEnum.APPLICATION.getValue());
|
||||
entity.setType(documentTypeEnum.getValue());
|
||||
entity.setSourceId(applicationId);
|
||||
|
||||
@@ -136,8 +136,8 @@ public class DashboardDao {
|
||||
}
|
||||
|
||||
private void setRegisteredUsers(Widget1 widget1, UserEntity requestedUserEntity) {
|
||||
Long activeUsers = userRepository.countByStatusAndRoleEntityRoleTypeAndHubId(UserStatusEnum.ACTIVE.getValue(),
|
||||
RoleStatusEnum.ROLE_BENEFICIARY.getValue(), requestedUserEntity.getHub().getId());
|
||||
Long activeUsers = userRepository.countByStatusAndRoleEntityRoleTypeInAndHubId(UserStatusEnum.ACTIVE.getValue(),
|
||||
List.of(RoleStatusEnum.ROLE_BENEFICIARY.getValue(),RoleStatusEnum.ROLE_CONFIDI.getValue()), requestedUserEntity.getHub().getId());
|
||||
if (activeUsers != null) {
|
||||
widget1.setNumberOfResgisteredUsers(activeUsers);
|
||||
}
|
||||
@@ -183,10 +183,21 @@ public class DashboardDao {
|
||||
.map(BeneficiaryPreferredCallEntity::getCallId)
|
||||
.collect(Collectors.toList());
|
||||
List<CallEntity> callEntities = callRepository.findByIdIn(callIds);
|
||||
long activeCallsCount = callEntities.stream()
|
||||
.filter(call -> CallStatusEnum.PUBLISH.getValue().equals(call.getStatus())
|
||||
&& userEntity.getHub().getId().equals(call.getHub().getId()))
|
||||
.count();
|
||||
long activeCallsCount=0;
|
||||
if(Boolean.TRUE.equals(validator.checkIsBeneficiary())) {
|
||||
activeCallsCount = callEntities.stream()
|
||||
.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);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,12 @@ public class DelegationDao {
|
||||
CompanyEntity companyEntity = companyDao.validateCompany(companyId);
|
||||
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -293,7 +298,7 @@ public class DelegationDao {
|
||||
if (validator.checkIsPreInstructor()) {
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluationByApplicationId(applicationId);
|
||||
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();
|
||||
}
|
||||
return companyService.getUserWithCompany(userId, companyId);
|
||||
|
||||
@@ -184,8 +184,11 @@ public class EmailNotificationDao {
|
||||
// Extract data from forms
|
||||
for (ApplicationFormEntity form : forms) {
|
||||
String content = form.getForm().getContent();
|
||||
List<Map<String, Object>> result = filterByName(content, "fileupload");
|
||||
allFormFields.addAll(getIdAndLabelFromResult(result));
|
||||
List<Map<String, Object>> fileUploadResult = filterByName(content, "fileupload");
|
||||
allFormFields.addAll(getIdAndLabelFromResult(fileUploadResult));
|
||||
|
||||
List<Map<String, Object>> fileSelectResult = filterByName(content,GepafinConstant.FILE_SELECT);
|
||||
allFormFields.addAll(getIdAndLabelFromResult(fileSelectResult));
|
||||
}
|
||||
|
||||
// Process allFormFields and generate bullet points
|
||||
|
||||
@@ -66,7 +66,7 @@ public class FaqDao {
|
||||
CallEntity callEntity = callService.validateCall(callId);
|
||||
FaqEntity entity = createOrUpdateFaqEntity(faqRequest, callEntity, userEntity, LookUpDataTypeEnum.FAQ);
|
||||
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));
|
||||
}
|
||||
UserWithCompanyEntity userWithCompanyEntity=null;
|
||||
@@ -132,7 +132,7 @@ public class FaqDao {
|
||||
oldFaqEntity = Utils.getClonedEntityForData(faqEntity);
|
||||
actionType = VersionActionTypeEnum.UPDATE;
|
||||
} 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);
|
||||
}
|
||||
faqEntity = new FaqEntity();
|
||||
|
||||
@@ -49,7 +49,8 @@ public class ProtocolDao {
|
||||
LocalDateTime utcDateTime = DateTimeUtil.DateServerToUTC(LocalDateTime.now());
|
||||
protocolEntity.setYear(utcDateTime.getYear());
|
||||
protocolEntity.setProtocolNumber(protocolNumber);
|
||||
protocolEntity.setTime(LocalTime.now());
|
||||
LocalTime time = utcDateTime.toLocalTime().withNano(0);
|
||||
protocolEntity.setTime(time);
|
||||
protocolEntity.setApplicationId(applicationEntity.getId());
|
||||
protocolEntity.setHubId(hubId);
|
||||
if(Boolean.TRUE.equals(isForApplication)){
|
||||
|
||||
@@ -195,7 +195,7 @@ public class UserDao {
|
||||
|
||||
private BeneficiaryEntity createBeneficiary(RoleEntity roleEntity, UserReq userReq, HubEntity hub) {
|
||||
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.setAddress(userReq.getAddress());
|
||||
beneficiaryEntity.setCity(userReq.getCity());
|
||||
@@ -791,7 +791,7 @@ public class UserDao {
|
||||
HubEntity hubEntity = hubService.valdateHub(userEntity.getHub().getId());
|
||||
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
|
||||
boolean emailExistsForBeneficiary = userRepository.existsByEmailIgnoreCaseForBeneficiaries(
|
||||
userReq.getEmail(), hubEntity.getUniqueUuid(), beneficiaryRoleType);
|
||||
|
||||
Reference in New Issue
Block a user