Resolved conflicts
This commit is contained in:
@@ -485,6 +485,11 @@ public class GepafinConstant {
|
||||
public static final String USAGE="usage";
|
||||
public static final String LIMIT="limit";
|
||||
public static final String DATA="data";
|
||||
|
||||
public static final String PREFERRED_CALL_ID="preferredCallId";
|
||||
|
||||
public static final String REGION_ID="regionId";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1047,7 +1047,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
|
||||
List<ApplicationAmendmentRequestEntity> amendmentRequests = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(
|
||||
existingApplicationAmendment.getApplicationEvaluationEntity().getId());
|
||||
Boolean allClosed = amendmentRequests.stream().allMatch(amendment -> amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()));
|
||||
Boolean allClosed = amendmentRequests.stream().allMatch(amendment -> (amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()) || amendment.getStatus().equals(ApplicationAmendmentRequestEnum.EXPIRED.getValue())));
|
||||
ApplicationEntity application = applicationService.validateApplication(existingApplicationAmendment.getApplicationId());
|
||||
ApplicationEntity oldApplicationEntityData = Utils.getClonedEntityForData(application);
|
||||
if (Boolean.TRUE.equals(allClosed)) {
|
||||
|
||||
@@ -424,7 +424,7 @@ public class ApplicationDao {
|
||||
responseBean.setCallTitle(applicationEntity.getCall().getName());
|
||||
responseBean.setCallEndDate(applicationEntity.getCall().getEndDate());
|
||||
responseBean.setCallEndTime(applicationEntity.getCall().getEndTime());
|
||||
responseBean.setModifiedDate(applicationEntity.getCall().getUpdatedDate());
|
||||
responseBean.setModifiedDate(applicationEntity.getUpdatedDate());
|
||||
responseBean.setCallId(applicationEntity.getCall().getId());
|
||||
responseBean.setSubmissionDate(applicationEntity.getSubmissionDate());
|
||||
responseBean.setStatus(applicationEntity.getStatus());
|
||||
|
||||
@@ -4,9 +4,12 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
@@ -16,6 +19,7 @@ import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.persistence.criteria.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
@@ -1083,10 +1087,14 @@ public class CallDao {
|
||||
expirePublishedCalls(request);
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
Map<String, FilterCriteria> filters = new HashMap<>();
|
||||
if (callPageableRequestBean.getGlobalFilters() != null) {
|
||||
year = callPageableRequestBean.getGlobalFilters().getYear();
|
||||
search = callPageableRequestBean.getGlobalFilters().getSearch();
|
||||
}
|
||||
if (callPageableRequestBean.getFilters() != null) {
|
||||
filters = callPageableRequestBean.getFilters();
|
||||
}
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
if (year != null && year > 0) {
|
||||
int filterYear = callPageableRequestBean.getGlobalFilters().getYear();
|
||||
@@ -1129,7 +1137,7 @@ public class CallDao {
|
||||
.toList();
|
||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||
}
|
||||
|
||||
applyFilters(root, criteriaBuilder, predicates, filters);
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB).get(GepafinConstant.ID), userEntity.getHub().getId()));
|
||||
|
||||
return predicates;
|
||||
@@ -1185,6 +1193,128 @@ public class CallDao {
|
||||
callRepository.saveAll(expiredCalls); // Save all modified calls at once
|
||||
}
|
||||
}
|
||||
private void applyFilters(Root<?> root, CriteriaBuilder criteriaBuilder, List<Predicate> predicates, Map<String, FilterCriteria> filters) {
|
||||
if (Boolean.FALSE.equals(filters.isEmpty())) {
|
||||
for (Map.Entry<String, FilterCriteria> entry : filters.entrySet()) {
|
||||
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.REGION_ID -> {
|
||||
// Ensure join is only created if not already present
|
||||
Join<?, RegionEntity> regionJoin = root.getJoins().stream()
|
||||
.filter(j -> j.getAttribute().getName().equals("region"))
|
||||
.findFirst()
|
||||
.map(j -> (Join<?, RegionEntity>) j)
|
||||
.orElseGet(() -> root.join("region", JoinType.LEFT));
|
||||
|
||||
yield regionJoin.get("id");
|
||||
}
|
||||
|
||||
default -> root.get(fieldName);
|
||||
};
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public CallResponse createCallStep2EvaluationV2(CallEntity callEntity, CreateCallRequestStep2EvaluationV2 createCallRequest, UserEntity user) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.AmazonS3Client;
|
||||
import com.amazonaws.services.s3.model.CopyObjectRequest;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
@@ -33,6 +34,7 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.net.URL;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -86,6 +88,9 @@ public class CompanyDocumentDao {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private AmazonS3 amazonS3;
|
||||
|
||||
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);
|
||||
@@ -271,8 +276,11 @@ public class CompanyDocumentDao {
|
||||
s3Client.copyObject(copyRequest);
|
||||
log.info("File copied successfully from {} to {}", oldS3Path, newS3Path);
|
||||
|
||||
URL amazonS3Url = amazonS3.getUrl(bucketName, newS3Path);
|
||||
String fileUrl = amazonS3Url.toString();
|
||||
|
||||
DocumentEntity entity = new DocumentEntity();
|
||||
entity.setFilePath(newS3Path);
|
||||
entity.setFilePath(fileUrl);
|
||||
entity.setFileName(companyDocumentEntity.getFileName());
|
||||
entity.setSource(DocumentSourceTypeEnum.APPLICATION.getValue());
|
||||
entity.setType(documentTypeEnum.getValue());
|
||||
|
||||
@@ -4,14 +4,14 @@ 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");
|
||||
STARTSWITH("startsWith"),
|
||||
ENDSWITH("endsWith"),
|
||||
CONTAINS("contains"),
|
||||
EQUALS("equals"),
|
||||
DATEIS("dateIs"),
|
||||
DATEISNOT("dateIsNot"),
|
||||
BEFORE("dateBefore"),
|
||||
AFTER("dateAfter");
|
||||
|
||||
private String value;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class CallPageableRequestBean {
|
||||
@@ -11,4 +12,6 @@ public class CallPageableRequestBean {
|
||||
private GlobalFilters globalFilters;
|
||||
|
||||
private List<CallStatusEnum> status;
|
||||
|
||||
private Map<String, FilterCriteria> filters;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user