Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grad release 1.14.0 #619

Merged
merged 22 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-student-api</artifactId>
<version>1.8.53</version>
<version>1.8.54</version>
<name>educ-grad-student-api</name>
<description>Student Demographics API for GRAD team</description>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.bc.gov.educ.api.gradstudent.config;

import ca.bc.gov.educ.api.gradstudent.exception.EntityNotFoundException;
import ca.bc.gov.educ.api.gradstudent.util.ApiResponseMessage.MessageTypeEnum;
import ca.bc.gov.educ.api.gradstudent.util.ApiResponseModel;
import ca.bc.gov.educ.api.gradstudent.util.GradBusinessRuleException;
Expand Down Expand Up @@ -55,7 +56,7 @@ protected ResponseEntity<Object> handleAuthorizationErrors(Exception ex, WebRequ
return new ResponseEntity<>(ApiResponseModel.ERROR(null, message), HttpStatus.FORBIDDEN);
}

@ExceptionHandler(value = { GradBusinessRuleException.class })
@ExceptionHandler(value = { GradBusinessRuleException.class, EntityNotFoundException.class })
protected ResponseEntity<Object> handleGradBusinessException(Exception ex, WebRequest request) {
ApiResponseModel<?> response = ApiResponseModel.ERROR(null);
validation.ifErrors(response::addErrorMessages);
Expand All @@ -64,7 +65,8 @@ protected ResponseEntity<Object> handleGradBusinessException(Exception ex, WebRe
response.addMessageItem(ex.getLocalizedMessage(), MessageTypeEnum.ERROR);
}
validation.clear();
return new ResponseEntity<>(response, HttpStatus.UNPROCESSABLE_ENTITY);
HttpStatus httpStatus = (ex instanceof EntityNotFoundException) ? HttpStatus.NOT_FOUND : HttpStatus.UNPROCESSABLE_ENTITY;
return new ResponseEntity<>(response, httpStatus);
}

