Merge pull request #232 from Kitzanos/develop
Sync Master with develop (04/03/2025)
This commit is contained in:
@@ -391,6 +391,16 @@ public class GepafinConstant {
|
||||
public static final String NON_EMPTY_TABLES="nonEmptyTables";
|
||||
public static final String VALIDATION_IN_TABLE = "validation.table.message";
|
||||
public static final String CALL_EXPIRED="call.expired";
|
||||
public static final String PROTOCOL="protocol";
|
||||
public static final String PROTOCOL_NUMBER="protocolNumber";
|
||||
public static final String NOTE="note";
|
||||
public static final String INTERNAL_NOTE="internalNote";
|
||||
public static final String ACTION_TYPE="actionType";
|
||||
public static final String ACTION_CONTEXT="actionContext";
|
||||
public static final String METHOD_TYPE="methodType";
|
||||
|
||||
|
||||
|
||||
public static final String AMOUNT_REQUEST_SHOULD_GREATED_THEN_ZERO = "amount.request.should.greated.then.zero";
|
||||
|
||||
|
||||
@@ -424,8 +434,57 @@ public class GepafinConstant {
|
||||
public static final String FORMULA_AMOUNT_NOT_MATCHED="formula.amount.not.matches.requested.amount";
|
||||
public static final String CRITERIA_TABLE_COLUMNS="criteria_table_columns";
|
||||
|
||||
public static final String COMPANY_DOCUMENT_NOT_FOUND = "company.document.not.found";
|
||||
public static final String COMPANY_DOCUMENT_UPDATED_SUCCESSFULLY = "company.document.updated.successfully";
|
||||
public static final String COMPANY_DOCUMENT_COPIED_SUCCESSFULLY = "company.document.copied.successfully";
|
||||
public static final String COMPANY_DOCUMENT_FETCHED_SUCCESSFULLY = "company.document.fetched.successfully";
|
||||
|
||||
public static final String DOCUMENT_CATEGORY_CREATE_SUCCESS = "document.category.success";
|
||||
public static final String DOCUMENT_CATEGORY_GET_SUCCESS = "document.category.get.success";
|
||||
public static final String DOCUMENT_CATEGORY_NOT_FOUND = "document.category.not.found";
|
||||
public static final String DOCUMENT_CATEGORY_DELETE_SUCCESS = "document.category.delete.success";
|
||||
public static final String DOCUMENT_CATEGORY_UPDATE_SUCCESS = "document.category.update.success";
|
||||
public static final String ERROR_MOVING_FILE_TO_DELETED_FOLDER = "error.moving.file.to.deleted.folder";
|
||||
|
||||
public static final String CATEGORY_CANNOT_BE_DELETED = "category.cannot.be.deleted";
|
||||
public static final String INVALID_EXPIRATION_DATE = "invalid.expiration.date";
|
||||
public static final String LABEL="label";
|
||||
public static final String FORMULA="formula";
|
||||
public static final String VARIABLE="variable";
|
||||
public static final String TOTAL="total";
|
||||
public static final String NUMBER_INPUT="numberinput";
|
||||
public static final String CHECK_BOXES="checkboxes";
|
||||
public static final String VALIDATION_FIELD_MAX = "validation.field.max_value";
|
||||
public static final String VALIDATION_FIELD_MIN = "validation.field.min_value";
|
||||
public static final String VALIDATION_FIELD_MAX_CHECK_BOX = "validation.field.max.checkbox";
|
||||
public static final String VALIDATION_FIELD_MIN_CHECK_BOX = "validation.field.min.checkbox";
|
||||
|
||||
|
||||
|
||||
|
||||
public static final String APPOINTMENT_CANNOT_BE_CREATED = "appointment.cannot.be.created";
|
||||
public static final String APPOINTMENT_NOT_CREATED = "appointment.not.created";
|
||||
|
||||
public static final String CALL_TITLE = "callTitle";
|
||||
public static final String CALL_ID="callId";
|
||||
public static final String CALL_END_DATE="callEndDate";
|
||||
public static final String END_DATE="endDate";
|
||||
|
||||
public static final String MODIFIED_DATE="modifiedDate";
|
||||
public static final String CALL_END_TIME="callEndTime";
|
||||
public static final String END_TIME="endTime";
|
||||
public static final String UPDATED_DATE="updatedDate";
|
||||
|
||||
public static final String SWITCH="switch";
|
||||
public static final String IS_CHECK_LIST_ITEM="isChecklistItem";
|
||||
public static final String VALIDATION_FAILED_FOR_CHECKLIST="validation.failed.checklist";
|
||||
public static final String INSUFFICIENT_SCORE_MESSAGE ="insufficient.score.msg";
|
||||
public static final String PEC_SERVICE_URL="https://ws.pecmassiva.com";
|
||||
public static final String PEC_SERVICE_SEND_MAIL="/send";
|
||||
public static final String PEC_SERVICE_INBOX_MAIL="/quota/inbox";
|
||||
public static final String USAGE="usage";
|
||||
public static final String LIMIT="limit";
|
||||
public static final String DATA="data";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@ package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Join;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
@@ -12,6 +14,7 @@ import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEm
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.SortBy;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.*;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
@@ -25,6 +28,8 @@ import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -37,6 +42,7 @@ import java.util.stream.Collectors;
|
||||
import static java.time.temporal.ChronoUnit.DAYS;
|
||||
import static net.gepafin.tendermanagement.util.Utils.log;
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
|
||||
@Component
|
||||
public class ApplicationAmendmentRequestDao {
|
||||
@@ -119,6 +125,15 @@ public class ApplicationAmendmentRequestDao {
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private EvaluationFormRepository evaluationFormRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationFormFieldRepository applicationEvaluationFormFieldRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationFormRepository applicationEvaluationFormRepository;
|
||||
|
||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
|
||||
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
||||
@@ -132,16 +147,10 @@ public class ApplicationAmendmentRequestDao {
|
||||
if(file != null){
|
||||
evaluationFileRequests=Utils.convertJsonStringToList(file,FieldRequest.class);
|
||||
}
|
||||
Boolean allValid = evaluationFileRequests.stream()
|
||||
.anyMatch(fieldRequest -> fieldRequest.getValid() == null);
|
||||
if(checkList != null) {
|
||||
checklistRequests=Utils.convertJsonStringToList(checkList,ChecklistRequest.class);
|
||||
}
|
||||
boolean resultCheckList = checklistRequests.stream()
|
||||
.anyMatch(checklistRequest -> Boolean.TRUE.equals(checklistRequest.getValid())) ? false : true;
|
||||
|
||||
if(Boolean.TRUE.equals(allValid) || Boolean.TRUE.equals(resultCheckList)){
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.All_DOCUMENT_CHECKED_AND_ONE_CHECKLIST_CHECKED));
|
||||
if(applicationEvaluationEntity.getEvaluationVersion().equals(EvaluationVersionEnum.V1.getValue())) {
|
||||
checklistValidationForEvaluationV1(evaluationFileRequests, checkList, checklistRequests);
|
||||
} else if (applicationEvaluationEntity.getEvaluationVersion().equals(EvaluationVersionEnum.V2.getValue())) {
|
||||
validationCheckEvaluationV2(applicationEvaluationEntity, application);
|
||||
}
|
||||
// Set common application-level details
|
||||
String callName = application.getCall().getName();
|
||||
@@ -186,6 +195,47 @@ public class ApplicationAmendmentRequestDao {
|
||||
return response;
|
||||
}
|
||||
|
||||
private void validationCheckEvaluationV2(ApplicationEvaluationEntity applicationEvaluationEntity, ApplicationEntity application) {
|
||||
Long callId= applicationEvaluationEntity.getAssignedApplicationsEntity().getApplication().getCall().getId();
|
||||
EvaluationFormEntity evaluationFormEntity=evaluationFormRepository.findByCallIdAndIsDeletedFalse(callId);
|
||||
Long numberOfCheck= application.getCall().getNumberOfCheck();
|
||||
ApplicationEvaluationFormEntity applicationEvaluationForm=applicationEvaluationFormRepository.findByApplicationEvaluation_IdAndIsDeletedFalse(applicationEvaluationEntity.getId());
|
||||
List<ContentResponseBean> contentResponseBeans=Utils.convertJsonStringToList(evaluationFormEntity.getContent(),ContentResponseBean.class);
|
||||
int count = 0;
|
||||
for (ContentResponseBean content : contentResponseBeans) {
|
||||
if (GepafinConstant.SWITCH.equals(content.getName()) && content.getSettings().stream()
|
||||
.anyMatch(setting -> GepafinConstant.IS_CHECK_LIST_ITEM.equals(setting.getName()))) {
|
||||
|
||||
ApplicationEvaluationFormFieldEntity field = applicationEvaluationFormFieldRepository
|
||||
.findByFieldIdAndApplicationEvaluationFormId(content.getId(), applicationEvaluationForm.getId());
|
||||
|
||||
if (field != null && Utils.isValidBoolean(field.getFieldValue())) {
|
||||
Boolean fieldValueAsBoolean = Boolean.parseBoolean(field.getFieldValue());
|
||||
|
||||
if (Boolean.FALSE.equals(fieldValueAsBoolean)) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,GepafinConstant.VALIDATION_FAILED_FOR_CHECKLIST);
|
||||
}
|
||||
|
||||
if (++count >= numberOfCheck) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checklistValidationForEvaluationV1(List<FieldRequest> evaluationFileRequests, String checkList, List<ChecklistRequest> checklistRequests) {
|
||||
Boolean allValid = evaluationFileRequests.stream()
|
||||
.anyMatch(fieldRequest -> fieldRequest.getValid() == null);
|
||||
if(checkList != null) {
|
||||
checklistRequests =Utils.convertJsonStringToList(checkList,ChecklistRequest.class);
|
||||
}
|
||||
boolean resultCheckList = checklistRequests.stream()
|
||||
.anyMatch(checklistRequest -> Boolean.TRUE.equals(checklistRequest.getValid())) ? false : true;
|
||||
|
||||
if(Boolean.TRUE.equals(allValid) || Boolean.TRUE.equals(resultCheckList)){
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.All_DOCUMENT_CHECKED_AND_ONE_CHECKLIST_CHECKED));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<AmendmentFormFieldResponse> getIdAndLabelFromResult(List<Map<String, Object>> result) {
|
||||
List<AmendmentFormFieldResponse> formFieldResponses = new ArrayList<>();
|
||||
@@ -1083,7 +1133,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
List<ApplicationAmendmentRequestResponse> response = new ArrayList<>();
|
||||
if (applicationAmendmentRequestEntity != null) {
|
||||
response = applicationAmendmentRequestEntity.stream()
|
||||
.map(entity -> convertEntityToResponse(entity, false))
|
||||
.map(entity -> convertEntityToResponse(entity, true))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return response;
|
||||
@@ -1214,4 +1264,118 @@ public class ApplicationAmendmentRequestDao {
|
||||
documentService.deleteFile(documentId);
|
||||
}
|
||||
|
||||
public PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(Long userId, ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||
Integer pageNo = null;
|
||||
Integer pageLimit = null;
|
||||
if (applicationAmendmentPaginationRequestBean.getGlobalFilters() != null) {
|
||||
pageNo = applicationAmendmentPaginationRequestBean.getGlobalFilters().getPage();
|
||||
pageLimit = applicationAmendmentPaginationRequestBean.getGlobalFilters().getLimit();
|
||||
}
|
||||
if (pageLimit == null || pageLimit <= 0) {
|
||||
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||
}
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
}
|
||||
Specification<ApplicationAmendmentRequestEntity> spec = searchPagination(userId,applicationAmendmentPaginationRequestBean);
|
||||
Page<ApplicationAmendmentRequestEntity> entityPage = applicationAmendmentRequestRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
|
||||
|
||||
List<ApplicationAmendmentRequestResponse> applicationResponses = entityPage.getContent().stream()
|
||||
.map(application -> {
|
||||
ApplicationAmendmentRequestResponse response = convertEntityToResponse(application,false);
|
||||
return response;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
PageableResponseBean<List<ApplicationAmendmentRequestResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||
pageableResponseBean.setBody(applicationResponses);
|
||||
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||
pageableResponseBean.setPageSize(entityPage.getSize());
|
||||
|
||||
return pageableResponseBean;
|
||||
}
|
||||
|
||||
public Specification<ApplicationAmendmentRequestEntity> searchPagination(Long userId,ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
|
||||
List<Predicate> predicates = getPredicates(applicationAmendmentPaginationRequestBean, criteriaBuilder, root,userId);
|
||||
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||
|
||||
if (applicationAmendmentPaginationRequestBean .getGlobalFilters() != null
|
||||
&& applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy() != null &&
|
||||
applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName() != null && Boolean.FALSE.equals(
|
||||
isEmpty(applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName()))) {
|
||||
sortBy.setColumnName(applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName());
|
||||
sortBy.setSortDesc(true);
|
||||
if (applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getSortDesc() != null) {
|
||||
sortBy.setSortDesc(applicationAmendmentPaginationRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
||||
}
|
||||
}
|
||||
|
||||
query.orderBy(criteriaBuilder.desc(root.get(sortBy.getColumnName())));
|
||||
if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||
query.orderBy(criteriaBuilder.asc(root.get(sortBy.getColumnName())));
|
||||
}
|
||||
return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private List<Predicate> getPredicates(ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean,
|
||||
CriteriaBuilder criteriaBuilder, Root<ApplicationAmendmentRequestEntity> root,Long userId) {
|
||||
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
if (amendmentPaginationRequestBean.getGlobalFilters() != null) {
|
||||
year = amendmentPaginationRequestBean.getGlobalFilters().getYear();
|
||||
search = amendmentPaginationRequestBean.getGlobalFilters().getSearch();
|
||||
}
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
if (year != null && year > 0) {
|
||||
int filterYear = amendmentPaginationRequestBean.getGlobalFilters().getYear();
|
||||
|
||||
// Create LocalDateTime boundaries for the start and end of the year
|
||||
LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
|
||||
LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
|
||||
|
||||
// Add the range comparison to filter records within the year
|
||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||
|
||||
}
|
||||
// Search in `title` and `message` (if search term is provided)
|
||||
if (search != null && !search.isEmpty()) {
|
||||
Predicate notePredicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(notePredicate));
|
||||
Predicate internalNotePredicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.INTERNAL_NOTE)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(internalNotePredicate));
|
||||
}
|
||||
|
||||
// Filter by `status` (if status list is provided)
|
||||
if (amendmentPaginationRequestBean.getStatus() != null && !amendmentPaginationRequestBean.getStatus().isEmpty()) {
|
||||
List<String> statusValues = amendmentPaginationRequestBean.getStatus().stream()
|
||||
.map(ApplicationAmendmentRequestEnum::name) // Convert enum to string
|
||||
.toList();
|
||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||
}
|
||||
if(Boolean.TRUE.equals(validator.checkIsBeneficiary())) {
|
||||
predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("application").get("userId").in(userId));
|
||||
}
|
||||
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||
predicates.add(root.get("applicationEvaluationEntity").get("assignedApplicationsEntity").get("userId").in(userId));
|
||||
}
|
||||
|
||||
return predicates;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.persistence.criteria.*;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.config.jwt.TokenProvider;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
|
||||
@@ -42,19 +44,22 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -64,6 +69,7 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
import static org.hibernate.validator.internal.engine.messageinterpolation.el.RootResolver.FORMATTER;
|
||||
|
||||
@Component
|
||||
public class ApplicationDao {
|
||||
@@ -117,8 +123,8 @@ public class ApplicationDao {
|
||||
@Autowired
|
||||
private AssignedApplicationsRepository assignedApplicationsRepository;
|
||||
|
||||
@Value("${default_System_Receiver_Email}")
|
||||
private String defaultSystemReceiverEmail;
|
||||
// @Value("${default_System_Receiver_Email}")
|
||||
// private String defaultSystemReceiverEmail;
|
||||
|
||||
@Value("${rinaldo_email}")
|
||||
private String rinaldoEmail;
|
||||
@@ -271,7 +277,8 @@ public class ApplicationDao {
|
||||
for (ApplicationFormFieldEntity applicationFormFieldEntity : applicationFormFieldEntities) {
|
||||
|
||||
Optional<ContentResponseBean> fileUploadContent = contentResponseBeans.stream()
|
||||
.filter(contentResponseBean -> "fileupload".equals(contentResponseBean.getName()) &&
|
||||
.filter(contentResponseBean -> ("fileupload".equals(contentResponseBean.getName()) ||
|
||||
"fileselect".equals(contentResponseBean.getName())) &&
|
||||
contentResponseBean.getId().equals(applicationFormFieldEntity.getFieldId()))
|
||||
.findFirst();
|
||||
|
||||
@@ -607,7 +614,7 @@ public class ApplicationDao {
|
||||
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
|
||||
if (Boolean.FALSE.equals(contentResponseBean.getName().equals("fileupload"))) {
|
||||
if (Boolean.FALSE.equals(contentResponseBean.getName().equals("fileupload") || contentResponseBean.getName().equals("fileselect"))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -663,7 +670,7 @@ public class ApplicationDao {
|
||||
// List<ContentResponseBean> contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class);
|
||||
List<ContentResponseBean> contentResponseBeans=formDao.convertFormEntityToFormResponseBean(formEntity).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("fileselect"))) {
|
||||
if (contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())) {
|
||||
Object fieldValueObject = applicationFormFieldRequestBean.getFieldValue();
|
||||
if (fieldValueObject instanceof String) {
|
||||
@@ -917,8 +924,10 @@ public class ApplicationDao {
|
||||
|
||||
public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) {
|
||||
|
||||
log.info("Updating status for Application id : " + applicationId);
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
checkCallEndDate(applicationEntity.getCall());
|
||||
log.info("Call end date verified successfully | callId: {}", applicationEntity.getCall().getId());
|
||||
//cloned entity for old application data
|
||||
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity);
|
||||
|
||||
@@ -949,14 +958,14 @@ public class ApplicationDao {
|
||||
sendMailToUserAndCompany(userEntity, applicationEntity);
|
||||
sendMailTodefaultSystemAndGepafin(userEntity, applicationEntity);
|
||||
applicationEntity.setStatus(status.getValue());
|
||||
log.info("Status updated to SUBMIT for applicationId: " + applicationId);
|
||||
}
|
||||
if (status.equals(ApplicationStatusTypeEnum.DRAFT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.AWAITING.getValue()))) {
|
||||
applicationEntity.setStatus(status.getValue());
|
||||
}
|
||||
if(status.equals(ApplicationStatusTypeEnum.ADMISSIBLE) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.APPOINTMENT.getValue()))){
|
||||
applicationEntity.setStatus(status.getValue());
|
||||
log.info("Status updated to DRAFT for applicationId: " + applicationId);
|
||||
}
|
||||
applicationEntity = applicationRepository.save(applicationEntity);
|
||||
log.info("Application status updated successfully | applicationId: {}, newStatus: {}", applicationId, applicationEntity.getStatus());
|
||||
|
||||
if (!status.equals(ApplicationStatusTypeEnum.SUBMIT)) {
|
||||
/** This code is responsible for adding a version history log for "Update application status" operation. **/
|
||||
@@ -1352,7 +1361,7 @@ public class ApplicationDao {
|
||||
FormEntity formEntity = applicationForm.getForm();
|
||||
if (formEntity != null) {
|
||||
List<ContentResponseBean> contentResponseBeans = formDao.convertFormEntityToFormResponseBean(formEntity).getContent();
|
||||
contentResponseBeans.stream().filter(content -> "fileupload".equals(content.getName())).forEach(content -> {
|
||||
contentResponseBeans.stream().filter(content -> "fileupload".equals(content.getName()) || "fileselect".equals(content.getName())).forEach(content -> {
|
||||
Optional<ApplicationFormFieldEntity> formField = applicationFormFieldRepository.findByFieldIdAndApplicationFormIdAndApplicationFormApplicationId(
|
||||
content.getId(), applicationForm.getId(), applicationId);
|
||||
formField.ifPresent(field -> {
|
||||
@@ -1444,7 +1453,7 @@ public class ApplicationDao {
|
||||
Integer pageLimit = null;
|
||||
|
||||
UserWithCompanyEntity userWithCompany= userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), companyId).orElse(null);
|
||||
|
||||
Long userWithCompanyId = userWithCompany!=null?userWithCompany.getId():null;
|
||||
if (applicationPageableRequestBean.getGlobalFilters() != null) {
|
||||
pageNo = applicationPageableRequestBean.getGlobalFilters().getPage();
|
||||
pageLimit = applicationPageableRequestBean.getGlobalFilters().getLimit();
|
||||
@@ -1455,7 +1464,7 @@ public class ApplicationDao {
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
}
|
||||
Specification<ApplicationEntity> spec = search(callId,companyId, userWithCompany.getId(), applicationPageableRequestBean, userEntity);
|
||||
Specification<ApplicationEntity> spec = search(callId,companyId, userWithCompanyId, applicationPageableRequestBean, userEntity);
|
||||
Page<ApplicationEntity> entityPage = applicationRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
// Prepare the response
|
||||
|
||||
@@ -1510,11 +1519,15 @@ public class ApplicationDao {
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
Integer daysRange = null;
|
||||
Map<String, FilterCriteria> filters = new HashMap<>();
|
||||
if (applicationPageableRequestBean.getGlobalFilters() != null) {
|
||||
year = applicationPageableRequestBean.getGlobalFilters().getYear();
|
||||
search = applicationPageableRequestBean.getGlobalFilters().getSearch();
|
||||
daysRange = applicationPageableRequestBean.getDaysRange();
|
||||
}
|
||||
if (applicationPageableRequestBean.getFilters() != null) {
|
||||
filters = applicationPageableRequestBean.getFilters();
|
||||
}
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||
@@ -1538,6 +1551,22 @@ public class ApplicationDao {
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.COMMENTS)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
// Predicate protocolPredicate = criteriaBuilder.like(
|
||||
// criteriaBuilder.function(
|
||||
// "TO_CHAR",
|
||||
// String.class,
|
||||
// criteriaBuilder.function("CAST", String.class, root.get(GepafinConstant.PROTOCOL).get(GepafinConstant.PROTOCOL_NUMBER))
|
||||
// ),
|
||||
// "%" + search + "%"
|
||||
// );
|
||||
|
||||
Predicate callNamePredicate =criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.CALL).get(GepafinConstant.NAME)), // Adjust field name
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
|
||||
// predicates.add(criteriaBuilder.or(protocolPredicate));
|
||||
predicates.add(criteriaBuilder.or(callNamePredicate));
|
||||
predicates.add(criteriaBuilder.or(titlePredicate));
|
||||
}
|
||||
|
||||
@@ -1567,13 +1596,133 @@ public class ApplicationDao {
|
||||
LocalDateTime pastDate = today.minusDays(daysRange);
|
||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), pastDate, today));
|
||||
}
|
||||
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
||||
applyFilters(root, criteriaBuilder, predicates, filters);
|
||||
|
||||
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
||||
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB_ID), userEntity.getHub().getId()));
|
||||
|
||||
|
||||
return predicates;
|
||||
}
|
||||
private void applyFilters(Root<?> root, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Map<String, FilterCriteria> filters) {
|
||||
if (Boolean.FALSE.equals(filters.isEmpty())) {
|
||||
for (Map.Entry<String, FilterCriteria> entry : filters.entrySet()) {
|
||||
String fieldName = entry.getKey();
|
||||
FilterCriteria filterCriteria = entry.getValue();
|
||||
Object value = filterCriteria.getValue();
|
||||
MatchModeEnum matchMode = filterCriteria.getMatchMode();
|
||||
|
||||
if (value != null && matchMode != null) {
|
||||
Path<?> fieldPath = getFieldPath(root, fieldName);
|
||||
if (fieldPath != null) {
|
||||
applyStringFilter(fieldPath, criteriaBuilder, predicates, value, matchMode);
|
||||
applyNumberFilter(fieldPath, criteriaBuilder, predicates, value, matchMode);
|
||||
applyDateFilter(fieldPath, criteriaBuilder, predicates, value, matchMode,root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyStringFilter(Path<?> fieldPath, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Object value, MatchModeEnum matchMode) {
|
||||
if (value instanceof String) {
|
||||
String valueStr = (String) value;
|
||||
if (fieldPath.getJavaType().equals(String.class)) {
|
||||
MatchModeEnum mode = MatchModeEnum.fromObject(matchMode.getValue());
|
||||
switch (mode) {
|
||||
case CONTAINS ->
|
||||
predicates.add(criteriaBuilder.like(criteriaBuilder.lower(fieldPath.as(String.class)), "%" + valueStr.toLowerCase() + "%"));
|
||||
case EQUALS -> predicates.add(criteriaBuilder.equal(fieldPath, valueStr));
|
||||
case STARTSWITH ->
|
||||
predicates.add(criteriaBuilder.like(criteriaBuilder.lower(fieldPath.as(String.class)), valueStr.toLowerCase() + "%"));
|
||||
case ENDSWITH ->
|
||||
predicates.add(criteriaBuilder.like(criteriaBuilder.lower(fieldPath.as(String.class)), "%" + valueStr.toLowerCase()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyNumberFilter(Path<?> fieldPath, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Object value, MatchModeEnum matchMode) {
|
||||
if (Number.class.isAssignableFrom(fieldPath.getJavaType())) {
|
||||
Number numberValue = null;
|
||||
if (value instanceof Number) {
|
||||
numberValue = (Number) value;
|
||||
}
|
||||
MatchModeEnum mode = MatchModeEnum.fromObject(matchMode.getValue());
|
||||
switch (mode) {
|
||||
case EQUALS -> predicates.add(criteriaBuilder.equal(fieldPath, numberValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void applyDateFilter(Path<?> fieldPath, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Object value, MatchModeEnum matchMode, Root<?> root) {
|
||||
if (fieldPath.getJavaType().equals(LocalDateTime.class)) {
|
||||
// Convert input string: Replace 'T' with space
|
||||
String formattedValue = value.toString().replace("T", " ");
|
||||
|
||||
// Handle timezones and UTC (`Z` or `+HH:mm`)
|
||||
if (formattedValue.contains("Z") || formattedValue.matches(".*[+-]\\d{2}:\\d{2}$")) {
|
||||
OffsetDateTime offsetDateTime = OffsetDateTime.parse(value.toString(), DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
formattedValue = offsetDateTime.toLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
||||
}
|
||||
|
||||
// Check if more than 3 decimal places exist
|
||||
if (formattedValue.contains(".")) {
|
||||
int dotIndex = formattedValue.indexOf(".");
|
||||
if (formattedValue.length() > dotIndex + 4) {
|
||||
formattedValue = formattedValue.substring(0, dotIndex + 4); // Keep only 3 decimals
|
||||
}
|
||||
} else {
|
||||
formattedValue += ".000"; // Ensure 3 decimals
|
||||
}
|
||||
|
||||
// Define correct date-time format
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
||||
// Parse the formatted value into LocalDateTime
|
||||
LocalDateTime dateTimeValue = LocalDateTime.parse(formattedValue, formatter);
|
||||
|
||||
// Extract only the date portion
|
||||
LocalDate dateValue = dateTimeValue.toLocalDate();
|
||||
|
||||
// Convert database field to LocalDate for date-only comparison
|
||||
Expression<LocalDate> dateField = criteriaBuilder.function("DATE", LocalDate.class, fieldPath);
|
||||
|
||||
MatchModeEnum mode = MatchModeEnum.fromObject(matchMode.getValue());
|
||||
|
||||
switch (mode) {
|
||||
case DATEIS -> predicates.add(criteriaBuilder.equal(dateField, dateValue));
|
||||
case DATEISNOT -> predicates.add(criteriaBuilder.notEqual(dateField, dateValue));
|
||||
case BEFORE -> predicates.add(criteriaBuilder.lessThan(fieldPath.as(Timestamp.class), Timestamp.valueOf(dateTimeValue)));
|
||||
case AFTER -> predicates.add(criteriaBuilder.greaterThan(fieldPath.as(Timestamp.class), Timestamp.valueOf(dateTimeValue)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private Path<?> getFieldPath(Root<?> root, String fieldName) {
|
||||
try {
|
||||
return switch (fieldName) {
|
||||
case GepafinConstant.CALL_ID -> root.get(GepafinConstant.CALL).get(GepafinConstant.ID);
|
||||
case GepafinConstant.CALL_TITLE -> root.get(GepafinConstant.CALL).get(GepafinConstant.NAME);
|
||||
case GepafinConstant.CALL_END_DATE -> root.get(GepafinConstant.CALL).get(GepafinConstant.END_DATE);
|
||||
case GepafinConstant.CALL_END_TIME -> root.get(GepafinConstant.CALL).get(GepafinConstant.END_TIME);
|
||||
case GepafinConstant.MODIFIED_DATE -> root.get(GepafinConstant.CALL).get(GepafinConstant.UPDATED_DATE);
|
||||
case GepafinConstant.PROTOCOL_NUMBER-> root.get(GepafinConstant.PROTOCOL).get(GepafinConstant.PROTOCOL_NUMBER);
|
||||
default -> root.get(fieldName);
|
||||
};
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void checkCallEndDate(CallEntity call) {
|
||||
LocalDateTime now = DateTimeUtil.DateServerToUTC(LocalDateTime.now());
|
||||
|
||||
@@ -1720,5 +1869,11 @@ public class ApplicationDao {
|
||||
// Step 4: Evaluate the mathematical expression
|
||||
return Utils.evaluateExpression(expression);
|
||||
}
|
||||
|
||||
public ApplicationEntity validateApplicationWithCompany(Long id,Long companyId) {
|
||||
ApplicationEntity application=applicationRepository.findByIdAndCompanyIdAndIsDeletedFalse(id,companyId);
|
||||
if (application==null){
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||
}
|
||||
return application;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationExceptio
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -28,6 +29,7 @@ import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.log;
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
@@ -1860,7 +1862,21 @@ public class ApplicationEvaluationDao {
|
||||
// UserEntity userEntity = userService.validateUser(application.getUserId());
|
||||
// callService.validatePublishedCall(application.getCall().getId(), userEntity.getHub().getId());
|
||||
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(application);
|
||||
application.setStatus(newStatus.getValue());
|
||||
|
||||
|
||||
if(newStatus.equals(ApplicationStatusForEvaluation.ADMISSIBLE) && Boolean.TRUE.equals(application.getStatus().equals(ApplicationStatusTypeEnum.APPOINTMENT.getValue()))){
|
||||
application.setStatus(newStatus.getValue());
|
||||
log.info("Status updated to ADMISSIBLE for applicationId: " + application.getId());
|
||||
emailNotificationDao.sendAdmissibilityNotificationEmailForAdmissibleApplication(application);
|
||||
}
|
||||
|
||||
if(newStatus.equals(ApplicationStatusForEvaluation.TECHNICAL_EVALUATION) && Boolean.TRUE.equals(application.getStatus().equals(ApplicationStatusTypeEnum.ADMISSIBLE.getValue()))){
|
||||
processTechnicalEvaluation(application.getId(), application, newStatus);
|
||||
}
|
||||
|
||||
if((newStatus.equals(ApplicationStatusForEvaluation.APPROVED) || newStatus.equals(ApplicationStatusForEvaluation.REJECTED)) && application.getStatus().equals(ApplicationStatusTypeEnum.EVALUATION.getValue())) {
|
||||
application.setStatus(newStatus.getValue());
|
||||
}
|
||||
application = applicationRepository.save(application);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update Application" operation. **/
|
||||
@@ -1901,7 +1917,7 @@ public class ApplicationEvaluationDao {
|
||||
application.setDateAccepted(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
application.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
application = applicationRepository.save(application);
|
||||
emailNotificationDao.sendAdmissibilityNotificationEmailForApprovedApplication(application);
|
||||
// emailNotificationDao.sendAdmissibilityNotificationEmailForApprovedApplication(application);
|
||||
}
|
||||
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.REJECTED.getValue())))) {
|
||||
application.setDateRejected(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
@@ -1971,7 +1987,9 @@ public class ApplicationEvaluationDao {
|
||||
//Handling Application Evaluation form
|
||||
EvaluationFormEntity evaluationFormEntity = evaluationFormService.validateEvaluationForm(evaluationFormId);
|
||||
validateFormFields(applicationEvaluationFormRequestBean,evaluationFormEntity);
|
||||
// formService.validateFormField(applicationRequestBean.getFormFields(),applicationEntity,formEntity);
|
||||
// ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationRepository.findByAssignedApplicationsId(assignedApplicationId);
|
||||
validateFormFieldCustom(applicationEvaluationFormRequestBean.getFormFields(),entity,evaluationFormEntity);
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = getApplicationEvaluationFormOrCreate(evaluationFormEntity,entity);
|
||||
createOrUpdateMultipleFormFields(applicationEvaluationFormRequestBean.getFormFields(), applicationEvaluationFormEntity, evaluationFormEntity);
|
||||
return processEvaluationForm(entity);
|
||||
@@ -2027,17 +2045,20 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
public List<ApplicationEvaluationFormFieldEntity> createOrUpdateMultipleFormFields(List<ApplicationFormFieldRequestBean> formFieldRequestBeans,
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity, EvaluationFormEntity evaluationFormEntity) {
|
||||
FieldValidator fieldValidator = FieldValidator.create();
|
||||
|
||||
List<ApplicationEvaluationFormFieldEntity> existingFields = applicationEvaluationFormFieldRepository.findByApplicationEvaluationFormId(applicationEvaluationFormEntity.getId());
|
||||
|
||||
return formFieldRequestBeans.stream().map(requestBean -> createOrUpdateApplicationEvaluationFormField(requestBean, applicationEvaluationFormEntity, existingFields, evaluationFormEntity))
|
||||
List<ApplicationEvaluationFormFieldEntity> applicationEvaluationFormFieldEntities= formFieldRequestBeans.stream().map(requestBean -> createOrUpdateApplicationEvaluationFormField(requestBean, applicationEvaluationFormEntity, existingFields, evaluationFormEntity,fieldValidator))
|
||||
.collect(Collectors.toList());
|
||||
fieldValidator.validate();
|
||||
return applicationEvaluationFormFieldEntities;
|
||||
}
|
||||
|
||||
public ApplicationEvaluationFormFieldEntity createOrUpdateApplicationEvaluationFormField(ApplicationFormFieldRequestBean applicationFormFieldRequestBean,
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity,
|
||||
List<ApplicationEvaluationFormFieldEntity> applicationEvaluationFormFieldEntities,
|
||||
EvaluationFormEntity evaluationFormEntity){
|
||||
EvaluationFormEntity evaluationFormEntity,FieldValidator fieldValidator){
|
||||
ApplicationEvaluationFormFieldEntity applicationEvaluationFormFieldEntity = new ApplicationEvaluationFormFieldEntity();
|
||||
validateFileUploadDocuments(applicationFormFieldRequestBean, evaluationFormEntity);
|
||||
VersionActionTypeEnum actionType = VersionActionTypeEnum.INSERT;
|
||||
@@ -2060,7 +2081,8 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
}
|
||||
Utils.setIfUpdated(applicationEvaluationFormFieldEntity::getFieldId, applicationEvaluationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId());
|
||||
|
||||
List<ContentResponseBean> contentBeans = Utils.convertJsonStringToList(evaluationFormEntity.getContent(), ContentResponseBean.class);
|
||||
calculationProcessForFormula(applicationEvaluationFormEntity,contentBeans,applicationFormFieldRequestBean,fieldValidator);
|
||||
if (applicationFormFieldRequestBean.getFieldValue() != null) {
|
||||
applicationEvaluationFormFieldEntity.setFieldValue(Utils.convertObjectToJsonString(applicationFormFieldRequestBean.getFieldValue()));
|
||||
} else {
|
||||
@@ -2205,7 +2227,8 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
ApplicationEvaluationFormResponse response = objectMapper.convertValue(convertedResponse, ApplicationEvaluationFormResponse.class);
|
||||
EvaluationFormEntity evaluationFormEntity = evaluationFormRepository.findByCallIdAndIsDeletedFalse(evaluationEntity.getAssignedApplicationsEntity().getApplication().getCall().getId());
|
||||
|
||||
response.setNumberOfCheck(evaluationEntity.getAssignedApplicationsEntity().getApplication().getCall().getNumberOfCheck());
|
||||
response.setAppointmentTemplateId(evaluationEntity.getAssignedApplicationsEntity().getApplication().getApplicationEvaluationId());
|
||||
if (evaluationFormEntity != null) {
|
||||
response.setApplicationEvaluationFormResponse(convertEvaluationFormToResponse(evaluationFormEntity, evaluationEntity));
|
||||
}
|
||||
@@ -2269,5 +2292,188 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
public void calculationProcessForFormula(ApplicationEvaluationFormEntity applicationFormEntity, List<ContentResponseBean> contentResponseBeans, ApplicationFormFieldRequestBean applicationFormFieldRequestBean,FieldValidator fieldValidator) {
|
||||
List<String> formulaValue = new ArrayList<>();
|
||||
String formulaValueOpt=null;
|
||||
String label=null;
|
||||
for (ContentResponseBean contentResponseBean:contentResponseBeans){
|
||||
if(contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())){
|
||||
for (SettingResponseBean settingResponseBean:contentResponseBean.getSettings()){
|
||||
if (settingResponseBean.getName().equals(GepafinConstant.LABEL)){
|
||||
label= String.valueOf(settingResponseBean.getValue());
|
||||
}
|
||||
|
||||
if(settingResponseBean.getName().equals(GepafinConstant.FORMULA)){
|
||||
String value= (String) settingResponseBean.getValue();
|
||||
formulaValueOpt=value;
|
||||
formulaValue=Utils.extractValues(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> mappedFormulaValue = new HashMap<>();
|
||||
Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
|
||||
if (formulaValueOpt != null && fieldValue==null) {
|
||||
fieldValue=0;
|
||||
}
|
||||
|
||||
for (ContentResponseBean contentResponseBean : contentResponseBeans) {
|
||||
String contentId = contentResponseBean.getId();
|
||||
|
||||
// Extract variable values once per contentResponseBean to avoid repeated stream operations
|
||||
Set<String> variableValues = contentResponseBean.getSettings().stream()
|
||||
.filter(setting -> GepafinConstant.VARIABLE.equals(setting.getName()))
|
||||
.flatMap(setting -> {
|
||||
Object value = setting.getValue(); // Get the raw value
|
||||
if (value instanceof String) {
|
||||
return Stream.of((String) value); // Handle single String case
|
||||
} else if (value instanceof List) {
|
||||
return ((List<?>) value).stream()
|
||||
.filter(item -> item instanceof String) // Ensure it's a String
|
||||
.map(item -> (String) item); // Convert to String
|
||||
} else {
|
||||
return Stream.empty(); // Ignore unexpected types
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toSet()); // Collect into a Set for uniqueness
|
||||
|
||||
for (String formula : formulaValue) {
|
||||
if (variableValues.contains(formula)) { // O(1) lookup instead of O(n)
|
||||
mappedFormulaValue.put(formula, contentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> updatedMappedFormulaValue = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : mappedFormulaValue.entrySet()) {
|
||||
String variable = entry.getKey();
|
||||
String contentId = entry.getValue();
|
||||
|
||||
// Repository call using contentId
|
||||
Optional<ApplicationEvaluationFormFieldEntity> optionalEntity = applicationEvaluationFormFieldRepository.findByApplicationEvaluationFormIdAndFieldIdAndIsDeletedFalse(applicationFormEntity.getId(),contentId);
|
||||
// If entity is found, extract fieldValue and fieldId
|
||||
optionalEntity.ifPresent(entity -> {
|
||||
String entityFieldValue = entity.getFieldValue(); // Assuming getter method exists
|
||||
String fieldId = entity.getFieldId(); // Assuming getter method exists
|
||||
String tableType = contentResponseBeans.stream()
|
||||
.filter(content -> content.getId().equals(fieldId)) // Match Content ID with fieldId
|
||||
.flatMap(content -> content.getSettings().stream()) // Extract settings
|
||||
.filter(setting -> GepafinConstant.CRITERIA_TABLE_COLUMNS.equals(setting.getName())) // Match name
|
||||
.map(setting -> setting.getName()) // Return the name of the setting
|
||||
.findFirst() // Get the first match
|
||||
.orElse(null); // Default to null if no match
|
||||
|
||||
if(tableType!=null){
|
||||
JSONObject jsonObject = new JSONObject(entityFieldValue);
|
||||
|
||||
// Extract the value of total
|
||||
entityFieldValue = jsonObject.getString(GepafinConstant.TOTAL);
|
||||
|
||||
}
|
||||
|
||||
updatedMappedFormulaValue.put(fieldId, entityFieldValue);
|
||||
});
|
||||
}
|
||||
if(formulaValueOpt==null || formulaValueOpt.isEmpty()){
|
||||
return;
|
||||
}
|
||||
double finalValue = applicationDao.evaluateFormula(formulaValueOpt, mappedFormulaValue, updatedMappedFormulaValue);
|
||||
|
||||
fieldValidator.formulaValidation(fieldValue, finalValue, label);
|
||||
}
|
||||
public void validateFormFieldCustom(List<ApplicationFormFieldRequestBean> applicationFormFieldRequestList, ApplicationEvaluationEntity applicationEvaluationEntity, EvaluationFormEntity evaluationFormEntity) {
|
||||
Map<String, Object> formFieldMap = new LinkedHashMap<String, Object>();
|
||||
for(ApplicationFormFieldRequestBean applicationFormFieldRequestBean:applicationFormFieldRequestList) {
|
||||
if(applicationFormFieldRequestBean.getFieldValue()==null )
|
||||
continue;
|
||||
if (applicationFormFieldRequestBean.getFieldValue() != null ) {
|
||||
Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
|
||||
// formDao.checkObjectData(applicationFormFieldRequestBean.getFieldId(), fieldValue, formFieldMap);
|
||||
if (fieldValue instanceof List<?>) {
|
||||
List<?> list = (List<?>) fieldValue;
|
||||
|
||||
// Only map if the list is not empty and contains Strings
|
||||
if (!list.isEmpty() && list.get(0) instanceof String) {
|
||||
for (Object value : list) {
|
||||
formDao.setFormFieldMap(applicationFormFieldRequestBean.getFieldId(), formFieldMap, value);
|
||||
}
|
||||
}else if (list.stream().allMatch(item -> item instanceof Map<?, ?> map &&
|
||||
map.keySet().stream().allMatch(String.class::isInstance))) {
|
||||
if (fieldValue != null) {
|
||||
formFieldMap.put(applicationFormFieldRequestBean.getFieldId(), fieldValue);
|
||||
}
|
||||
} else formDao.setFormFieldMap(applicationFormFieldRequestBean.getFieldId(), formFieldMap, fieldValue);
|
||||
}
|
||||
else {
|
||||
formDao.setFormFieldMap(applicationFormFieldRequestBean.getFieldId(), formFieldMap, fieldValue);
|
||||
}
|
||||
}}
|
||||
|
||||
EvaluationFormResponseBean evaluationFormResponseBean = evaluationFormDao.convertEvaluationFormEntityToEvaluationFormResponseBean(evaluationFormEntity);
|
||||
ApplicationEvaluationFormEntity applicationEvaluationForm=applicationEvaluationFormRepository.findByEvaluationIdAndEvaluationFormId(applicationEvaluationEntity.getId(),evaluationFormEntity.getId());
|
||||
Boolean isApplicationFormExist= getApplicationEvaluationFormExist(applicationEvaluationForm);
|
||||
FieldValidator validator = FieldValidator.create();
|
||||
evaluationFormResponseBean.getContent().forEach(contentResponseBean -> {
|
||||
String fieldId = contentResponseBean.getId();
|
||||
String fieldLabel=contentResponseBean.getLabel();
|
||||
Object object=formFieldMap.get(fieldId);
|
||||
String value =Utils.convertToStringForFormFieldValue(object);
|
||||
if(value == null && isApplicationFormExist) {
|
||||
return;
|
||||
}
|
||||
FieldValidatorBean fieldValidatorBean = Utils.convertSourceObjectToDestinationObject(contentResponseBean.getValidators(), FieldValidatorBean.class);
|
||||
validator
|
||||
.minLength(value, fieldValidatorBean.getMinLength(), fieldLabel,fieldValidatorBean.getMin(),contentResponseBean) // Only applies if minLength is not null
|
||||
.maxLength(value, fieldValidatorBean.getMaxLength(), fieldLabel,fieldValidatorBean.getMax(),contentResponseBean) // Only applies if maxLength is not null
|
||||
.matchesPattern(value, fieldValidatorBean.getPattern(), fieldLabel) // Only applies if pattern is present
|
||||
.validateCustom(value, fieldValidatorBean.getCustom(), fieldLabel,contentResponseBean); // Add the custom validation here
|
||||
});
|
||||
validator.validate();
|
||||
}
|
||||
private Boolean getApplicationEvaluationFormExist(ApplicationEvaluationFormEntity applicationEvaluationFormEntity) {
|
||||
if(applicationEvaluationFormEntity !=null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private void processTechnicalEvaluation(Long applicationId, ApplicationEntity applicationEntity, ApplicationStatusForEvaluation status){
|
||||
Optional<ApplicationEvaluationEntity> evaluationEntityOpt = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
|
||||
if (evaluationEntityOpt.isPresent()){
|
||||
ApplicationEvaluationEntity evaluationEntity = evaluationEntityOpt.get();
|
||||
String criteriaJson = evaluationEntity.getCriteria();
|
||||
if (criteriaJson != null){
|
||||
Integer totalScore = calculateTotalScore(evaluationEntity.getCriteria());
|
||||
if (totalScore > 40) {
|
||||
applicationEntity.setStatus(status.getValue());
|
||||
log.info("Status updated to TECHNICAL_EVALUATION for applicationId: " + applicationId);
|
||||
}
|
||||
else{
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.INSUFFICIENT_SCORE_MESSAGE));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Integer calculateTotalScore(String criteriaJson){
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// Convert JSON string to List of Maps
|
||||
List<Map<String, Object>> criteriaList = objectMapper.readValue(criteriaJson, new TypeReference<>() {
|
||||
});
|
||||
|
||||
// Sum all scores (ignoring null scores)
|
||||
Integer totalScore = criteriaList.stream()
|
||||
.mapToInt(obj -> obj.get("score") != null ? ((Number) obj.get("score")).intValue() : 0)
|
||||
.sum();
|
||||
|
||||
return totalScore;
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(" Error parsing criteria JSON: {}", e.getMessage());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.SortBy;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
@@ -25,16 +33,20 @@ import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationExceptio
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.log;
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
|
||||
@Component
|
||||
public class AssignedApplicationsDao {
|
||||
@@ -288,6 +300,118 @@ public class AssignedApplicationsDao {
|
||||
log.info("Assigned application fetched successfully: {}", response);
|
||||
return response;
|
||||
}
|
||||
public PageableResponseBean<List<AssignedApplicationsResponse>> getAllAssignedApplicationsByPagination(UserEntity user, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean,Long userId) {
|
||||
Integer pageNo = null;
|
||||
Integer pageLimit = null;
|
||||
if (assignedApplicationPageableRequestBean.getGlobalFilters() != null) {
|
||||
pageNo = assignedApplicationPageableRequestBean.getGlobalFilters().getPage();
|
||||
pageLimit = assignedApplicationPageableRequestBean.getGlobalFilters().getLimit();
|
||||
}
|
||||
if (pageLimit == null || pageLimit <= 0) {
|
||||
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||
}
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
}
|
||||
Specification<AssignedApplicationsEntity> spec = searchByPagination( assignedApplicationPageableRequestBean, user,userId);
|
||||
Page<AssignedApplicationsEntity> entityPage = assignedApplicationsRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
// Prepare the response
|
||||
|
||||
|
||||
List<AssignedApplicationsResponse> assignedApplicationsResponses = entityPage.getContent().stream()
|
||||
.map(application -> {
|
||||
AssignedApplicationsResponse response = convertEntityToResponse(application);
|
||||
return response;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
|
||||
PageableResponseBean<List<AssignedApplicationsResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||
pageableResponseBean.setBody(assignedApplicationsResponses);
|
||||
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1);
|
||||
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||
pageableResponseBean.setPageSize(entityPage.getSize());
|
||||
|
||||
return pageableResponseBean;
|
||||
}
|
||||
|
||||
public Specification<AssignedApplicationsEntity> searchByPagination(AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean, UserEntity userEntity,Long userId) {
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
|
||||
List<Predicate> predicates = getPredicates(assignedApplicationPageableRequestBean, criteriaBuilder, root, userEntity,userId);
|
||||
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||
|
||||
if (assignedApplicationPageableRequestBean.getGlobalFilters() != null
|
||||
&& assignedApplicationPageableRequestBean.getGlobalFilters().getSortBy() != null &&
|
||||
assignedApplicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName() != null && Boolean.FALSE.equals(
|
||||
isEmpty(assignedApplicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName()))) {
|
||||
sortBy.setColumnName(assignedApplicationPageableRequestBean.getGlobalFilters().getSortBy().getColumnName());
|
||||
sortBy.setSortDesc(true);
|
||||
if (assignedApplicationPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc() != null) {
|
||||
sortBy.setSortDesc(assignedApplicationPageableRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
||||
}
|
||||
}
|
||||
|
||||
query.orderBy(criteriaBuilder.desc(root.get(sortBy.getColumnName())));
|
||||
if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||
query.orderBy(criteriaBuilder.asc(root.get(sortBy.getColumnName())));
|
||||
}
|
||||
return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private List<Predicate> getPredicates(AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean,
|
||||
CriteriaBuilder criteriaBuilder, Root<AssignedApplicationsEntity> root, UserEntity userEntity,Long userId) {
|
||||
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
if (assignedApplicationPageableRequestBean.getGlobalFilters() != null) {
|
||||
year = assignedApplicationPageableRequestBean.getGlobalFilters().getYear();
|
||||
search = assignedApplicationPageableRequestBean.getGlobalFilters().getSearch();
|
||||
}
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||
if (userId!=null) {
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_ID), userId));
|
||||
}
|
||||
if (year != null && year > 0) {
|
||||
int filterYear = assignedApplicationPageableRequestBean.getGlobalFilters().getYear();
|
||||
|
||||
// Create LocalDateTime boundaries for the start and end of the year
|
||||
LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
|
||||
LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
|
||||
|
||||
// Add the range comparison to filter records within the year
|
||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||
|
||||
}
|
||||
// Search in `title` and `message` (if search term is provided)
|
||||
if (search != null && !search.isEmpty()) {
|
||||
Predicate titlePredicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.NOTE)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(titlePredicate));
|
||||
}
|
||||
|
||||
// Filter by `status` (if status list is provided)
|
||||
if (assignedApplicationPageableRequestBean.getStatus() != null && !assignedApplicationPageableRequestBean.getStatus().isEmpty()) {
|
||||
List<String> statusValues = assignedApplicationPageableRequestBean.getStatus().stream()
|
||||
.map(AssignedApplicationEnum::name) // Convert enum to string
|
||||
.toList();
|
||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||
}
|
||||
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
||||
|
||||
|
||||
|
||||
return predicates;
|
||||
|
||||
}
|
||||
public AssignedApplicationsResponse updateAssignedApplicationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedApplicationEnum status) {
|
||||
|
||||
AssignedApplicationsEntity assignedApplication = validateAssignedApplication(assignedApplicationId);
|
||||
|
||||
@@ -571,7 +571,7 @@ public class CallDao {
|
||||
}
|
||||
}
|
||||
|
||||
public CallResponse updateCallStep1(CallEntity callEntity, UpdateCallRequestStep1 updateCallRequest, UserEntity userEntity) {
|
||||
public CallResponse updateCallStep1(HttpServletRequest request,CallEntity callEntity, UpdateCallRequestStep1 updateCallRequest, UserEntity userEntity) {
|
||||
CallEntity oldCallEntity = Utils.getClonedEntityForData(callEntity);
|
||||
isValidDateRange(updateCallRequest, callEntity);
|
||||
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
|
||||
@@ -580,15 +580,49 @@ public class CallDao {
|
||||
setIfUpdated(callEntity::getDescriptionLong, callEntity::setDescriptionLong,
|
||||
updateCallRequest.getDescriptionLong());
|
||||
List<LocalDateTime> dates=updateCallRequest.getDates();
|
||||
|
||||
boolean isEndDateUpdated = false;
|
||||
boolean isEndTimeUpdated = false;
|
||||
if (dates != null && dates.size()>1) {
|
||||
if (dates.size() > 0) {
|
||||
setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, dates.get(0));
|
||||
}
|
||||
if (dates.size() > 1) {
|
||||
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
|
||||
LocalDate requestEndDate = dates.get(1).toLocalDate(); // Extract only the date
|
||||
LocalDate storedEndDate = callEntity.getEndDate().toLocalDate(); // Extract only the date
|
||||
|
||||
if (!requestEndDate.equals(storedEndDate)) { // Check if dates are different
|
||||
|
||||
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
|
||||
callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
callRepository.save(callEntity);
|
||||
isEndDateUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateCallRequest.getEndTime() != null) {
|
||||
LocalTime requestEndTime = DateTimeUtil.parseTime(updateCallRequest.getEndTime());
|
||||
LocalTime storedEndTime = callEntity.getEndTime();
|
||||
|
||||
if (!requestEndTime.equals(storedEndTime)) {
|
||||
setIfUpdated(callEntity::getEndTime, callEntity::setEndTime, DateTimeUtil.parseTime(updateCallRequest.getEndTime()));
|
||||
callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||
callRepository.save(callEntity);
|
||||
isEndTimeUpdated = true;
|
||||
}
|
||||
}
|
||||
if (isEndDateUpdated || isEndTimeUpdated) {
|
||||
|
||||
loggingUtil.logUserAction(UserActionRequest.builder()
|
||||
.request(request)
|
||||
.actionType(UserActionLogsEnum.UPDATE)
|
||||
.actionContext(UserActionContextEnum.UPDATE_CALL_END_DATE_AND_TIME)
|
||||
.build());
|
||||
|
||||
/** This code is responsible for adding a version history log for the "update call end date and time" operation **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCallEntity).newData(callEntity).build());
|
||||
}
|
||||
|
||||
// setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, updateCallRequest.getStartDate());
|
||||
// setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, updateCallRequest.getEndDate());
|
||||
setIfUpdated(callEntity::getAmount, callEntity::setAmount, updateCallRequest.getAmount());
|
||||
@@ -606,7 +640,6 @@ public class CallDao {
|
||||
setIfUpdated(callEntity::getEmail, callEntity::setEmail, updateCallRequest.getEmail());
|
||||
setIfUpdated(callEntity::getPhoneNumber, callEntity::setPhoneNumber, updateCallRequest.getPhoneNumber());
|
||||
setIfUpdated(callEntity::getStartTime, callEntity::setStartTime, DateTimeUtil.parseTime(updateCallRequest.getStartTime()));
|
||||
setIfUpdated(callEntity::getEndTime, callEntity::setEndTime, DateTimeUtil.parseTime(updateCallRequest.getEndTime()));
|
||||
setIfUpdated(callEntity::getConfidi, callEntity::setConfidi, updateCallRequest.getConfidi());
|
||||
setIfUpdated(callEntity::getEvaluationVersion, callEntity::setEvaluationVersion, updateCallRequest.getEvaluationVersion().getValue());
|
||||
setIfUpdated(callEntity::getNumberOfCheck, callEntity::setNumberOfCheck, updateCallRequest.getNumberOfCheck());
|
||||
@@ -1089,4 +1122,4 @@ public class CallDao {
|
||||
createCallResponseBean.setCurrentStep(GepafinConstant.EVALUATION_V2_STEP_2);
|
||||
return createCallResponseBean;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,340 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3Client;
|
||||
import com.amazonaws.services.s3.model.CopyObjectRequest;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentCategoryResponse;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UploadFileOnAmazonS3Response;
|
||||
import net.gepafin.tendermanagement.repositories.CompanyDocumentRepository;
|
||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.service.impl.AmazonS3ServiceImpl;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CompanyDocumentDao {
|
||||
|
||||
@Autowired
|
||||
private S3PathConfig s3ConfigBean;
|
||||
|
||||
@Autowired
|
||||
private AmazonS3Service amazonS3Service;
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentRepository companyDocumentRepository;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private DocumentCategoryDao categoryDao;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
@Value("${aws.s3.bucket.name}")
|
||||
private String bucketName;
|
||||
|
||||
@Autowired
|
||||
private AmazonS3Client s3Client;
|
||||
|
||||
@Autowired
|
||||
private DocumentRepository documentRepository;
|
||||
|
||||
@Autowired
|
||||
private CallDao callDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationService applicationService;
|
||||
|
||||
@Autowired
|
||||
private AmazonS3ServiceImpl amazonS3ServiceImpl;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
public List<CompanyDocumentResponseBean> uploadFileForCompany(HttpServletRequest request, Long userId, List<MultipartFile> files, Long companyId, Long documentCategoryId, CompanyDocumentTypeEnum companyDocumentSourceTypeEnum, LocalDateTime expirationDate,String name){
|
||||
DocumentCategoryEntity categoryEntity = categoryDao.validateCategory(documentCategoryId);
|
||||
validator.validateUserWithCompany(request,companyId);
|
||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userId,companyId);
|
||||
|
||||
LocalDateTime currentDate = LocalDateTime.now();
|
||||
if (expirationDate.isBefore(currentDate)) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_EXPIRATION_DATE));
|
||||
}
|
||||
List<CompanyDocumentEntity> companyDocumentEntities = new ArrayList<>();
|
||||
for (MultipartFile file : files){
|
||||
UploadFileOnAmazonS3Response uploadFileOnAmazonS3Response = uploadFileOnAmazonS3(file, companyDocumentSourceTypeEnum, companyId);
|
||||
if (uploadFileOnAmazonS3Response != null) {
|
||||
CompanyDocumentEntity companyDocumentEntity = new CompanyDocumentEntity();
|
||||
companyDocumentEntity.setFileName(uploadFileOnAmazonS3Response.getFileName());
|
||||
companyDocumentEntity.setCompanyId(companyId);
|
||||
companyDocumentEntity.setType(companyDocumentSourceTypeEnum.getValue());
|
||||
companyDocumentEntity.setFilePath(uploadFileOnAmazonS3Response.getFilePath());
|
||||
companyDocumentEntity.setIsDeleted(false);
|
||||
companyDocumentEntity.setUploadedBy(userId);
|
||||
companyDocumentEntity.setName(name);
|
||||
if (expirationDate.isBefore(currentDate.plusDays(7))) {
|
||||
companyDocumentEntity.setStatus(CompanyDocumentStatusEnum.DUE.getValue());
|
||||
} else {
|
||||
companyDocumentEntity.setStatus(CompanyDocumentStatusEnum.VALID.getValue());
|
||||
}
|
||||
|
||||
companyDocumentEntity.setCategoryEntity(categoryEntity);
|
||||
companyDocumentEntity.setUserWithCompany(userWithCompanyEntity);
|
||||
companyDocumentEntity.setExpirationDate(expirationDate);
|
||||
companyDocumentEntities.add(companyDocumentEntity);
|
||||
}
|
||||
}
|
||||
companyDocumentRepository.saveAll(companyDocumentEntities);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Upload company document" operation. **/
|
||||
|
||||
companyDocumentEntities.forEach(entity -> loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(entity).build()));
|
||||
|
||||
return companyDocumentEntities.stream()
|
||||
.map(this::convertToCompanyDocumentResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
private UploadFileOnAmazonS3Response uploadFileOnAmazonS3(MultipartFile file, CompanyDocumentTypeEnum type, Long companyId) {
|
||||
try {
|
||||
String s3Path = generateS3PathForCompany(type,companyId);
|
||||
log.info("Generated S3 path {}", s3Path);
|
||||
return amazonS3Service.uploadFileOnAmazonS3(s3Path, file);
|
||||
} catch (Exception e) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
||||
}
|
||||
}
|
||||
|
||||
public String generateS3PathForCompany(CompanyDocumentTypeEnum typeOfDocument, Long companyId) {
|
||||
try {
|
||||
return s3ConfigBean.generateCompanyDocumentPath(typeOfDocument, companyId);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.S3_PATH_GENERATION_ERROR_MSG));
|
||||
}
|
||||
}
|
||||
|
||||
public CompanyDocumentEntity validateCompanyDocument(Long id) {
|
||||
return companyDocumentRepository.findByIdAndNotDeleted(id).orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.COMPANY_DOCUMENT_NOT_FOUND)));
|
||||
}
|
||||
|
||||
public CompanyDocumentResponseBean convertToCompanyDocumentResponseBean(CompanyDocumentEntity entity) {
|
||||
CompanyDocumentResponseBean responseBean = new CompanyDocumentResponseBean();
|
||||
DocumentCategoryEntity categoryEntity = entity.getCategoryEntity();
|
||||
DocumentCategoryResponse responseCategory = categoryDao.convertToResponseBean(categoryEntity);
|
||||
responseBean.setId(entity.getId());
|
||||
responseBean.setFileName(entity.getFileName());
|
||||
responseBean.setType(CompanyDocumentTypeEnum.valueOf(entity.getType()));
|
||||
responseBean.setFilePath(entity.getFilePath());
|
||||
responseBean.setCompanyId(entity.getCompanyId());
|
||||
responseBean.setExpirationDate(entity.getExpirationDate());
|
||||
responseBean.setStatus(entity.getStatus());
|
||||
responseBean.setUploadedBy(entity.getUploadedBy());
|
||||
responseBean.setCategory(responseCategory);
|
||||
responseBean.setName(entity.getName());
|
||||
responseBean.setUserWithCompanyId(entity.getUserWithCompany().getId());
|
||||
responseBean.setCreatedDate(entity.getCreatedDate());
|
||||
responseBean.setUpdatedDate(entity.getUpdatedDate());
|
||||
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
public CompanyDocumentResponseBean updateCompanyDocument(HttpServletRequest request,Long companyDocumentId, CompanyDocumentRequest companyDocumentRequest){
|
||||
|
||||
CompanyDocumentEntity companyDocumentEntity = validateCompanyDocument(companyDocumentId);
|
||||
validator.validateUserWithCompany(request,companyDocumentEntity.getCompanyId());
|
||||
CompanyDocumentEntity oldCompanyDocumentData = Utils.getClonedEntityForData(companyDocumentEntity);
|
||||
LocalDateTime currentDate = LocalDateTime.now();
|
||||
if (companyDocumentRequest.getExpirationDate() != null) {
|
||||
if (companyDocumentRequest.getExpirationDate().isBefore(currentDate)) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_EXPIRATION_DATE));
|
||||
}
|
||||
companyDocumentEntity.setExpirationDate(companyDocumentRequest.getExpirationDate());
|
||||
if (companyDocumentRequest.getExpirationDate().isBefore(currentDate.plusDays(7))) {
|
||||
companyDocumentEntity.setStatus(CompanyDocumentStatusEnum.DUE.getValue());
|
||||
} else {
|
||||
companyDocumentEntity.setStatus(CompanyDocumentStatusEnum.VALID.getValue());
|
||||
}
|
||||
}
|
||||
if (companyDocumentRequest.getCategoryId() != null && companyDocumentRequest.getCategoryId() >0) {
|
||||
DocumentCategoryEntity categoryEntity = categoryDao.validateCategory(companyDocumentRequest.getCategoryId());
|
||||
setIfUpdated(companyDocumentEntity::getCategoryEntity, companyDocumentEntity::setCategoryEntity, categoryEntity);
|
||||
}
|
||||
setIfUpdated(companyDocumentEntity::getName, companyDocumentEntity::setName, companyDocumentRequest.getName());
|
||||
companyDocumentRepository.save(companyDocumentEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "updating company document" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCompanyDocumentData).newData(companyDocumentEntity).build());
|
||||
|
||||
return convertToCompanyDocumentResponseBean(companyDocumentEntity);
|
||||
}
|
||||
|
||||
public CompanyDocumentResponseBean getCompanyDocument(UserEntity user ,Long companyDocumentId) {
|
||||
CompanyDocumentEntity companyDocumentEntity = validateCompanyDocument(companyDocumentId);
|
||||
validator.validateUserWithCompany(request,companyDocumentEntity.getCompanyId());
|
||||
return convertToCompanyDocumentResponseBean(companyDocumentEntity);
|
||||
}
|
||||
|
||||
public void deleteCompanyFile(Long companyDocumentId){
|
||||
CompanyDocumentEntity companyDocumentEntity = validateCompanyDocument(companyDocumentId);
|
||||
deleteCompanyFileFromS3(companyDocumentEntity);
|
||||
}
|
||||
|
||||
public void deleteCompanyFileFromS3(CompanyDocumentEntity companyDocumentEntity){
|
||||
|
||||
try {
|
||||
CompanyDocumentEntity oldCompanyDocumentEntity = Utils.getClonedEntityForData(companyDocumentEntity);
|
||||
validator.validateUserWithCompany(request,companyDocumentEntity.getCompanyId());
|
||||
String oldCompanyDocumentPath = companyDocumentEntity.getFilePath();
|
||||
String newS3Path = s3ConfigBean.generateCompanyDocumentPathForOther(CompanyDocSourceTypeEnum.valueOf("DELETED_" + companyDocumentEntity.getType().toUpperCase()), companyDocumentEntity.getCompanyId());
|
||||
UploadFileOnAmazonS3Response response = amazonS3Service.moveFile(companyDocumentEntity.getFileName(), oldCompanyDocumentPath, newS3Path);
|
||||
companyDocumentEntity.setFileName(response.getFileName());
|
||||
companyDocumentEntity.setFilePath(response.getFilePath());
|
||||
companyDocumentEntity.setIsDeleted(true);
|
||||
companyDocumentRepository.save(companyDocumentEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Soft delete document" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldCompanyDocumentEntity).newData(companyDocumentEntity).build());
|
||||
log.info("File for company document ID {} successfully moved to deleted folder.", companyDocumentEntity.getId());
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Error moving file for company document ID {} to deleted folder: {}", companyDocumentEntity.getId(), e.getMessage());
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.ERROR_MOVING_FILE_TO_DELETED_FOLDER));
|
||||
}
|
||||
}
|
||||
|
||||
public UserActionContextEnum getUserActionContextEnum(CompanyDocumentTypeEnum type){
|
||||
UserActionContextEnum userActionContext = null;
|
||||
if (type.equals(CompanyDocumentTypeEnum.COMPANY_DOCUMENT)){
|
||||
userActionContext = UserActionContextEnum.UPLOAD_COMPANY_DOCUMENT;
|
||||
}
|
||||
else if(type.equals(CompanyDocumentTypeEnum.PERSONAL_DOCUMENT)){
|
||||
userActionContext = UserActionContextEnum.UPLOAD_COMPANY_PERSONAL_DOCUMENT;
|
||||
}
|
||||
return userActionContext;
|
||||
}
|
||||
|
||||
public DocumentResponseBean validateAndDuplicateCompanyDocument(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);
|
||||
|
||||
log.info("Original Paths - oldPath: {}, newPath: {}", oldS3Path, newS3Path);
|
||||
|
||||
oldS3Path = amazonS3ServiceImpl.decodeS3Key(amazonS3ServiceImpl.cleanOldPath(oldS3Path));
|
||||
newS3Path = amazonS3ServiceImpl.cleanNewPath(oldS3Path, newS3Path);
|
||||
log.info("Moving file from {} to {} in bucket {}", oldS3Path, newS3Path, bucketName);
|
||||
|
||||
CopyObjectRequest copyRequest = new CopyObjectRequest(bucketName, oldS3Path, bucketName, newS3Path);
|
||||
s3Client.copyObject(copyRequest);
|
||||
log.info("File copied successfully from {} to {}", oldS3Path, newS3Path);
|
||||
|
||||
DocumentEntity entity = new DocumentEntity();
|
||||
entity.setFilePath(newS3Path);
|
||||
entity.setFileName(companyDocumentEntity.getFileName());
|
||||
entity.setSource(DocumentSourceTypeEnum.APPLICATION.getValue());
|
||||
entity.setType(documentTypeEnum.getValue());
|
||||
entity.setSourceId(applicationId);
|
||||
entity.setUploadedBy(userId);
|
||||
|
||||
documentRepository.save(entity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "inserting data" operation. **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(entity).build());
|
||||
|
||||
DocumentResponseBean responseBean = callDao.convertToDocumentResponseBean(entity);
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
public List<CompanyDocumentResponseBean> getAllCompanyDocument(UserEntity user , Long companyId, CompanyDocumentTypeEnum typeEnum){
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
companyService.validateCompany(companyId);
|
||||
|
||||
Specification<CompanyDocumentEntity> spec = filterCompanyDocuments(companyId, user.getId(), typeEnum);
|
||||
|
||||
List<CompanyDocumentEntity> companyDocumentEntities = companyDocumentRepository.findAll(spec);
|
||||
return companyDocumentEntities.stream()
|
||||
.map(this::convertToCompanyDocumentResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
private Specification<CompanyDocumentEntity> filterCompanyDocuments(Long companyId, Long userId, CompanyDocumentTypeEnum typeEnum) {
|
||||
return (root, query, builder) -> {
|
||||
Predicate predicate = builder.equal(root.get("companyId"), companyId);
|
||||
|
||||
predicate = builder.and(predicate, builder.isFalse(root.get("isDeleted")));
|
||||
|
||||
if (typeEnum != null) {
|
||||
if (typeEnum == CompanyDocumentTypeEnum.COMPANY_DOCUMENT) {
|
||||
// Case 1: Fetch only COMPANY_DOCUMENT type documents for the given company
|
||||
predicate = builder.and(predicate, builder.equal(root.get("type"), CompanyDocumentTypeEnum.COMPANY_DOCUMENT.getValue()));
|
||||
|
||||
} else if (typeEnum == CompanyDocumentTypeEnum.PERSONAL_DOCUMENT) {
|
||||
// Case 2: Fetch only PERSONAL_DOCUMENT type documents for the logged-in user
|
||||
predicate = builder.and(
|
||||
predicate,
|
||||
builder.equal(root.get("type"), CompanyDocumentTypeEnum.PERSONAL_DOCUMENT.getValue()),
|
||||
builder.equal(root.get("userWithCompany").get("userId"), userId)
|
||||
);
|
||||
}
|
||||
}
|
||||
// Case 3: If typeEnum is null, fetch all documents for the company and personal documents for the user
|
||||
Predicate companyPredicate = builder.equal(root.get("companyId"), companyId);
|
||||
Predicate personalPredicate = builder.and(
|
||||
builder.equal(root.get("type"), CompanyDocumentTypeEnum.PERSONAL_DOCUMENT.getValue()),
|
||||
builder.equal(root.get("userWithCompany").get("userId"), userId)
|
||||
);
|
||||
predicate = builder.and(predicate, builder.or(companyPredicate, personalPredicate));
|
||||
|
||||
return predicate;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.amazonaws.services.dynamodbv2.xspec.S;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
@@ -16,6 +17,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationExceptio
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -62,14 +64,36 @@ public class DashboardDao {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private PecDao pecDao;
|
||||
|
||||
@Value("${default.hub.uuid}")
|
||||
private String defaultHubUuid;
|
||||
|
||||
public SuperAdminWidgetResponseBean getDashboardWidget(UserEntity requestedUserEntity) {
|
||||
SuperAdminWidgetResponseBean widgetResponseBean = new SuperAdminWidgetResponseBean();
|
||||
widgetResponseBean.setWidget1(createWidget1(requestedUserEntity));
|
||||
Map<String, Object> widgetBars = getStatistics(requestedUserEntity);
|
||||
widgetResponseBean.setWidgetBars(widgetBars);
|
||||
if(requestedUserEntity.getHub().getUniqueUuid().equals(defaultHubUuid)) {
|
||||
getEmailUsageForGepafin(requestedUserEntity, widgetResponseBean);
|
||||
}
|
||||
return widgetResponseBean;
|
||||
}
|
||||
|
||||
private void getEmailUsageForGepafin(UserEntity requestedUserEntity, SuperAdminWidgetResponseBean widgetResponseBean) {
|
||||
Map<String,Object> emailData=pecDao.getUsageDetails(requestedUserEntity.getHub().getId());
|
||||
Map<String,Object> data= (Map<String, Object>) emailData.get(GepafinConstant.DATA);
|
||||
Object usage=data.get(GepafinConstant.USAGE);
|
||||
Object limit=data.get(GepafinConstant.LIMIT);
|
||||
if(usage!=null) {
|
||||
widgetResponseBean.setPecUsage(String.valueOf(usage));
|
||||
}
|
||||
if (limit!=null) {
|
||||
widgetResponseBean.setPecLimit(String.valueOf(limit));
|
||||
}
|
||||
}
|
||||
|
||||
private Widget1 createWidget1(UserEntity requestedUserEntity) {
|
||||
Widget1 widget1 = initializeWidget1();
|
||||
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jdk.jfr.Category;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.DocumentCategoryEntity;
|
||||
import net.gepafin.tendermanagement.entities.CompanyDocumentEntity;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.DocumentCategoryRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentCategoryResponse;
|
||||
import net.gepafin.tendermanagement.repositories.DocumentCategoryRepository;
|
||||
import net.gepafin.tendermanagement.repositories.CompanyDocumentRepository;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Component
|
||||
public class DocumentCategoryDao {
|
||||
|
||||
@Autowired
|
||||
private DocumentCategoryRepository categoryRepository;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentRepository companyDocumentRepository;
|
||||
|
||||
public DocumentCategoryResponse createDocumentCategory(HttpServletRequest request, DocumentCategoryRequest categoryRequest){
|
||||
|
||||
DocumentCategoryEntity entity = createCategoryEntity(new DocumentCategoryEntity(),categoryRequest);
|
||||
categoryRepository.save(entity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Create Company Document Category" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(entity).build());
|
||||
|
||||
return convertToResponseBean(entity);
|
||||
}
|
||||
|
||||
public DocumentCategoryEntity createCategoryEntity(DocumentCategoryEntity entity, DocumentCategoryRequest companyDocumentCategoryRequest){
|
||||
entity.setCategoryName(companyDocumentCategoryRequest.getCategoryName());
|
||||
entity.setDescription(companyDocumentCategoryRequest.getDescription());
|
||||
entity.setIsDeleted(false);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public DocumentCategoryResponse convertToResponseBean(DocumentCategoryEntity entity){
|
||||
DocumentCategoryResponse response = new DocumentCategoryResponse();
|
||||
response.setId(entity.getId());
|
||||
response.setCategoryName(entity.getCategoryName());
|
||||
response.setDescription(entity.getDescription());
|
||||
response.setCreatedDate(entity.getCreatedDate());
|
||||
response.setUpdatedDate(entity.getUpdatedDate());
|
||||
return response;
|
||||
}
|
||||
|
||||
public DocumentCategoryResponse getDocumentCategoryById(HttpServletRequest request, Long id){
|
||||
return convertToResponseBean(validateCategory(id));
|
||||
}
|
||||
|
||||
public DocumentCategoryEntity validateCategory(Long id) {
|
||||
return categoryRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_NOT_FOUND)));
|
||||
}
|
||||
|
||||
public void deleteDocumentCategory(HttpServletRequest request,Long id) {
|
||||
DocumentCategoryEntity entity = validateCategory(id);
|
||||
|
||||
List<CompanyDocumentEntity> companyDocumentEntities = companyDocumentRepository.findByCategoryEntityId(id);
|
||||
if (!companyDocumentEntities.isEmpty()){
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.CATEGORY_CANNOT_BE_DELETED));
|
||||
}
|
||||
DocumentCategoryEntity oldCategoryEntity = Utils.getClonedEntityForData(entity);
|
||||
entity.setIsDeleted(true);
|
||||
categoryRepository.save(entity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "soft delete category" operation **/
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.SOFT_DELETE).oldData(oldCategoryEntity).newData(entity).build());
|
||||
}
|
||||
|
||||
public DocumentCategoryResponse updateDocumentCategory(HttpServletRequest request, Long id , DocumentCategoryRequest categoryRequest){
|
||||
DocumentCategoryEntity entity = validateCategory(id);
|
||||
DocumentCategoryEntity oldCategoryEntity = Utils.getClonedEntityForData(entity);
|
||||
DocumentCategoryEntity newCategoryEntity = updateCategoryEntity(entity, categoryRequest);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update Category" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCategoryEntity).newData(newCategoryEntity).build());
|
||||
return convertToResponseBean(entity);
|
||||
}
|
||||
|
||||
public DocumentCategoryEntity updateCategoryEntity(DocumentCategoryEntity entity , DocumentCategoryRequest categoryRequest){
|
||||
setIfUpdated(entity::getCategoryName, entity::setCategoryName, categoryRequest.getCategoryName());
|
||||
setIfUpdated(entity::getDescription, entity::setDescription, categoryRequest.getDescription());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<DocumentCategoryResponse> getAllDocumentCategory(){
|
||||
List<DocumentCategoryEntity> documentCategoryEntityList = categoryRepository.findAll();
|
||||
return documentCategoryEntityList.stream()
|
||||
.map(this::convertToResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -316,7 +316,7 @@ public class DocumentDao {
|
||||
log.info("File for document ID {} successfully moved to deleted folder.", documentEntity.getId());
|
||||
} catch (Exception e) {
|
||||
log.error("Error moving file for document ID {} to deleted folder: {}", documentEntity.getId(), e.getMessage());
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, "Error occurred while moving file to deleted folder.");
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.ERROR_MOVING_FILE_TO_DELETED_FOLDER));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ public class EmailNotificationDao {
|
||||
sendEmail(applicationEntity, SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE, bodyPlaceholders, null,amendmentRequest.getId());
|
||||
}
|
||||
|
||||
public void sendAdmissibilityNotificationEmailForApprovedApplication(ApplicationEntity applicationEntity) {
|
||||
public void sendAdmissibilityNotificationEmailForAdmissibleApplication(ApplicationEntity applicationEntity) {
|
||||
Map<String, String> bodyPlaceholders = new HashMap<>();
|
||||
bodyPlaceholders.put("{{call_name}}", applicationEntity.getCall().getName());
|
||||
bodyPlaceholders.put("{{protocol_number}}", applicationEntity.getProtocol().getProtocolNumber().toString());
|
||||
|
||||
@@ -248,7 +248,7 @@ public class FlowFormDao {
|
||||
//
|
||||
// return applicationFormEntities.isEmpty() ? null : applicationFormEntities.get(0).getForm().getId();
|
||||
// }
|
||||
public NextOrPreviousFormResponse getNextOrPreviousForm(ApplicationEntity applicationEntity, Long formId,
|
||||
public NextOrPreviousFormResponse getNextOrPreviousForm(ApplicationEntity applicationEntity,Long companyId, Long formId,
|
||||
FormActionEnum action) {
|
||||
Long calculatedFormId = null;
|
||||
FormEntity formEntity = null;
|
||||
|
||||
@@ -415,8 +415,8 @@ public class FormDao {
|
||||
}
|
||||
FieldValidatorBean fieldValidatorBean = Utils.convertSourceObjectToDestinationObject(contentResponseBean.getValidators(), FieldValidatorBean.class);
|
||||
validator
|
||||
.minLength(value, fieldValidatorBean.getMinLength(), fieldLabel) // Only applies if minLength is not null
|
||||
.maxLength(value, fieldValidatorBean.getMaxLength(), fieldLabel) // Only applies if maxLength is not null
|
||||
.minLength(value, fieldValidatorBean.getMinLength(), fieldLabel,fieldValidatorBean.getMin(),contentResponseBean) // Only applies if minLength is not null
|
||||
.maxLength(value, fieldValidatorBean.getMaxLength(), fieldLabel,fieldValidatorBean.getMax(),contentResponseBean) // Only applies if maxLength is not null
|
||||
.matchesPattern(value, fieldValidatorBean.getPattern(), fieldLabel) // Only applies if pattern is present
|
||||
.validateCustom(value, fieldValidatorBean.getCustom(), fieldLabel,contentResponseBean); // Add the custom validation here
|
||||
if (fieldValidatorBean.getCustom() != null && fieldValidatorBean.getCustom().equals(GepafinConstant.IS_PIVA)) {
|
||||
@@ -429,28 +429,34 @@ public class FormDao {
|
||||
validator.validate();
|
||||
}
|
||||
|
||||
private void checkObjectData(String fieldId, Object fieldValue, Map<String, Object> formFieldMap) {
|
||||
if (fieldValue instanceof List<?>) {
|
||||
public void checkObjectData(String fieldId, Object fieldValue, Map<String, Object> formFieldMap) {
|
||||
if (fieldValue instanceof List<?>) {
|
||||
List<?> list = (List<?>) fieldValue;
|
||||
|
||||
// Only map if the list is not empty and contains Strings
|
||||
if (!list.isEmpty() && list.get(0) instanceof String) {
|
||||
if (list.stream().allMatch(item -> item instanceof String)) {
|
||||
formFieldMap.put(fieldId, list);
|
||||
}
|
||||
else if (!list.isEmpty() && list.get(0) instanceof String) {
|
||||
for (Object value : list) {
|
||||
setFormFieldMap(fieldId, formFieldMap, value);
|
||||
}
|
||||
}else if (list.stream().allMatch(item -> item instanceof Map<?, ?> map &&
|
||||
}
|
||||
else if (list.stream().allMatch(item -> item instanceof Map<?, ?> map &&
|
||||
map.keySet().stream().allMatch(String.class::isInstance))) {
|
||||
if (fieldValue != null) {
|
||||
formFieldMap.put(fieldId, fieldValue);
|
||||
}
|
||||
} else setFormFieldMap(fieldId, formFieldMap, fieldValue);
|
||||
}
|
||||
else setFormFieldMap(fieldId, formFieldMap, fieldValue);
|
||||
}
|
||||
private void setFormFieldMap(String fieldId, Map<String, Object> formFieldMap, Object value) {
|
||||
if (value instanceof String) {
|
||||
if(value !=null && Boolean.FALSE.equals(StringUtils.isEmpty((String)value))) {
|
||||
public void setFormFieldMap(String fieldId, Map<String, Object> formFieldMap, Object value) {
|
||||
if(value !=null){
|
||||
String fieldValue= String.valueOf(value);
|
||||
if(Boolean.FALSE.equals(StringUtils.isEmpty(fieldValue))) {
|
||||
formFieldMap.put(fieldId, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,11 @@ import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.entities.NotificationEntity;
|
||||
import net.gepafin.tendermanagement.entities.NotificationTypeEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||
@@ -27,6 +23,7 @@ import net.gepafin.tendermanagement.repositories.NotificationTypeRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
@@ -80,6 +77,9 @@ public class NotificationDao {
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
public NotificationResponse sendNotification(NotificationReq notificationReq) {
|
||||
|
||||
// Ensure userId is properly set in notificationReq if not already
|
||||
@@ -414,4 +414,60 @@ public class NotificationDao {
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_ID), userId));
|
||||
return predicates;
|
||||
}
|
||||
|
||||
public void sendNotificationToBeneficiaryForDocumentExpiration(CompanyDocumentEntity companyDocumentEntity, NotificationTypeEnum notificationTypeEnum) {
|
||||
|
||||
CompanyEntity companyEntity = companyService.validateCompany(companyDocumentEntity.getCompanyId());
|
||||
Map<String, String> placeHolders = new HashMap<>();
|
||||
placeHolders.put("{{file_name}}", companyDocumentEntity.getFileName());
|
||||
placeHolders.put("{{company_name}}", companyEntity.getCompanyName());
|
||||
placeHolders.put("{{expiration_date}}", companyDocumentEntity.getExpirationDate().toString());
|
||||
NotificationReq notificationReq = createNotificationReq(notificationTypeEnum.getValue(), placeHolders, companyDocumentEntity.getUserWithCompany().getUserId(), companyDocumentEntity.getUserWithCompany(),
|
||||
listOf(companyDocumentEntity.getCompanyId()));
|
||||
sendNotification(notificationReq);
|
||||
}
|
||||
|
||||
public PageableResponseBean<List<NotificationResponse>> getNotificationsByUserIdAndCompanyIdByPagination(Long userId, Long companyId, NotificationRequestBean notificationRequestBean) {
|
||||
UserWithCompanyEntity userWithCompany;
|
||||
if (companyId != null) {
|
||||
userWithCompany = companyDao.validateUserWithCompny(userId, companyId);
|
||||
}else {
|
||||
userWithCompany=null;
|
||||
}
|
||||
Integer pageNo = null;
|
||||
Integer pageLimit = null;
|
||||
if (notificationRequestBean.getGlobalFilters() != null) {
|
||||
pageNo = notificationRequestBean.getGlobalFilters().getPage();
|
||||
pageLimit = notificationRequestBean.getGlobalFilters().getLimit();
|
||||
}
|
||||
if (pageLimit == null || pageLimit <= 0) {
|
||||
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||
}
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
}
|
||||
Specification<NotificationEntity> spec = search(userId, notificationRequestBean);
|
||||
if(userWithCompany!=null){
|
||||
spec = spec.and((root, query, criteriaBuilder) ->
|
||||
criteriaBuilder.equal(root.get("userWithCompany").get("id"), userWithCompany.getId()));
|
||||
}
|
||||
Page<NotificationEntity> entityPage = notificationRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
// Prepare the response
|
||||
List<NotificationResponse> notificationResponses = entityPage.getContent().stream()
|
||||
.map(notification -> {
|
||||
NotificationResponse response = convertNotificationEntityToNotificationResponse(notification);
|
||||
return response;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
PageableResponseBean<List<NotificationResponse>> pageableResponseBean = new PageableResponseBean<>();
|
||||
pageableResponseBean.setBody(notificationResponses);
|
||||
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||
pageableResponseBean.setPageSize(entityPage.getSize());
|
||||
|
||||
return pageableResponseBean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,7 +560,7 @@ public class PdfDao {
|
||||
}
|
||||
|
||||
// Process 'fileupload' and 'checkboxes' cases as in the original logic
|
||||
if (name.equals("fileupload")) {
|
||||
if (name.equals("fileupload") || name.equals("fileselect")) {
|
||||
if (fieldValue instanceof List<?> && ((List<?>) fieldValue).stream().allMatch(item -> item instanceof DocumentResponseBean)) {
|
||||
List<DocumentResponseBean> documentList = (List<DocumentResponseBean>) fieldValue;
|
||||
List<String> names = documentList.stream()
|
||||
|
||||
59
src/main/java/net/gepafin/tendermanagement/dao/PecDao.java
Normal file
59
src/main/java/net/gepafin/tendermanagement/dao/PecDao.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import feign.FeignException;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||
import net.gepafin.tendermanagement.service.feignClient.PecFeignService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class PecDao {
|
||||
|
||||
public final Logger log = LoggerFactory.getLogger(PecDao.class);
|
||||
|
||||
@Autowired
|
||||
private PecFeignService pecFeignService;
|
||||
|
||||
@Autowired
|
||||
private EmailNotificationDao emailNotificationDao;
|
||||
|
||||
|
||||
public Map<String, Object> getUsageDetails(Long hubId) {
|
||||
EmailConfig emailConfig = emailNotificationDao.retrieveEmailConfig(hubId);
|
||||
|
||||
Map<String, Object> responseBody = new HashMap<>();
|
||||
try {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set(GepafinConstant.AUTHORIZATION, "Bearer " + emailConfig.getAuthToken());
|
||||
headers.set("x-username", emailConfig.getUsername());
|
||||
headers.set("x-password", emailConfig.getPassword());
|
||||
headers.add(org.apache.http.HttpHeaders.USER_AGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0");
|
||||
|
||||
URI baseUrl = URI.create(GepafinConstant.PEC_SERVICE_URL+GepafinConstant.PEC_SERVICE_INBOX_MAIL);
|
||||
ResponseEntity<Object> response = pecFeignService.getUsageDetails(baseUrl,headers);
|
||||
|
||||
|
||||
if (response.getStatusCode() == HttpStatus.OK && response.hasBody()) {
|
||||
log.info("Successfully fetched usage and limit");
|
||||
responseBody = (Map<String, Object>) response.getBody();
|
||||
}
|
||||
} catch (FeignException ex) {
|
||||
}
|
||||
return responseBody;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
|
||||
import net.gepafin.tendermanagement.enums.CompanyDocSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.CompanyDocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.repositories.S3ConfigRepository;
|
||||
@@ -49,4 +51,29 @@ public class S3PathConfig {
|
||||
public String getBucketNameForCallAppType(DocumentSourceTypeEnum type){
|
||||
return s3ConfigRepository.getBucketNameByType(type);
|
||||
}
|
||||
|
||||
public String generateCompanyDocumentPath(CompanyDocumentTypeEnum type, Long companyId) {
|
||||
S3ConfigEntity config = getCompanyDocumentPath(type);
|
||||
return config.getParentFolder() + "/" + buildCompanyDocumentS3Path(config.getPath(), companyId);
|
||||
}
|
||||
|
||||
private String buildCompanyDocumentS3Path(String pathTemplate, Long companyId) {
|
||||
return pathTemplate
|
||||
.replace("{company_id}", companyId != null && companyId != 0L ? "company_" + companyId : "");
|
||||
}
|
||||
|
||||
private S3ConfigEntity getCompanyDocumentPath(CompanyDocumentTypeEnum type) {
|
||||
return s3ConfigRepository.getPathByType(type.name()).orElseThrow(() -> new IllegalArgumentException("No path configuration found for type: " + type));
|
||||
}
|
||||
|
||||
private S3ConfigEntity getCompanyDocumentPathForOther(CompanyDocSourceTypeEnum type) {
|
||||
|
||||
return s3ConfigRepository.getPathByType(type.name()).orElseThrow(() -> new IllegalArgumentException("No path configuration found for type: " + type));
|
||||
}
|
||||
|
||||
public String generateCompanyDocumentPathForOther(CompanyDocSourceTypeEnum type, Long companyId) {
|
||||
|
||||
S3ConfigEntity config = getCompanyDocumentPathForOther(type);
|
||||
return config.getParentFolder() + "/" + buildCompanyDocumentS3Path(config.getPath(),companyId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,18 @@ package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.RoleActionContextEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserActionEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.TimePeriodEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
|
||||
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserActionResponseBean;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationPageableRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.SortBy;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
import net.gepafin.tendermanagement.repositories.RoleActionContextRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserActionsRepository;
|
||||
@@ -23,9 +26,12 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
|
||||
@Component
|
||||
public class UserActionDao {
|
||||
|
||||
@@ -41,16 +47,14 @@ public class UserActionDao {
|
||||
@Autowired
|
||||
private RoleActionContextRepository roleActionContextRepository;
|
||||
|
||||
public SummaryPageResponseBean getUserAction(HttpServletRequest request, UserEntity userEntity, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext){
|
||||
public SummaryPageResponseBean getUserAction(HttpServletRequest request, UserEntity userEntity){
|
||||
Long numberOfLoginAttempts = userActionsRepository.countUserLoginAttempts(userEntity.getId());
|
||||
Long applicationsProcessed = assignedApplicationsRepository.countAssignedApplicationsByUserId(userEntity.getId());
|
||||
|
||||
List<UserActionEntity> userActions = getFilterUserActions(userEntity.getId(),timeFilter,actionContext);
|
||||
|
||||
return createSummaryPageResponse(userEntity,numberOfLoginAttempts,applicationsProcessed,userActions);
|
||||
return createSummaryPageResponse(userEntity,numberOfLoginAttempts,applicationsProcessed);
|
||||
}
|
||||
|
||||
public SummaryPageResponseBean createSummaryPageResponse(UserEntity user, Long numberOfLoginAttempts, Long applicationsProcessed, List<UserActionEntity> userActions){
|
||||
public SummaryPageResponseBean createSummaryPageResponse(UserEntity user, Long numberOfLoginAttempts, Long applicationsProcessed){
|
||||
SummaryPageResponseBean response = new SummaryPageResponseBean();
|
||||
response.setRole(user.getRoleEntity().getRoleName());
|
||||
response.setLastLogin(user.getLastLogin());
|
||||
@@ -59,9 +63,6 @@ public class UserActionDao {
|
||||
response.setEmail(user.getEmail());
|
||||
response.setNumberOfLoginAttempts(numberOfLoginAttempts);
|
||||
response.setApplicationsProcessed(applicationsProcessed);
|
||||
|
||||
List<UserActionResponseBean> userAction = convertEntityToResponse(userActions);
|
||||
response.setUserActions(userAction);
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -137,6 +138,7 @@ public class UserActionDao {
|
||||
responseBean.setResponse(action.getResponse());
|
||||
responseBean.setCreatedDate(action.getCreatedDate());
|
||||
responseBean.setUpdatedDate(action.getUpdatedDate());
|
||||
responseBean.setMethodType(action.getMethodType());
|
||||
return responseBean;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
@@ -157,4 +159,138 @@ public class UserActionDao {
|
||||
return responseBean;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
public PageableResponseBean<List<UserActionResponseBean>> getUserActionByPagination(UserEntity user, UserActionPaginationRequest userActionPaginationRequest) {
|
||||
Integer pageNo = null;
|
||||
Integer pageLimit = null;
|
||||
if (userActionPaginationRequest.getGlobalFilters() != null) {
|
||||
pageNo = userActionPaginationRequest.getGlobalFilters().getPage();
|
||||
pageLimit = userActionPaginationRequest.getGlobalFilters().getLimit();
|
||||
}
|
||||
if (pageLimit == null || pageLimit <= 0) {
|
||||
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||
}
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
}
|
||||
Specification<UserActionEntity> spec = search(userActionPaginationRequest,user);
|
||||
Page<UserActionEntity> entityPage = userActionsRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
// Prepare the response
|
||||
Long numberOfLoginAttempts = userActionsRepository.countUserLoginAttempts(user.getId());
|
||||
Long applicationsProcessed = assignedApplicationsRepository.countAssignedApplicationsByUserId(user.getId());
|
||||
|
||||
|
||||
List<UserActionResponseBean> userActionResponseBeans = convertEntityToResponse(entityPage.stream().toList());
|
||||
|
||||
|
||||
PageableResponseBean<List<UserActionResponseBean>> pageableResponseBean = new PageableResponseBean<>();
|
||||
pageableResponseBean.setBody(userActionResponseBeans);
|
||||
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||
pageableResponseBean.setPageSize(entityPage.getSize());
|
||||
|
||||
return pageableResponseBean;
|
||||
}
|
||||
public Specification<UserActionEntity> search(UserActionPaginationRequest userActionPaginationRequest,UserEntity userEntity) {
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
|
||||
List<Predicate> predicates = getPredicates(userActionPaginationRequest, criteriaBuilder, root,userEntity);
|
||||
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||
|
||||
if (userActionPaginationRequest .getGlobalFilters() != null
|
||||
&& userActionPaginationRequest.getGlobalFilters().getSortBy() != null &&
|
||||
userActionPaginationRequest.getGlobalFilters().getSortBy().getColumnName() != null && Boolean.FALSE.equals(
|
||||
isEmpty(userActionPaginationRequest.getGlobalFilters().getSortBy().getColumnName()))) {
|
||||
sortBy.setColumnName(userActionPaginationRequest.getGlobalFilters().getSortBy().getColumnName());
|
||||
sortBy.setSortDesc(true);
|
||||
if (userActionPaginationRequest.getGlobalFilters().getSortBy().getSortDesc() != null) {
|
||||
sortBy.setSortDesc(userActionPaginationRequest.getGlobalFilters().getSortBy().getSortDesc());
|
||||
}
|
||||
}
|
||||
|
||||
query.orderBy(criteriaBuilder.desc(root.get(sortBy.getColumnName())));
|
||||
if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||
query.orderBy(criteriaBuilder.asc(root.get(sortBy.getColumnName())));
|
||||
}
|
||||
return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private List<Predicate> getPredicates(UserActionPaginationRequest userActionPaginationRequest,
|
||||
CriteriaBuilder criteriaBuilder, Root<UserActionEntity> root,UserEntity userEntity) {
|
||||
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
if (userActionPaginationRequest.getGlobalFilters() != null) {
|
||||
year = userActionPaginationRequest.getGlobalFilters().getYear();
|
||||
search = userActionPaginationRequest.getGlobalFilters().getSearch();
|
||||
}
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
if (year != null && year > 0) {
|
||||
int filterYear = userActionPaginationRequest.getGlobalFilters().getYear();
|
||||
|
||||
// Create LocalDateTime boundaries for the start and end of the year
|
||||
LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
|
||||
LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
|
||||
|
||||
// Add the range comparison to filter records within the year
|
||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||
|
||||
}
|
||||
// Search in `title` and `message` (if search term is provided)
|
||||
if (search != null && !search.isEmpty()) {
|
||||
Predicate actionType = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.ACTION_TYPE)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(actionType));
|
||||
Predicate actionContext = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.ACTION_CONTEXT)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(actionContext));
|
||||
Predicate methodType = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get(GepafinConstant.METHOD_TYPE)),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(methodType));
|
||||
}
|
||||
|
||||
// Filter by `status` (if status list is provided)
|
||||
if (userActionPaginationRequest.getActionContext() != null && !userActionPaginationRequest.getActionContext().isEmpty()) {
|
||||
List<String> statusValues = userActionPaginationRequest.getActionContext().stream()
|
||||
.map(UserActionContextEnum::name) // Convert enum to string
|
||||
.toList();
|
||||
predicates.add(root.get("actionContext").in(statusValues));
|
||||
}
|
||||
if (userActionPaginationRequest.getActionType() != null && !userActionPaginationRequest.getActionType().isEmpty()) {
|
||||
List<String> statusValues = userActionPaginationRequest.getActionType().stream()
|
||||
.map(UserActionLogsEnum::name) // Convert enum to string
|
||||
.toList();
|
||||
predicates.add(root.get("actionType").in(statusValues));
|
||||
}
|
||||
|
||||
TimePeriodEnum timeRange= userActionPaginationRequest.getTimeFilter();
|
||||
if (timeRange != null) {
|
||||
LocalDateTime startDate = null;
|
||||
LocalDateTime endDate = LocalDateTime.now();
|
||||
|
||||
switch (timeRange) {
|
||||
case LAST_WEEK -> startDate = endDate.minusWeeks(1);
|
||||
case LAST_QUARTER -> startDate = endDate.minusMonths(3);
|
||||
case LAST_SEMESTER -> startDate = endDate.minusMonths(6);
|
||||
case LAST_YEAR -> startDate = endDate.minusYears(1);
|
||||
}
|
||||
|
||||
if (startDate != null) {
|
||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startDate, endDate));
|
||||
}
|
||||
}
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.USER_ID), userEntity.getId()));
|
||||
|
||||
return predicates;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.config.SamlSuccessHandler;
|
||||
@@ -10,6 +13,7 @@ import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.model.util.SortBy;
|
||||
import net.gepafin.tendermanagement.repositories.BeneficiaryRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.service.HubService;
|
||||
@@ -29,8 +33,13 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,6 +47,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
|
||||
@Component
|
||||
public class UserDao {
|
||||
@@ -597,6 +607,152 @@ public class UserDao {
|
||||
log.info("Total users found with role ID {}: {}", roleIds, userResponseBeans.size());
|
||||
return userResponseBeans;
|
||||
}
|
||||
public PageableResponseBean<List<UserResponseBean>> getUserByPagination(UserPaginationRequestBean userPaginationRequestBean,UserEntity userEntity) {
|
||||
Integer pageNo = null;
|
||||
Integer pageLimit = null;
|
||||
if (userPaginationRequestBean.getGlobalFilters() != null) {
|
||||
pageNo = userPaginationRequestBean.getGlobalFilters().getPage();
|
||||
pageLimit = userPaginationRequestBean.getGlobalFilters().getLimit();
|
||||
}
|
||||
if (pageLimit == null || pageLimit <= 0) {
|
||||
pageLimit = GepafinConstant.DEFAULT_PAGE_LIMIT;
|
||||
}
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
}
|
||||
Specification<UserEntity> spec = search(userPaginationRequestBean,userEntity);
|
||||
Page<UserEntity> entityPage = userRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
|
||||
List<UserResponseBean> applicationResponses = entityPage.getContent().stream()
|
||||
.map(user -> {
|
||||
UserResponseBean response = convertUserEntityToUserResponse(user);
|
||||
return response;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
PageableResponseBean<List<UserResponseBean>> pageableResponseBean = new PageableResponseBean<>();
|
||||
pageableResponseBean.setBody(applicationResponses);
|
||||
pageableResponseBean.setCurrentPage(entityPage.getNumber() + 1); // Page numbers typically start from 0, so add 1 for user-friendly indexing
|
||||
pageableResponseBean.setTotalPages(entityPage.getTotalPages());
|
||||
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
|
||||
pageableResponseBean.setPageSize(entityPage.getSize());
|
||||
|
||||
return pageableResponseBean;
|
||||
}
|
||||
|
||||
public Specification<UserEntity> search(UserPaginationRequestBean userPaginationRequestBean,UserEntity userEntity) {
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
|
||||
List<Predicate> predicates = getPredicates(userPaginationRequestBean, criteriaBuilder, root,userEntity);
|
||||
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||
|
||||
if (userPaginationRequestBean .getGlobalFilters() != null
|
||||
&& userPaginationRequestBean.getGlobalFilters().getSortBy() != null &&
|
||||
userPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName() != null && Boolean.FALSE.equals(
|
||||
isEmpty(userPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName()))) {
|
||||
sortBy.setColumnName(userPaginationRequestBean.getGlobalFilters().getSortBy().getColumnName());
|
||||
sortBy.setSortDesc(true);
|
||||
if (userPaginationRequestBean.getGlobalFilters().getSortBy().getSortDesc() != null) {
|
||||
sortBy.setSortDesc(userPaginationRequestBean.getGlobalFilters().getSortBy().getSortDesc());
|
||||
}
|
||||
}
|
||||
|
||||
query.orderBy(criteriaBuilder.desc(root.get(sortBy.getColumnName())));
|
||||
if (Boolean.FALSE.equals(sortBy.getSortDesc())) {
|
||||
query.orderBy(criteriaBuilder.asc(root.get(sortBy.getColumnName())));
|
||||
}
|
||||
return query.where(criteriaBuilder.and(predicates.toArray(new Predicate[0]))).getRestriction();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private List<Predicate> getPredicates(UserPaginationRequestBean userPaginationRequestBean,
|
||||
CriteriaBuilder criteriaBuilder, Root<UserEntity> root,UserEntity user) {
|
||||
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
if (userPaginationRequestBean.getGlobalFilters() != null) {
|
||||
year = userPaginationRequestBean.getGlobalFilters().getYear();
|
||||
search = userPaginationRequestBean.getGlobalFilters().getSearch();
|
||||
}
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
if (year != null && year > 0) {
|
||||
int filterYear = userPaginationRequestBean.getGlobalFilters().getYear();
|
||||
|
||||
// Create LocalDateTime boundaries for the start and end of the year
|
||||
LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
|
||||
LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
|
||||
|
||||
// Add the range comparison to filter records within the year
|
||||
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));
|
||||
|
||||
}
|
||||
// Search in `title` and `message` (if search term is provided)
|
||||
if (search != null && !search.isEmpty()) {
|
||||
Predicate predicate = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get("firstName")),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(predicate));
|
||||
Predicate predicate1 = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get("lastName")),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(predicate1));
|
||||
|
||||
Predicate predicate2 = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get("phoneNumber")),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(predicate2));
|
||||
|
||||
Predicate predicate3 = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get("organization")),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(predicate3));
|
||||
|
||||
Predicate predicate4 = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get("address")),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(predicate4));
|
||||
|
||||
Predicate predicate5 = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get("city")),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(predicate5));
|
||||
|
||||
Predicate predicate6 = criteriaBuilder.like(
|
||||
criteriaBuilder.upper(root.get("country")),
|
||||
"%" + search.toUpperCase() + "%"
|
||||
);
|
||||
predicates.add(criteriaBuilder.or(predicate6));
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Filter by `status` (if status list is provided)
|
||||
if (userPaginationRequestBean.getStatus() != null && !userPaginationRequestBean.getStatus().isEmpty()) {
|
||||
List<String> statusValues = userPaginationRequestBean.getStatus().stream()
|
||||
.map(UserStatusEnum::name) // Convert enum to string
|
||||
.toList();
|
||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||
}
|
||||
if (userPaginationRequestBean.getRole() != null && !userPaginationRequestBean.getRole().isEmpty()) {
|
||||
List<String> roleValues = userPaginationRequestBean.getRole().stream()
|
||||
.map(RoleStatusEnum::name) // Convert enum to string
|
||||
.toList();
|
||||
predicates.add(root.get("roleEntity").get("roleType").in(roleValues));
|
||||
}
|
||||
predicates.add(root.get(GepafinConstant.HUB).get("id").in(user.getHub().getId()));
|
||||
|
||||
return predicates;
|
||||
|
||||
}
|
||||
|
||||
public UserResponseBean updateUserDetails(HttpServletRequest request , Long userId, UpdateUserReqForBeneficiary userReq){
|
||||
log.info("Updating user by beneficiary with ID: {}", userId);
|
||||
@@ -647,9 +803,4 @@ public class UserDao {
|
||||
return convertUserEntityToUserResponse(userEntity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Table(name = "COMPANY_DOCUMENT")
|
||||
@Data
|
||||
public class CompanyDocumentEntity extends BaseEntity {
|
||||
|
||||
@Column(name = "FILE_NAME")
|
||||
private String fileName;
|
||||
|
||||
@Column(name = "FILE_PATH")
|
||||
private String filePath;
|
||||
|
||||
@Column(name ="name")
|
||||
private String name;
|
||||
|
||||
@Column(name="TYPE")
|
||||
private String type;
|
||||
|
||||
@Column(name="COMPANY_ID")
|
||||
private Long companyId;
|
||||
|
||||
@Column(name ="IS_DELETED")
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
@Column(name="UPLOADED_BY")
|
||||
private Long uploadedBy;
|
||||
|
||||
@Column(name = "EXPIRATION_DATE")
|
||||
private LocalDateTime expirationDate;
|
||||
|
||||
@Column(name ="STATUS")
|
||||
private String status;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "USER_WITH_COMPANY_ID")
|
||||
private UserWithCompanyEntity userWithCompany;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "DOCUMENT_CATEGORY_ID")
|
||||
private DocumentCategoryEntity categoryEntity;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
@Entity
|
||||
@Table(name = "document_category")
|
||||
@Data
|
||||
public class DocumentCategoryEntity extends BaseEntity {
|
||||
|
||||
@Column(name = "CATEGORY_NAME")
|
||||
private String categoryName;
|
||||
|
||||
@Column(name = "DESCRIPTION")
|
||||
private String description;
|
||||
|
||||
@Column(name ="IS_DELETED")
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
}
|
||||
@@ -4,7 +4,9 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum ApplicationStatusForEvaluation {
|
||||
APPROVED("APPROVED"),
|
||||
REJECTED("REJECTED");
|
||||
REJECTED("REJECTED"),
|
||||
ADMISSIBLE("ADMISSIBLE"),
|
||||
TECHNICAL_EVALUATION("TECHNICAL_EVALUATION");
|
||||
|
||||
private String value;
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ public enum ApplicationStatusTypeEnum {
|
||||
EVALUATION("EVALUATION"),
|
||||
APPOINTMENT("APPOINTMENT"),
|
||||
NDG("NDG"),
|
||||
ADMISSIBLE("ADMISSIBLE");
|
||||
ADMISSIBLE("ADMISSIBLE"),
|
||||
TECHNICAL_EVALUATION("TECHNICAL_EVALUATION");
|
||||
|
||||
private String value;
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
|
||||
public enum CompanyDocSourceTypeEnum {
|
||||
|
||||
DELETED_PERSONAL_DOCUMENT("DELETED_PERSONAL_DOCUMENT"),
|
||||
DELETED_COMPANY_DOCUMENT("DELETED_COMPANY_DOCUMENT");
|
||||
|
||||
|
||||
private String value;
|
||||
|
||||
CompanyDocSourceTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
public enum CompanyDocumentStatusEnum {
|
||||
VALID("VALID"),
|
||||
DUE("DUE"),
|
||||
EXPIRED("EXPIRED");
|
||||
|
||||
private String value;
|
||||
|
||||
CompanyDocumentStatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
public enum CompanyDocumentTypeEnum {
|
||||
COMPANY_DOCUMENT("COMPANY_DOCUMENT"),
|
||||
PERSONAL_DOCUMENT("PERSONAL_DOCUMENT");
|
||||
|
||||
private String value;
|
||||
|
||||
CompanyDocumentTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public enum EmailScenarioTypeEnum {
|
||||
APPLICATION_AMENDMENT_REQUESTED("APPLICATION_AMENDMENT_REQUESTED"),
|
||||
APPLICATION_AMENDMENT_EXPIRED("APPLICATION_AMENDMENT_EXPIRED"),
|
||||
APPLICATION_AMENDMENT_REMINDER("APPLICATION_AMENDMENT_REMINDER"),
|
||||
APPLICATION_APPROVED("APPLICATION_APPROVED"),
|
||||
APPLICATION_ADMISSIBLE("APPLICATION_ADMISSIBLE"),
|
||||
USER_CREATION("USER_CREATION"),
|
||||
PASSWORD_RESET_REQUEST("PASSWORD_RESET_REQUEST"),
|
||||
APPLICATION_REJECTED("APPLICATION_REJECTED");
|
||||
|
||||
@@ -5,7 +5,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
public enum ExpirationTypeEnum {
|
||||
|
||||
AMENDMENT("AMENDMENT"),
|
||||
EVALUATION("EVALUATION");
|
||||
EVALUATION("EVALUATION"),
|
||||
COMPANY_DOCUMENT("COMPANY_DOCUMENT");
|
||||
|
||||
private String value;
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
|
||||
public enum MatchModeEnum {
|
||||
STARTSWITH("Starts with"),
|
||||
ENDSWITH("Ends with"),
|
||||
CONTAINS("Contains"),
|
||||
EQUALS("Equals"),
|
||||
DATEIS("Date is"),
|
||||
DATEISNOT("Date is not"),
|
||||
BEFORE("Date is before"),
|
||||
AFTER("Date is after");
|
||||
|
||||
private String value;
|
||||
|
||||
MatchModeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
public static MatchModeEnum fromObject(Object value) {
|
||||
if (value instanceof String) {
|
||||
String strValue = ((String) value).trim();
|
||||
for (MatchModeEnum mode : MatchModeEnum.values()) {
|
||||
if (mode.getValue().equalsIgnoreCase(strValue)) {
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid MatchModeEnum: " + value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@ public enum NotificationTypeEnum {
|
||||
EVALUATION_CREATION("EVALUATION_CREATION"),
|
||||
EVALUATION_EXPIRED("EVALUATION_EXPIRED"),
|
||||
AMENDMENT_EXPIRATION_REMINDER("AMENDMENT_EXPIRATION_REMINDER"),
|
||||
EVALUATION_EXPIRATION_REMINDER("EVALUATION_EXPIRATION_REMINDER");
|
||||
EVALUATION_EXPIRATION_REMINDER("EVALUATION_EXPIRATION_REMINDER"),
|
||||
COMPANY_DOCUMENT_EXPIRATION_REMINDER("COMPANY_DOCUMENT_EXPIRATION_REMINDER");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
@@ -192,7 +192,28 @@ public enum UserActionContextEnum {
|
||||
|
||||
|
||||
GET_USER_ACTION("GET_USER_ACTION"),
|
||||
GET_ACTION_CONTEXT_LABELS("GET_ACTION_CONTEXT_LABELS");
|
||||
GET_ACTION_CONTEXT_LABELS("GET_ACTION_CONTEXT_LABELS"),
|
||||
|
||||
GET_COMPANY_DOCUMENT("GET_COMPANY_DOCUMENT"),
|
||||
DELETE_COMPANY_DOCUMENT("DELETE_COMPANY_DOCUMENT"),
|
||||
UPLOAD_COMPANY_DOCUMENT("UPLOAD_COMPANY_DOCUMENT"),
|
||||
UPLOAD_COMPANY_PERSONAL_DOCUMENT("UPLOAD_COMPANY_PERSONAL_DOCUMENT"),
|
||||
GET_ALL_COMPANY_DOCUMENT("GET_ALL_COMPANY_DOCUMENT"),
|
||||
UPDATE_COMPANY_DOCUMENT("UPDATE_COMPANY_DOCUMENT"),
|
||||
DUPLICATE_COMPANY_DOCUMENT("DUPLICATE_COMPANY_DOCUMENT"),
|
||||
|
||||
CREATE_DOCUMENT_CATEGORY("CREATE_DOCUMENT_CATEGORY"),
|
||||
GET_DOCUMENT_CATEGORY("GET_DOCUMENT_CATEGORY"),
|
||||
DELETE_DOCUMENT_CATEGORY("DELETE_DOCUMENT_CATEGORY"),
|
||||
UPDATE_DOCUMENT_CATEGORY("UPDATE_DOCUMENT_CATEGORY"),
|
||||
COMPANY_DOCUMENT_EXPIRATION_SCHEDULER("COMPANY_DOCUMENT_EXPIRATION_SCHEDULER"),
|
||||
GET_ALL_DOCUMENT_CATEGORY("GET_ALL_DOCUMENT_CATEGORY"),
|
||||
|
||||
GET_ALL_ASSIGNED_APPLICATION_BY_PAGINATION("GET_ALL_ASSIGNED_APPLICATION_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_BY_PAGINATION("GET_ALL_USER_BY_PAGINATION"),
|
||||
UPDATE_CALL_END_DATE_AND_TIME("UPDATE_CALL_END_DATE_AND_TIME");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApplicationAmendmentPaginationRequestBean {
|
||||
|
||||
private GlobalFilters globalFilters;
|
||||
|
||||
private List<ApplicationAmendmentRequestEnum> status;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class ApplicationPageableRequestBean {
|
||||
@@ -13,4 +14,6 @@ public class ApplicationPageableRequestBean {
|
||||
private Integer daysRange;
|
||||
|
||||
private List<ApplicationStatusTypeEnum> status;
|
||||
|
||||
private Map<String, FilterCriteria> filters;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AssignedApplicationPageableRequestBean {
|
||||
|
||||
|
||||
private GlobalFilters globalFilters;
|
||||
|
||||
private List<AssignedApplicationEnum> status;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
@Data
|
||||
public class CompanyDocumentRequest {
|
||||
private Long categoryId;
|
||||
private String name ;
|
||||
private LocalDateTime expirationDate;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DocumentCategoryRequest {
|
||||
private String categoryName;
|
||||
private String description;
|
||||
}
|
||||
@@ -11,6 +11,10 @@ public class FieldValidatorBean {
|
||||
|
||||
private Long maxLength;
|
||||
|
||||
private Long min;
|
||||
|
||||
private Long max;
|
||||
|
||||
private String pattern;
|
||||
|
||||
private String custom;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.MatchModeEnum;
|
||||
|
||||
@Data
|
||||
public class FilterCriteria {
|
||||
|
||||
private Object value;
|
||||
private MatchModeEnum matchMode;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.TimePeriodEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UserActionPaginationRequest {
|
||||
|
||||
private GlobalFilters globalFilters;
|
||||
|
||||
private TimePeriodEnum timeFilter;
|
||||
|
||||
private List<UserActionContextEnum> actionContext;
|
||||
|
||||
private List<UserActionLogsEnum> actionType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UserPaginationRequestBean {
|
||||
|
||||
private GlobalFilters globalFilters;
|
||||
|
||||
private List<UserStatusEnum> status;
|
||||
|
||||
private List<RoleStatusEnum> role;
|
||||
}
|
||||
@@ -44,5 +44,7 @@ public class ApplicationEvaluationFormResponse {
|
||||
private LocalDateTime dateAccepted;
|
||||
private LocalDateTime dateRejected;
|
||||
private EvaluationVersionEnum evaluationVersion;
|
||||
private Long numberOfCheck;
|
||||
private Long appointmentTemplateId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.CompanyDocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CompanyDocumentResponseBean extends BaseBean {
|
||||
|
||||
private String fileName;
|
||||
|
||||
private String filePath;
|
||||
|
||||
private CompanyDocumentTypeEnum type;
|
||||
|
||||
private Long companyId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String status;
|
||||
|
||||
private LocalDateTime expirationDate;
|
||||
|
||||
private Long uploadedBy;
|
||||
|
||||
private Long userWithCompanyId;
|
||||
|
||||
private DocumentCategoryResponse category;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
|
||||
@Data
|
||||
public class DocumentCategoryResponse extends BaseBean {
|
||||
private String categoryName;
|
||||
private String description;
|
||||
|
||||
}
|
||||
@@ -14,5 +14,4 @@ public class SummaryPageResponseBean {
|
||||
private LocalDateTime registrationDate;
|
||||
private Long numberOfLoginAttempts;
|
||||
private Long applicationsProcessed;
|
||||
private List<UserActionResponseBean> userActions;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.entities.UserActionEntity;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -12,6 +13,12 @@ public class SuperAdminWidgetResponseBean {
|
||||
|
||||
private Widget1 widget1;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String pecUsage;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String pecLimit;
|
||||
|
||||
private Map<String, Object> widgetBars;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface ApplicationEvaluationFormFieldRepository extends JpaRepository<ApplicationEvaluationFormFieldEntity,Long> {
|
||||
@@ -15,4 +16,23 @@ public interface ApplicationEvaluationFormFieldRepository extends JpaRepository<
|
||||
"AND f.isDeleted = false")
|
||||
List<ApplicationEvaluationFormFieldEntity> findByApplicationEvaluationFormId(
|
||||
@Param("applicationEvaluationFormId") Long applicationEvaluationFormId);
|
||||
|
||||
Optional<ApplicationEvaluationFormFieldEntity> findByApplicationEvaluationFormIdAndFieldIdAndIsDeletedFalse(Long applicationEvaluationFormId, String fieldId);
|
||||
|
||||
@Query("SELECT f FROM ApplicationEvaluationFormFieldEntity f " +
|
||||
"WHERE f.applicationEvaluationForm.id = :applicationEvaluationFormId " +
|
||||
"AND f.fieldId IN :fieldIds " +
|
||||
"AND f.isDeleted = false")
|
||||
List<ApplicationEvaluationFormFieldEntity> findByApplicationEvaluationFormIdAndFieldIds(
|
||||
@Param("applicationEvaluationFormId") Long applicationEvaluationFormId,
|
||||
@Param("fieldIds") List<String> fieldIds);
|
||||
|
||||
|
||||
@Query("SELECT f FROM ApplicationEvaluationFormFieldEntity f " +
|
||||
"WHERE f.applicationEvaluationForm.id = :applicationEvaluationFormId " +
|
||||
"AND f.fieldId = :fieldId " +
|
||||
"AND f.isDeleted = false")
|
||||
ApplicationEvaluationFormFieldEntity findByFieldIdAndApplicationEvaluationFormId(
|
||||
@Param("fieldId") String fieldId,
|
||||
@Param("applicationEvaluationFormId") Long applicationEvaluationFormId);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -112,24 +110,31 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
||||
@Param("userId") Long userId,
|
||||
@Param("userWithCompanyId") Long userWithCompanyId);
|
||||
|
||||
@Query("""
|
||||
SELECT TO_CHAR(a.submissionDate, 'Mon') AS month,
|
||||
SUM(a.amountRequested) AS totalRequested,
|
||||
SUM(a.amountAccepted) AS totalApproved
|
||||
FROM ApplicationEntity a
|
||||
WHERE a.isDeleted = false
|
||||
AND a.status = 'APPROVED'
|
||||
AND a.call.hub.id = :hubId
|
||||
AND a.userId = :userId
|
||||
AND a.userWithCompany.id = :userWithCompanyId
|
||||
GROUP BY TO_CHAR(a.submissionDate, 'Mon'), EXTRACT(YEAR FROM a.submissionDate), EXTRACT(MONTH FROM a.submissionDate)
|
||||
ORDER BY EXTRACT(YEAR FROM a.submissionDate), EXTRACT(MONTH FROM a.submissionDate)
|
||||
""")
|
||||
List<Object[]> findRequestedVsApprovedAmountsPerMonth(
|
||||
@Param("hubId") Long hubId,
|
||||
@Param("userId") Long userId,
|
||||
@Param("userWithCompanyId") Long userWithCompanyId
|
||||
);
|
||||
@Query(value = """
|
||||
WITH months AS (
|
||||
SELECT TO_CHAR(generate_series(CURRENT_DATE - INTERVAL '5 months', CURRENT_DATE, INTERVAL '1 month'), 'Mon') AS month_label,
|
||||
EXTRACT(YEAR FROM generate_series(CURRENT_DATE - INTERVAL '5 months', CURRENT_DATE, INTERVAL '1 month')) AS year_value,
|
||||
EXTRACT(MONTH FROM generate_series(CURRENT_DATE - INTERVAL '5 months', CURRENT_DATE, INTERVAL '1 month')) AS month_value
|
||||
)
|
||||
SELECT m.month_label AS month,
|
||||
COALESCE(SUM(a.amount_requested), 0) AS totalRequested,
|
||||
COALESCE(SUM(a.amount_accepted), 0) AS totalApproved
|
||||
FROM months m
|
||||
LEFT JOIN {h-schema}application a ON EXTRACT(YEAR FROM a.date_accepted) = m.year_value
|
||||
AND EXTRACT(MONTH FROM a.date_accepted) = m.month_value
|
||||
AND a.is_deleted = false
|
||||
AND a.status = 'APPROVED'
|
||||
AND a.hub_id = :hubId
|
||||
AND a.user_id = :userId
|
||||
AND a.user_with_company_id = :userWithCompanyId
|
||||
GROUP BY m.month_label, m.year_value, m.month_value
|
||||
ORDER BY m.year_value, m.month_value
|
||||
""", nativeQuery = true)
|
||||
List<Object[]> findRequestedVsApprovedAmountsPerMonth(@Param("hubId") Long hubId,
|
||||
@Param("userId") Long userId,
|
||||
@Param("userWithCompanyId") Long userWithCompanyId);
|
||||
|
||||
|
||||
|
||||
@Query("SELECT COUNT(a) FROM ApplicationEntity a " +
|
||||
"WHERE a.hubId = :hubId " +
|
||||
@@ -162,4 +167,7 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
||||
List<ApplicationEntity> findByUserIdAndUserWithCompany_IdAndCall_IdAndIsDeletedFalseAndStatusNot(
|
||||
Long userId, Long userWithCompanyId, Long callId, String status
|
||||
);
|
||||
|
||||
ApplicationEntity findByIdAndCompanyIdAndIsDeletedFalse(Long id,Long companyId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import feign.Param;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
||||
import net.gepafin.tendermanagement.entities.CompanyDocumentEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface CompanyDocumentRepository extends JpaRepository<CompanyDocumentEntity,Long>, JpaSpecificationExecutor<CompanyDocumentEntity> {
|
||||
|
||||
@Query("SELECT c FROM CompanyDocumentEntity c WHERE c.id = :id AND c.isDeleted = false")
|
||||
Optional<CompanyDocumentEntity> findByIdAndNotDeleted(@Param("id") Long id);
|
||||
|
||||
@Query("SELECT d FROM CompanyDocumentEntity d " +
|
||||
"WHERE d.isDeleted = false " +
|
||||
"AND d.expirationDate BETWEEN :startTime AND :endTime")
|
||||
List<CompanyDocumentEntity> findExpiringBetween(LocalDateTime startTime, LocalDateTime endTime);
|
||||
|
||||
@Query("SELECT c FROM CompanyDocumentEntity c " +
|
||||
"WHERE c.isDeleted = false " +
|
||||
"AND c.expirationDate < :now")
|
||||
List<CompanyDocumentEntity> findByExpirationDateBeforeAndIsDeletedFalse(LocalDateTime now);
|
||||
|
||||
@Query("SELECT c FROM CompanyDocumentEntity c " +
|
||||
"WHERE c.companyId = :companyId " +
|
||||
"AND c.isDeleted = false")
|
||||
List<CompanyDocumentEntity> findByCompanyId(Long companyId);
|
||||
|
||||
List<CompanyDocumentEntity> findByCategoryEntityId(Long categoryId);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.DocumentCategoryEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface DocumentCategoryRepository extends JpaRepository<DocumentCategoryEntity,Long> {
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -10,7 +11,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
||||
public interface UserRepository extends JpaRepository<UserEntity, Long>, JpaSpecificationExecutor<UserEntity> {
|
||||
|
||||
UserEntity findByBeneficiaryId(Long beneficiaryId);
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package net.gepafin.tendermanagement.scheduler;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.NotificationDao;
|
||||
import net.gepafin.tendermanagement.entities.CompanyDocumentEntity;
|
||||
import net.gepafin.tendermanagement.entities.ExpirationConfigEntity;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.repositories.CompanyDocumentRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ExpirationConfigRepository;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class CompanyDocumentExpirationScheduler {
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentRepository companyDocumentRepository;
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private ExpirationConfigRepository expirationConfigRepository;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ExpirationScheduler.class);
|
||||
|
||||
@Scheduled(cron = "0 0 4 * * ?")
|
||||
public void processDocumentExpiration(){
|
||||
log.info("Starting the Document Expiration scheduler...");
|
||||
|
||||
try {
|
||||
Utils.setHttpServletRequestForScheduler();
|
||||
|
||||
// Logging user action for the scheduler operation
|
||||
loggingUtil.logUserActionWithoutToken(
|
||||
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.SCHEDULER)
|
||||
.actionContext(UserActionContextEnum.COMPANY_DOCUMENT_EXPIRATION_SCHEDULER).build());
|
||||
|
||||
|
||||
log.info("Starting processing expiration notifications for document");
|
||||
processExpirationReminder(ExpirationTypeEnum.COMPANY_DOCUMENT);
|
||||
updateExpiredDocuments();
|
||||
|
||||
log.info("Expiration scheduler completed successfully.");
|
||||
}
|
||||
catch (Exception e){
|
||||
log.error("An error occurred during the Notification Expiration Scheduler of Document: {}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void processExpirationReminder(ExpirationTypeEnum typeEnum){
|
||||
List<ExpirationConfigEntity> configEntities = expirationConfigRepository.findByTypeAndIsDeletedFalse(typeEnum.getValue());
|
||||
|
||||
for (ExpirationConfigEntity config : configEntities){
|
||||
Long daysBefore = config.getIntervalDays();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime startDate = now.plusDays(daysBefore).withHour(0).withMinute(0).withSecond(0).withNano(2);
|
||||
LocalDateTime endDate = startDate.plusDays(1).minusNanos(2);
|
||||
|
||||
processDocumentExpiration(startDate, endDate, daysBefore);
|
||||
}
|
||||
}
|
||||
|
||||
private void processDocumentExpiration(LocalDateTime startDate, LocalDateTime endDate, Long daysBefore){
|
||||
List<CompanyDocumentEntity> expiringDocuments = companyDocumentRepository.findExpiringBetween(startDate, endDate);
|
||||
|
||||
for (CompanyDocumentEntity document : expiringDocuments) {
|
||||
notificationDao.sendNotificationToBeneficiaryForDocumentExpiration(document, NotificationTypeEnum.COMPANY_DOCUMENT_EXPIRATION_REMINDER);
|
||||
updateDocumentStatus(document, CompanyDocumentStatusEnum.DUE.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateDocumentStatus(CompanyDocumentEntity companyDocument,String status) {
|
||||
CompanyDocumentEntity oldCompanyDocumentEntity = Utils.getClonedEntityForData(companyDocument);
|
||||
companyDocument.setStatus(status);
|
||||
companyDocumentRepository.save(companyDocument);
|
||||
|
||||
// Logging version history for the update operation
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request)
|
||||
.actionType(VersionActionTypeEnum.UPDATE).oldData(oldCompanyDocumentEntity)
|
||||
.newData(companyDocument).build());
|
||||
|
||||
log.info("Updated document status for document: {}", companyDocument.getFileName());
|
||||
}
|
||||
|
||||
|
||||
private void updateExpiredDocuments() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<CompanyDocumentEntity> expiredDocuments = companyDocumentRepository.findByExpirationDateBeforeAndIsDeletedFalse(now);
|
||||
|
||||
for (CompanyDocumentEntity document : expiredDocuments) {
|
||||
updateDocumentStatus(document, CompanyDocumentStatusEnum.EXPIRED.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,12 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentPaginationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||
|
||||
import java.util.List;
|
||||
@@ -27,4 +29,5 @@ public interface ApplicationAmendmentRequestService {
|
||||
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(HttpServletRequest request, Long applicationAmendmentId, ApplicationAmendmentRequestEnum status);
|
||||
|
||||
void sendReminderEmail(HttpServletRequest request,Long amendmentId);
|
||||
PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public interface ApplicationService {
|
||||
|
||||
public ApplicationResponse createApplication(HttpServletRequest request, Long companyId, ApplicationRequest applicationRequest, Long callId);
|
||||
|
||||
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId, FormActionEnum action);
|
||||
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId,Long companyId, Long formId, FormActionEnum action);
|
||||
|
||||
public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status);
|
||||
|
||||
@@ -45,4 +45,5 @@ public interface ApplicationService {
|
||||
|
||||
PageableResponseBean<List<ApplicationResponse>> getAllApplicationByPagination(HttpServletRequest request, Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean);
|
||||
|
||||
public ApplicationEntity validateApplicationWithCompany(Long applicationId,Long companyId);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationPageableRequestBean;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,5 +23,6 @@ public interface AssignedApplicationsService {
|
||||
AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, UpdateAssignedApplicationRequest assignedApplicationsRequest);
|
||||
AssignedApplicationsResponse getAssignedApplicationById(HttpServletRequest request, Long id);
|
||||
AssignedApplicationsEntity validateAssignedApplication(Long assignedApplicationId);
|
||||
PageableResponseBean<List<AssignedApplicationsResponse>> getAllAssignedApplicationsByPagination(HttpServletRequest request, Long userId, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean);
|
||||
AssignedApplicationsResponse updateAssignedApplicationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedApplicationEnum status);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.enums.CompanyDocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface CompanyDocumentService {
|
||||
List<CompanyDocumentResponseBean> uploadFileForCompany(HttpServletRequest request, List<MultipartFile> files, Long companyId, Long documentCategoryId, CompanyDocumentTypeEnum documentSourceTypeEnum, LocalDateTime expirationDate,String name);
|
||||
|
||||
CompanyDocumentResponseBean updateCompanyDocument(HttpServletRequest httpServletRequest, Long companyDocumentId, CompanyDocumentRequest companyDocumentRequest);
|
||||
|
||||
CompanyDocumentResponseBean getCompanyDocument(HttpServletRequest request, Long companyDocumentId);
|
||||
|
||||
void deleteCompanyFile(HttpServletRequest request,Long companyDocumentId);
|
||||
|
||||
DocumentResponseBean validateAndDuplicateCompanyDocument(HttpServletRequest request, Long companyDocumentId, Long applicationId, DocumentTypeEnum typeEnum);
|
||||
|
||||
List<CompanyDocumentResponseBean> getAllCompanyDocument(HttpServletRequest request ,Long companyId , CompanyDocumentTypeEnum typeEnum);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.model.request.DocumentCategoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentCategoryResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DocumentCategoryService {
|
||||
|
||||
DocumentCategoryResponse createDocumentCategory(HttpServletRequest request, DocumentCategoryRequest categoryRequest);
|
||||
DocumentCategoryResponse getDocumentCategoryById(HttpServletRequest request, Long id);
|
||||
void deleteDocumentCategory(HttpServletRequest request,Long id);
|
||||
DocumentCategoryResponse updateDocumentCategory(HttpServletRequest request, Long id, DocumentCategoryRequest categoryRequest);
|
||||
List<DocumentCategoryResponse> getAllDocumentCategory(HttpServletRequest request);
|
||||
}
|
||||
@@ -7,7 +7,9 @@ import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,4 +27,7 @@ public interface NotificationService {
|
||||
public List<NotificationResponse> getNotificationsByCompanyIdAndUserId(Long userId, Long companyId, List<NotificationEnum> statuses);
|
||||
|
||||
PageableResponseBean<List<NotificationResponse>> getAllNotification(HttpServletRequest request,Long userId, NotificationRequestBean notificationRequestBean);
|
||||
}
|
||||
|
||||
PageableResponseBean<List<NotificationResponse>> getNotificationsByUserIdAndCompanyIdByPagination(HttpServletRequest request, Long userId, Long companyId, NotificationRequestBean notificationRequestBean);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,19 @@ package net.gepafin.tendermanagement.service;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.enums.TimePeriodEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserActionResponseBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserActionService {
|
||||
public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext);
|
||||
public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId);
|
||||
|
||||
public List<ActionContextLabelResponse> getActionContextLabels(HttpServletRequest request, Long userId);
|
||||
|
||||
public PageableResponseBean<List<UserActionResponseBean>> getUserActionByPagination(HttpServletRequest request, Long userId, UserActionPaginationRequest userActionPaginationRequest);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
@@ -47,6 +48,7 @@ public interface UserService {
|
||||
public UserEntity getUserEntityById(Long userId);
|
||||
List<UserResponseBean> getAllUsers(HttpServletRequest request, List<Long> roleIds);
|
||||
|
||||
PageableResponseBean<List<UserResponseBean>> getUserByPagination(HttpServletRequest request, UserPaginationRequestBean userPaginationRequestBean);
|
||||
UserResponseBean updateUserDetails(HttpServletRequest request, Long userId, UpdateUserReqForBeneficiary userReq);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.gepafin.tendermanagement.service.feignClient;
|
||||
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
|
||||
@FeignClient(value = "pec-service" ,url = GepafinConstant.PEC_SERVICE_URL)
|
||||
public interface PecFeignService {
|
||||
|
||||
@GetMapping(GepafinConstant.PEC_SERVICE_INBOX_MAIL)
|
||||
ResponseEntity<Object> getUsageDetails(URI uri,@RequestHeader HttpHeaders headers
|
||||
);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
||||
}
|
||||
}
|
||||
|
||||
private String decodeS3Key(String key) {
|
||||
public String decodeS3Key(String key) {
|
||||
return URLDecoder.decode(key, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@@ -186,11 +186,11 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
||||
}
|
||||
}
|
||||
|
||||
private String cleanNewPath(String oldPath, String newPath) {
|
||||
public String cleanNewPath(String oldPath, String newPath) {
|
||||
return newPath + "/" + oldPath.substring(oldPath.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
private String cleanOldPath(String oldPath) {
|
||||
public String cleanOldPath(String oldPath) {
|
||||
return oldPath.replace(s3Url, "");
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,12 @@ import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentPaginationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
||||
@@ -149,4 +151,10 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
applicationAmendmentRequestDao.sendReminderEmail(amendmentId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean) {
|
||||
UserEntity user=validator.validateUser(request);
|
||||
return applicationAmendmentRequestDao.getApplicationAmendmentByPaginnation(userId,amendmentPaginationRequestBean);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -74,11 +75,22 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId,
|
||||
FormActionEnum action) {
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
return flowFormDao.getNextOrPreviousForm(applicationEntity, formId, action);
|
||||
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long companyId, Long formId,
|
||||
FormActionEnum action) {
|
||||
if (companyId !=null) {
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
}
|
||||
ApplicationEntity applicationEntity =null;
|
||||
if(validator.checkIsBeneficiary()){
|
||||
if(companyId==null){
|
||||
throw new ForbiddenAccessException(Status.FORBIDDEN,Translator.toLocale(GepafinConstant.COMPANY_ID_MANDATORY));
|
||||
}
|
||||
applicationEntity = validateApplicationWithCompany(applicationId, companyId);
|
||||
|
||||
}else {
|
||||
applicationEntity=validateApplication(applicationId);
|
||||
}
|
||||
return flowFormDao.getNextOrPreviousForm(applicationEntity, companyId, formId, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,4 +147,9 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
return applicationDao.getAllApplicationByPagination(userEntity,callId,companyId,applicationPageableRequestBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationEntity validateApplicationWithCompany(Long applicationId,Long companyId) {
|
||||
return applicationDao.validateApplicationWithCompany(applicationId,companyId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.AssignedApplicationsDao;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationPageableRequestBean;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -62,6 +64,13 @@ public class AssignedApplicationsServiceImpl implements AssignedApplicationsServ
|
||||
public AssignedApplicationsEntity validateAssignedApplication(Long assignedApplicationId) {
|
||||
return assignedApplicationsDao.validateAssignedApplication(assignedApplicationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableResponseBean<List<AssignedApplicationsResponse>> getAllAssignedApplicationsByPagination(HttpServletRequest request, Long userId, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean) {
|
||||
UserEntity user=validator.validateUser(request);
|
||||
return assignedApplicationsDao.getAllAssignedApplicationsByPagination(user,assignedApplicationPageableRequestBean,userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssignedApplicationsResponse updateAssignedApplicationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedApplicationEnum status) {
|
||||
return assignedApplicationsDao.updateAssignedApplicationStatus(request, assignedApplicationId, status);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CallServiceImpl implements CallService {
|
||||
UpdateCallRequestStep1 updateCallRequest) {
|
||||
UserEntity user = validator.validateUser(request);
|
||||
CallEntity call = validator.validateUserWithCall(user, callId);
|
||||
return callDao.updateCallStep1(call, updateCallRequest, user);
|
||||
return callDao.updateCallStep1(request,call, updateCallRequest, user);
|
||||
}
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.CompanyDocumentDao;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.CompanyDocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.service.CompanyDocumentService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class CompanyDocumentServiceImpl implements CompanyDocumentService {
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentDao companyDocumentDao;
|
||||
|
||||
@Override
|
||||
public List<CompanyDocumentResponseBean> uploadFileForCompany(HttpServletRequest request, List<MultipartFile> files, Long companyId, Long documentCategoryId , CompanyDocumentTypeEnum documentSourceTypeEnum, LocalDateTime expirationDate,String name) {
|
||||
Map<String, Object> userInfo = validator.getUserInfoFromToken(request);
|
||||
Long userId = validator.getUserId(userInfo);
|
||||
return companyDocumentDao.uploadFileForCompany(request,userId,files,companyId,documentCategoryId,documentSourceTypeEnum,expirationDate,name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyDocumentResponseBean updateCompanyDocument(HttpServletRequest request, Long companyDocumentId, CompanyDocumentRequest companyDocumentRequest) {
|
||||
validator.validateUser(request);
|
||||
return companyDocumentDao.updateCompanyDocument(request,companyDocumentId, companyDocumentRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyDocumentResponseBean getCompanyDocument(HttpServletRequest request, Long companyDocumentId) {
|
||||
UserEntity user = validator.validateUser(request);
|
||||
return companyDocumentDao.getCompanyDocument(user , companyDocumentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCompanyFile(HttpServletRequest request,Long companyDocumentId) {
|
||||
validator.validateUser(request);
|
||||
companyDocumentDao.deleteCompanyFile(companyDocumentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentResponseBean validateAndDuplicateCompanyDocument(HttpServletRequest request, Long companyDocumentId, Long applicationId, DocumentTypeEnum typeEnum) {
|
||||
UserEntity user = validator.validateUser(request);
|
||||
return companyDocumentDao.validateAndDuplicateCompanyDocument(request, user.getId(), companyDocumentId,applicationId,typeEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyDocumentResponseBean> getAllCompanyDocument(HttpServletRequest request, Long companyId, CompanyDocumentTypeEnum typeEnum) {
|
||||
UserEntity user = validator.validateUser(request);
|
||||
return companyDocumentDao.getAllCompanyDocument(user,companyId,typeEnum);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.DocumentCategoryDao;
|
||||
import net.gepafin.tendermanagement.model.request.DocumentCategoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentCategoryResponse;
|
||||
import net.gepafin.tendermanagement.service.DocumentCategoryService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DocumentCategoryServiceImpl implements DocumentCategoryService {
|
||||
|
||||
@Autowired
|
||||
DocumentCategoryDao categoryDao;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public DocumentCategoryResponse createDocumentCategory(HttpServletRequest request, DocumentCategoryRequest categoryRequest) {
|
||||
validator.validateUser(request);
|
||||
return categoryDao.createDocumentCategory(request,categoryRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public DocumentCategoryResponse getDocumentCategoryById(HttpServletRequest request, Long id) {
|
||||
validator.validateUser(request);
|
||||
return categoryDao.getDocumentCategoryById(request,id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDocumentCategory(HttpServletRequest request, Long id) {
|
||||
validator.validateUser(request);
|
||||
categoryDao.deleteDocumentCategory(request,id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public DocumentCategoryResponse updateDocumentCategory(HttpServletRequest request, Long id, DocumentCategoryRequest categoryRequest) {
|
||||
validator.validateUser(request);
|
||||
return categoryDao.updateDocumentCategory(request,id,categoryRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DocumentCategoryResponse> getAllDocumentCategory(HttpServletRequest request) {
|
||||
validator.validateUser(request);
|
||||
return categoryDao.getAllDocumentCategory();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -74,4 +74,9 @@ public class NotificationServiceImpl implements NotificationService {
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
return notificationDao.getAllNotification(userId,notificationRequestBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableResponseBean<List<NotificationResponse>> getNotificationsByUserIdAndCompanyIdByPagination(HttpServletRequest request, Long userId, Long companyId, NotificationRequestBean notificationRequestBean) {
|
||||
return notificationDao.getNotificationsByUserIdAndCompanyIdByPagination(userId,companyId,notificationRequestBean);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.service.impl;
|
||||
import com.mashape.unirest.http.HttpResponse;
|
||||
import com.mashape.unirest.http.Unirest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.dao.EmailLogDao;
|
||||
import net.gepafin.tendermanagement.entities.EmailLogEntity;
|
||||
import net.gepafin.tendermanagement.enums.EmailServiceTypeEnum;
|
||||
@@ -13,6 +14,7 @@ import net.gepafin.tendermanagement.model.request.PecEmailRequest;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
|
||||
import org.opensaml.xmlsec.signature.G;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -26,6 +28,9 @@ public class PecEmailService implements EmailService {
|
||||
@Value("${isMailSendingEnabled}")
|
||||
private String isEmailSendingEnabled;
|
||||
|
||||
@Value("${isPecServiceEnabled}")
|
||||
private String isPecServiceEnabled;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@@ -46,7 +51,7 @@ public class PecEmailService implements EmailService {
|
||||
emailRequest.setUsername(emailConfig.getUsername());
|
||||
emailRequest.setPassword(emailConfig.getPassword());
|
||||
emailRequest.setRecipient(recipientEmails);
|
||||
String url=emailConfig.getUrl();
|
||||
String url=emailConfig.getUrl()+ GepafinConstant.PEC_SERVICE_SEND_MAIL;
|
||||
String authToken = emailConfig.getAuthToken();
|
||||
HttpResponse<String> response2=null;
|
||||
if (Boolean.FALSE.equals(validator.isTestProfileActivated())) {
|
||||
@@ -55,23 +60,27 @@ public class PecEmailService implements EmailService {
|
||||
emailLogRequest.setSendStatus(StatusTypeEnum.SUCCESS.getValue());
|
||||
emailLogRequest.setRecipientEmails(Utils.listToCommaSeparatedString(emailRequest.getRecipient()));
|
||||
try {
|
||||
Unirest.setTimeouts(0, 0);
|
||||
response2 = Unirest.post(url)
|
||||
.header("Authorization", "Bearer " + authToken)
|
||||
.header("Content-Type", "application/json")
|
||||
.body(Utils.convertObjectToJson(emailRequest)) // Serialize the emailRequest object to JSON
|
||||
.asString();
|
||||
if (Boolean.TRUE.equals(Boolean.parseBoolean(isPecServiceEnabled))) {
|
||||
Unirest.setTimeouts(0, 0);
|
||||
response2 = Unirest.post(url)
|
||||
.header("Authorization", "Bearer " + authToken)
|
||||
.header("Content-Type", "application/json")
|
||||
.body(Utils.convertObjectToJson(emailRequest)) // Serialize the emailRequest object to JSON
|
||||
.asString();
|
||||
}
|
||||
}catch(Exception e) {
|
||||
emailLogRequest.setSendStatus(StatusTypeEnum.FAILED.getValue());
|
||||
emailLogRequest.setEmailServiceType(EmailServiceTypeEnum.PEC_SERVICE);
|
||||
emailLogRequest.setErrorMessage(e.getMessage());
|
||||
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||
emailLogDao.createEmailLog(emailLogRequest);
|
||||
throw new RuntimeException("Failed to send email via PEC: " + response2.getStatus());
|
||||
}
|
||||
emailLogRequest.setEmailServiceResponse(response2.getBody());
|
||||
if(response2 != null) {
|
||||
emailLogRequest.setEmailServiceResponse(response2.getBody());
|
||||
}
|
||||
}
|
||||
emailLogRequest.setEmailServiceType(EmailServiceTypeEnum.PEC_SERVICE);
|
||||
EmailLogEntity emailLogEntity= emailLogDao.createEmailLog(emailLogRequest);
|
||||
emailLogDao.createEmailLog(emailLogRequest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,11 @@ import net.gepafin.tendermanagement.dao.UserActionDao;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.TimePeriodEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserActionResponseBean;
|
||||
import net.gepafin.tendermanagement.service.UserActionService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -25,9 +28,9 @@ public class UserActionServiceImpl implements UserActionService {
|
||||
|
||||
|
||||
@Override
|
||||
public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext) {
|
||||
public SummaryPageResponseBean getUserAction(HttpServletRequest request, Long userId) {
|
||||
UserEntity user = validator.validateUserId(request, userId);
|
||||
return userActionDao.getUserAction(request,user,timeFilter,actionContext);
|
||||
return userActionDao.getUserAction(request,user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,4 +38,10 @@ public class UserActionServiceImpl implements UserActionService {
|
||||
UserEntity user = validator.validateUserId(request, userId);
|
||||
return userActionDao.getActionContextLabels(request,user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableResponseBean<List<UserActionResponseBean>> getUserActionByPagination(HttpServletRequest request, Long userId, UserActionPaginationRequest userActionPaginationRequest) {
|
||||
UserEntity user = validator.validateUserId(request, userId);
|
||||
return userActionDao.getUserActionByPagination(user,userActionPaginationRequest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.gepafin.tendermanagement.model.request.UpdateUserReq;
|
||||
import net.gepafin.tendermanagement.model.request.UserReq;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
@@ -131,6 +132,11 @@ public class UserServiceImpl implements UserService {
|
||||
return userDao.getAllUsers(user, roleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableResponseBean<List<UserResponseBean>> getUserByPagination(HttpServletRequest request, UserPaginationRequestBean userPaginationRequestBean) {
|
||||
UserEntity user = validator.validateUser(request);
|
||||
return userDao.getUserByPagination(userPaginationRequestBean, user);
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public UserResponseBean updateUserDetails(HttpServletRequest request, Long userId, UpdateUserReqForBeneficiary userReq) {
|
||||
|
||||
@@ -92,6 +92,10 @@ public class DateTimeUtil {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
return LocalDateTime.parse(dateTimeStr, formatter);
|
||||
}
|
||||
public static LocalDateTime parseStringToLocalDateTime(String timestampStr) {
|
||||
// Use ISO_LOCAL_DATE_TIME to parse the input string
|
||||
return LocalDateTime.parse(timestampStr, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
||||
}
|
||||
|
||||
public static String parseLocalTimeToString(LocalTime time, String format) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
|
||||
|
||||
@@ -59,16 +59,56 @@ public class FieldValidator {
|
||||
throw new ValidationException(Status.VALIDATION_ERROR, errors, Translator.toLocale(GepafinConstant.VALIDATION_MESSAGE));
|
||||
}
|
||||
}
|
||||
public FieldValidator minLength(String value, Long minLength, String fieldLabel) {
|
||||
if (minLength != null && value != null && value.length() < minLength) {
|
||||
errors.add(MessageFormat.format(Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MIN_LENGTH), fieldLabel, minLength));
|
||||
}
|
||||
public FieldValidator minLength(String value, Long minLength, String fieldLabel,Long min,ContentResponseBean contentResponseBean) {
|
||||
if (value != null) {
|
||||
if(min!=null) {
|
||||
if(contentResponseBean.getName().equals(GepafinConstant.NUMBER_INPUT)) {
|
||||
long numericValue = Long.parseLong(value); // Convert String to Long
|
||||
if (numericValue < min) {
|
||||
errors.add(MessageFormat.format(
|
||||
Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MIN), fieldLabel, min));
|
||||
}
|
||||
}
|
||||
else if(contentResponseBean.getName().equals(GepafinConstant.CHECK_BOXES)){
|
||||
List<String> check = Utils.convertJsonStringToList(value,String.class);
|
||||
if (check== null || check.size() < min) {
|
||||
errors.add(MessageFormat.format(
|
||||
Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MIN_CHECK_BOX), fieldLabel, min));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(minLength!=null) {
|
||||
if (value.length() < minLength) {
|
||||
errors.add(MessageFormat.format(Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MIN_LENGTH), fieldLabel, minLength));
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public FieldValidator maxLength(String value, Long maxLength, String fieldLabel) {
|
||||
if (maxLength != null && value != null && value.length() > maxLength) {
|
||||
errors.add(MessageFormat.format(Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MAX_LENGTH), fieldLabel, maxLength));
|
||||
public FieldValidator maxLength(String value, Long maxLength, String fieldLabel, Long max, ContentResponseBean contentResponseBean) {
|
||||
if (value != null) {
|
||||
if (max != null) {
|
||||
if(contentResponseBean.getName().equals(GepafinConstant.NUMBER_INPUT)) {
|
||||
long numericValue = Long.parseLong(value); // Convert String to Long
|
||||
if (numericValue > max) {
|
||||
errors.add(MessageFormat.format(
|
||||
Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MAX), fieldLabel, max));
|
||||
}
|
||||
}
|
||||
else if(contentResponseBean.getName().equals(GepafinConstant.CHECK_BOXES)){
|
||||
List<String> check = Utils.convertJsonStringToList(value,String.class);
|
||||
if (check== null || check.size() > max) {
|
||||
errors.add(MessageFormat.format(
|
||||
Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MAX_CHECK_BOX), fieldLabel, max));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (maxLength != null) {
|
||||
if (value.length() > maxLength) {
|
||||
errors.add(MessageFormat.format(Translator.toLocale(GepafinConstant.VALIDATION_FIELD_MAX_LENGTH), fieldLabel, maxLength));
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -167,13 +207,12 @@ public class FieldValidator {
|
||||
switch (customRule) {
|
||||
|
||||
case GepafinConstant.NON_EMPTY_TABLES:
|
||||
try {
|
||||
|
||||
checkTableValidation(value, fieldId, contentResponseBean, errors);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
break;
|
||||
try {
|
||||
checkTableValidation(value, fieldId, contentResponseBean, errors);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -189,13 +228,13 @@ public class FieldValidator {
|
||||
|
||||
|
||||
if (tableType!=null){
|
||||
try {
|
||||
try {
|
||||
Object object = PdfUtils.extractRows(value);;
|
||||
value= Utils.convertToString(object);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
contentResponseBean.getSettings().stream()
|
||||
.filter(setting -> "table_columns".equals(setting.getName()) || GepafinConstant.CRITERIA_TABLE_COLUMNS.equals(setting.getName())) // Check for "table_columns"
|
||||
|
||||
@@ -785,5 +785,7 @@ public class Utils {
|
||||
|
||||
return input.matches("-?\\d+(\\.\\d+)?");
|
||||
}
|
||||
|
||||
public static boolean isValidBoolean(String value) {
|
||||
return "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,11 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
@@ -78,7 +78,7 @@ public interface ApplicationAmendmentRequestApi {
|
||||
@GetMapping(value = "", produces = "application/json")
|
||||
ResponseEntity<Response<ApplicationAmendmentRequestResponse>> getApplicationAmendmentRequestById(HttpServletRequest request,@Parameter(description = "The application amendment id", required = true) @RequestParam(value = "id", required = true) Long id);
|
||||
|
||||
@Operation(summary = "Api to get all applications amendment request by preInstructor user Id",
|
||||
@Operation(summary = "Api to get all applications amendment request by preInstructor user Id (deprecated)",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@@ -107,7 +107,7 @@ public interface ApplicationAmendmentRequestApi {
|
||||
@Parameter(description = "The Application Amendment id", required = true) @PathVariable("id") Long id,
|
||||
@Parameter(description = "Assigned Application request object", required = true) @Valid @RequestBody ApplicationAmendmentRequestBean applicationAmendmentRequestBean);
|
||||
|
||||
@Operation(summary = "Api to get all applications amendment request by beneficary user Id",
|
||||
@Operation(summary = "Api to get all applications amendment request by beneficary user Id (deprecated)",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@@ -191,4 +191,17 @@ public interface ApplicationAmendmentRequestApi {
|
||||
@Parameter( required = true)
|
||||
@PathVariable(value = "amendmentId") Long amendmentId);
|
||||
|
||||
@Operation(summary = "Api to get all application amendment by pagination",
|
||||
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 = "/user/{userId}/pagination", produces = { "application/json" })
|
||||
ResponseEntity<Response<PageableResponseBean<List<ApplicationAmendmentRequestResponse>>>> getApplicationAmendmentByPaginnation(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
|
||||
@RequestBody ApplicationAmendmentPaginationRequestBean userActionPaginationRequest);
|
||||
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ public interface ApplicationApi {
|
||||
@GetMapping(value = "/{applicationId}/form/next-previous", produces = "application/json")
|
||||
ResponseEntity<Response<NextOrPreviousFormResponse>> getNextOrPreviousForm(HttpServletRequest request,
|
||||
@Parameter(description = "The applicaltion id", required = true) @PathVariable("applicationId") Long applicationId,
|
||||
@Parameter(description = "The company id", required = false) @RequestParam(value = "companyId",required = false) Long companyId,
|
||||
@Parameter(description = "The form id", required = false) @RequestParam(value = "formId", required = false) Long formId,
|
||||
@RequestParam(value = "action", required = false) FormActionEnum action);
|
||||
|
||||
|
||||
@@ -6,12 +6,14 @@ import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationPageableRequestBean;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -58,7 +60,7 @@ public interface AssignedApplicationsApi {
|
||||
ResponseEntity<Response<Void>> deleteAssignedApplication(HttpServletRequest request,
|
||||
@Parameter(description = "The assigned application id", required = true) @PathVariable("id") Long id);
|
||||
|
||||
@Operation(summary = "Api to get all assigned applications",
|
||||
@Operation(summary = "Api to get all assigned applications (deprecated) ",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@@ -116,5 +118,18 @@ public interface AssignedApplicationsApi {
|
||||
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) AssignedApplicationEnum status);
|
||||
|
||||
|
||||
@Operation(summary = "Api to get all assigned applications by pagination",
|
||||
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 = "/pagination", produces = "application/json")
|
||||
ResponseEntity<Response<PageableResponseBean<List<AssignedApplicationsResponse>>>> getAllAssignedApplicationsByPagination(HttpServletRequest request,
|
||||
@Parameter(description = "The User ID", required = false) @RequestParam(value = "userId",required = false) Long userId, @RequestBody AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.enums.CompanyDocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.FormRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Validated
|
||||
public interface CompanyDocumentApi {
|
||||
@Operation(summary = "Api to upload a file for company",
|
||||
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 = "/company/{companyId}/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
default ResponseEntity<Response<List<CompanyDocumentResponseBean>>> uploadFileForCompany(HttpServletRequest httpServletRequest,
|
||||
@Parameter(description = "Company Id", required = true) @PathVariable("companyId") Long companyId,
|
||||
@Parameter(description = "The Document Category id", required = true) @RequestParam(value = "documentCategoryId", required = false) Long documentCategoryId,
|
||||
@Parameter(description = "The Document Name", required = true) @RequestParam(value = "name", required = false) String name,
|
||||
@RequestParam("documentType") CompanyDocumentTypeEnum documentTypeEnum,
|
||||
@RequestParam("expirationDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime expirationDate,
|
||||
@RequestParam("file") List<MultipartFile> files) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Operation(summary = "Api to update company document",
|
||||
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) }))})
|
||||
@PutMapping(value = "/{id}",produces = "application/json")
|
||||
default ResponseEntity<Response<CompanyDocumentResponseBean>> updateCompanyDocument(HttpServletRequest httpServletRequest, @Parameter(description = "Company Document Id", required = true) @PathVariable("id") Long companyDocumentId,@Valid @RequestBody CompanyDocumentRequest companyDocumentRequest) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Operation(summary = "API to get company document by id",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<CompanyDocumentResponseBean>> getCompanyDocumentById(HttpServletRequest request,
|
||||
@Parameter(description = "Company Document Id", required = true)
|
||||
@PathVariable("id") Long id);
|
||||
|
||||
@Operation(summary = "API to delete a file by company document id",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "File deleted successfully"),
|
||||
@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) }))
|
||||
})
|
||||
@DeleteMapping(value = "")
|
||||
default ResponseEntity<Response<Void>> deleteCompanyFile(HttpServletRequest httpServletRequest,
|
||||
@RequestParam( "id") Long id) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "Api to copy a company document",
|
||||
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) }))})
|
||||
@PutMapping(value = "/{id}/document/upload", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
default ResponseEntity<Response<DocumentResponseBean>> validateAndDuplicateCompanyDocument (HttpServletRequest httpServletRequest, @Parameter(description = "Company Document Id", required = true) @PathVariable("id") Long companyDocumentId,
|
||||
@Parameter(description = "Application Id", required = true) @RequestParam Long applicationId,
|
||||
@RequestParam("documentType") DocumentTypeEnum documentTypeEnum) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@Operation(summary = "API to get all company documents",
|
||||
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) }))
|
||||
})
|
||||
@GetMapping(value = "/company/{companyId}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<List<CompanyDocumentResponseBean>>> getAllCompanyDocuments(HttpServletRequest request,
|
||||
@Parameter(description = "Company Id", required = true)
|
||||
@PathVariable("companyId") Long companyId , @RequestParam(value = "documentType", required = false) CompanyDocumentTypeEnum documentTypeEnum);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public interface DashboardApi {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "",
|
||||
produces = { "application/json" })
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN') || hasRole('ROLE_INSTRUCTOR_MANAGER')")
|
||||
ResponseEntity<Response<SuperAdminWidgetResponseBean>> getDashboardWidgetForSuperAdmin(HttpServletRequest request);
|
||||
|
||||
@Operation(summary = "Api to get dashboard widget for beneficiary",
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.model.request.DocumentCategoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentCategoryResponse;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Validated
|
||||
public interface DocumentCategoryApi {
|
||||
|
||||
@Operation(summary = "Api to create document category", 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 = "", produces = "application/json")
|
||||
ResponseEntity<Response<DocumentCategoryResponse>> createDocumentCategory(HttpServletRequest request,
|
||||
@Parameter(description = "Company Document Category request object", required = true)
|
||||
@Valid @RequestBody DocumentCategoryRequest categoryRequest);
|
||||
|
||||
|
||||
@Operation(summary = "Api to get document category by id", responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@GetMapping(value = "/{id}", produces = "application/json")
|
||||
ResponseEntity<Response<DocumentCategoryResponse>> getDocumentCategoryById(HttpServletRequest request,
|
||||
@Parameter(description = "The document category id", required = true)
|
||||
@PathVariable("id") Long id);
|
||||
|
||||
|
||||
@Operation(summary = "Api to delete a document category", 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) }))
|
||||
})
|
||||
@DeleteMapping(value = "/{id}")
|
||||
ResponseEntity<Response<Void>> deleteDocumentCategory(HttpServletRequest request,
|
||||
@Parameter(description = "The document category id", required = true)
|
||||
@PathVariable("id") Long id);
|
||||
|
||||
|
||||
@Operation(summary = "API to update a document category", 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) }))
|
||||
})
|
||||
@PutMapping(value = "/{id}", produces = "application/json")
|
||||
ResponseEntity<Response<DocumentCategoryResponse>> updateDocumentCategory(HttpServletRequest request,
|
||||
@Parameter(description = "The document category id", required = true)
|
||||
@PathVariable("id") Long id,
|
||||
@Parameter(description = "Category request object", required = true)
|
||||
@Valid @RequestBody DocumentCategoryRequest categoryRequest);
|
||||
|
||||
@Operation(summary = "Api to get all document category",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "", produces = "application/json")
|
||||
ResponseEntity<Response<List<DocumentCategoryResponse>>> getAllDocumentCategory(HttpServletRequest request);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public interface NotificationApi {
|
||||
ResponseEntity<Response<Void>> deleteNotification(HttpServletRequest request,
|
||||
@Parameter(description = "The notification id", required = true) @PathVariable(value = "id", required = true) Long id);
|
||||
|
||||
@Operation(summary = "API to get notifications by user ID and company ID", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@Operation(summary = "API to get notifications by user ID and company ID (deprecated) ", 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 = {
|
||||
@@ -110,6 +110,22 @@ public interface NotificationApi {
|
||||
@PostMapping(value = "/user/{userId}/pagination", consumes = "application/json", produces = "application/json")
|
||||
ResponseEntity<Response<PageableResponseBean<List<NotificationResponse>>>> getAllNotification(HttpServletRequest request,@Parameter(description = "The user id", required = true) @PathVariable(value = "userId") Long userId, @RequestBody NotificationRequestBean notificationRequestBean);
|
||||
|
||||
|
||||
|
||||
|
||||
@Operation(summary = "API to get notifications by user ID and company ID by pagination", 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 = "/user/{userId}/company/{companyId}/pagination", produces = "application/json")
|
||||
ResponseEntity<Response<PageableResponseBean<List<NotificationResponse>>>> getNotificationsByUserIdAndCompanyIdByPagination(HttpServletRequest request,
|
||||
@Parameter(description = "The user id", required = true) @PathVariable(value = "userId") Long userId,
|
||||
@Parameter(description = "The company ID", required = true) @PathVariable(value = "companyId") Long companyId,
|
||||
@RequestBody NotificationRequestBean notificationRequestBean);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,20 +8,21 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.enums.TimePeriodEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserActionResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserActionApi {
|
||||
@Operation(summary = "Api to get user action",
|
||||
@Operation(summary = "Api to get user summary ",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@@ -31,9 +32,7 @@ public interface UserActionApi {
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "/user/{userId}", produces = { "application/json" })
|
||||
ResponseEntity<Response<SummaryPageResponseBean>> getUserAction(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
|
||||
@Parameter(description = "Time Filter") @RequestParam(value = "timeFilter", required = false) TimePeriodEnum timeFilter,
|
||||
@Parameter(description = "Action Context") @RequestParam(value = "actionContext", required = false) List<UserActionContextEnum> actionContext);
|
||||
ResponseEntity<Response<SummaryPageResponseBean>> getUserAction(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId);
|
||||
|
||||
@Operation(summary = "Api to get action context label",
|
||||
responses = {
|
||||
@@ -46,4 +45,18 @@ public interface UserActionApi {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "/user/{userId}/action-context", produces = { "application/json" })
|
||||
ResponseEntity<Response<List<ActionContextLabelResponse>>> getActionContextLabels(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId);
|
||||
|
||||
@Operation(summary = "Api to get all user action by pagination",
|
||||
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 = "/user/{userId}/pagination", produces = { "application/json" })
|
||||
ResponseEntity<Response<PageableResponseBean<List<UserActionResponseBean>>>> getUserActionByPaginnation(HttpServletRequest request, @Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
|
||||
@RequestBody UserActionPaginationRequest userActionPaginationRequest);
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
@@ -225,7 +227,7 @@ public interface UserApi {
|
||||
ResponseEntity<Response<UserSamlResponse>> validateNewUserToken(HttpServletRequest request,
|
||||
@Parameter(description = "The spid token", required = true) @PathVariable("token") String token);
|
||||
|
||||
@Operation(summary = "Api to get all users",
|
||||
@Operation(summary = "Api to get all users (deprecated)",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@@ -244,6 +246,20 @@ public interface UserApi {
|
||||
@ResponseBody
|
||||
void returnNoFavicon();
|
||||
|
||||
@Operation(summary = "Api to get all user by pagination",
|
||||
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 = "/pagination", produces = { "application/json" })
|
||||
ResponseEntity<Response<PageableResponseBean<List<UserResponseBean>>>> getUserByPagination(HttpServletRequest request,
|
||||
@RequestBody UserPaginationRequestBean userPaginationRequestBean);
|
||||
|
||||
|
||||
@Operation(summary = "Api to update user",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springframework.security.authorization.AuthorizationDeniedException;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
@@ -49,6 +50,7 @@ public class GlobalExceptionHandler {
|
||||
return new Response<>(ex.getErrors(), ex.getStatus(), ex.getMessage());
|
||||
}
|
||||
|
||||
@ResponseStatus(value = HttpStatus.NOT_FOUND)
|
||||
@ExceptionHandler(ResourceNotFoundException.class)
|
||||
public ResponseEntity<Response<Void>> handleResourceNotFoundException(ResourceNotFoundException ex) {
|
||||
log.error(ex.getMessage());
|
||||
@@ -179,4 +181,13 @@ public class GlobalExceptionHandler {
|
||||
return Utils.convertIntoJson(exceptionString);
|
||||
}
|
||||
|
||||
@ResponseStatus(value = HttpStatus.NOT_FOUND)
|
||||
@ExceptionHandler(NoResourceFoundException.class)
|
||||
public ResponseEntity<Response<Void>> handlNoeResourceNotFoundException(NoResourceFoundException ex) {
|
||||
log.error(ex.getMessage());
|
||||
// log.error(ex.getLocalizedMessage(), ex);
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(new Response<>(null, Status.NOT_FOUND, ex.getMessage()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,11 +7,9 @@ import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
||||
@@ -188,4 +186,15 @@ public class ApplicationAmendmentRequestController implements ApplicationAmendme
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.REMINDER_EMAIL_SENT_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<PageableResponseBean<List<ApplicationAmendmentRequestResponse>>>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean) {
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_ALL_APPLICATION_AMENDMENT_BY_PAGINATION).build());
|
||||
|
||||
PageableResponseBean<List<ApplicationAmendmentRequestResponse>> listPageableResponseBean=applicationAmendmentRequestService.getApplicationAmendmentByPaginnation(request,userId,amendmentPaginationRequestBean);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(listPageableResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_DATA_FOR_AMENDMENT_SUCCESS_MSG)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -116,13 +116,13 @@ public class ApplicationApiController implements ApplicationApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<NextOrPreviousFormResponse>> getNextOrPreviousForm(HttpServletRequest request, Long applicationId,
|
||||
public ResponseEntity<Response<NextOrPreviousFormResponse>> getNextOrPreviousForm(HttpServletRequest request, Long applicationId,Long companyId,
|
||||
Long formId, FormActionEnum action) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "get next or previous form" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_NEXT_PREVIOUS_FORM).build());
|
||||
|
||||
NextOrPreviousFormResponse data = applicationService.getNextOrPreviousForm(request, applicationId, formId, action);
|
||||
NextOrPreviousFormResponse data = applicationService.getNextOrPreviousForm(request, applicationId,companyId, formId, action);
|
||||
log.info("Get Next Or Previous Form ");
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
||||
|
||||
@@ -8,11 +8,14 @@ import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationPageableRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateAssignedApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
@@ -93,6 +96,15 @@ public class AssignedApplicationsController implements AssignedApplicationsApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<PageableResponseBean<List<AssignedApplicationsResponse>>>> getAllAssignedApplicationsByPagination(HttpServletRequest request, Long userId, AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean) {
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_ALL_ASSIGNED_APPLICATION_BY_PAGINATION).build());
|
||||
|
||||
PageableResponseBean<List<AssignedApplicationsResponse>> assigenedApplicationResponses=assignedApplicationsService.getAllAssignedApplicationsByPagination(request, userId,assignedApplicationPageableRequestBean);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(assigenedApplicationResponses, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ASSIGNED_APPLICATION_SUCCESS_MSG)));
|
||||
|
||||
}
|
||||
|
||||
public ResponseEntity<Response<AssignedApplicationsResponse>> updateAssignedApplicationStatus(HttpServletRequest request, Long assignedApplicationId, AssignedApplicationEnum status) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "update assigned application status" operation. **/
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.dao.CompanyDocumentDao;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyDocumentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyDocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.CompanyDocumentService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.web.rest.api.CompanyDocumentApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/companyDocument}")
|
||||
@Slf4j
|
||||
public class CompanyDocumentApiControlller implements CompanyDocumentApi {
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentService companyDocumentService;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
private CompanyDocumentDao companyDocumentDao;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<CompanyDocumentResponseBean>>> uploadFileForCompany(HttpServletRequest request, Long companyId, Long documentCategoryId, String name ,CompanyDocumentTypeEnum companyDocumentSourceTypeEnum, LocalDateTime expirationDate,
|
||||
List<MultipartFile> files) {
|
||||
try {
|
||||
UserActionContextEnum userActionContext = companyDocumentDao.getUserActionContextEnum(companyDocumentSourceTypeEnum);
|
||||
|
||||
/** This code is responsible for creating user action logs for the "upload document for company" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPLOAD).actionContext(userActionContext).build());
|
||||
|
||||
List<CompanyDocumentResponseBean> responseBeans = companyDocumentService.uploadFileForCompany(request,files, companyId, documentCategoryId ,companyDocumentSourceTypeEnum,expirationDate,name);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<List<CompanyDocumentResponseBean>>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILES_UPLOADED_MSG)));
|
||||
} catch (CustomValidationException ex) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<CompanyDocumentResponseBean>> updateCompanyDocument(HttpServletRequest httpServletRequest, Long companyDocumentId, CompanyDocumentRequest companyDocumentRequest) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "update company document" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(httpServletRequest).actionType(UserActionLogsEnum.UPDATE).actionContext(UserActionContextEnum.UPDATE_COMPANY_DOCUMENT).build());
|
||||
|
||||
CompanyDocumentResponseBean responseBeans = companyDocumentService.updateCompanyDocument(httpServletRequest, companyDocumentId, companyDocumentRequest);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<CompanyDocumentResponseBean>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_DOCUMENT_UPDATED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<CompanyDocumentResponseBean>> getCompanyDocumentById(HttpServletRequest request, Long id) {
|
||||
/** This code is responsible for creating user action logs for the "Get Company Document" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_COMPANY_DOCUMENT).build());
|
||||
|
||||
CompanyDocumentResponseBean companyDocumentResponseBean = companyDocumentService.getCompanyDocument(request, id);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<CompanyDocumentResponseBean>(companyDocumentResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_DOCUMENT_FETCHED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> deleteCompanyFile(HttpServletRequest request, Long companyDocumentId) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "delete company document" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.DELETE).actionContext(UserActionContextEnum.DELETE_COMPANY_DOCUMENT).build());
|
||||
|
||||
companyDocumentService.deleteCompanyFile(request,companyDocumentId);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<Void>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILE_DELETED_SUCCESSFULLY_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<DocumentResponseBean>> validateAndDuplicateCompanyDocument(HttpServletRequest httpServletRequest, Long companyDocumentId , Long applicationId,DocumentTypeEnum typeEnum) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "duplicate company document" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(httpServletRequest).actionType(UserActionLogsEnum.UPDATE).actionContext(UserActionContextEnum.DUPLICATE_COMPANY_DOCUMENT).build());
|
||||
|
||||
DocumentResponseBean responseBeans = companyDocumentService.validateAndDuplicateCompanyDocument(httpServletRequest, companyDocumentId,applicationId,typeEnum);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<DocumentResponseBean>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_DOCUMENT_COPIED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<CompanyDocumentResponseBean>>> getAllCompanyDocuments(HttpServletRequest request, Long companyId, CompanyDocumentTypeEnum typeEnum) {
|
||||
log.info("Get All Company Document");
|
||||
|
||||
/** This code is responsible for creating user action logs for the "get all Company Document" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_ALL_COMPANY_DOCUMENT).build());
|
||||
|
||||
List<CompanyDocumentResponseBean> companyDocumentResponseBeans = companyDocumentService.getAllCompanyDocument(request,companyId,typeEnum);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(companyDocumentResponseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_DOCUMENT_FETCHED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.DocumentCategoryRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentCategoryResponse;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.DocumentCategoryService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.web.rest.api.DocumentCategoryApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/documentCategory}")
|
||||
@Log4j2
|
||||
public class DocumentCategoryApiController implements DocumentCategoryApi {
|
||||
|
||||
@Autowired
|
||||
LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
DocumentCategoryService categoryService;
|
||||
|
||||
public ResponseEntity<Response<DocumentCategoryResponse>> createDocumentCategory(HttpServletRequest request, @Valid DocumentCategoryRequest categoryRequest){
|
||||
|
||||
/** This code is responsible for creating user action logs for the "Create Document category" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.INSERT)
|
||||
.actionContext(UserActionContextEnum.CREATE_DOCUMENT_CATEGORY).build());
|
||||
|
||||
DocumentCategoryResponse categoryResponse = categoryService.createDocumentCategory(request,categoryRequest);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(categoryResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_CREATE_SUCCESS)));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<DocumentCategoryResponse>> getDocumentCategoryById(HttpServletRequest request, Long id) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "get document category by id" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_DOCUMENT_CATEGORY).build());
|
||||
|
||||
DocumentCategoryResponse categoryResponse = categoryService.getDocumentCategoryById(request,id);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(categoryResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_GET_SUCCESS)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> deleteDocumentCategory(HttpServletRequest request, Long id) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "Delete category" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.DELETE).actionContext(UserActionContextEnum.DELETE_DOCUMENT_CATEGORY).build());
|
||||
|
||||
categoryService.deleteDocumentCategory(request,id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_DELETE_SUCCESS)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<DocumentCategoryResponse>> updateDocumentCategory(HttpServletRequest request, Long id, DocumentCategoryRequest categoryRequest) {
|
||||
|
||||
/** This code is responsible for "Updating Category details" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE)
|
||||
.actionContext(UserActionContextEnum.UPDATE_DOCUMENT_CATEGORY).build());
|
||||
|
||||
DocumentCategoryResponse categoryResponse = categoryService.updateDocumentCategory(request,id, categoryRequest);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(categoryResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_UPDATE_SUCCESS)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<DocumentCategoryResponse>>> getAllDocumentCategory(HttpServletRequest request) {
|
||||
log.info("Get All Document Category");
|
||||
|
||||
/** This code is responsible for creating user action logs for the "get all document category" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_ALL_DOCUMENT_CATEGORY).build());
|
||||
|
||||
List<DocumentCategoryResponse> documentCategoryResponseList = categoryService.getAllDocumentCategory(request);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(documentCategoryResponseList, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_CATEGORY_GET_SUCCESS)));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -92,4 +92,11 @@ public class NotificationApiController implements NotificationApi {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(notificationResponses, Status.SUCCESS, Translator.toLocale(GepafinConstant.NOTIFICATION_FETCHED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<PageableResponseBean<List<NotificationResponse>>>> getNotificationsByUserIdAndCompanyIdByPagination(HttpServletRequest request, Long userId, Long companyId, NotificationRequestBean notificationRequestBean) {
|
||||
PageableResponseBean<List<NotificationResponse>> notificationResponses=notificationService.getNotificationsByUserIdAndCompanyIdByPagination(request, userId,companyId,notificationRequestBean);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(notificationResponses, Status.SUCCESS, Translator.toLocale(GepafinConstant.NOTIFICATION_FETCHED_SUCCESSFULLY)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,9 +6,12 @@ import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.TimePeriodEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionPaginationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ActionContextLabelResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserActionResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.UserActionService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
@@ -33,12 +36,12 @@ public class UserActionApiController implements UserActionApi {
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<SummaryPageResponseBean>> getUserAction(HttpServletRequest request, Long userId, TimePeriodEnum timeFilter, List<UserActionContextEnum> actionContext) {
|
||||
public ResponseEntity<Response<SummaryPageResponseBean>> getUserAction(HttpServletRequest request, Long userId) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "get user action" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_USER_ACTION).build());
|
||||
SummaryPageResponseBean userActionResponse= userActionService.getUserAction(request,userId,timeFilter,actionContext);
|
||||
SummaryPageResponseBean userActionResponse= userActionService.getUserAction(request,userId);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(userActionResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_ACTION_FETCHED_SUCCESSFULLY)));
|
||||
}
|
||||
@@ -54,5 +57,16 @@ public class UserActionApiController implements UserActionApi {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(actionContextResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.ACTION_CONTEXT_LABELS_FETCHED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<PageableResponseBean<List<UserActionResponseBean>>>> getUserActionByPaginnation(HttpServletRequest request, Long userId, UserActionPaginationRequest userActionPaginationRequest) {
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_ALL_USER_ACTION_BY_PAGINATION).build());
|
||||
|
||||
PageableResponseBean<List<UserActionResponseBean>> userActionResponse= userActionService.getUserActionByPagination(request,userId,userActionPaginationRequest);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(userActionResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.USER_ACTION_FETCHED_SUCCESSFULLY)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
@@ -249,6 +250,15 @@ public class UserApiController implements UserApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<PageableResponseBean<List<UserResponseBean>>>> getUserByPagination(HttpServletRequest request, UserPaginationRequestBean userPaginationRequestBean) {
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_ALL_USER_BY_PAGINATION).build());
|
||||
|
||||
PageableResponseBean<List<UserResponseBean>> users = userService.getUserByPagination(request, userPaginationRequestBean);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(users, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_USERS_SUCCESS_MSG)));
|
||||
|
||||
}
|
||||
public ResponseEntity<Response<UserResponseBean>> updateUserDetails(HttpServletRequest request,
|
||||
@PathVariable("userId") Long userId,
|
||||
@Valid @RequestBody UpdateUserReqForBeneficiary userReq) {
|
||||
|
||||
@@ -10,7 +10,8 @@ spring.h2.console.enabled=true
|
||||
isVatCheckGloballyDisabled = false
|
||||
|
||||
isMailSendingEnabled = true
|
||||
default_System_Receiver_Email=antonio.manca@bflows.net
|
||||
isPecServiceEnabled = false
|
||||
#default_System_Receiver_Email=antonio.manca@bflows.net
|
||||
gepafin_email=rinaldo.bonazzo@bflows.net
|
||||
rinaldo_email=rinaldo.bonazzo@bflows.net
|
||||
carlo_email=test@test.test
|
||||
|
||||
@@ -9,7 +9,8 @@ spring.jpa.show-sql=true
|
||||
base-url=http://localhost:8080
|
||||
|
||||
isMailSendingEnabled = false
|
||||
default_System_Receiver_Email=test@test.test
|
||||
isPecServiceEnabled = false
|
||||
#default_System_Receiver_Email=test@test.test
|
||||
gepafin_email=test@test.test
|
||||
rinaldo_email=test@test.test
|
||||
carlo_email=test@test.test
|
||||
|
||||
@@ -16,7 +16,8 @@ spid.ipd.base.url=https://login.regione.umbria.it
|
||||
active.profile.folder=production
|
||||
|
||||
isMailSendingEnabled = true
|
||||
default_System_Receiver_Email=m.gaudino@gepafin.it,f.marinelli@gepafin.it
|
||||
isPecServiceEnabled = true
|
||||
#default_System_Receiver_Email=m.gaudino@gepafin.it,f.marinelli@gepafin.it
|
||||
gepafin_email=bandi@pec.gepafin.it
|
||||
rinaldo_email=rinaldo.bonazzo@bflows.net
|
||||
carlo_email=carlo.mancosu@bflows.net
|
||||
|
||||
@@ -7,7 +7,8 @@ spring.datasource.password=sa
|
||||
spring.h2.console.enabled=true
|
||||
base-url=http://localhost:8080
|
||||
isMailSendingEnabled = false
|
||||
default_System_Receiver_Email=test@test.test
|
||||
isPecServiceEnabled = false
|
||||
#default_System_Receiver_Email=test@test.test
|
||||
gepafin_email=test@test.test
|
||||
rinaldo_email=test@test.test
|
||||
carlo_email=test@test.test
|
||||
|
||||
@@ -2380,6 +2380,17 @@
|
||||
path="db/dump/update_system_email_template_application_rejected_04_02_2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="14-02-2025_PK_124000" author="Piyush Kag">
|
||||
|
||||
<addColumn tableName="COMPANY">
|
||||
<column name="JSON" type="TEXT"/>
|
||||
</addColumn>
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/insert_json_column_in_company_data_06_02_2025.sql"/>
|
||||
<dropColumn tableName="USER_WITH_COMPANY" columnName="JSON"/>
|
||||
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="06-02-2025_NK_155519" author="Nisha Kashyap">
|
||||
<addColumn tableName="call">
|
||||
<column name="number_of_check" type="numeric"></column>
|
||||
@@ -2418,21 +2429,137 @@
|
||||
<modifyDataType tableName="call" columnName="product_id" newDataType="INTEGER"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="24-02-2025_RK_192024" author="Rajesh Khore">
|
||||
<createTable tableName="document_category">
|
||||
<column name="id" type="INTEGER" autoIncrement="true">
|
||||
<constraints primaryKey="true" primaryKeyName="document_category_pkey" nullable="false"/>
|
||||
</column>
|
||||
<column name="CATEGORY_NAME" type="VARCHAR(255)"/>
|
||||
<column name="DESCRIPTION" type="TEXT"/>
|
||||
<column name="IS_DELETED" type="BOOLEAN" defaultValue="false"/>
|
||||
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="24-02-2025_RK_190220" author="Rajesh Khore">
|
||||
<createTable tableName="company_document">
|
||||
<column name="id" type="INTEGER" autoIncrement="true">
|
||||
<constraints primaryKey="true" primaryKeyName="company_document_pkey" nullable="false"/>
|
||||
</column>
|
||||
<column name="file_name" type="VARCHAR(255)"/>
|
||||
<column name="file_path" type="TEXT"/>
|
||||
<column name="type" type="VARCHAR(255)"/>
|
||||
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="uploaded_by" type="INTEGER"/>
|
||||
<column name="expiration_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="status" type="VARCHAR(255)"/>
|
||||
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="USER_WITH_COMPANY_ID" type="INTEGER">
|
||||
<constraints foreignKeyName="fk_USER_WITH_COMPANY_COMPANY_DOCUMENT" references="user_with_company(id)" nullable="false"/>
|
||||
</column>
|
||||
<column name="COMPANY_ID" type="INTEGER">
|
||||
<constraints nullable="true" foreignKeyName="fk_COMPANY_COMPANY_DOCUMENT" references="company(id)"/>
|
||||
</column>
|
||||
<column name="DOCUMENT_CATEGORY_ID" type="INTEGER">
|
||||
<constraints nullable="true" foreignKeyName="fk_DOCUMENT_CATEGORY_COMPANY_DOCUMENT" references="document_category(id)"/>
|
||||
</column>
|
||||
</createTable>
|
||||
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="24-02-2025_RK_020220" author="Rajesh Khore">
|
||||
<insert tableName="s3_path_configuration">
|
||||
<column name="type" value="COMPANY_DOCUMENT"/>
|
||||
<column name="path" value="company/{company_id}"/>
|
||||
<column name="bucket_name" value="mementoresources"/>
|
||||
<column name="created_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="updated_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="parent_folder" value="gepafin/local"/>
|
||||
</insert>
|
||||
|
||||
<insert tableName="s3_path_configuration">
|
||||
<column name="type" value="DELETED_PERSONAL_DOCUMENT"/>
|
||||
<column name="path" value="company/{company_id}/deleted"/>
|
||||
<column name="bucket_name" value="mementoresources"/>
|
||||
<column name="created_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="updated_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="parent_folder" value="gepafin/local"/>
|
||||
</insert>
|
||||
|
||||
<insert tableName="s3_path_configuration">
|
||||
<column name="type" value="PERSONAL_DOCUMENT"/>
|
||||
<column name="path" value="company/{company_id}"/>
|
||||
<column name="bucket_name" value="mementoresources"/>
|
||||
<column name="created_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="updated_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="parent_folder" value="gepafin/local"/>
|
||||
</insert>
|
||||
|
||||
<insert tableName="s3_path_configuration">
|
||||
<column name="type" value="DELETED_COMPANY_DOCUMENT"/>
|
||||
<column name="path" value="company/{company_id}/deleted"/>
|
||||
<column name="bucket_name" value="mementoresources"/>
|
||||
<column name="created_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="updated_date" value="2025-02-20 03:00:00"/>
|
||||
<column name="parent_folder" value="gepafin/local"/>
|
||||
</insert>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="24-02-2025_RK_125215" author="Rajesh Khore">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/updated_expiration_scheduler_data_24_02_2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="24-02-2025_RK_125145" author="Rajesh Khore">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/updated_json_template_for_notification_24_02_2025.sql"/>
|
||||
</changeSet>
|
||||
<changeSet id="17-02-2025_PK_025237" author="Piyush Kag">
|
||||
<renameColumn tableName="call"
|
||||
oldColumnName="product_id"
|
||||
newColumnName="appointment_template_id"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="14-02-2025_PK_124000" author="Piyush Kag">
|
||||
|
||||
<addColumn tableName="COMPANY">
|
||||
<column name="JSON" type="TEXT"/>
|
||||
</addColumn>
|
||||
<changeSet id="27-02-2025_RK_192415" author="Rajesh Khore">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/insert_json_column_in_company_data_06_02_2025.sql"/>
|
||||
<dropColumn tableName="USER_WITH_COMPANY" columnName="JSON"/>
|
||||
path="db/dump/updated_system_email_template_email_scenario_27_02_2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="26-02-2025_NK_180530" author="Nisha Kashyap">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/updated_hub_data_for_email_service_config_25-02-2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
|
||||
<changeSet id="27-02-2025_RK_270225" author="Rajesh Khore">
|
||||
<addColumn tableName="company_document">
|
||||
<column name="name" type="VARCHAR(255)">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="03-03-2025_RK_120515" author="Rajesh Khore">
|
||||
|
||||
<sql dbms="postgresql">select
|
||||
setval('gepafin_schema.form_field_id_seq', (select
|
||||
max(id)+1
|
||||
from gepafin_schema.form_field), false)
|
||||
</sql>
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/update_form_field_data_03-03-2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
INSERT INTO FORM_FIELD (SORT_ORDER, NAME, LABEL, DESCRIPTION, SETTINGS, VALIDATORS, CREATED_DATE, UPDATED_DATE)
|
||||
VALUES
|
||||
(
|
||||
23,
|
||||
'fileselect',
|
||||
'Caricamento File',
|
||||
'Per selezionare di documenti o immagini',
|
||||
'[{name: "label",value: "Seleziona File"},{ name: "isDelegation", value: false }]',
|
||||
'{"isRequired":false}',
|
||||
CURRENT_TIMESTAMP,
|
||||
CURRENT_TIMESTAMP
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
INSERT INTO expiration_config (interval_days, type, created_date, updated_date)
|
||||
VALUES
|
||||
(7, 'COMPANY_DOCUMENT', '2025-02-24T11:00:51', '2025-02-24T11:00:51');
|
||||
@@ -0,0 +1,4 @@
|
||||
UPDATE hub
|
||||
SET email_service_type = 'PEC_SERVICE',
|
||||
email_service_config = 'JkFbBfuVvq7VWwp5LcWIi+hAa1RJ1ekI0jq3w7gLTXETZiTaN8zC4OBWD53x8FtbfFTh3L/5805CIYTH1BQGa3X9q16q9SDzMy7DKHdmJzOnLKhn74C5akoXKaeXUCGnzp0cSk2c01FV6lwefC29IshijFSumCHtVlgWNeZigBzmWK+M7NS+EXf4goIMzguL5bHpYXfoQunQozeY1SpOoxf4XZfd/MNPeVOA/ZNHDGU='
|
||||
WHERE UNIQUE_UUID = 'p4lk3bcx1RStqTaIVVbXs';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user