diff --git a/.gitignore b/.gitignore
index 07c41426..1ca7b04e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,4 +52,7 @@ target/
build/
### VS Code ###
-.vscode/
\ No newline at end of file
+.vscode/
+
+### Local dev ###
+**/application-local.yaml
\ No newline at end of file
diff --git a/api/.gitignore b/api/.gitignore
deleted file mode 100644
index 07c41426..00000000
--- a/api/.gitignore
+++ /dev/null
@@ -1,55 +0,0 @@
-# Compiled class file
-*.class
-
-# Log file
-*.log
-
-# BlueJ files
-*.ctxt
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.jar
-*.war
-*.nar
-*.ear
-*.zip
-*.tar.gz
-*.rar
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-
-HELP.md
-target/
-!.mvn/wrapper/maven-wrapper.jar
-!**/src/main/**
-!**/src/test/**
-
-### STS ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-.sts4-cache
-
-### IntelliJ IDEA ###
-.idea
-*.iws
-*.iml
-*.ipr
-
-### NetBeans ###
-/nbproject/private/
-/nbbuild/
-/dist/
-/nbdist/
-/.nb-gradle/
-build/
-
-### VS Code ###
-.vscode/
\ No newline at end of file
diff --git a/api/pom.xml b/api/pom.xml
index a8c08838..8b32e1af 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -6,7 +6,7 @@
ca.bc.gov.educ
educ-grad-student-api
- 1.8.62
+ 1.8.63
educ-grad-student-api
Student Demographics API for GRAD team
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GradStudentController.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GradStudentController.java
index dfcebcbb..a241c1b4 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GradStudentController.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GradStudentController.java
@@ -1,22 +1,23 @@
package ca.bc.gov.educ.api.gradstudent.controller;
-import java.util.List;
-
import ca.bc.gov.educ.api.gradstudent.model.dto.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
import ca.bc.gov.educ.api.gradstudent.service.GradStudentService;
import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants;
+import ca.bc.gov.educ.api.gradstudent.util.PermissionsConstants;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.UUID;
@RestController
@CrossOrigin
@@ -116,4 +117,12 @@ public GraduationStudentRecordDistribution getGradStudentByStudentIDFromGRAD(@Pa
public Student addNewPenFromStudentAPI(@Validated @RequestBody StudentCreate student, @RequestHeader(name="Authorization") String accessToken) {
return gradStudentService.addNewPenFromStudentAPI(student, accessToken.replaceAll("Bearer ", ""));
}
+
+ @PostMapping (EducGradStudentApiConstants.GRAD_STUDENT_BY_SEARCH_CRITERIAS)
+ @PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT)
+ @Operation(summary = "Find Students by StudentSearchRequest criteria", description = "Find Students by StudentSearchRequest criteria", tags = { "Search Student Records" })
+ @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
+ public List searchGraduationStudentRecords(@RequestBody StudentSearchRequest searchRequest) {
+ return gradStudentService.getStudentIDsBySearchCriteriaOrAll(searchRequest);
+ }
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusController.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusController.java
index fdf11e18..ca0c016d 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusController.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusController.java
@@ -60,7 +60,7 @@ public ResponseEntity getStudentGradStatus(@PathVariabl
GraduationStudentRecord gradResponse = gradStatusService.getGraduationStatus(UUID.fromString(studentID),accessToken.replace(BEARER, ""));
if(gradResponse != null) {
return response.GET(gradResponse);
- }else {
+ } else {
return response.NO_CONTENT();
}
}
@@ -349,20 +349,19 @@ public ResponseEntity> getStudentsForYearlyRun() {
@PreAuthorize(PermissionsConstants.UPDATE_GRADUATION_STUDENT)
@Operation(summary = "Save Student Grad Status by Student ID for projected run", description = "Save Student Grad Status by Student ID for projected run", tags = { "Student Graduation Status" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
- public ResponseEntity saveStudentGradStatusDistributionRun(@PathVariable String studentID, @RequestParam(required = false) Long batchId,@RequestParam(required = false) String activityCode) {
+ public ResponseEntity saveStudentGradStatusDistributionRun(@PathVariable String studentID, @RequestParam(required = false) Long batchId, @RequestParam(required = false) String activityCode, @RequestParam(required = false) String username) {
logger.debug("Save Distribution student Grad Status for Student ID");
- GraduationStudentRecord gradRecord = gradStatusService.saveStudentRecordDistributionRun(UUID.fromString(studentID),batchId,activityCode);
+ GraduationStudentRecord gradRecord = gradStatusService.saveStudentRecordDistributionRun(UUID.fromString(studentID),batchId,activityCode,username);
return response.GET(gradRecord);
}
@PutMapping(EducGradStudentApiConstants.GRADUATION_RECORD_HISTORY_BY_BATCH_ID_DISTRIBUTION_RUN)
@PreAuthorize(PermissionsConstants.UPDATE_GRADUATION_STUDENT)
- @Operation(summary = "Save Student Grad Status by Student ID for projected run", description = "Save Student Grad Status by Student ID for projected run", tags = { "Student Graduation Status" })
+ @Operation(summary = "Save Student Grad Status History by List of Student IDs", description = "Save Student Grad Status History by List of Student IDs", tags = { "Student Graduation History" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
- public ResponseEntity> updateStudentGradHistoryStatusDistributionRun(@PathVariable Long batchID, @RequestParam(required = false) String userName) {
+ public ResponseEntity> updateStudentGradHistoryStatusDistributionRun(@PathVariable Long batchID, @RequestParam(required = false) String userName, @RequestParam(required = false) String activityCode, @RequestBody List studentGuids) {
logger.debug("Save Distribution student Grad history for Student ID");
- historyService.updateStudentRecordHistoryDistributionRun(batchID, userName);
- return response.UPDATED(null);
+ return response.UPDATED(historyService.updateStudentRecordHistoryDistributionRun(batchID, userName, activityCode, studentGuids));
}
@GetMapping (EducGradStudentApiConstants.STUDENT_LIST_FOR_SCHOOL_REPORT)
@@ -392,6 +391,22 @@ public ResponseEntity getStudentsCountForAmalgamatedSchoolReport(@PathV
return response.GET(gradStatusService.countStudentsForAmalgamatedSchoolReport(schoolOfRecord));
}
+ @PostMapping (EducGradStudentApiConstants.STUDENT_COUNT)
+ @PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT)
+ @Operation(summary = "Get Students Count by mincode and status", description = "Get Students Count by mincode and status", tags = { "Business" })
+ @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
+ public ResponseEntity getStudentsCount(@RequestParam(required = false) String studentStatus, @RequestBody List schoolOfRecords) {
+ return response.GET(gradStatusService.countBySchoolOfRecordsAndStudentStatus(schoolOfRecords, studentStatus));
+ }
+
+ @PostMapping (EducGradStudentApiConstants.STUDENT_ARCHIVE)
+ @PreAuthorize(PermissionsConstants.ARCHIVE_GRADUATION_STUDENT)
+ @Operation(summary = "Get Students Count by mincode and status", description = "Get Students Count by mincode and status", tags = { "Business" })
+ @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
+ public ResponseEntity archiveStudents(@RequestParam long batchId, @RequestParam(required = false) String studentStatus, @RequestParam(required = false) String userName, @RequestBody List schoolOfRecords) {
+ return response.GET(gradStatusService.archiveStudents(batchId, schoolOfRecords, studentStatus, userName));
+ }
+
@PostMapping (EducGradStudentApiConstants.UPDATE_GRAD_STUDENT_FLAG_BY_BATCH_JOB_TYPE_AND_MULTIPLE_STUDENTIDS)
@PreAuthorize(PermissionsConstants.UPDATE_GRADUATION_STUDENT)
@Operation(summary = "Update Student Flag ready for batch by Batch Job Type and Student IDs", description = "Update Student Flag ready for batch by Batch Job Type and Student IDs", tags = { "Batch Algorithm" })
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/StudentSearchRequest.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/StudentSearchRequest.java
index ebd70a8b..b983211b 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/StudentSearchRequest.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/StudentSearchRequest.java
@@ -29,12 +29,14 @@ public class StudentSearchRequest implements Serializable {
String schoolOfRecord;
String gradProgram;
- private List schoolOfRecords;
- private List districts;
- private List schoolCategoryCodes;
- private List pens;
- private List programs;
- private List studentIDs;
+ private List schoolOfRecords = new ArrayList<>();
+ private List districts = new ArrayList<>();
+ private List schoolCategoryCodes = new ArrayList<>();
+ private List pens = new ArrayList<>();
+ private List programs = new ArrayList<>();
+ private List studentIDs = new ArrayList<>();
+ private List statuses = new ArrayList<>();
+ private List reportTypes = new ArrayList();
@JsonFormat(pattern= EducGradStudentApiConstants.DEFAULT_DATE_FORMAT)
LocalDate gradDateFrom;
@@ -82,4 +84,13 @@ public List getPrograms() {
public String toJson() {
return new Gson().toJson(this);
}
+
+ public boolean isEmpty() {
+ return schoolOfRecords.isEmpty() &&
+ districts.isEmpty() &&
+ schoolCategoryCodes.isEmpty() &&
+ pens.isEmpty() &&
+ studentIDs.isEmpty() &&
+ programs.isEmpty();
+ }
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/BaseEntity.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/BaseEntity.java
index d3b957bd..ae1bfc7b 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/BaseEntity.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/BaseEntity.java
@@ -42,9 +42,13 @@ protected void onCreate() {
if (StringUtils.isBlank(updateUser)) {
this.updateUser = EducGradStudentApiConstants.DEFAULT_UPDATED_BY;
}
- }
- this.createDate = LocalDateTime.now();
- this.updateDate = LocalDateTime.now();
+ }
+ if(this.createDate == null) {
+ this.createDate = LocalDateTime.now();
+ }
+ if(this.updateDate == null) {
+ this.updateDate = LocalDateTime.now();
+ }
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordEntity.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordEntity.java
index 665bc4ac..c429104b 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordEntity.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordEntity.java
@@ -1,9 +1,9 @@
package ca.bc.gov.educ.api.gradstudent.model.entity;
+import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
-import jakarta.persistence.*;
import java.util.Date;
import java.util.UUID;
@@ -78,6 +78,12 @@ public GraduationStudentRecordEntity() {
@Column(name = "STUDENT_PROJECTED_GRAD_DATA", columnDefinition="CLOB")
private String studentProjectedGradData;
+ @Column(name = "SCHOOL_OF_RECORD_ID", nullable = true)
+ private UUID schoolOfRecordId;
+
+ @Column(name = "SCHOOL_AT_GRADUATION_ID", nullable = true)
+ private UUID schoolAtGraduationId;
+
@Transient
private String legalFirstName;
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordHistoryEntity.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordHistoryEntity.java
index 6556a4c3..a7b4c323 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordHistoryEntity.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordHistoryEntity.java
@@ -1,10 +1,10 @@
package ca.bc.gov.educ.api.gradstudent.model.entity;
+import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.GenericGenerator;
-import jakarta.persistence.*;
import java.util.Date;
import java.util.UUID;
@@ -75,6 +75,12 @@ public class GraduationStudentRecordHistoryEntity extends BaseEntity {
@Column(name = "ADULT_START_DATE", nullable = true)
private Date adultStartDate;
+ @Column(name = "SCHOOL_OF_RECORD_ID", nullable = true)
+ private UUID schoolOfRecordId;
+
+ @Column(name = "SCHOOL_AT_GRADUATION_ID", nullable = true)
+ private UUID schoolAtGraduationId;
+
//@Lob
//@Column(name = "STUDENT_PROJECTED_GRAD_DATA", columnDefinition="CLOB")
@Transient
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordView.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordView.java
index 8a7c834d..6e19ec77 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordView.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/GraduationStudentRecordView.java
@@ -22,6 +22,8 @@ public interface GraduationStudentRecordView {
public String getStudentCitizenship();
public Date getAdultStartDate();
public String getStudentProjectedGradData() ;
+ public UUID getSchoolOfRecordId();
+ public UUID getSchoolAtGraduationId();
public LocalDateTime getCreateDate();
public LocalDateTime getUpdateDate();
}
\ No newline at end of file
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/StudentGuidPenXrefEntity.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/StudentGuidPenXrefEntity.java
new file mode 100644
index 00000000..d3c31fd9
--- /dev/null
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/StudentGuidPenXrefEntity.java
@@ -0,0 +1,24 @@
+package ca.bc.gov.educ.api.gradstudent.model.entity;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.UUID;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Entity
+@Table(name = "STUDENT_GUID_PEN_XREF")
+public class StudentGuidPenXrefEntity extends BaseEntity {
+
+ @Id
+ @Column(name = "STUDENT_GUID", nullable = false)
+ private UUID studentID;
+
+ @Column(name = "STUDENT_PEN", nullable = false)
+ private String pen;
+}
\ No newline at end of file
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordHistoryRepository.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordHistoryRepository.java
index f2234732..90816cbf 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordHistoryRepository.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordHistoryRepository.java
@@ -1,10 +1,6 @@
package ca.bc.gov.educ.api.gradstudent.repository;
-import java.time.LocalDateTime;
-import java.util.List;
-import java.util.Optional;
-import java.util.UUID;
-
+import ca.bc.gov.educ.api.gradstudent.model.entity.GraduationStudentRecordHistoryEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
@@ -13,7 +9,8 @@
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
-import ca.bc.gov.educ.api.gradstudent.model.entity.GraduationStudentRecordHistoryEntity;
+import java.util.List;
+import java.util.UUID;
@Repository
public interface GraduationStudentRecordHistoryRepository extends JpaRepository {
@@ -24,7 +21,123 @@ public interface GraduationStudentRecordHistoryRepository extends JpaRepository<
void deleteByStudentID(UUID studentID);
@Modifying
- @Query(value="update GRADUATION_STUDENT_RECORD_HISTORY set UPDATE_USER = :updateUser, UPDATE_DATE = :updateDate where BATCH_ID = :batchId", nativeQuery=true)
- void updateGradStudentUpdateUser(@Param(value = "batchId") Long batchId, @Param(value = "updateUser") String updateUser, @Param(value = "updateDate") LocalDateTime updateDate);
+ @Query(value="update GRADUATION_STUDENT_RECORD_HISTORY set UPDATE_USER = :updateUser, UPDATE_DATE = SYSDATE where BATCH_ID = :batchId", nativeQuery=true)
+ Integer updateGradStudentUpdateUser(@Param(value = "batchId") Long batchId, @Param(value = "updateUser") String updateUser);
+
+ @Modifying
+ @Query(value="update GRADUATION_STUDENT_RECORD_HISTORY set HISTORY_ACTIVITY_CODE = :activityCode, UPDATE_USER = :updateUser, UPDATE_DATE = SYSDATE where BATCH_ID = :batchId", nativeQuery=true)
+ Integer updateGradStudentUpdateUser(@Param(value = "batchId") Long batchId, @Param(value = "activityCode") String activityCode, @Param(value = "updateUser") String updateUser);
+
+ String INSERT_INTO_GRADUATION_STUDENT_RECORD_HISTORY_BY_BATCH_ID_SQL = """
+ INSERT INTO GRADUATION_STUDENT_RECORD_HISTORY (
+ GRADUATION_STUDENT_RECORD_HISTORY_ID,
+ HISTORY_ACTIVITY_CODE,
+ GRADUATION_STUDENT_RECORD_ID,
+ GRADUATION_PROGRAM_CODE,
+ GPA,
+ STUDENT_STATUS_CODE,
+ HONOURS_STANDING,
+ PROGRAM_COMPLETION_DATE,
+ RECALCULATE_GRAD_STATUS,
+ SCHOOL_OF_RECORD,
+ STUDENT_GRADE,
+ SCHOOL_AT_GRADUATION,
+ CREATE_USER,
+ CREATE_DATE,
+ UPDATE_USER,
+ UPDATE_DATE,
+ RECALCULATE_PROJECTED_GRAD,
+ BATCH_ID,
+ CONSUMER_EDUC_REQT_MET,
+ STUDENT_CITIZENSHIP_CODE,
+ ADULT_START_DATE,
+ SCHOOL_OF_RECORD_ID,
+ SCHOOL_AT_GRADUATION_ID
+ ) SELECT
+ SYS_GUID(),
+ :activityCode,
+ GRADUATION_STUDENT_RECORD_ID,
+ GRADUATION_PROGRAM_CODE,
+ GPA,
+ STUDENT_STATUS_CODE,
+ HONOURS_STANDING,
+ PROGRAM_COMPLETION_DATE,
+ RECALCULATE_GRAD_STATUS,
+ SCHOOL_OF_RECORD,
+ STUDENT_GRADE,
+ SCHOOL_AT_GRADUATION,
+ CREATE_USER,
+ CREATE_DATE,
+ :updateUser,
+ SYSDATE,
+ RECALCULATE_PROJECTED_GRAD,
+ BATCH_ID,
+ CONSUMER_EDUC_REQT_MET,
+ STUDENT_CITIZENSHIP_CODE,
+ ADULT_START_DATE,
+ SCHOOL_OF_RECORD_ID,
+ SCHOOL_AT_GRADUATION_ID
+ FROM GRADUATION_STUDENT_RECORD
+ WHERE BATCH_ID = :batchId
+ """;
+ @Modifying
+ @Query(value= INSERT_INTO_GRADUATION_STUDENT_RECORD_HISTORY_BY_BATCH_ID_SQL, nativeQuery=true)
+ Integer insertGraduationStudentRecordHistoryByBatchId(@Param(value = "batchId") Long batchId, @Param(value = "activityCode") String activityCode, @Param(value = "updateUser") String updateUser);
+
+ String INSERT_INTO_GRADUATION_STUDENT_RECORD_HISTORY_BY_BATCH_ID_AND_STUDENT_ID_IN_SQL = """
+ INSERT INTO GRADUATION_STUDENT_RECORD_HISTORY (
+ GRADUATION_STUDENT_RECORD_HISTORY_ID,
+ HISTORY_ACTIVITY_CODE,
+ GRADUATION_STUDENT_RECORD_ID,
+ GRADUATION_PROGRAM_CODE,
+ GPA,
+ STUDENT_STATUS_CODE,
+ HONOURS_STANDING,
+ PROGRAM_COMPLETION_DATE,
+ RECALCULATE_GRAD_STATUS,
+ SCHOOL_OF_RECORD,
+ STUDENT_GRADE,
+ SCHOOL_AT_GRADUATION,
+ CREATE_USER,
+ CREATE_DATE,
+ UPDATE_USER,
+ UPDATE_DATE,
+ RECALCULATE_PROJECTED_GRAD,
+ BATCH_ID,
+ CONSUMER_EDUC_REQT_MET,
+ STUDENT_CITIZENSHIP_CODE,
+ ADULT_START_DATE,
+ SCHOOL_OF_RECORD_ID,
+ SCHOOL_AT_GRADUATION_ID
+ ) SELECT
+ SYS_GUID(),
+ :activityCode,
+ GRADUATION_STUDENT_RECORD_ID,
+ GRADUATION_PROGRAM_CODE,
+ GPA,
+ STUDENT_STATUS_CODE,
+ HONOURS_STANDING,
+ PROGRAM_COMPLETION_DATE,
+ RECALCULATE_GRAD_STATUS,
+ SCHOOL_OF_RECORD,
+ STUDENT_GRADE,
+ SCHOOL_AT_GRADUATION,
+ CREATE_USER,
+ CREATE_DATE,
+ :updateUser,
+ SYSDATE,
+ RECALCULATE_PROJECTED_GRAD,
+ BATCH_ID,
+ CONSUMER_EDUC_REQT_MET,
+ STUDENT_CITIZENSHIP_CODE,
+ ADULT_START_DATE,
+ SCHOOL_OF_RECORD_ID,
+ SCHOOL_AT_GRADUATION_ID
+ FROM GRADUATION_STUDENT_RECORD
+ WHERE BATCH_ID = :batchId and GRADUATION_STUDENT_RECORD_ID IN (:studentIDs)
+ """;
+ @Modifying
+ @Query(value= INSERT_INTO_GRADUATION_STUDENT_RECORD_HISTORY_BY_BATCH_ID_AND_STUDENT_ID_IN_SQL, nativeQuery=true)
+ Integer insertGraduationStudentRecordHistoryByBatchIdAndStudentIDs(@Param(value = "batchId") Long batchId, @Param(value = "studentIDs") List studentIDs, @Param(value = "activityCode") String activityCode, @Param(value = "updateUser") String updateUser);
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java
index 99d81b24..b175d344 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java
@@ -47,11 +47,43 @@ public interface GraduationStudentRecordRepository extends JpaRepository findBySchoolOfRecordAndStudentStatus(String schoolOfRecord, String studentStatus);
+ @Query("select c.studentID from GraduationStudentRecordEntity c where c.schoolOfRecord IN (:schoolOfRecords) and c.studentStatus=:studentStatus")
+ List findBySchoolOfRecordInAndStudentStatus(List schoolOfRecords, String studentStatus);
+
+ @Query("select c.studentID from GraduationStudentRecordEntity c where c.schoolOfRecord IN (:schoolOfRecords)")
+ List findBySchoolOfRecordIn(List schoolOfRecords);
+
+ @Query("select c.studentID from GraduationStudentRecordEntity c where c.studentStatus=:studentStatus")
+ List findByStudentStatus(String studentStatus);
+
+ @Query("select c.studentID from GraduationStudentRecordEntity c where c.studentStatus=:studentStatus")
+ Page findByStudentStatus(String studentStatus, Pageable paging);
+
+ @Query("select distinct c.studentID from GraduationStudentRecordEntity c")
+ List findAllStudentGuids();
+
List findBySchoolOfRecordAndStudentStatusAndStudentGradeIn(String schoolOfRecord, String studentStatus, List studentGrade);
@Query("select count(*) from GraduationStudentRecordEntity c where c.schoolOfRecord=:schoolOfRecord and c.studentStatus='CUR' and (c.studentGrade='AD' or c.studentGrade='12')")
Integer countBySchoolOfRecordAmalgamated(String schoolOfRecord);
+ @Query("select count(*) from GraduationStudentRecordEntity c where c.schoolOfRecord IN (:schoolOfRecords) and c.studentStatus=:studentStatus")
+ Long countBySchoolOfRecordsAndStudentStatus(List schoolOfRecords, String studentStatus);
+
+ @Query("select count(*) from GraduationStudentRecordEntity c where c.schoolOfRecord IN (:schoolOfRecords)")
+ Long countBySchoolOfRecords(List schoolOfRecords);
+
+ @Query("select count(*) from GraduationStudentRecordEntity c where c.studentStatus=:studentStatus")
+ Long countByStudentStatus(String studentStatus);
+
+ @Modifying
+ @Query(value="update graduation_student_record set student_status_code = :inStudStatTo, batch_id = :batchId, student_grad_data = json_transform(student_grad_data, SET '$.gradStatus.studentStatus' = :inStudStatTo IGNORE ON MISSING), update_date = SYSDATE, update_user = :userName where school_of_record in (:inSor) and student_status_code = :inStudStatFrom", nativeQuery=true)
+ Integer archiveStudents(List inSor, String inStudStatFrom, String inStudStatTo, long batchId, String userName);
+
+ @Modifying
+ @Query(value="update graduation_student_record set student_status_code = :inStudStatTo, batch_id = :batchId, student_grad_data = json_transform(student_grad_data, SET '$.gradStatus.studentStatus' = :inStudStatTo IGNORE ON MISSING), update_date = SYSDATE, update_user = :userName where student_status_code = :inStudStatFrom", nativeQuery=true)
+ Integer archiveStudents(String inStudStatFrom, String inStudStatTo, long batchId, String userName);
+
// Data Conversion
@Modifying
@Query(value="insert into STUDENT_GUID_PEN_XREF(STUDENT_GUID, STUDENT_PEN, CREATE_USER, CREATE_DATE, UPDATE_USER, UPDATE_DATE)\n"
@@ -75,9 +107,8 @@ void updateStudentGuidPenXrefRecord(
"where gpx.STUDENT_GUID = :studentGuid", nativeQuery=true)
long countStudentGuidPenXrefRecord(@Param("studentGuid") UUID studentGuid);
- @Query(value="select STUDENT_GUID from STUDENT_GUID_PEN_XREF \n"
- + "where STUDENT_PEN = :pen", nativeQuery = true)
- byte[] findStudentID(@Param("pen") String pen);
+ @Query(value="select e.studentID from StudentGuidPenXrefEntity e where e.pen in (:pens)")
+ List findStudentIDsByPenIn(@Param("pens") List pens);
@Query("select c.studentID from GraduationStudentRecordEntity c where c.studentStatus = :statusCode and c.studentID in :studentIDList")
List filterGivenStudentsByStatusCode(@Param("studentIDList") List studentIDs, @Param("statusCode") String statusCode);
@@ -94,6 +125,14 @@ void updateStudentGuidPenXrefRecord(
@Query( "update GraduationStudentRecordEntity e set e.recalculateProjectedGrad = 'Y' where e.studentStatus = 'CUR' and e.programCompletionDate is null and (e.studentGrade = '12' or e.studentGrade = 'AD')")
void updateGradStudentRecalcFlagsForCurrentStudentsWithNullCompletion();
+ @Modifying
+ @Query( "update GraduationStudentRecordEntity e set e.batchId = :batchId where e.studentID in :studentIDs")
+ Integer updateGraduationStudentRecordEntitiesBatchIdWhereStudentIDsIn(Long batchId, List studentIDs);
+
+ @Modifying
+ @Query( "update GraduationStudentRecordEntity e set e.batchId = :batchId where e.studentStatus = :studentStatus")
+ Integer updateGraduationStudentRecordEntitiesBatchIdWhereStudentStatus(Long batchId, String studentStatus);
+
/**
* Find a GraduationStudentRecord By Student ID using generics. Pass an object with the
* same subset of field names, getters/setters of GraduationStudentRecordEntity to return
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java
index ca504475..4ed1793a 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java
@@ -3,7 +3,9 @@
import ca.bc.gov.educ.api.gradstudent.constant.FieldName;
import ca.bc.gov.educ.api.gradstudent.constant.TraxEventType;
import ca.bc.gov.educ.api.gradstudent.model.dto.*;
-import ca.bc.gov.educ.api.gradstudent.model.entity.*;
+import ca.bc.gov.educ.api.gradstudent.model.entity.GraduationStudentRecordEntity;
+import ca.bc.gov.educ.api.gradstudent.model.entity.StudentCareerProgramEntity;
+import ca.bc.gov.educ.api.gradstudent.model.entity.StudentOptionalProgramEntity;
import ca.bc.gov.educ.api.gradstudent.model.transformer.GradStudentCareerProgramTransformer;
import ca.bc.gov.educ.api.gradstudent.model.transformer.GradStudentOptionalProgramTransformer;
import ca.bc.gov.educ.api.gradstudent.model.transformer.GraduationStatusTransformer;
@@ -21,7 +23,10 @@
import org.springframework.web.reactive.function.client.WebClient;
import java.time.LocalDateTime;
-import java.util.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
/**
* Initial Student Loads
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentService.java
index 9472a754..c7c15d17 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentService.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentService.java
@@ -143,7 +143,7 @@ public GradOnlyStudentSearch getGRADStudents(StudentSearchRequest studentSearchR
h.set(EducGradStudentApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID());
})
.retrieve().bodyToMono(new ParameterizedTypeReference>() {}).block();
- List studentList = response != null ?response.getContent():new ArrayList<>();
+ List studentList = response != null ? response.getContent() : new ArrayList<>();
if (!studentList.isEmpty()) {
studentList.forEach(st -> {
GradSearchStudent gradStu = populateGradSearchStudent(st, accessToken);
@@ -405,4 +405,18 @@ public List getStudentIDsByStatusCode(List studentIDs, String status
}
return results;
}
+
+ public List getStudentIDsBySearchCriteriaOrAll(StudentSearchRequest searchRequest) {
+ ArrayList result = new ArrayList<>();
+ if(searchRequest.getStudentIDs() != null && !searchRequest.getStudentIDs().isEmpty()) {
+ result.addAll(searchRequest.getStudentIDs());
+ }
+ if(searchRequest.getPens() != null && !searchRequest.getPens().isEmpty()) {
+ result.addAll(graduationStatusRepository.findStudentIDsByPenIn(searchRequest.getPens()));
+ }
+ if(searchRequest.getSchoolOfRecords() != null && !searchRequest.getSchoolOfRecords().isEmpty()) {
+ result.addAll(graduationStatusRepository.findBySchoolOfRecordIn(searchRequest.getSchoolOfRecords()));
+ }
+ return result;
+ }
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java
index 1541df34..46045085 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java
@@ -50,6 +50,8 @@ public class GraduationStatusService {
public static final int PAGE_SIZE = 500;
+ public static final long MAX_ROWS_COUNT = 50000;
+
private static final Logger logger = LoggerFactory.getLogger(GraduationStatusService.class);
private static final String CREATE_USER = "createUser";
@@ -1219,12 +1221,12 @@ public boolean restoreGradStudentRecord(UUID studentID,boolean isGraduated) {
}
@Retry(name = "generalpostcall")
- public GraduationStudentRecord saveStudentRecordDistributionRun(UUID studentID, Long batchId,String activityCode) {
+ public GraduationStudentRecord saveStudentRecordDistributionRun(UUID studentID, Long batchId, String activityCode, String username) {
Optional gradStatusOptional = graduationStatusRepository.findById(studentID);
if (gradStatusOptional.isPresent()) {
GraduationStudentRecordEntity gradEntity = gradStatusOptional.get();
- gradEntity.setUpdateUser(null);
- gradEntity.setUpdateDate(null);
+ gradEntity.setUpdateUser(StringUtils.isNotBlank(username) && !StringUtils.equalsIgnoreCase(username, "null") ? username : null);
+ gradEntity.setUpdateDate(LocalDateTime.now());
gradEntity.setBatchId(batchId);
gradEntity = graduationStatusRepository.saveAndFlush(gradEntity);
historyService.createStudentHistory(gradEntity, activityCode);
@@ -1233,6 +1235,20 @@ public GraduationStudentRecord saveStudentRecordDistributionRun(UUID studentID,
return null;
}
+ @Retry(name = "generalpostcall")
+ public void saveStudentHistoryRecordArchiveStudentsRun(UUID studentID, Long batchId, String activityCode) {
+ List graduationStudentRecordViews = graduationStatusRepository.findByStudentIDIn(List.of(studentID));
+ for(GraduationStudentRecordView st: graduationStudentRecordViews) {
+ GraduationStudentRecordEntity toBeSaved = new GraduationStudentRecordEntity();
+ BeanUtils.copyProperties(st, toBeSaved);
+ toBeSaved.setStudentStatus("ARC");
+ toBeSaved.setUpdateUser(null);
+ toBeSaved.setUpdateDate(null);
+ toBeSaved.setBatchId(batchId);
+ historyService.createStudentHistory(toBeSaved, activityCode);
+ }
+ }
+
@Retry(name = "generalpostcall")
public GraduationStudentRecord saveStudentRecordProjectedTVRRun(UUID studentID, Long batchId, ProjectedRunClob projectedRunClob) {
Optional gradStatusOptional = graduationStatusRepository.findById(studentID);
@@ -1305,6 +1321,7 @@ private List processStudentDataList(Page studentGuids) {
return result;
}
+ @Generated
private void processUUIDDataTasksAsync(List> tasks, List result) {
if(tasks.isEmpty()) return;
List> executionResult;
@@ -1338,7 +1355,7 @@ private GraduationStudentRecord processReceivedStudent(GraduationStudentRecord e
ent.setLegalFirstName(existingData.getGradStudent().getLegalFirstName());
ent.setLegalMiddleNames(existingData.getGradStudent().getLegalMiddleNames());
ent.setLegalLastName(existingData.getGradStudent().getLegalLastName());
- }else {
+ } else {
Student stuData = webClient.get().uri(String.format(constants.getPenStudentApiByStudentIdUrl(), ent.getStudentID()))
.headers(h -> {
h.setBearerAuth(accessToken);
@@ -1369,6 +1386,38 @@ public Integer countStudentsForAmalgamatedSchoolReport(String schoolOfRecord) {
return graduationStatusRepository.countBySchoolOfRecordAmalgamated(schoolOfRecord);
}
+ public Long countBySchoolOfRecordsAndStudentStatus(List schoolOfRecords, String studentStatus) {
+ if(schoolOfRecords != null && !schoolOfRecords.isEmpty() && StringUtils.isNotBlank(studentStatus) && !StringUtils.equalsAnyIgnoreCase(studentStatus, "null")) {
+ return graduationStatusRepository.countBySchoolOfRecordsAndStudentStatus(schoolOfRecords, StringUtils.upperCase(studentStatus));
+ } else if(StringUtils.isNotBlank(studentStatus) && !StringUtils.equalsAnyIgnoreCase(studentStatus, "null")) {
+ return graduationStatusRepository.countByStudentStatus(StringUtils.upperCase(studentStatus));
+ } else {
+ return countBySchoolOfRecords(schoolOfRecords);
+ }
+ }
+
+ @Transactional
+ public Integer archiveStudents(long batchId, List schoolOfRecords, String studentStatus, String user) {
+ String recordStudentStatus = StringUtils.defaultString(studentStatus, "CUR");
+ Integer archivedStudentsCount = 0;
+ Integer auditHistoryStudentsCount = 0;
+ List graduationStudentRecordGuids = new ArrayList<>();
+ if(schoolOfRecords != null && !schoolOfRecords.isEmpty()) {
+ graduationStudentRecordGuids.addAll(graduationStatusRepository.findBySchoolOfRecordInAndStudentStatus(schoolOfRecords, recordStudentStatus));
+ archivedStudentsCount = graduationStatusRepository.archiveStudents(schoolOfRecords, recordStudentStatus, "ARC", batchId, user);
+ } else {
+ Integer numberOfUpdated = graduationStatusRepository.updateGraduationStudentRecordEntitiesBatchIdWhereStudentStatus(batchId, recordStudentStatus);
+ if(numberOfUpdated > 0) {
+ archivedStudentsCount = graduationStatusRepository.archiveStudents(recordStudentStatus, "ARC", batchId, user);
+ }
+ }
+ if(archivedStudentsCount > 0) {
+ auditHistoryStudentsCount = historyService.updateStudentRecordHistoryDistributionRun(batchId, user, "USERSTUDARC", graduationStudentRecordGuids);
+ }
+ logger.debug("Archived {} students and {} student audit records created", archivedStudentsCount, auditHistoryStudentsCount);
+ return archivedStudentsCount;
+ }
+
public void updateStudentFlagReadyForBatchJobByStudentIDs(String batchJobType, List studentIDs) {
logger.debug("updateStudentFlagReadyForBatchJobByStudentIDs");
for(UUID uuid: studentIDs) {
@@ -1405,6 +1454,14 @@ private void saveBatchFlagsOfGraduationStudentRecord(GraduationStudentRecordEnti
}
}
+ private Long countBySchoolOfRecords(List schoolOfRecords) {
+ if(schoolOfRecords != null && !schoolOfRecords.isEmpty()) {
+ return graduationStatusRepository.countBySchoolOfRecords(schoolOfRecords);
+ } else {
+ return graduationStatusRepository.count();
+ }
+ }
+
private void resetBatchFlags(GraduationStudentRecordEntity gradEntity, boolean projectedRun) {
String flag = null;
if (gradEntity.getProgram().equalsIgnoreCase("SCCP") && EducGradStudentApiUtils.isDateInFuture(gradEntity.getProgramCompletionDate())) {
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/HistoryService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/HistoryService.java
index ce4d2022..251fc456 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/HistoryService.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/HistoryService.java
@@ -9,10 +9,12 @@
import ca.bc.gov.educ.api.gradstudent.model.transformer.GraduationStudentRecordHistoryTransformer;
import ca.bc.gov.educ.api.gradstudent.model.transformer.StudentOptionalProgramHistoryTransformer;
import ca.bc.gov.educ.api.gradstudent.repository.GraduationStudentRecordHistoryRepository;
+import ca.bc.gov.educ.api.gradstudent.repository.GraduationStudentRecordRepository;
import ca.bc.gov.educ.api.gradstudent.repository.HistoryActivityRepository;
import ca.bc.gov.educ.api.gradstudent.repository.StudentOptionalProgramHistoryRepository;
import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants;
import ca.bc.gov.educ.api.gradstudent.util.ThreadLocalStateUtil;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
@@ -24,8 +26,8 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.reactive.function.client.WebClient;
-import java.time.LocalDateTime;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
@@ -37,6 +39,7 @@ public class HistoryService {
final
WebClient webClient;
+ final GraduationStudentRecordRepository graduationStatusRepository;
final GraduationStudentRecordHistoryRepository graduationStudentRecordHistoryRepository;
final GraduationStudentRecordHistoryTransformer graduationStudentRecordHistoryTransformer;
final StudentOptionalProgramHistoryRepository studentOptionalProgramHistoryRepository;
@@ -45,24 +48,27 @@ public class HistoryService {
final EducGradStudentApiConstants constants;
@Autowired
- public HistoryService(WebClient webClient, GraduationStudentRecordHistoryRepository graduationStudentRecordHistoryRepository, GraduationStudentRecordHistoryTransformer graduationStudentRecordHistoryTransformer, StudentOptionalProgramHistoryRepository studentOptionalProgramHistoryRepository, StudentOptionalProgramHistoryTransformer studentOptionalProgramHistoryTransformer, EducGradStudentApiConstants constants, HistoryActivityRepository historyActivityRepository) {
+ public HistoryService(WebClient webClient, GraduationStudentRecordHistoryRepository graduationStudentRecordHistoryRepository, GraduationStudentRecordHistoryTransformer graduationStudentRecordHistoryTransformer, StudentOptionalProgramHistoryRepository studentOptionalProgramHistoryRepository, StudentOptionalProgramHistoryTransformer studentOptionalProgramHistoryTransformer, EducGradStudentApiConstants constants, HistoryActivityRepository historyActivityRepository, GraduationStudentRecordRepository graduationStatusRepository) {
this.webClient = webClient;
this.graduationStudentRecordHistoryRepository = graduationStudentRecordHistoryRepository;
this.graduationStudentRecordHistoryTransformer = graduationStudentRecordHistoryTransformer;
this.studentOptionalProgramHistoryRepository = studentOptionalProgramHistoryRepository;
this.studentOptionalProgramHistoryTransformer = studentOptionalProgramHistoryTransformer;
this.historyActivityRepository = historyActivityRepository;
+ this.graduationStatusRepository = graduationStatusRepository;
this.constants = constants;
}
public void createStudentHistory(GraduationStudentRecordEntity curStudentEntity, String historyActivityCode) {
- if(curStudentEntity != null) {
+ if (curStudentEntity != null) {
logger.debug("Create Student History");
final GraduationStudentRecordHistoryEntity graduationStudentRecordHistoryEntity = new GraduationStudentRecordHistoryEntity();
BeanUtils.copyProperties(curStudentEntity, graduationStudentRecordHistoryEntity);
+ graduationStudentRecordHistoryEntity.setCreateUser(curStudentEntity.getCreateUser());
+ graduationStudentRecordHistoryEntity.setCreateDate(curStudentEntity.getCreateDate());
graduationStudentRecordHistoryEntity.setActivityCode(historyActivityCode);
graduationStudentRecordHistoryEntity.setStudentGradData("{ EMPTY CLOB }");
- graduationStudentRecordHistoryRepository.save(graduationStudentRecordHistoryEntity);
+ graduationStudentRecordHistoryRepository.saveAndFlush(graduationStudentRecordHistoryEntity);
}
}
@@ -75,18 +81,18 @@ public void createStudentOptionalProgramHistory(StudentOptionalProgramEntity cur
studentOptionalProgramHistoryEntity.setStudentOptionalProgramData("{ EMPTY CLOB }");
studentOptionalProgramHistoryRepository.save(studentOptionalProgramHistoryEntity);
}
-
+
public List getStudentEditHistory(UUID studentID) {
List histList = graduationStudentRecordHistoryTransformer.transformToDTO(graduationStudentRecordHistoryRepository.findByStudentID(studentID));
- histList.forEach(gS->{
+ histList.forEach(gS -> {
Optional entOpt = historyActivityRepository.findById(gS.getActivityCode());
entOpt.ifPresent(historyActivityCodeEntity -> gS.setActivityCodeDescription(historyActivityCodeEntity.getDescription()));
});
return histList;
}
- public List getStudentOptionalProgramEditHistory(UUID studentID,String accessToken) {
- List histList = studentOptionalProgramHistoryTransformer.transformToDTO(studentOptionalProgramHistoryRepository.findByStudentID(studentID));
+ public List getStudentOptionalProgramEditHistory(UUID studentID, String accessToken) {
+ List histList = studentOptionalProgramHistoryTransformer.transformToDTO(studentOptionalProgramHistoryRepository.findByStudentID(studentID));
histList.forEach(sP -> {
OptionalProgram gradOptionalProgram = webClient.get()
.uri(String.format(constants.getGradOptionalProgramNameUrl(), sP.getOptionalProgramID()))
@@ -97,7 +103,7 @@ public List getStudentOptionalProgramEditHistory(
.retrieve()
.bodyToMono(OptionalProgram.class)
.block();
- if(gradOptionalProgram != null) {
+ if (gradOptionalProgram != null) {
sP.setOptionalProgramName(gradOptionalProgram.getOptionalProgramName());
sP.setOptionalProgramCode(gradOptionalProgram.getOptProgramCode());
sP.setProgramCode(gradOptionalProgram.getGraduationProgramCode());
@@ -113,9 +119,9 @@ public GraduationStudentRecordHistory getStudentHistoryByID(UUID historyID) {
return graduationStudentRecordHistoryTransformer.transformToDTO(graduationStudentRecordHistoryRepository.findById(historyID));
}
- public StudentOptionalProgramHistory getStudentOptionalProgramHistoryByID(UUID historyID,String accessToken) {
+ public StudentOptionalProgramHistory getStudentOptionalProgramHistoryByID(UUID historyID, String accessToken) {
StudentOptionalProgramHistory obj = studentOptionalProgramHistoryTransformer.transformToDTO(studentOptionalProgramHistoryRepository.findById(historyID));
- if(obj.getOptionalProgramID() != null) {
+ if (obj.getOptionalProgramID() != null) {
OptionalProgram gradOptionalProgram = webClient.get()
.uri(String.format(constants.getGradOptionalProgramNameUrl(), obj.getOptionalProgramID()))
.headers(h -> {
@@ -125,7 +131,7 @@ public StudentOptionalProgramHistory getStudentOptionalProgramHistoryByID(UUID h
.retrieve()
.bodyToMono(OptionalProgram.class)
.block();
- if(gradOptionalProgram != null) {
+ if (gradOptionalProgram != null) {
obj.setOptionalProgramName(gradOptionalProgram.getOptionalProgramName());
obj.setOptionalProgramCode(gradOptionalProgram.getOptProgramCode());
obj.setProgramCode(gradOptionalProgram.getGraduationProgramCode());
@@ -134,18 +140,18 @@ public StudentOptionalProgramHistory getStudentOptionalProgramHistoryByID(UUID h
return obj;
}
- public Page getStudentHistoryByBatchID(Long batchId, Integer pageNumber, Integer pageSize,String accessToken) {
+ public Page getStudentHistoryByBatchID(Long batchId, Integer pageNumber, Integer pageSize, String accessToken) {
Pageable paging = PageRequest.of(pageNumber, pageSize);
- Page pagedDate = graduationStudentRecordHistoryRepository.findByBatchId(batchId,paging);
+ Page pagedDate = graduationStudentRecordHistoryRepository.findByBatchId(batchId, paging);
List list = pagedDate.getContent();
- list.forEach(ent->{
+ list.forEach(ent -> {
Student stuData = webClient.get().uri(String.format(constants.getPenStudentApiByStudentIdUrl(), ent.getStudentID()))
- .headers(h -> {
- h.setBearerAuth(accessToken);
- h.set(EducGradStudentApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID());
- })
- .retrieve().bodyToMono(Student.class).block();
- if(stuData != null) {
+ .headers(h -> {
+ h.setBearerAuth(accessToken);
+ h.set(EducGradStudentApiConstants.CORRELATION_ID, ThreadLocalStateUtil.getCorrelationID());
+ })
+ .retrieve().bodyToMono(Student.class).block();
+ if (stuData != null) {
ent.setPen(stuData.getPen());
ent.setLegalFirstName(stuData.getLegalFirstName());
ent.setLegalMiddleNames(stuData.getLegalMiddleNames());
@@ -157,11 +163,20 @@ public Page getStudentHistoryByBatchID(Lon
}
@Transactional
- public void updateStudentRecordHistoryDistributionRun(Long batchId, String updateUser) {
-
- LocalDateTime updateDate = LocalDateTime.now();
- graduationStudentRecordHistoryRepository.updateGradStudentUpdateUser(batchId, updateUser, updateDate);
-
+ public Integer updateStudentRecordHistoryDistributionRun(Long batchId, String updateUser, String activityCode, List studentGuids) {
+ Integer historyRecordsCreated;
+ if(studentGuids != null && !studentGuids.isEmpty()) {
+ Integer studentRecordsCreated = graduationStatusRepository.updateGraduationStudentRecordEntitiesBatchIdWhereStudentIDsIn(batchId, studentGuids);
+ historyRecordsCreated = graduationStudentRecordHistoryRepository.insertGraduationStudentRecordHistoryByBatchIdAndStudentIDs(batchId, studentGuids, activityCode, updateUser);
+ assert Objects.equals(studentRecordsCreated, historyRecordsCreated);
+ } else if(StringUtils.equalsIgnoreCase(activityCode, "USERSTUDARC")) {
+ historyRecordsCreated = graduationStudentRecordHistoryRepository.insertGraduationStudentRecordHistoryByBatchId(batchId, activityCode, updateUser);
+ } else if(StringUtils.isBlank(activityCode) || StringUtils.equalsIgnoreCase(activityCode, "null")) {
+ historyRecordsCreated = graduationStudentRecordHistoryRepository.updateGradStudentUpdateUser(batchId, updateUser);
+ } else {
+ historyRecordsCreated = graduationStudentRecordHistoryRepository.updateGradStudentUpdateUser(batchId, activityCode, updateUser);
}
+ return historyRecordsCreated;
+ }
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java
index 89bbc849..dad2e2f3 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java
@@ -20,11 +20,14 @@ public class EducGradStudentApiConstants {
public static final String API_ROOT_MAPPING = "";
public static final String API_VERSION = "v1";
public static final String GRAD_STUDENT_API_ROOT_MAPPING = "/api/" + API_VERSION + "/student" ;
+ public static final String STUDENT_COUNT = "/count";
+ public static final String STUDENT_ARCHIVE = "/archive";
public static final String GRAD_STUDENT_BY_PEN = "/{pen}";
public static final String GRAD_STUDENT_BY_PEN_STUDENT_API = "/pen/{pen}";
public static final String GRAD_STUDENT_DEMOG_BY_PEN = "/demog/pen/{pen}";
public static final String GRAD_STUDENT_BY_STUDENT_ID_STUDENT_API = "/stdid/{studentID}";
public static final String GRAD_STUDENT_BY_STUDENT_ID_GRAD="/grad/{studentID}";
+ public static final String GRAD_STUDENT_BY_SEARCH_CRITERIAS = "/gradstudentbysearchcriteria";
public static final String GRAD_STUDENT_BY_LAST_NAME = "/gradstudent";
public static final String GRAD_STUDENT_BY_FIRST_NAME = "/studentsearchfirstname";
public static final String GRAD_STUDENT_BY_MULTIPLE_STUDENTIDS = "/multistudentids";
@@ -54,7 +57,7 @@ public class EducGradStudentApiConstants {
public static final String GRAD_STUDENT_BY_STUDENT_ID_FOR_BATCH_RUN = "/batch/gradstudent/studentid/{studentID}";
public static final String STUDENT_LIST_FOR_SCHOOL_REPORT = "/batch/schoolreport/{schoolOfRecord}";
public static final String STUDENT_LIST_FOR_AMALGAMATED_SCHOOL_REPORT = "/amalgamated/schoolreport/{schoolOfRecord}/type/{type}";
- public static final String STUDENT_COUNT_FOR_AMALGAMATED_SCHOOL_REPORT = "/amalgamated/schoolreport/{schoolOfRecord}/count";
+ public static final String STUDENT_COUNT_FOR_AMALGAMATED_SCHOOL_REPORT = "/amalgamated/schoolreport/{schoolOfRecord}" + STUDENT_COUNT;
public static final String STUDENT_RECORD_STUDENT_ID_BATCH_RUN = "/batch/{studentID}";
public static final String GET_STUDENT_STATUS_BY_STATUS_CODE_MAPPING = "/checkstudentstatus/{statusCode}";
public static final String UNGRAD_STUDENT = "/undocompletionstudent/studentid/{studentID}";
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/PermissionsConstants.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/PermissionsConstants.java
index a3d06c3e..1a7a70c9 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/PermissionsConstants.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/PermissionsConstants.java
@@ -8,6 +8,7 @@ private PermissionsConstants() {}
public static final String UPDATE_GRADUATION_STUDENT = PREFIX + "SCOPE_UPDATE_GRAD_GRADUATION_STATUS" + SUFFIX;
public static final String READ_GRADUATION_STUDENT = PREFIX + "SCOPE_READ_GRAD_GRADUATION_STATUS" + SUFFIX;
+ public static final String ARCHIVE_GRADUATION_STUDENT = PREFIX + "SCOPE_ARCHIVE_GRADUATION_STUDENT_RECORD" + SUFFIX;
public static final String UPDATE_GRADUATION_STUDENT_OPTIONAL_PROGRAM = PREFIX + "SCOPE_UPDATE_GRAD_STUDENT_SPECIAL_DATA" + SUFFIX;
public static final String READ_GRADUATION_STUDENT_OPTIONAL_PROGRAM = PREFIX + "SCOPE_READ_GRAD_STUDENT_SPECIAL_DATA" + SUFFIX;
diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml
index 28ba64e9..43748528 100644
--- a/api/src/main/resources/application.yaml
+++ b/api/src/main/resources/application.yaml
@@ -78,6 +78,7 @@ server:
threads:
worker: 128
io: 16
+ max-http-request-header-size: 20000
#port: ${HTTP_PORT}
#tomcat:
#connection-timeout: 200s
diff --git a/api/src/main/resources/db/migration/1.0/V1.0.68__DML-INSERT_DATA-ADD_HISTORY_ACTIVITY_CODE.sql b/api/src/main/resources/db/migration/1.0/V1.0.68__DML-INSERT_DATA-ADD_HISTORY_ACTIVITY_CODE.sql
new file mode 100644
index 00000000..562dcaca
--- /dev/null
+++ b/api/src/main/resources/db/migration/1.0/V1.0.68__DML-INSERT_DATA-ADD_HISTORY_ACTIVITY_CODE.sql
@@ -0,0 +1,2 @@
+INSERT INTO HISTORY_ACTIVITY_CODE (HISTORY_ACTIVITY_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE)
+VALUES ('TVRDELETED','Delete Student TVR','TVR deleted by User Request (Delete Student Reports)',270,TIMESTAMP'2024-06-24 00:00:00.0',NULL);
diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GradStudentControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GradStudentControllerTest.java
index 9c18bea9..48c82f6d 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GradStudentControllerTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GradStudentControllerTest.java
@@ -1,6 +1,9 @@
package ca.bc.gov.educ.api.gradstudent.controller;
-import ca.bc.gov.educ.api.gradstudent.model.dto.*;
+import ca.bc.gov.educ.api.gradstudent.model.dto.GradSearchStudent;
+import ca.bc.gov.educ.api.gradstudent.model.dto.StudentCreate;
+import ca.bc.gov.educ.api.gradstudent.model.dto.StudentSearch;
+import ca.bc.gov.educ.api.gradstudent.model.dto.StudentSearchRequest;
import ca.bc.gov.educ.api.gradstudent.service.GradStudentService;
import org.junit.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -12,6 +15,7 @@
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Arrays;
+import java.util.List;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -134,4 +138,12 @@ public void testAddNewPenFromStudentAPI() {
Mockito.verify(gradStudentService).addNewPenFromStudentAPI(student, "accessToken");
}
+ @Test
+ public void testSearchGraduationStudentRecords() {
+ StudentSearchRequest searchRequest = StudentSearchRequest.builder().schoolOfRecords(List.of("12345678")).build();
+ Mockito.when(gradStudentService.getStudentIDsBySearchCriteriaOrAll(searchRequest)).thenReturn(List.of(UUID.randomUUID()));
+ gradStudentController.searchGraduationStudentRecords(searchRequest);
+ Mockito.verify(gradStudentService).getStudentIDsBySearchCriteriaOrAll(searchRequest);
+ }
+
}
diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusControllerTest.java
index e8905fe6..27c6710e 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusControllerTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/GraduationStatusControllerTest.java
@@ -438,9 +438,9 @@ public void testSaveStudentRecord_DsitributionRun() {
graduationStatus.setSchoolOfRecord("12345678");
graduationStatus.setRecalculateGradStatus("Y");
- Mockito.when(graduationStatusService.saveStudentRecordDistributionRun(studentID,null,"ACTIVITYCODE")).thenReturn(graduationStatus);
- graduationStatusController.saveStudentGradStatusDistributionRun(studentID.toString(),null,"ACTIVITYCODE");
- Mockito.verify(graduationStatusService).saveStudentRecordDistributionRun(studentID,null,"ACTIVITYCODE");
+ Mockito.when(graduationStatusService.saveStudentRecordDistributionRun(studentID,null,"ACTIVITYCODE", "USER")).thenReturn(graduationStatus);
+ graduationStatusController.saveStudentGradStatusDistributionRun(studentID.toString(),null,"ACTIVITYCODE", "USER");
+ Mockito.verify(graduationStatusService).saveStudentRecordDistributionRun(studentID,null,"ACTIVITYCODE", "USER");
}
@Test
@@ -558,6 +558,13 @@ public void testGetStudentsForYearlyRun() {
Mockito.verify(graduationStatusService).getStudentsForYearlyDistribution();
}
+ @Test
+ public void testUpdateStudentGradHistoryStatusDistributionRun() {
+ Mockito.when(historyService.updateStudentRecordHistoryDistributionRun(1L, "Batch Archive Process", "activityCode", List.of())).thenReturn(1);
+ graduationStatusController.updateStudentGradHistoryStatusDistributionRun(1L, "Batch Archive Process", "activityCode", List.of());
+ Mockito.verify(historyService).updateStudentRecordHistoryDistributionRun(1L, "Batch Archive Process", "activityCode", List.of());
+ }
+
@Test
public void testGetStudentsForSchoolReport() {
// ID
@@ -603,6 +610,36 @@ public void testGetStudentsCountForAmalgamatedSchoolReport() {
Mockito.verify(graduationStatusService).countStudentsForAmalgamatedSchoolReport(mincode);
}
+ @Test
+ public void testGetStudentsCount() {
+ // ID
+ String mincode = "123456789";
+ Mockito.when(graduationStatusService.countBySchoolOfRecordsAndStudentStatus(List.of(mincode), "CUR")).thenReturn(1L);
+ graduationStatusController.getStudentsCount("CUR", List.of(mincode));
+ Mockito.verify(graduationStatusService).countBySchoolOfRecordsAndStudentStatus(List.of(mincode), "CUR");
+
+ Mockito.when(graduationStatusService.countBySchoolOfRecordsAndStudentStatus(List.of(), "CUR")).thenReturn(1L);
+ graduationStatusController.getStudentsCount("CUR", List.of());
+ Mockito.verify(graduationStatusService).countBySchoolOfRecordsAndStudentStatus(List.of(), "CUR");
+
+ Mockito.when(graduationStatusService.countBySchoolOfRecordsAndStudentStatus(List.of(mincode), null)).thenReturn(1L);
+ graduationStatusController.getStudentsCount(null, List.of(mincode));
+ Mockito.verify(graduationStatusService).countBySchoolOfRecordsAndStudentStatus(List.of(mincode), null);
+
+ Mockito.when(graduationStatusService.countBySchoolOfRecordsAndStudentStatus(List.of(), null)).thenReturn(1L);
+ graduationStatusController.getStudentsCount(null, List.of());
+ Mockito.verify(graduationStatusService).countBySchoolOfRecordsAndStudentStatus(List.of(), null);
+ }
+
+ @Test
+ public void testArchiveStudents() {
+ // ID
+ String mincode = "123456789";
+ Mockito.when(graduationStatusService.archiveStudents(1L, List.of(mincode), "CUR", "Batch Archive Process")).thenReturn(1);
+ graduationStatusController.archiveStudents(1L, "CUR", "Batch Archive Process", List.of(mincode));
+ Mockito.verify(graduationStatusService).archiveStudents(1L, List.of(mincode), "CUR", "Batch Archive Process");
+ }
+
@Test
public void testGetStudentForBatch() {
String mincode = "123456789";
diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentServiceTest.java
index 50f27a05..8ee2f046 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GradStudentServiceTest.java
@@ -422,6 +422,16 @@ public String getStudentProjectedGradData() {
return null;
}
+ @Override
+ public UUID getSchoolOfRecordId() {
+ return null;
+ }
+
+ @Override
+ public UUID getSchoolAtGraduationId() {
+ return null;
+ }
+
@Override
public LocalDateTime getCreateDate() {
return null;
@@ -432,10 +442,10 @@ public LocalDateTime getUpdateDate() {
return null;
}
};
+
List studentSubList = new ArrayList<>();
studentSubList.add(graduationStatusView.getStudentID());
-
when(this.graduationStatusRepository.findByStudentID(studentID)).thenReturn(graduationStatusEntity);
when(this.graduationStatusTransformer.transformToDTOWithModifiedProgramCompletionDate(graduationStatusEntity)).thenReturn(graduationStatus);
when(this.graduationStatusRepository.findByStudentIDIn(studentSubList)).thenReturn(List.of(graduationStatusView));
@@ -819,7 +829,23 @@ public void testGetStudentIDsByStatusCode() {
assertThat(result.get(0)).isEqualTo(studentID1);
}
+ @Test
+ public void testGetStudentIDsBySearchCriterias() {
+ List result = List.of(UUID.randomUUID());
+ StudentSearchRequest searchRequest = StudentSearchRequest.builder()
+ .schoolOfRecords(List.of("12345678"))
+ .pens(List.of("12345678"))
+ .studentIDs(result)
+ .build();
+
+ when(graduationStatusRepository.findBySchoolOfRecordIn(searchRequest.getSchoolOfRecords())).thenReturn(result);
+ when(graduationStatusRepository.findStudentIDsByPenIn(searchRequest.getPens())).thenReturn(result);
+ when(graduationStatusRepository.findAllStudentGuids()).thenReturn(result);
+
+ List results = gradStudentService.getStudentIDsBySearchCriteriaOrAll(searchRequest);
+ assertThat(results).isNotEmpty();
+ }
@SneakyThrows
protected Object createDataObjectFromJson(String jsonPath, Class> clazz) {
diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java
index 41ba286b..b2268093 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusServiceTest.java
@@ -53,8 +53,7 @@
@ActiveProfiles("test")
public class GraduationStatusServiceTest {
- @Autowired
- EducGradStudentApiConstants constants;
+ @Autowired EducGradStudentApiConstants constants;
@Autowired GraduationStatusService graduationStatusService;
@MockBean GradStudentService gradStudentService;
@MockBean HistoryService historyService;
@@ -65,6 +64,7 @@ public class GraduationStatusServiceTest {
@MockBean StudentCareerProgramRepository gradStudentCareerProgramRepository;
@MockBean ReportGradStudentDataRepository reportGradStudentDataRepository;
@MockBean StudentNonGradReasonRepository studentNonGradReasonRepository;
+ @MockBean GraduationStudentRecordHistoryRepository graduationStudentRecordHistoryRepository;
@MockBean CommonService commonService;
@MockBean GradValidation validation;
@MockBean WebClient webClient;
@@ -1530,6 +1530,8 @@ public void testDeleteCRUDStudentGradCareerProgram() {
Optional optionalGraduationStudentRecordEntity = Optional.of(graduationStudentRecordEntity);
+ historyService.createStudentOptionalProgramHistory(gradStudentOptionalProgramEntity, "USER_DELETE");
+
when(graduationStatusRepository.findById(studentID)).thenReturn(optionalGraduationStudentRecordEntity);
when(gradStudentOptionalProgramRepository.findByStudentIDAndOptionalProgramID(studentID, optionalProgramID)).thenReturn(Optional.of(gradStudentOptionalProgramEntity));
doNothing().when(gradStudentOptionalProgramRepository).delete(gradStudentOptionalProgramEntity);
@@ -2214,10 +2216,130 @@ public void testSaveStudentRecord_DistributionRun() {
when(graduationStatusRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity));
when(graduationStatusRepository.saveAndFlush(graduationStatusEntity2)).thenReturn(graduationStatusEntity2);
- GraduationStudentRecord res =graduationStatusService.saveStudentRecordDistributionRun(studentID, batchId, "ACTIVITYCODE");
+ GraduationStudentRecord res =graduationStatusService.saveStudentRecordDistributionRun(studentID, batchId, "ACTIVITYCODE", "USER");
assertThat(res).isNotNull();
}
+ @Test
+ public void testSaveStudentRecord_DistributionRun_2() {
+
+ GraduationStatusService graduationStatusServiceMock = mock(GraduationStatusService.class);
+
+ UUID studentID = new UUID(1, 1);
+ Long batchId = null;
+ GraduationStudentRecordView graduationStatusEntity = new GraduationStudentRecordView() {
+
+ @Override
+ public String getProgram() {
+ return null;
+ }
+
+ @Override
+ public java.util.Date getProgramCompletionDate() {
+ return null;
+ }
+
+ @Override
+ public String getGpa() {
+ return null;
+ }
+
+ @Override
+ public String getHonoursStanding() {
+ return null;
+ }
+
+ @Override
+ public String getRecalculateGradStatus() {
+ return null;
+ }
+
+ @Override
+ public String getSchoolOfRecord() {
+ return "12345678";
+ }
+
+ @Override
+ public String getStudentGrade() {
+ return null;
+ }
+
+ @Override
+ public String getStudentStatus() {
+ return "A";
+ }
+
+ @Override
+ public UUID getStudentID() {
+ return studentID;
+ }
+
+ @Override
+ public String getSchoolAtGrad() {
+ return null;
+ }
+
+ @Override
+ public String getRecalculateProjectedGrad() {
+ return null;
+ }
+
+ @Override
+ public Long getBatchId() {
+ return null;
+ }
+
+ @Override
+ public String getConsumerEducationRequirementMet() {
+ return null;
+ }
+
+ @Override
+ public String getStudentCitizenship() {
+ return null;
+ }
+
+ @Override
+ public java.util.Date getAdultStartDate() {
+ return null;
+ }
+
+ @Override
+ public String getStudentProjectedGradData() {
+ return null;
+ }
+
+ @Override
+ public UUID getSchoolOfRecordId() {
+ return null;
+ }
+
+ @Override
+ public UUID getSchoolAtGraduationId() {
+ return null;
+ }
+
+ @Override
+ public LocalDateTime getCreateDate() {
+ return null;
+ }
+
+ @Override
+ public LocalDateTime getUpdateDate() {
+ return null;
+ }
+ };
+
+ when(graduationStatusRepository.findByStudentIDIn(List.of(studentID))).thenReturn(List.of(graduationStatusEntity));
+
+ doNothing().when(graduationStatusServiceMock).saveStudentHistoryRecordArchiveStudentsRun(studentID, batchId, "ACTIVITYCODE");
+ graduationStatusServiceMock.saveStudentHistoryRecordArchiveStudentsRun(studentID, batchId, "ACTIVITYCODE");
+ Mockito.verify(graduationStatusServiceMock).saveStudentHistoryRecordArchiveStudentsRun(studentID, batchId, "ACTIVITYCODE");
+
+ graduationStatusService.saveStudentHistoryRecordArchiveStudentsRun(studentID, batchId, "ACTIVITYCODE");
+
+ }
+
@Test
public void testGetStudentDataByStudentIds() {
// ID
@@ -2313,6 +2435,16 @@ public String getStudentProjectedGradData() {
return null;
}
+ @Override
+ public UUID getSchoolOfRecordId() {
+ return null;
+ }
+
+ @Override
+ public UUID getSchoolAtGraduationId() {
+ return null;
+ }
+
@Override
public LocalDateTime getCreateDate() {
return null;
@@ -2787,6 +2919,16 @@ public String getStudentProjectedGradData() {
return null;
}
+ @Override
+ public UUID getSchoolOfRecordId() {
+ return null;
+ }
+
+ @Override
+ public UUID getSchoolAtGraduationId() {
+ return null;
+ }
+
@Override
public LocalDateTime getCreateDate() {
return null;
@@ -2891,6 +3033,69 @@ public void testGetStudentsCountForAmalgamatedSchoolReport() {
}
+ @Test
+ public void testCountBySchoolOfRecordsAndStudentStatus() {
+ Mockito.when(graduationStatusRepository.countBySchoolOfRecordsAndStudentStatus(List.of("12345678"), "CUR")).thenReturn(1L);
+ Long count = graduationStatusService.countBySchoolOfRecordsAndStudentStatus(List.of("12345678"), "CUR");
+ assertThat(count).isNotNull().isEqualTo(1L);
+
+ Mockito.when(graduationStatusRepository.countByStudentStatus("CUR")).thenReturn(1L);
+ count = graduationStatusService.countBySchoolOfRecordsAndStudentStatus(List.of(), "CUR");
+ assertThat(count).isNotNull().isEqualTo(1L);
+
+ Mockito.when(graduationStatusRepository.countBySchoolOfRecords(List.of("12345678"))).thenReturn(1L);
+ count = graduationStatusService.countBySchoolOfRecordsAndStudentStatus(List.of("12345678"), null);
+ assertThat(count).isNotNull().isEqualTo(1L);
+
+ Mockito.when(graduationStatusRepository.countBySchoolOfRecords(List.of("12345678"))).thenReturn(1L);
+ count = graduationStatusService.countBySchoolOfRecordsAndStudentStatus(List.of("12345678"), "null");
+ assertThat(count).isNotNull().isEqualTo(1L);
+
+ Mockito.when(graduationStatusRepository.count()).thenReturn(2L);
+ count = graduationStatusService.countBySchoolOfRecordsAndStudentStatus(List.of(), null);
+ assertThat(count).isNotNull().isEqualTo(2L);
+
+ }
+
+ @Test
+ public void testArchiveStudents() {
+
+ UUID studentID = new UUID(1, 1);
+ GraduationStudentRecordEntity graduationStatusEntity = new GraduationStudentRecordEntity();
+ graduationStatusEntity.setStudentID(studentID);
+ graduationStatusEntity.setPen("12321321");
+ graduationStatusEntity.setStudentStatus("A");
+ graduationStatusEntity.setSchoolOfRecord("12345678");
+
+ when(graduationStatusRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity));
+ Mockito.when(graduationStatusRepository.findBySchoolOfRecordInAndStudentStatus(List.of("12345678"), "CUR")).thenReturn(List.of(studentID));
+ Mockito.when(graduationStatusRepository.archiveStudents(List.of("12345678"), "CUR", "ARC", 1L, "USER")).thenReturn(1);
+ Mockito.when(graduationStatusRepository.updateGraduationStudentRecordEntitiesBatchIdWhereStudentIDsIn(1L, List.of(studentID))).thenReturn(1);
+ Mockito.when(historyService.updateStudentRecordHistoryDistributionRun(1L, "USER", "USERSTUDARC", List.of(studentID))).thenReturn(1);
+
+ Integer count = graduationStatusService.archiveStudents(1L, List.of("12345678"), "CUR", "USER");
+ assertThat(count).isNotNull().isEqualTo(1);
+ }
+
+ @Test
+ public void testArchiveStudentEmpty() {
+ LocalDateTime updateDate = LocalDateTime.now();
+ UUID studentID = new UUID(1, 1);
+ GraduationStudentRecordEntity graduationStatusEntity = new GraduationStudentRecordEntity();
+ graduationStatusEntity.setStudentID(studentID);
+ graduationStatusEntity.setPen("12321321");
+ graduationStatusEntity.setStudentStatus("A");
+ graduationStatusEntity.setSchoolOfRecord("12345678");
+
+ when(graduationStatusRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity));
+ Mockito.when(graduationStatusRepository.findByStudentStatus("CUR")).thenReturn(List.of(studentID));
+ Mockito.when(graduationStatusRepository.archiveStudents("CUR", "ARC", 1L, "USER")).thenReturn(1);
+ Mockito.when(historyService.updateStudentRecordHistoryDistributionRun(1L, "USER", "USERSTUDARC", List.of(studentID))).thenReturn(1);
+
+ Integer count = graduationStatusService.archiveStudents(1L, List.of(), "CUR", "USER");
+ assertThat(count).isNotNull().isEqualTo(0);
+ }
+
@Test
public void testGetStudentsForAmalgamatedSchoolReport() {
List res = amalgamatedReports("TVRNONGRAD",false);
@@ -2991,6 +3196,16 @@ public String getStudentProjectedGradData() {
return jsonTransformer.marshall(projectedRunClob);
}
+ @Override
+ public UUID getSchoolOfRecordId() {
+ return null;
+ }
+
+ @Override
+ public UUID getSchoolAtGraduationId() {
+ return null;
+ }
+
@Override
public LocalDateTime getCreateDate() {
return null;
diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/HistoryServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/HistoryServiceTest.java
index fa27c142..107bdd6e 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/HistoryServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/HistoryServiceTest.java
@@ -4,12 +4,16 @@
import ca.bc.gov.educ.api.gradstudent.messaging.jetstream.FetchGradStatusSubscriber;
import ca.bc.gov.educ.api.gradstudent.messaging.jetstream.Publisher;
import ca.bc.gov.educ.api.gradstudent.messaging.jetstream.Subscriber;
-import ca.bc.gov.educ.api.gradstudent.model.dto.*;
+import ca.bc.gov.educ.api.gradstudent.model.dto.GradSearchStudent;
+import ca.bc.gov.educ.api.gradstudent.model.dto.GraduationData;
+import ca.bc.gov.educ.api.gradstudent.model.dto.OptionalProgram;
+import ca.bc.gov.educ.api.gradstudent.model.dto.Student;
import ca.bc.gov.educ.api.gradstudent.model.entity.GraduationStudentRecordEntity;
import ca.bc.gov.educ.api.gradstudent.model.entity.GraduationStudentRecordHistoryEntity;
import ca.bc.gov.educ.api.gradstudent.model.entity.HistoryActivityCodeEntity;
import ca.bc.gov.educ.api.gradstudent.model.entity.StudentOptionalProgramHistoryEntity;
import ca.bc.gov.educ.api.gradstudent.repository.GraduationStudentRecordHistoryRepository;
+import ca.bc.gov.educ.api.gradstudent.repository.GraduationStudentRecordRepository;
import ca.bc.gov.educ.api.gradstudent.repository.HistoryActivityRepository;
import ca.bc.gov.educ.api.gradstudent.repository.StudentOptionalProgramHistoryRepository;
import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants;
@@ -34,7 +38,10 @@
import java.sql.Date;
import java.time.LocalDateTime;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
import java.util.function.Consumer;
import static org.assertj.core.api.Assertions.assertThat;
@@ -51,6 +58,7 @@ public class HistoryServiceTest {
@Autowired HistoryService historyService;
@MockBean CommonService commonService;
@MockBean GraduationStudentRecordHistoryRepository graduationStudentRecordHistoryRepository;
+ @MockBean GraduationStudentRecordRepository graduationStudentRecordRepository;
@MockBean HistoryActivityRepository historyActivityRepository;
@MockBean StudentOptionalProgramHistoryRepository studentOptionalProgramHistoryRepository;
@MockBean WebClient webClient;
@@ -136,6 +144,22 @@ public void testGetStudentOptionalProgramHistory() {
}
+ @Test
+ public void testCreateStudentHistory() {
+ UUID studentID = new UUID(1, 1);
+ GraduationStudentRecordEntity graduationStatusEntity = new GraduationStudentRecordEntity();
+ graduationStatusEntity.setStudentID(studentID);
+ graduationStatusEntity.setPen("12321321");
+ graduationStatusEntity.setStudentStatus("A");
+ graduationStatusEntity.setSchoolOfRecord("12345678");
+
+ when(graduationStudentRecordRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity));
+
+ historyService.createStudentHistory(graduationStatusEntity, "ACTIVITYCODE");
+
+ assertThat(graduationStatusEntity).isNotNull();
+ }
+
@Test
public void testGetStudentHistoryByHistoryID() {
// ID
@@ -195,7 +219,6 @@ public void testGetStudentOptionalProgramHistoryByID() {
public void testGetStudentHistoryByBatchID() {
// ID
UUID studentID = UUID.randomUUID();
- UUID historyID = UUID.randomUUID();
List histList = new ArrayList<>();
Student std = new Student();
@@ -245,4 +268,76 @@ public void testGetStudentHistoryByBatchID() {
assertThat(list).isNotEmpty();
assertThat(list.getContent()).hasSize(1);
}
+
+ @Test
+ public void testUpdateStudentRecordHistoryDistributionRun() {
+ // ID
+ UUID studentID = UUID.randomUUID();
+ List histList = new ArrayList<>();
+ LocalDateTime updateDate = LocalDateTime.now();
+
+ Student std = new Student();
+ std.setPen("123123");
+ std.setLegalFirstName("Asdad");
+ std.setLegalMiddleNames("Adad");
+ std.setLegalLastName("sadad");
+
+ GradSearchStudent serObj = new GradSearchStudent();
+ serObj.setPen("123123");
+ serObj.setLegalFirstName("Asdad");
+ serObj.setLegalMiddleNames("Adad");
+ serObj.setLegalLastName("sadad");
+ GraduationData gd = new GraduationData();
+ gd.setGradStudent(serObj);
+
+ GraduationStudentRecordHistoryEntity graduationStudentRecordHistoryEntity = new GraduationStudentRecordHistoryEntity();
+ graduationStudentRecordHistoryEntity.setStudentID(studentID);
+ graduationStudentRecordHistoryEntity.setStudentStatus("A");
+ graduationStudentRecordHistoryEntity.setRecalculateGradStatus("Y");
+ graduationStudentRecordHistoryEntity.setProgram("2018-EN");
+ graduationStudentRecordHistoryEntity.setSchoolOfRecord("223333");
+ graduationStudentRecordHistoryEntity.setGpa("4");
+ graduationStudentRecordHistoryEntity.setHistoryID(new UUID(1,1));
+ graduationStudentRecordHistoryEntity.setActivityCode("GRADALG");
+ graduationStudentRecordHistoryEntity.setBatchId(4000L);
+ graduationStudentRecordHistoryEntity.setPen("123123");
+ graduationStudentRecordHistoryEntity.setLegalFirstName("Asdad");
+ graduationStudentRecordHistoryEntity.setLegalMiddleNames("Adad");
+ graduationStudentRecordHistoryEntity.setLegalLastName("sadad");
+ histList.add(graduationStudentRecordHistoryEntity);
+ Page hPage = new PageImpl(histList);
+
+ GraduationStudentRecordEntity graduationStudentRecordEntity = new GraduationStudentRecordEntity();
+ graduationStudentRecordEntity.setStudentID(studentID);
+
+ when(graduationStudentRecordHistoryRepository.findByBatchId(4000L, PageRequest.of(0, Integer.SIZE))).thenReturn(hPage);
+ when(graduationStudentRecordHistoryRepository.findByStudentID(studentID)).thenReturn(List.of(graduationStudentRecordHistoryEntity));
+ when(graduationStudentRecordHistoryRepository.updateGradStudentUpdateUser(4000L, "USER")).thenReturn(1);
+ when(graduationStudentRecordRepository.findByStudentID(studentID)).thenReturn(graduationStudentRecordEntity);
+
+ when(graduationStudentRecordRepository.updateGraduationStudentRecordEntitiesBatchIdWhereStudentIDsIn(4000L, List.of(studentID))).thenReturn(1);
+ when(graduationStudentRecordHistoryRepository.insertGraduationStudentRecordHistoryByBatchIdAndStudentIDs(4000L, List.of(studentID), "activityCode", "USER")).thenReturn(1);
+ when(graduationStudentRecordHistoryRepository.insertGraduationStudentRecordHistoryByBatchId(4000L, "activityCode", "USER")).thenReturn(1);
+ when(graduationStudentRecordHistoryRepository.insertGraduationStudentRecordHistoryByBatchId(4000L, "USERSTUDARC", "USER")).thenReturn(1);
+
+ var result = historyService.updateStudentRecordHistoryDistributionRun(4000L, "USER", "activityCode", List.of(studentID));
+ assertThat(result).isNotNull().isEqualTo(1);
+
+ when(graduationStudentRecordHistoryRepository.findByBatchId(4000L, PageRequest.of(0, Integer.SIZE))).thenReturn(null);
+ result = historyService.updateStudentRecordHistoryDistributionRun(4000L, "USER", "activityCode", List.of(studentID));
+ assertThat(result).isNotNull().isEqualTo(1);
+
+ when(graduationStudentRecordHistoryRepository.findByBatchId(4000L, PageRequest.of(0, Integer.SIZE))).thenReturn(new PageImpl(List.of()));
+ result = historyService.updateStudentRecordHistoryDistributionRun(4000L, "USER", "activityCode", List.of(studentID));
+ assertThat(result).isNotNull().isEqualTo(1);
+
+ result = historyService.updateStudentRecordHistoryDistributionRun(4000L, "USER", "activityCode", List.of());
+ assertThat(result).isNotNull().isZero();
+
+ result = historyService.updateStudentRecordHistoryDistributionRun(4000L, "USER", "", List.of());
+ assertThat(result).isNotNull().isEqualTo(1);
+
+ result = historyService.updateStudentRecordHistoryDistributionRun(4000L, "USER", "USERSTUDARC", List.of());
+ assertThat(result).isNotNull().isEqualTo(1);
+ }
}