@ExceptionHandler(value = { OptimisticEntityLockException.class })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class CommonController {

private static final Logger logger = LoggerFactory.getLogger(CommonController.class);

private static final String STATUS_CODE="Status Code";
private static final String STATUS_CODE = "Status Code";
private static final String BEARER = "Bearer ";

@Autowired
CommonService commonService;
Expand Down Expand Up @@ -276,4 +277,36 @@ public ResponseEntity<List<UUID>> getDeceasedStudentIDs(@RequestBody List<UUID>
return response.GET(commonService.getDeceasedStudentIDs(studentIds));
}

@PostMapping (EducGradStudentApiConstants.GRAD_STUDENT_OPTIONAL_PROGRAMS)
@PreAuthorize(PermissionsConstants.UPDATE_GRADUATION_STUDENT_OPTIONAL_PROGRAM)
@Operation(summary = "Create Student Optional Grad Program by Student ID", description = "Create Student Optional Grad Program by Student ID", tags = { "Optional Student Graduation Status" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<GraduationStudentRecord> createStudentGradOptionalProgram(@PathVariable UUID studentID, @RequestBody StudentOptionalProgram gradStudentOptionalProgram, @RequestParam (value = "careerProgramCode", required = false) String careerProgramCode,
@RequestHeader(name="Authorization") String accessToken) {
logger.debug("Create student Optional Grad Program for Student ID: {}", studentID);
graduationStatusService.createStudentGradOptionalProgram(studentID, gradStudentOptionalProgram, careerProgramCode);
return response.GET(graduationStatusService.getGraduationStatus(studentID, accessToken.replace(BEARER, "")));
}

@PutMapping (EducGradStudentApiConstants.GRAD_STUDENT_OPTIONAL_PROGRAM_UPDATE)
@PreAuthorize(PermissionsConstants.UPDATE_GRADUATION_STUDENT_OPTIONAL_PROGRAM)
@Operation(summary = "Update Student Optional Grad Program for Student ID", description = "Update Student Optional Grad Program for Student ID", tags = { "Optional Student Graduation Status" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<GraduationStudentRecord> updateStudentGradOptionalProgram(@PathVariable UUID studentID, @PathVariable UUID optionalProgramID, @RequestBody StudentOptionalProgram gradStudentOptionalProgram,
@RequestHeader(name="Authorization") String accessToken) {
logger.debug("Create student Optional Grad Program for Student ID: {}", studentID);
graduationStatusService.updateStudentGradOptionalProgram(studentID, optionalProgramID, gradStudentOptionalProgram);
return response.GET(graduationStatusService.getGraduationStatus(studentID, accessToken.replace(BEARER, "")));
}

@DeleteMapping (EducGradStudentApiConstants.GRAD_STUDENT_OPTIONAL_PROGRAM_DELETE)
@PreAuthorize(PermissionsConstants.UPDATE_GRADUATION_STUDENT_OPTIONAL_PROGRAM)
@Operation(summary = "Delete Student Optional Grad Program by Student ID", description = "Delete Student Optional Grad Program by Student ID", tags = { "Optional Student Graduation Status" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<GraduationStudentRecord> deleteStudentGradOptionalProgram(@PathVariable UUID studentID, @PathVariable UUID optionalProgramID, @RequestParam (value = "careerProgramCode", required = false) String careerProgramCode,
@RequestHeader(name="Authorization") String accessToken) {
logger.debug("Delete student Optional Program for Student ID: {}", studentID);
graduationStatusService.deleteStudentGradOptionalProgram(studentID, optionalProgramID, careerProgramCode);
return response.GET(graduationStatusService.getGraduationStatus(studentID, accessToken.replace(BEARER, "")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
import ca.bc.gov.educ.api.gradstudent.model.entity.GraduationStudentRecordHistoryEntity;
import ca.bc.gov.educ.api.gradstudent.service.GraduationStatusService;
import ca.bc.gov.educ.api.gradstudent.service.HistoryService;
import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants;
import ca.bc.gov.educ.api.gradstudent.util.GradValidation;
import ca.bc.gov.educ.api.gradstudent.util.PermissionsConstants;
import ca.bc.gov.educ.api.gradstudent.util.ResponseHelper;
import ca.bc.gov.educ.api.gradstudent.util.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -199,8 +196,6 @@ public ResponseEntity<GraduationStudentRecord> getDataForBatch(@PathVariable Str
return response.GET(gradStatusService.getDataForBatch(UUID.fromString(studentID),accessToken.replace(BEARER, "")));
}



@PostMapping (EducGradStudentApiConstants.GRAD_STUDENT_BY_LIST_CRITERIAS)
@PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT)
@Operation(summary = "Find Students by multiple criteria", description = "Find Students by multiple criteria", tags = { "Search Student Records" })
Expand Down Expand Up @@ -360,6 +355,16 @@ public ResponseEntity<GraduationStudentRecord> saveStudentGradStatusDistribution
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" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<ApiResponseModel<Void>> updateStudentGradHistoryStatusDistributionRun(@PathVariable Long batchID, @RequestParam(required = false) String userName) {
logger.debug("Save Distribution student Grad history for Student ID");
historyService.updateStudentRecordHistoryDistributionRun(batchID, userName);
return response.UPDATED(null);
}

@GetMapping (EducGradStudentApiConstants.STUDENT_LIST_FOR_SCHOOL_REPORT)
@PreAuthorize(PermissionsConstants.READ_GRADUATION_STUDENT)
@Operation(summary = "Get Students For School Report by mincode", description = "Get Students For School Report by mincode", tags = { "Batch Algorithm" })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ca.bc.gov.educ.api.gradstudent.exception;

public class EntityNotFoundException extends Exception {
import ca.bc.gov.educ.api.gradstudent.util.GradBusinessRuleException;

public class EntityNotFoundException extends GradBusinessRuleException {


public EntityNotFoundException() {
Expand All @@ -11,11 +13,4 @@ public EntityNotFoundException(String message) {
super(message);
}

public EntityNotFoundException(String message, Throwable cause) {
super(message, cause);
}

public EntityNotFoundException(Throwable cause) {
super(cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Data
@EqualsAndHashCode(callSuper = false)
@Component
public class GraduationStudentRecord extends BaseModel{
public class GraduationStudentRecord extends BaseModel {

private String studentGradData;
private String pen;
Expand Down Expand Up @@ -44,5 +44,6 @@ public class GraduationStudentRecord extends BaseModel{
private Date adultStartDate;

private List<StudentCareerProgram> careerPrograms;
private List<StudentOptionalProgram> optionalPrograms;
private List<GradRequirement> nonGradReasons;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Data
@EqualsAndHashCode(callSuper = false)
@Component
public class StudentOptionalProgram extends BaseModel{
public class StudentOptionalProgram extends BaseModel {

private UUID id;
private String pen;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +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.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.util.UUID;

@Data
Expand All @@ -16,6 +14,11 @@
public class StudentCareerProgramEntity extends BaseEntity {

@Id
@GeneratedValue(generator = "UUID")
@GenericGenerator(
name = "UUID",
strategy = "org.hibernate.id.UUIDGenerator"
)
@Column(name = "STUDENT_CAREER_PROGRAM_ID", nullable = false)
private UUID id;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
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 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.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import ca.bc.gov.educ.api.gradstudent.model.entity.GraduationStudentRecordHistoryEntity;
Expand All @@ -18,4 +22,9 @@ public interface GraduationStudentRecordHistoryRepository extends JpaRepository<
List<GraduationStudentRecordHistoryEntity> findByStudentID(UUID studentID);
Page<GraduationStudentRecordHistoryEntity> findByBatchId(Long batchId, Pageable paging);
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);

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,8 @@ void updateStudentGuidPenXrefRecord(

@Query("select c.studentID from GraduationStudentRecordEntity c where c.studentStatus = :statusCode and c.studentID in :studentIDList")
List<UUID> filterGivenStudentsByStatusCode(@Param("studentIDList") List<UUID> studentIDs, @Param("statusCode") String statusCode);

@Modifying
@Query("update GraduationStudentRecordEntity e set e.recalculateGradStatus = :recalculateGradStatus, e.recalculateProjectedGrad = :recalculateProjectedGrad where e.studentID = :studentGuid")
void updateGradStudentRecalculationFlags(@Param(value = "studentGuid") UUID studentGuid, @Param(value = "recalculateGradStatus") String recalculateGradStatus, @Param(value = "recalculateProjectedGrad") String recalculateProjectedGrad);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ public interface StudentCareerProgramRepository extends JpaRepository<StudentCar
List<StudentCareerProgramEntity> existsByCareerProgramCode(String cpCode);

void deleteByStudentID(UUID studentID);

void deleteStudentCareerProgramEntityByStudentIDAndCareerProgramCode(UUID studentGuid, String careerProgramCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,20 @@ private GraduationStudentRecordEntity handleNewGraduationStatus(GraduationStuden
private void populateOngoingUpdateFields(List<OngoingUpdateFieldDTO> fields, GraduationStudentRecordEntity targetObject, String accessToken) {
fields.forEach(f -> {
if (f.getName() == FieldName.GRAD_PROGRAM) {
String newProgram = (String) f.getValue();
String newProgram = getStringValue(f.getValue());
String currentProgram = targetObject.getProgram();
handleStudentAchievements(currentProgram, newProgram, targetObject, accessToken);
resetAdultStartDate(currentProgram, newProgram, targetObject);
} else if (f.getName() == FieldName.STUDENT_STATUS) {
String newStatus = getStringValue(f.getValue());
if ("MER".equals(newStatus)) {
targetObject.setStudentGradData(null);
targetObject.setStudentProjectedGradData(null);
targetObject.setRecalculateGradStatus(null);
targetObject.setRecalculateProjectedGrad(null);
log.info(" {} ==> {}: Delete Student Achievements.", targetObject.getStudentStatus(), newStatus);
graduationStatusService.deleteStudentAchievements(targetObject.getStudentID(), accessToken);
}
}
populate(f, targetObject);
});
Expand Down
Loading
Loading