From 3f3de15aef80d5418fcc6d3decb2fec2c6ceb348 Mon Sep 17 00:00:00 2001 From: SodhiA1 <38086281+SodhiA1@users.noreply.github.com> Date: Wed, 15 Nov 2023 14:19:32 -0800 Subject: [PATCH 1/2] Pagination with validation issues --- .../SdcSchoolCollectionStudentController.java | 5 +- ...SdcSchoolCollectionStudentFilterSpecs.java | 5 +- .../SdcSchoolCollectionStudentDecorator.java | 13 ++ .../v1/SdcSchoolCollectionStudentMapper.java | 7 + ...hoolCollectionStudentPaginationEntity.java | 187 ++++++++++++++++++ ...CollectionStudentPaginationRepository.java | 13 ++ ...cSchoolCollectionStudentSearchService.java | 26 +-- 7 files changed, 241 insertions(+), 15 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/model/v1/SdcSchoolCollectionStudentPaginationEntity.java create mode 100644 api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentPaginationRepository.java diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/SdcSchoolCollectionStudentController.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/SdcSchoolCollectionStudentController.java index 2ca68bc4d..0237ba4b9 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/SdcSchoolCollectionStudentController.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/controller/v1/SdcSchoolCollectionStudentController.java @@ -5,6 +5,7 @@ import ca.bc.gov.educ.studentdatacollection.api.exception.InvalidParameterException; import ca.bc.gov.educ.studentdatacollection.api.mappers.v1.SdcSchoolCollectionStudentMapper; import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentEntity; +import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentPaginationEntity; import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionRepository; import ca.bc.gov.educ.studentdatacollection.api.service.v1.SdcSchoolCollectionStudentHeadcountService; import ca.bc.gov.educ.studentdatacollection.api.service.v1.SdcSchoolCollectionStudentSearchService; @@ -60,7 +61,7 @@ public SdcSchoolCollectionStudentValidationIssueErrorWarningCount getErrorAndWar @Override public CompletableFuture> findAll(Integer pageNumber, Integer pageSize, String sortCriteriaJson, String searchCriteriaListJson) { final List sorts = new ArrayList<>(); - Specification studentSpecs = sdcSchoolCollectionStudentSearchService + Specification studentSpecs = sdcSchoolCollectionStudentSearchService .setSpecificationAndSortCriteria( sortCriteriaJson, searchCriteriaListJson, @@ -69,7 +70,7 @@ public CompletableFuture> findAll(Integer pageN ); return this.sdcSchoolCollectionStudentSearchService .findAll(studentSpecs, pageNumber, pageSize, sorts) - .thenApplyAsync(sdcSchoolStudentEntities -> sdcSchoolStudentEntities.map(mapper::toSdcSchoolStudent)); + .thenApplyAsync(sdcSchoolStudentEntities -> sdcSchoolStudentEntities.map(mapper::toSdcSchoolCollectionStudentWithValidationIssues)); } @Override diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/filter/SdcSchoolCollectionStudentFilterSpecs.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/filter/SdcSchoolCollectionStudentFilterSpecs.java index 4f77f3e65..805f25e34 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/filter/SdcSchoolCollectionStudentFilterSpecs.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/filter/SdcSchoolCollectionStudentFilterSpecs.java @@ -1,6 +1,7 @@ package ca.bc.gov.educ.studentdatacollection.api.filter; import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentEntity; +import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentPaginationEntity; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -10,9 +11,9 @@ @Service @Slf4j -public class SdcSchoolCollectionStudentFilterSpecs extends BaseFilterSpecs { +public class SdcSchoolCollectionStudentFilterSpecs extends BaseFilterSpecs { - public SdcSchoolCollectionStudentFilterSpecs(FilterSpecifications dateFilterSpecifications, FilterSpecifications> dateTimeFilterSpecifications, FilterSpecifications integerFilterSpecifications, FilterSpecifications stringFilterSpecifications, FilterSpecifications longFilterSpecifications, FilterSpecifications uuidFilterSpecifications,FilterSpecifications booleanFilterSpecifications, Converters converters) { + public SdcSchoolCollectionStudentFilterSpecs(FilterSpecifications dateFilterSpecifications, FilterSpecifications> dateTimeFilterSpecifications, FilterSpecifications integerFilterSpecifications, FilterSpecifications stringFilterSpecifications, FilterSpecifications longFilterSpecifications, FilterSpecifications uuidFilterSpecifications,FilterSpecifications booleanFilterSpecifications, Converters converters) { super(dateFilterSpecifications, dateTimeFilterSpecifications, integerFilterSpecifications, stringFilterSpecifications, longFilterSpecifications, uuidFilterSpecifications, booleanFilterSpecifications, converters); } } diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/mappers/v1/SdcSchoolCollectionStudentDecorator.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/mappers/v1/SdcSchoolCollectionStudentDecorator.java index 668b9647a..c33c75f1a 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/mappers/v1/SdcSchoolCollectionStudentDecorator.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/mappers/v1/SdcSchoolCollectionStudentDecorator.java @@ -1,6 +1,7 @@ package ca.bc.gov.educ.studentdatacollection.api.mappers.v1; import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentEntity; +import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentPaginationEntity; import ca.bc.gov.educ.studentdatacollection.api.struct.v1.SdcSchoolCollectionStudent; import lombok.extern.slf4j.Slf4j; import org.springframework.transaction.annotation.Transactional; @@ -27,4 +28,16 @@ public SdcSchoolCollectionStudent toSdcSchoolCollectionStudentWithValidationIssu sdcSchoolCollectionStudentEntity.getSDCStudentValidationIssueEntities().stream().forEach(issue -> sdcSchoolCollectionStudent.getSdcSchoolCollectionStudentValidationIssues().add(studentValidationIssueMapper.toStructure(issue))); return sdcSchoolCollectionStudent; } + + @Override + public SdcSchoolCollectionStudent toSdcSchoolCollectionStudentWithValidationIssues(SdcSchoolCollectionStudentPaginationEntity sdcSchoolCollectionStudentEntity) { + final SdcSchoolCollectionStudent sdcSchoolCollectionStudent = this.delegate.toSdcSchoolStudent(sdcSchoolCollectionStudentEntity); + SdcSchoolCollectionStudentValidationIssueMapper studentValidationIssueMapper = SdcSchoolCollectionStudentValidationIssueMapper.mapper; + SdcSchoolCollectionStudentEnrolledProgramMapper sdcSchoolCollectionStudentEnrolledProgramMapper = SdcSchoolCollectionStudentEnrolledProgramMapper.mapper; + sdcSchoolCollectionStudent.setSdcSchoolCollectionStudentEnrolledPrograms(new ArrayList<>()); + sdcSchoolCollectionStudent.setSdcSchoolCollectionStudentValidationIssues(new ArrayList<>()); + sdcSchoolCollectionStudentEntity.getSdcStudentEnrolledProgramEntities().stream().forEach(program -> sdcSchoolCollectionStudent.getSdcSchoolCollectionStudentEnrolledPrograms().add(sdcSchoolCollectionStudentEnrolledProgramMapper.toStructure(program))); + sdcSchoolCollectionStudentEntity.getSDCStudentValidationIssueEntities().stream().forEach(issue -> sdcSchoolCollectionStudent.getSdcSchoolCollectionStudentValidationIssues().add(studentValidationIssueMapper.toStructure(issue))); + return sdcSchoolCollectionStudent; + } } diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/mappers/v1/SdcSchoolCollectionStudentMapper.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/mappers/v1/SdcSchoolCollectionStudentMapper.java index 2e86bb1e3..2017d01f1 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/mappers/v1/SdcSchoolCollectionStudentMapper.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/mappers/v1/SdcSchoolCollectionStudentMapper.java @@ -3,6 +3,7 @@ import ca.bc.gov.educ.studentdatacollection.api.mappers.UUIDMapper; import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentEntity; +import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentPaginationEntity; import ca.bc.gov.educ.studentdatacollection.api.struct.v1.SdcSchoolCollectionStudent; import org.mapstruct.DecoratedWith; import org.mapstruct.Mapper; @@ -21,6 +22,12 @@ public interface SdcSchoolCollectionStudentMapper { @Mapping(target = "sdcSchoolCollectionID", source = "sdcSchoolCollection.sdcSchoolCollectionID") SdcSchoolCollectionStudent toSdcSchoolCollectionStudentWithValidationIssues(SdcSchoolCollectionStudentEntity sdcSchoolStudentEntity); + @Mapping(target = "sdcSchoolCollectionID", source = "sdcSchoolCollection.sdcSchoolCollectionID") + SdcSchoolCollectionStudent toSdcSchoolStudent(SdcSchoolCollectionStudentPaginationEntity sdcSchoolStudentEntity); + + @Mapping(target = "sdcSchoolCollectionID", source = "sdcSchoolCollection.sdcSchoolCollectionID") + SdcSchoolCollectionStudent toSdcSchoolCollectionStudentWithValidationIssues(SdcSchoolCollectionStudentPaginationEntity sdcSchoolStudentEntity); + @Mapping(target = "sdcSchoolCollection.sdcSchoolCollectionID", source = "sdcSchoolCollectionID") SdcSchoolCollectionStudentEntity toSdcSchoolStudentEntity(SdcSchoolCollectionStudent sdcSchoolStudent); diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/model/v1/SdcSchoolCollectionStudentPaginationEntity.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/model/v1/SdcSchoolCollectionStudentPaginationEntity.java new file mode 100644 index 000000000..ae0e2bdfe --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/model/v1/SdcSchoolCollectionStudentPaginationEntity.java @@ -0,0 +1,187 @@ +package ca.bc.gov.educ.studentdatacollection.api.model.v1; + +import ca.bc.gov.educ.studentdatacollection.api.util.UpperCase; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import jakarta.persistence.*; +import jakarta.validation.constraints.PastOrPresent; +import lombok.*; +import org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Parameter; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@DynamicUpdate +@Entity +@Table(name = "SDC_SCHOOL_COLLECTION_STUDENT") +@JsonIgnoreProperties(ignoreUnknown = true) +public class SdcSchoolCollectionStudentPaginationEntity { + + @Id + @GeneratedValue(generator = "UUID") + @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator", parameters = { + @Parameter(name = "uuid_gen_strategy_class", value = "org.hibernate.id.uuid.CustomVersionOneStrategy")}) + @Column(name = "SDC_SCHOOL_COLLECTION_STUDENT_ID", unique = true, updatable = false, columnDefinition = "BINARY(16)") + UUID sdcSchoolCollectionStudentID; + + @ToString.Exclude + @EqualsAndHashCode.Exclude + @ManyToOne(optional = false, targetEntity = SdcSchoolCollectionEntity.class) + @JoinColumn(name = "SDC_SCHOOL_COLLECTION_ID", referencedColumnName = "SDC_SCHOOL_COLLECTION_ID", updatable = false) + private SdcSchoolCollectionEntity sdcSchoolCollection; + + @Column(name = "LOCAL_ID") + private String localID; + + @Column(name = "STUDENT_PEN") + private String studentPen; + + @Column(name = "LEGAL_FIRST_NAME") + private String legalFirstName; + + @Column(name = "LEGAL_MIDDLE_NAMES") + private String legalMiddleNames; + + @Column(name = "LEGAL_LAST_NAME") + private String legalLastName; + + @Column(name = "USUAL_FIRST_NAME") + private String usualFirstName; + + @Column(name = "USUAL_MIDDLE_NAMES") + private String usualMiddleNames; + + @Column(name = "USUAL_LAST_NAME") + private String usualLastName; + + @Column(name = "DOB") + private String dob; + + @Column(name = "GENDER_CODE", length = 1) + private String gender; + + @Column(name = "SPECIAL_EDUCATION_CATEGORY_CODE") + private String specialEducationCategoryCode; + + @Column(name = "SCHOOL_FUNDING_CODE") + private String schoolFundingCode; + + @Column(name = "NATIVE_ANCESTRY_IND") + private String nativeAncestryInd; + + @Column(name = "HOME_LANGUAGE_SPOKEN_CODE") + private String homeLanguageSpokenCode; + + @Column(name = "OTHER_COURSES") + private String otherCourses; + + @Column(name = "SUPPORT_BLOCKS") + private String supportBlocks; + + @Column(name = "ENROLLED_GRADE_CODE") + private String enrolledGradeCode; + + @Column(name = "ENROLLED_PROGRAM_CODES") + private String enrolledProgramCodes; + + @Column(name = "CAREER_PROGRAM_CODE") + private String careerProgramCode; + + @Column(name = "NUMBER_OF_COURSES") + private String numberOfCourses; + + @Column(name = "BAND_CODE") + private String bandCode; + + @Column(name = "POSTAL_CODE") + @UpperCase + private String postalCode; + + @Column(name = "SDC_SCHOOL_COLLECTION_STUDENT_STATUS_CODE") + private String sdcSchoolCollectionStudentStatusCode; + + @Column(name = "IS_ADULT") + private Boolean isAdult; + + @Column(name = "IS_SCHOOL_AGED") + private Boolean isSchoolAged; + + @Column(name = "FTE") + private BigDecimal fte; + + @Column(name = "FTE_ZERO_REASON_CODE", length = 10) + private String fteZeroReasonCode; + + @Column(name = "FRENCH_PROGRAM_NON_ELIG_REASON_CODE", length = 10) + private String frenchProgramNonEligReasonCode; + + @Column(name = "ELL_NON_ELIG_REASON_CODE", length = 10) + private String ellNonEligReasonCode; + + @Column(name = "INDIGENOUS_SUPPORT_PROGRAM_NON_ELIG_REASON_CODE", length = 10) + private String indigenousSupportProgramNonEligReasonCode; + + @Column(name = "CAREER_PROGRAM_NON_ELIG_REASON_CODE", length = 10) + private String careerProgramNonEligReasonCode; + + @Column(name = "SPECIAL_EDUCATION_NON_ELIG_REASON_CODE", length = 10) + private String specialEducationNonEligReasonCode; + + @Column(name = "IS_GRADUATED") + private Boolean isGraduated; + + @Column(name = "ASSIGNED_STUDENT_ID", columnDefinition = "BINARY(16)") + private UUID assignedStudentId; + + @Column(name = "ASSIGNED_PEN") + private String assignedPen; + + @Column(name = "PEN_MATCH_RESULT") + private String penMatchResult; + + @Column(name = "CREATE_USER", updatable = false , length = 32) + private String createUser; + + @PastOrPresent + @Column(name = "CREATE_DATE", updatable = false) + private LocalDateTime createDate; + + @Column(name = "UPDATE_USER", length = 32) + private String updateUser; + + @PastOrPresent + @Column(name = "UPDATE_DATE") + private LocalDateTime updateDate; + + @EqualsAndHashCode.Exclude + @ToString.Exclude + @OneToMany(mappedBy = "sdcSchoolCollectionStudentEntity", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, targetEntity = SdcSchoolCollectionStudentValidationIssueEntity.class) + Set sdcStudentValidationIssueEntities; + + @EqualsAndHashCode.Exclude + @ToString.Exclude + @OneToMany(mappedBy = "sdcSchoolCollectionStudentEntity", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, targetEntity = SdcSchoolCollectionStudentEnrolledProgramEntity.class) + Set sdcStudentEnrolledProgramEntities; + + public Set getSDCStudentValidationIssueEntities() { + if (this.sdcStudentValidationIssueEntities == null) { + this.sdcStudentValidationIssueEntities = new HashSet<>(); + } + return this.sdcStudentValidationIssueEntities; + } + + public Set getSdcStudentEnrolledProgramEntities() { + if (this.sdcStudentEnrolledProgramEntities == null) { + this.sdcStudentEnrolledProgramEntities = new HashSet<>(); + } + return this.sdcStudentEnrolledProgramEntities; + } + +} diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentPaginationRepository.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentPaginationRepository.java new file mode 100644 index 000000000..9a96048bb --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/SdcSchoolCollectionStudentPaginationRepository.java @@ -0,0 +1,13 @@ +package ca.bc.gov.educ.studentdatacollection.api.repository.v1; + +import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentPaginationEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +import java.util.UUID; + +@Repository +public interface SdcSchoolCollectionStudentPaginationRepository extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/SdcSchoolCollectionStudentSearchService.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/SdcSchoolCollectionStudentSearchService.java index 6206f20f0..d15e3234e 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/SdcSchoolCollectionStudentSearchService.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/SdcSchoolCollectionStudentSearchService.java @@ -6,6 +6,8 @@ import ca.bc.gov.educ.studentdatacollection.api.filter.FilterOperation; import ca.bc.gov.educ.studentdatacollection.api.filter.SdcSchoolCollectionStudentFilterSpecs; import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentEntity; +import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentPaginationEntity; +import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionStudentPaginationRepository; import ca.bc.gov.educ.studentdatacollection.api.repository.v1.SdcSchoolCollectionStudentRepository; import ca.bc.gov.educ.studentdatacollection.api.struct.v1.Condition; import ca.bc.gov.educ.studentdatacollection.api.struct.v1.Search; @@ -44,11 +46,13 @@ public class SdcSchoolCollectionStudentSearchService { private final SdcSchoolCollectionStudentRepository sdcSchoolCollectionStudentRepository; + private final SdcSchoolCollectionStudentPaginationRepository sdcSchoolCollectionStudentPaginationRepository; + private final Executor paginatedQueryExecutor = new EnhancedQueueExecutor.Builder() .setThreadFactory(new ThreadFactoryBuilder().setNameFormat("async-pagination-query-executor-%d").build()) .setCorePoolSize(2).setMaximumPoolSize(10).setKeepAliveTime(Duration.ofSeconds(60)).build(); - public Specification getSpecifications(Specification schoolSpecs, int i, Search search) { + public Specification getSpecifications(Specification schoolSpecs, int i, Search search) { if (i == 0) { schoolSpecs = getSchoolCollectionStudentEntitySpecification(search.getSearchCriteriaList()); } else { @@ -61,8 +65,8 @@ public Specification getSpecifications(Specifi return schoolSpecs; } - private Specification getSchoolCollectionStudentEntitySpecification(List criteriaList) { - Specification studentSpecs = null; + private Specification getSchoolCollectionStudentEntitySpecification(List criteriaList) { + Specification studentSpecs = null; if (!criteriaList.isEmpty()) { int i = 0; for (SearchCriteria criteria : criteriaList) { @@ -71,7 +75,7 @@ private Specification getSchoolCollectionStude if(StringUtils.isNotBlank(criteria.getValue()) && TransformUtil.isUppercaseField(SdcSchoolCollectionStudentEntity.class, criteria.getKey())) { criteriaValue = criteriaValue.toUpperCase(); } - Specification typeSpecification = getTypeSpecification(criteria.getKey(), criteria.getOperation(), criteriaValue, criteria.getValueType()); + Specification typeSpecification = getTypeSpecification(criteria.getKey(), criteria.getOperation(), criteriaValue, criteria.getValueType()); studentSpecs = getSpecificationPerGroup(studentSpecs, i, criteria, typeSpecification); i++; } else { @@ -82,7 +86,7 @@ private Specification getSchoolCollectionStude return studentSpecs; } - private Specification getSpecificationPerGroup(Specification schoolEntitySpecification, int i, SearchCriteria criteria, Specification typeSpecification) { + private Specification getSpecificationPerGroup(Specification schoolEntitySpecification, int i, SearchCriteria criteria, Specification typeSpecification) { if (i == 0) { schoolEntitySpecification = Specification.where(typeSpecification); } else { @@ -95,8 +99,8 @@ private Specification getSpecificationPerGroup return schoolEntitySpecification; } - private Specification getTypeSpecification(String key, FilterOperation filterOperation, String value, ValueType valueType) { - Specification schoolEntitySpecification = null; + private Specification getTypeSpecification(String key, FilterOperation filterOperation, String value, ValueType valueType) { + Specification schoolEntitySpecification = null; switch (valueType) { case STRING: schoolEntitySpecification = sdcSchoolCollectionStudentFilterSpecs.getStringTypeSpecification(key, value, filterOperation); @@ -123,13 +127,13 @@ private Specification getTypeSpecification(Str } @Transactional(propagation = Propagation.SUPPORTS) - public CompletableFuture> findAll(Specification studentSpecs, final Integer pageNumber, final Integer pageSize, final List sorts) { + public CompletableFuture> findAll(Specification studentSpecs, final Integer pageNumber, final Integer pageSize, final List sorts) { log.trace("In find all query: {}", studentSpecs); return CompletableFuture.supplyAsync(() -> { Pageable paging = PageRequest.of(pageNumber, pageSize, Sort.by(sorts)); try { log.trace("Running paginated query: {}", studentSpecs); - var results = this.sdcSchoolCollectionStudentRepository.findAll(studentSpecs, paging); + var results = this.sdcSchoolCollectionStudentPaginationRepository.findAll(studentSpecs, paging); log.trace("Paginated query returned with results: {}", results); return results; } catch (final Throwable ex) { @@ -140,8 +144,8 @@ public CompletableFuture> findAll(Specifi } - public Specification setSpecificationAndSortCriteria(String sortCriteriaJson, String searchCriteriaListJson, ObjectMapper objectMapper, List sorts) { - Specification schoolSpecs = null; + public Specification setSpecificationAndSortCriteria(String sortCriteriaJson, String searchCriteriaListJson, ObjectMapper objectMapper, List sorts) { + Specification schoolSpecs = null; try { RequestUtil.getSortCriteria(sortCriteriaJson, objectMapper, sorts); if (StringUtils.isNotBlank(searchCriteriaListJson)) { From 5ab06e20748b1d7eddaf538b93b1004b77a50c7d Mon Sep 17 00:00:00 2001 From: SodhiA1 <38086281+SodhiA1@users.noreply.github.com> Date: Wed, 15 Nov 2023 16:13:32 -0800 Subject: [PATCH 2/2] code smell fix --- .../api/filter/SdcSchoolCollectionStudentFilterSpecs.java | 1 - 1 file changed, 1 deletion(-) diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/filter/SdcSchoolCollectionStudentFilterSpecs.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/filter/SdcSchoolCollectionStudentFilterSpecs.java index 805f25e34..5430b17cc 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/filter/SdcSchoolCollectionStudentFilterSpecs.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/filter/SdcSchoolCollectionStudentFilterSpecs.java @@ -1,6 +1,5 @@ package ca.bc.gov.educ.studentdatacollection.api.filter; -import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentEntity; import ca.bc.gov.educ.studentdatacollection.api.model.v1.SdcSchoolCollectionStudentPaginationEntity; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service;