Skip to content

Commit

Permalink
Merge pull request #490 from bcgov/feature/GRAD2-2325
Browse files Browse the repository at this point in the history
GRAD2-2325: hypothetical grad algorithm support is added.
  • Loading branch information
infstar authored Oct 19, 2023
2 parents f25d461 + bdd8ab6 commit 63336c9
Show file tree
Hide file tree
Showing 12 changed files with 734 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package ca.bc.gov.educ.api.graduation.controller;

import ca.bc.gov.educ.api.graduation.model.dto.EdwGraduationSnapshot;
import ca.bc.gov.educ.api.graduation.service.EdwSnapshotService;
import ca.bc.gov.educ.api.graduation.util.EducGraduationApiConstants;
import ca.bc.gov.educ.api.graduation.util.GradValidation;
import ca.bc.gov.educ.api.graduation.util.PermissionsContants;
import ca.bc.gov.educ.api.graduation.util.ResponseHelper;
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.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping(EducGraduationApiConstants.GRADUATION_API_ROOT_MAPPING)
@OpenAPIDefinition(info = @Info(title = "API for EDW Snapshot of Graduation Status", description = "This API is for EDW Snapshot of Graduation Status.", version = "1"), security = {@SecurityRequirement(name = "OAUTH2", scopes = {"GRAD_GRADUATE_STUDENT"})})
public class EdwSnapshotController {

private static final Logger LOGGER = LoggerFactory.getLogger(EdwSnapshotController.class);
private static final String BEARER = "Bearer ";

@Autowired
EdwSnapshotService edwSnapshotService;

@Autowired
GradValidation validation;

@Autowired
ResponseHelper response;

@PostMapping(EducGraduationApiConstants.EDW_GRADUATION_SNAPSHOT)
@PreAuthorize(PermissionsContants.GRADUATE_STUDENT)
@Operation(summary = "Run a Graduation snapshot for EDW", description = "Run a Graduation snapshot for EDW", tags = { "EDW Snapshot" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<EdwGraduationSnapshot> snapshotGraduationStatus(@RequestBody EdwGraduationSnapshot snapshotRequest, @RequestHeader(name="Authorization") String accessToken) {
LOGGER.debug("Snapshot Graduation Status for Student - pen# {}", snapshotRequest.getPen());
return response.GET(edwSnapshotService.processSnapshot(snapshotRequest, accessToken.replace(BEARER, "")));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package ca.bc.gov.educ.api.graduation.model.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.UUID;

import static ca.bc.gov.educ.api.graduation.util.EducGraduationApiConstants.DEFAULT_DATE_FORMAT;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class EdwGraduationSnapshot {
private UUID studentID;

private Integer gradYear;
private String pen;
private String graduationFlag;
private String honoursStanding;
private BigDecimal gpa;
private String graduatedDate;

private String nonGradReason1;
private String nonGradReason2;
private String nonGradReason3;
private String nonGradReason4;
private String nonGradReason5;
private String nonGradReason6;
private String nonGradReason7;
private String nonGradReason8;
private String nonGradReason9;
private String nonGradReason10;
private String nonGradReason11;
private String nonGradReason12;

@JsonFormat(pattern=DEFAULT_DATE_FORMAT)
private LocalDate runDate;
@JsonFormat(pattern=DEFAULT_DATE_FORMAT)
private LocalDate sessionDate;

private String schoolOfRecord;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package ca.bc.gov.educ.api.graduation.model.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.UUID;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class StudentNonGradReason {

private UUID graduationStudentRecordId;
private String pen;

private String transcriptRule1;
private String description1;
private String gradRule1;
private String projected1;

private String transcriptRule2;
private String description2;
private String gradRule2;
private String projected2;

private String transcriptRule3;
private String description3;
private String gradRule3;
private String projected3;

private String transcriptRule4;
private String description4;
private String gradRule4;
private String projected4;

private String transcriptRule5;
private String description5;
private String gradRule5;
private String projected5;

private String transcriptRule6;
private String description6;
private String gradRule6;
private String projected6;

private String transcriptRule7;
private String description7;
private String gradRule7;
private String projected7;

private String transcriptRule8;
private String description8;
private String gradRule8;
private String projected8;

private String transcriptRule9;
private String description9;
private String gradRule9;
private String projected9;

private String transcriptRule10;
private String description10;
private String gradRule10;
private String projected10;

private String transcriptRule11;
private String description11;
private String gradRule11;
private String projected11;

private String transcriptRule12;
private String description12;
private String gradRule12;
private String projected12;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,32 @@ public class AlgorithmProcessFactory {

@Autowired
GraduateStudentProcess graduateStudentProcess;

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

public AlgorithmProcess createProcess(AlgorithmProcessType processImplementation) {
AlgorithmProcess pcs = null;
switch(processImplementation.name()) {
case "REGFM":
logger.debug("\n************* PROJECTED (REGFM): Graduating Student START ************");
pcs = projectedGradFinalMarksRegistrationsProcess;
break;
case "FM":
logger.debug("\n************* PROJECTED (FM): Graduating Student START ************");
pcs = projectedGradFinalMarksProcess;
break;
case "FMR":
logger.debug("\n************* PROJECTED (FMR): Graduating Student START ************");
pcs = projectedGradFinalMarksReportsProcess;
break;
case "GS":
logger.debug("\n************* Graduating Student START ************");
pcs = graduateStudentProcess;
break;
default:
break;
}
switch (processImplementation.name()) {
case "REGFM" -> {
logger.debug("\n************* PROJECTED (REGFM): Graduating Student START ************");
pcs = projectedGradFinalMarksRegistrationsProcess;
}
case "FM" -> {
logger.debug("\n************* PROJECTED (FM): Graduating Student START ************");
pcs = projectedGradFinalMarksProcess;
}
case "FMR" -> {
logger.debug("\n************* PROJECTED (FMR): Graduating Student START ************");
pcs = projectedGradFinalMarksReportsProcess;
}
case "GS" -> {
logger.debug("\n************* Graduating Student START ************");
pcs = graduateStudentProcess;
}
default -> {
logger.debug("\n************ No matched Algorithm Process is found for {} ************", processImplementation.name());
}
}
return pcs;
}
}
Loading

0 comments on commit 63336c9

Please sign in to comment.