Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
keeganbcgov committed Nov 16, 2023
2 parents 0ada944 + fcf43f0 commit 99e4f7c
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,7 +61,7 @@ public SdcSchoolCollectionStudentValidationIssueErrorWarningCount getErrorAndWar
@Override
public CompletableFuture<Page<SdcSchoolCollectionStudent>> findAll(Integer pageNumber, Integer pageSize, String sortCriteriaJson, String searchCriteriaListJson) {
final List<Sort.Order> sorts = new ArrayList<>();
Specification<SdcSchoolCollectionStudentEntity> studentSpecs = sdcSchoolCollectionStudentSearchService
Specification<SdcSchoolCollectionStudentPaginationEntity> studentSpecs = sdcSchoolCollectionStudentSearchService
.setSpecificationAndSortCriteria(
sortCriteriaJson,
searchCriteriaListJson,
Expand All @@ -69,7 +70,7 @@ public CompletableFuture<Page<SdcSchoolCollectionStudent>> findAll(Integer pageN
);
return this.sdcSchoolCollectionStudentSearchService
.findAll(studentSpecs, pageNumber, pageSize, sorts)
.thenApplyAsync(sdcSchoolStudentEntities -> sdcSchoolStudentEntities.map(mapper::toSdcSchoolStudent));
.thenApplyAsync(sdcSchoolStudentEntities -> sdcSchoolStudentEntities.map(mapper::toSdcSchoolCollectionStudentWithValidationIssues));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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;

Expand All @@ -10,9 +10,9 @@

@Service
@Slf4j
public class SdcSchoolCollectionStudentFilterSpecs extends BaseFilterSpecs<SdcSchoolCollectionStudentEntity> {
public class SdcSchoolCollectionStudentFilterSpecs extends BaseFilterSpecs<SdcSchoolCollectionStudentPaginationEntity> {

public SdcSchoolCollectionStudentFilterSpecs(FilterSpecifications<SdcSchoolCollectionStudentEntity, ChronoLocalDate> dateFilterSpecifications, FilterSpecifications<SdcSchoolCollectionStudentEntity, ChronoLocalDateTime<?>> dateTimeFilterSpecifications, FilterSpecifications<SdcSchoolCollectionStudentEntity, Integer> integerFilterSpecifications, FilterSpecifications<SdcSchoolCollectionStudentEntity, String> stringFilterSpecifications, FilterSpecifications<SdcSchoolCollectionStudentEntity, Long> longFilterSpecifications, FilterSpecifications<SdcSchoolCollectionStudentEntity, UUID> uuidFilterSpecifications,FilterSpecifications<SdcSchoolCollectionStudentEntity, Boolean> booleanFilterSpecifications, Converters converters) {
public SdcSchoolCollectionStudentFilterSpecs(FilterSpecifications<SdcSchoolCollectionStudentPaginationEntity, ChronoLocalDate> dateFilterSpecifications, FilterSpecifications<SdcSchoolCollectionStudentPaginationEntity, ChronoLocalDateTime<?>> dateTimeFilterSpecifications, FilterSpecifications<SdcSchoolCollectionStudentPaginationEntity, Integer> integerFilterSpecifications, FilterSpecifications<SdcSchoolCollectionStudentPaginationEntity, String> stringFilterSpecifications, FilterSpecifications<SdcSchoolCollectionStudentPaginationEntity, Long> longFilterSpecifications, FilterSpecifications<SdcSchoolCollectionStudentPaginationEntity, UUID> uuidFilterSpecifications,FilterSpecifications<SdcSchoolCollectionStudentPaginationEntity, Boolean> booleanFilterSpecifications, Converters converters) {
super(dateFilterSpecifications, dateTimeFilterSpecifications, integerFilterSpecifications, stringFilterSpecifications, longFilterSpecifications, uuidFilterSpecifications, booleanFilterSpecifications, converters);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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<SdcSchoolCollectionStudentValidationIssueEntity> sdcStudentValidationIssueEntities;

@EqualsAndHashCode.Exclude
@ToString.Exclude
@OneToMany(mappedBy = "sdcSchoolCollectionStudentEntity", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, targetEntity = SdcSchoolCollectionStudentEnrolledProgramEntity.class)
Set<SdcSchoolCollectionStudentEnrolledProgramEntity> sdcStudentEnrolledProgramEntities;

public Set<SdcSchoolCollectionStudentValidationIssueEntity> getSDCStudentValidationIssueEntities() {
if (this.sdcStudentValidationIssueEntities == null) {
this.sdcStudentValidationIssueEntities = new HashSet<>();
}
return this.sdcStudentValidationIssueEntities;
}

public Set<SdcSchoolCollectionStudentEnrolledProgramEntity> getSdcStudentEnrolledProgramEntities() {
if (this.sdcStudentEnrolledProgramEntities == null) {
this.sdcStudentEnrolledProgramEntities = new HashSet<>();
}
return this.sdcStudentEnrolledProgramEntities;
}

}
Original file line number Diff line number Diff line change
@@ -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<SdcSchoolCollectionStudentPaginationEntity, UUID>, JpaSpecificationExecutor<SdcSchoolCollectionStudentPaginationEntity> {

}
Loading

0 comments on commit 99e4f7c

Please sign in to comment.