Skip to content

Commit

Permalink
Merge pull request #282 from bcgov/grad-release
Browse files Browse the repository at this point in the history
Grad release 1.23
  • Loading branch information
githubmamatha authored Sep 12, 2024
2 parents 69664a7 + 6aef499 commit 79e3f9a
Show file tree
Hide file tree
Showing 15 changed files with 629 additions and 73 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ target/
build/

### VS Code ###
.vscode/
.vscode/

### Local dev ###
**/application-local.yaml
55 changes: 0 additions & 55 deletions api/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ca.bc.gov.educ</groupId>
<artifactId>educ-grad-graduation-report-api</artifactId>
<version>1.8.49</version>
<version>1.8.50</version>
<name>educ-grad-graduation-report-api</name>
<description>Grad Graduation Report API for GRAD team</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ResponseEntity<Boolean> getStudentReport(@PathVariable String reportTypeC
public ResponseEntity<ApiResponseModel<GradStudentReports>> saveStudentReport(@RequestBody GradStudentReports gradStudentReports,@RequestParam(value = "isGraduated", required = false, defaultValue = "false") boolean isGraduated) {
logger.debug("Save student Grad Report for Student ID: {}",gradStudentReports.getStudentID());
validation.requiredField(gradStudentReports.getStudentID(), "Student ID");
return response.UPDATED(commonService.saveGradReports(gradStudentReports,isGraduated));
return response.UPDATED(commonService.saveGradStudentReports(gradStudentReports,isGraduated));
}

@GetMapping(EducGradReportApiConstants.STUDENT_REPORT)
Expand All @@ -80,6 +80,28 @@ public ResponseEntity<InputStreamResource> getStudentReportByType(
return commonService.getStudentReportByType(UUID.fromString(studentID),reportType,documentStatusCode);
}

@DeleteMapping(EducGradReportApiConstants.STUDENT_REPORT_BY_STUDENTID)
@PreAuthorize(PermissionsConstants.DELETE_STUDENT_REPORT)
@Operation(summary = "Delete Student Reports by Student ID and Report Type", description = "Delete Student Reports by Student ID and Report Type", tags = { "Reports" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<Integer> deleteStudentReportByType(
@RequestParam(value = "reportType") String reportType,
@PathVariable UUID studentID) {
logger.debug("deleteStudentReportByType");
return response.GET(commonService.deleteStudentReports(studentID, reportType));
}

@PostMapping(EducGradReportApiConstants.STUDENT_REPORTS)
@PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT_REPORTS)
@Operation(summary = "Read Student Reports by Student ID and Report Type", description = "Read Student Reports by Student ID and Report Type", tags = { "Reports" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<Long> processStudentReports(
@RequestParam(value = "reportTypeCode") String reportTypeCode,
@RequestBody List<UUID> studentIDs) {
logger.debug("processStudentReports : ");
return response.GET(commonService.processStudentReports(studentIDs, reportTypeCode));
}

@GetMapping(EducGradReportApiConstants.STUDENT_CERTIFICATES)
@PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT_CERTIFICATES)
@Operation(summary = "Read Student Certificates by Student ID", description = "Read Student Certificates by Student ID", tags = { "Reports" })
Expand Down Expand Up @@ -374,5 +396,41 @@ public ResponseEntity<InputStreamResource> getStudentCredentialByType(@PathVaria
return commonService.getStudentCredentialByType(UUID.fromString(studentID),type);
}

@PostMapping (EducGradReportApiConstants.REPORT_COUNT)
@PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT_REPORTS)
@Operation(summary = "Get Reports Count by mincode and status", description = "Get Students Count by mincode and status", tags = { "Business" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<Integer> getReportsCount(@RequestParam String reportType, @RequestBody List<String> reportContainerIds) {
if(StringUtils.containsAnyIgnoreCase(reportType, "ACHV")) {
return response.GET(commonService.countByStudentGuidsAndReportType(reportContainerIds, reportType));
} else {
return response.GET(commonService.countBySchoolOfRecordsAndReportType(reportContainerIds, reportType));
}
}

@PostMapping (EducGradReportApiConstants.STUDENT_REPORTS_BY_GUIDS)
@PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT_REPORTS)
@Operation(summary = "Get Report Students Guids by mincode and type", description = "Get Report Students Guids by mincode and type", tags = { "Business" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<List<UUID>> getStudentIDsByIdentityAndReportType(@RequestParam String reportType, @RequestParam Integer rowCount, @RequestBody List<String> reportContainerIds) {
return response.GET(commonService.getStudentIDsByStudentGuidsAndReportType(reportContainerIds, reportType, rowCount));
}

@PostMapping (EducGradReportApiConstants.REPORT_ARCHIVE)
@PreAuthorize(PermissionsConstants.ARCHIVE_SCHOOL_REPORT)
@Operation(summary = "Archive Reports", description = "Archive Reports", tags = { "Business" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<Integer> archiveReports(@RequestParam long batchId, @RequestParam String reportType, @RequestBody List<String> schoolOfRecords) {
logger.debug("Archive Reports for batch {}", batchId);
return response.GET(commonService.archiveSchoolReports(batchId, schoolOfRecords, reportType));
}

@PostMapping (EducGradReportApiConstants.REPORT_DELETE)
@PreAuthorize(PermissionsConstants.DELETE_STUDENT_REPORT)
@Operation(summary = "Delete Reports", description = "Delete Reports", tags = { "Business" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<Integer> deleteReports(@RequestParam long batchId, @RequestParam String reportType, @RequestBody List<UUID> studentGuids) {
logger.debug("Delete Reports for batch {}", batchId);
return response.GET(commonService.deleteStudentReports(studentGuids, reportType));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package ca.bc.gov.educ.api.grad.report.model.dto;

import java.io.Serializable;

public class Address implements Serializable {

private static final long serialVersionUID = 2L;

private String streetLine1;
private String streetLine2;
private String streetLine3;
private String city;
private String region;
private String country;
private String code;

public String getStreetLine1() {
return streetLine1;
}

public void setStreetLine1(String value) {
this.streetLine1 = value;
}

public String getStreetLine2() {
return streetLine2;
}

public void setStreetLine2(String value) {
this.streetLine2 = value;
}

public String getStreetLine3() {
return streetLine3;
}

public void setStreetLine3(String streetLine3) {
this.streetLine3 = streetLine3;
}

public String getCity() {
return city;
}

public void setCity(String value) {
this.city = value;
}

public String getRegion() {
return region;
}

public void setRegion(String value) {
this.region = value;
}

public String getCountry() {
return country;
}

public void setCountry(String value) {
this.country = value;
}

public String getCode() {
return code;
}

public void setCode(String value) {
this.code = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.Serializable;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

Expand All @@ -19,12 +20,17 @@
@AllArgsConstructor
@Builder
public class StudentSearchRequest implements Serializable {
private List<String> schoolOfRecords;
private List<String> districts;
private List<String> schoolCategoryCodes;
private List<String> pens;
private List<String> programs;
private List<UUID> studentIDs;
private List<String> schoolOfRecords = new ArrayList<>();
private List<String> districts = new ArrayList<>();
private List<String> schoolCategoryCodes = new ArrayList<>();
private List<String> pens = new ArrayList<>();
private List<String> programs = new ArrayList<>();
private List<UUID> studentIDs = new ArrayList<>();
private List<String> statuses = new ArrayList<>();
private List<String> reportTypes = new ArrayList();

private String user;
private Address address;

@JsonFormat(pattern= EducGradReportApiConstants.DEFAULT_DATE_FORMAT)
LocalDate gradDateFrom;
Expand All @@ -33,5 +39,15 @@ public class StudentSearchRequest implements Serializable {

Boolean validateInput;
String activityCode;
String localDownload;

public boolean isEmpty() {
return schoolOfRecords.isEmpty() &&
districts.isEmpty() &&
schoolCategoryCodes.isEmpty() &&
pens.isEmpty() &&
studentIDs.isEmpty() &&
programs.isEmpty();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import ca.bc.gov.educ.api.grad.report.model.dto.SchoolStudentCredentialDistribution;
import ca.bc.gov.educ.api.grad.report.model.entity.GradStudentReportsEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

Expand All @@ -17,8 +20,18 @@ public interface GradStudentReportsRepository extends JpaRepository<GradStudentR

@Query("select c from GradStudentReportsEntity c where c.gradReportTypeCode=:reportType")
List<GradStudentReportsEntity> existsByReportTypeCode(String reportType);

long deleteByStudentID(UUID studentID);

@Modifying
@Query(value="DELETE from STUDENT_REPORT where GRADUATION_STUDENT_RECORD_ID in (:studentIDs) and REPORT_TYPE_CODE = :gradReportTypeCode", nativeQuery = true)
Integer deleteByStudentIDInAndGradReportTypeCode(List<UUID> studentIDs, String gradReportTypeCode);

@Modifying
@Query(value="DELETE from STUDENT_REPORT where REPORT_TYPE_CODE = :gradReportTypeCode", nativeQuery = true)
Integer deleteByGradReportTypeCode(String gradReportTypeCode);

@Modifying
@Query(value="DELETE from STUDENT_REPORT where GRADUATION_STUDENT_RECORD_ID = :studentID and REPORT_TYPE_CODE = :gradReportTypeCode", nativeQuery = true)
Integer deleteByStudentIDAndGradReportTypeCode(UUID studentID, String gradReportTypeCode);

List<GradStudentReportsEntity> findByStudentID(UUID studentID);

Expand All @@ -30,4 +43,16 @@ public interface GradStudentReportsRepository extends JpaRepository<GradStudentR

@Query("select new ca.bc.gov.educ.api.grad.report.model.dto.SchoolStudentCredentialDistribution(c.id,c.gradReportTypeCode,c.studentID,c.documentStatusCode) from GradStudentReportsEntity c where c.reportUpdateDate is null or c.reportUpdateDate < c.updateDate")
List<SchoolStudentCredentialDistribution> findByReportUpdateDate();

@Query("select count(*) from GradStudentReportsEntity c where c.studentID IN (:studentGuids) and c.gradReportTypeCode=:reportType")
Integer countByStudentGuidsAndReportType(List<UUID> studentGuids, String reportType);

@Query("select c.studentID from GradStudentReportsEntity c where c.studentID IN (:studentGuids) and c.gradReportTypeCode=:reportType")
Page<UUID> getReportStudentIDsByStudentIDsAndReportType(List<UUID> studentGuids, String reportType, Pageable page);

@Query("select count(*) from GradStudentReportsEntity c where c.gradReportTypeCode=:reportType")
Integer countByReportType(String reportType);

@Query("select c.studentID from GradStudentReportsEntity c where c.gradReportTypeCode=:reportType")
Page<UUID> findStudentIDByGradReportTypeCode(String reportType, Pageable page);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ca.bc.gov.educ.api.grad.report.model.entity.SchoolReportsEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

Expand All @@ -23,4 +24,35 @@ public interface SchoolReportsRepository extends JpaRepository<SchoolReportsEnti

Optional<SchoolReportsEntity> findBySchoolOfRecordAndReportTypeCodeOrderBySchoolOfRecord(String schoolOfRecord, String reportTypeCode);

@Query("select count(*) from SchoolReportsLightEntity c where c.schoolOfRecord IN (:schoolOfRecords) and c.reportTypeCode=:reportType")
Integer countBySchoolOfRecordsAndReportType(List<String> schoolOfRecords, String reportType);

@Query("select count(*) from SchoolReportsLightEntity c where c.reportTypeCode=:reportType")
Integer countByReportType(String reportType);

@Query("select c.id from SchoolReportsLightEntity c where c.schoolOfRecord IN (:schoolOfRecords) and c.reportTypeCode=:reportType")
List<UUID> getReportGuidsBySchoolOfRecordsAndReportType(List<String> schoolOfRecords, String reportType);

@Query("select c.id from SchoolReportsLightEntity c where c.reportTypeCode=:reportType")
List<UUID> getReportGuidsByReportType(String reportType);

@Query("select c.schoolOfRecord from SchoolReportsLightEntity c where c.reportTypeCode=:reportType")
List<String> getReportSchoolOfRecordsByReportType(String reportType);

@Modifying
@Query(value="update SCHOOL_REPORT set REPORT_TYPE_CODE = :reportTypeTo, update_date = SYSDATE, update_user = 'Batch ' || :batchId || ' Archive Process' where school_of_record in (:schoolOfRecords) and REPORT_TYPE_CODE = :reportTypeFrom", nativeQuery=true)
Integer archiveSchoolReports(List<String> schoolOfRecords, String reportTypeFrom, String reportTypeTo, long batchId);

@Modifying
@Query(value="update SCHOOL_REPORT set REPORT_TYPE_CODE = :reportTypeTo, update_date = SYSDATE, update_user = 'Batch ' || :batchId || ' Archive Process' where REPORT_TYPE_CODE = :reportTypeFrom", nativeQuery=true)
Integer archiveSchoolReports(String reportTypeFrom, String reportTypeTo, long batchId);

@Modifying
@Query(value="delete from SCHOOL_REPORT where SCHOOL_REPORT_ID not in (:schoolReportGuids) and school_of_record in (:schoolOfRecords) and REPORT_TYPE_CODE = :archivedReportType", nativeQuery=true)
Integer deleteSchoolOfRecordsNotMatchingSchoolReports(List<UUID> schoolReportGuids, List<String> schoolOfRecords, String archivedReportType);

@Modifying
@Query(value="delete from SCHOOL_REPORT where SCHOOL_REPORT_ID not in (:schoolReportGuids) and REPORT_TYPE_CODE = :archivedReportType", nativeQuery=true)
Integer deleteAllNotMatchingSchoolReports(List<UUID> schoolReportGuids, String archivedReportType);

}
Loading

0 comments on commit 79e3f9a

Please sign in to comment.