Skip to content

Commit

Permalink
Merge pull request #302 from bcgov/grad-release
Browse files Browse the repository at this point in the history
Grad release 1.21.0
  • Loading branch information
githubmamatha authored Jun 19, 2024
2 parents 266faae + ee05327 commit 44fb861
Show file tree
Hide file tree
Showing 31 changed files with 1,143 additions and 13 deletions.
8 changes: 7 additions & 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-course-api</artifactId>
<version>1.8.41</version>
<version>1.8.42</version>
<name>educ-grad-course-api</name>
<description>Ministry of Education GRAD Course API</description>

Expand Down Expand Up @@ -51,6 +51,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>8.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package ca.bc.gov.educ.api.course.config;

import ca.bc.gov.educ.api.course.exception.EntityNotFoundException;
import ca.bc.gov.educ.api.course.exception.GradBusinessRuleException;
import ca.bc.gov.educ.api.course.util.ApiResponseMessage.MessageTypeEnum;
import ca.bc.gov.educ.api.course.util.ApiResponseModel;
import ca.bc.gov.educ.api.course.util.GradValidation;
import org.hibernate.dialect.lock.OptimisticEntityLockException;
import org.hibernate.exception.ConstraintViolationException;
import org.jboss.logging.Logger;
Expand All @@ -15,11 +20,6 @@
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

import ca.bc.gov.educ.api.course.util.ApiResponseMessage.MessageTypeEnum;
import ca.bc.gov.educ.api.course.util.ApiResponseModel;
import ca.bc.gov.educ.api.course.exception.GradBusinessRuleException;
import ca.bc.gov.educ.api.course.util.GradValidation;

@ControllerAdvice
public class RestErrorHandler extends ResponseEntityExceptionHandler {

Expand Down Expand Up @@ -55,16 +55,17 @@ protected ResponseEntity<Object> handleAuthorizationErrors(Exception ex, WebRequ
return new ResponseEntity<>(ApiResponseModel.ERROR(null, message), HttpStatus.FORBIDDEN);
}

@ExceptionHandler(value = { GradBusinessRuleException.class })
protected ResponseEntity<Object> handleIrisBusinessException(Exception ex, WebRequest request) {
ApiResponseModel<?> response = ApiResponseModel.ERROR(null);
@ExceptionHandler(value = { GradBusinessRuleException.class, EntityNotFoundException.class })
protected ResponseEntity<Object> handleGradBusinessException(Exception ex, WebRequest request) {
ApiResponseModel<?> response = ApiResponseModel.ERROR(request.toString());
validation.ifErrors(response::addErrorMessages);
validation.ifWarnings(response::addWarningMessages);
if (response.getMessages().isEmpty()) {
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 @@ -6,7 +6,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeStrategies;
import org.springframework.web.reactive.function.client.WebClient;
Expand All @@ -17,7 +16,6 @@
import java.time.Duration;

@Configuration
@Profile("!test")
public class RestWebClient {
@Autowired
EducCourseApiConstants constants;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package ca.bc.gov.educ.api.course.controller;

import ca.bc.gov.educ.api.course.model.dto.EquivalentOrChallengeCode;
import ca.bc.gov.educ.api.course.service.EquivalentOrChallengeCodeService;
import ca.bc.gov.educ.api.course.util.EducCourseApiConstants;
import ca.bc.gov.educ.api.course.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.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(EducCourseApiConstants.GRAD_COURSE_API_ROOT_MAPPING)
@OpenAPIDefinition(info = @Info(title = "API for Student Course Data.", description = "This API is for Reading Student Course data.", version = "1"),
security = {@SecurityRequirement(name = "OAUTH2", scopes = {"READ_GRAD_STUDENT_COURSE_DATA"})})
public class EquivalentOrChallengeCodeController {

final EquivalentOrChallengeCodeService equivalentOrChallengeCodeService;

public EquivalentOrChallengeCodeController(EquivalentOrChallengeCodeService equivalentOrChallengeCodeService) {
this.equivalentOrChallengeCodeService = equivalentOrChallengeCodeService;
}

@GetMapping(EducCourseApiConstants.EQUIVALENT_OR_CHALLENGE_CODES_MAPPING)
@PreAuthorize(PermissionsConstants.READ_EQUIVALENT_OR_CHALLENGE_CODE)
@Operation(summary = "Find All Equivalent Or Challenge Codes", description = "Find All Equivalent Or Challenge Codes", tags = {"Equivalent Or Challenge Codes"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<List<EquivalentOrChallengeCode>> getEquivalentOrChallengeCodes() {
return ResponseEntity.ok().body(equivalentOrChallengeCodeService.getEquivalentOrChallengeCodeList());
}

@GetMapping(EducCourseApiConstants.EQUIVALENT_OR_CHALLENGE_CODE_MAPPING)
@PreAuthorize(PermissionsConstants.READ_EQUIVALENT_OR_CHALLENGE_CODE)
@Operation(summary = "Find Equivalent Or Challenge Code", description = "Find Equivalent Or Challenge Code", tags = {"Equivalent Or Challenge Code"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "NOT FOUND")})
public ResponseEntity<EquivalentOrChallengeCode> getEquivalentOrChallengeCode(@PathVariable String equivalentOrChallengeCode) {
return ResponseEntity.ok().body(equivalentOrChallengeCodeService.getEquivalentOrChallengeCode(equivalentOrChallengeCode));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package ca.bc.gov.educ.api.course.controller;

import ca.bc.gov.educ.api.course.model.dto.ExamSpecialCaseCode;
import ca.bc.gov.educ.api.course.service.ExamSpecialCaseCodeService;
import ca.bc.gov.educ.api.course.util.EducCourseApiConstants;
import ca.bc.gov.educ.api.course.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.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(EducCourseApiConstants.GRAD_COURSE_API_ROOT_MAPPING)
@OpenAPIDefinition(info = @Info(title = "API for Student Course Data.", description = "This API is for Reading Student Course data.", version = "1"),
security = {@SecurityRequirement(name = "OAUTH2", scopes = {"READ_GRAD_STUDENT_COURSE_DATA"})})
public class ExamSpecialCaseCodeController {

final ExamSpecialCaseCodeService examSpecialCaseCodeService;

public ExamSpecialCaseCodeController(ExamSpecialCaseCodeService examSpecialCaseCodeService) {
this.examSpecialCaseCodeService = examSpecialCaseCodeService;
}

@GetMapping(EducCourseApiConstants.EXAM_SPECIAL_CASE_CODES_MAPPING)
@PreAuthorize(PermissionsConstants.READ_EXAM_SPECIAL_CASE_CODE)
@Operation(summary = "Find All Exam Special Case Codes", description = "Find All Exam Special Case Codes", tags = {"Exam Special Case Codes"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<List<ExamSpecialCaseCode>> getExamSpecialCaseCodes() {
return ResponseEntity.ok().body(examSpecialCaseCodeService.getExamSpecialCaseCodeList());
}

@GetMapping(EducCourseApiConstants.EXAM_SPECIAL_CASE_CODE_MAPPING)
@PreAuthorize(PermissionsConstants.READ_EXAM_SPECIAL_CASE_CODE)
@Operation(summary = "Find Exam Special Case Code", description = "Find Exam Special Case Code", tags = {"Exam Special Case Code"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "NOT FOUND")})
public ResponseEntity<ExamSpecialCaseCode> getExamSpecialCaseCode(@PathVariable String examSpecialCaseCode) {
return ResponseEntity.ok().body(examSpecialCaseCodeService.getExamSpecialCaseCode(examSpecialCaseCode));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package ca.bc.gov.educ.api.course.controller;

import ca.bc.gov.educ.api.course.model.dto.FineArtsAppliedSkillsCode;
import ca.bc.gov.educ.api.course.service.FineArtsAppliedSkillsCodeService;
import ca.bc.gov.educ.api.course.util.EducCourseApiConstants;
import ca.bc.gov.educ.api.course.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.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(EducCourseApiConstants.GRAD_COURSE_API_ROOT_MAPPING)
@OpenAPIDefinition(info = @Info(title = "API for Student Course Data.", description = "This API is for Reading Student Course data.", version = "1"),
security = {@SecurityRequirement(name = "OAUTH2", scopes = {"READ_GRAD_STUDENT_COURSE_DATA"})})
public class FineArtsAppliedSkillsCodeController {

final FineArtsAppliedSkillsCodeService fineArtsAppliedSkillsCodeService;

public FineArtsAppliedSkillsCodeController(FineArtsAppliedSkillsCodeService fineArtsAppliedSkillsCodeService) {
this.fineArtsAppliedSkillsCodeService = fineArtsAppliedSkillsCodeService;
}

@GetMapping(EducCourseApiConstants.FINE_ART_APPLIED_SKILLS_CODES_MAPPING)
@PreAuthorize(PermissionsConstants.READ_FINE_ART_APPLIED_SKILLS_CODE)
@Operation(summary = "Find All Fine Arts Applied Skills Codes", description = "Find All Fine Arts Applied Skills Codes", tags = {"Fine Arts Applied Skills Codes"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<List<FineArtsAppliedSkillsCode>> getFineArtsAppliedSkillsCodes() {
return ResponseEntity.ok().body(fineArtsAppliedSkillsCodeService.getFineArtsAppliedSkillsCodeList());
}

@GetMapping(EducCourseApiConstants.FINE_ART_APPLIED_SKILLS_CODE_MAPPING)
@PreAuthorize(PermissionsConstants.READ_FINE_ART_APPLIED_SKILLS_CODE)
@Operation(summary = "Find Fine Arts Applied Skills Code", description = "Find Fine Arts Applied Skills Code", tags = {"Fine Arts Applied Skills Code"})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "NOT FOUND")})
public ResponseEntity<FineArtsAppliedSkillsCode> getFineArtsAppliedSkillsCode(@PathVariable String fineArtsAppliedSkillsCode) {
return ResponseEntity.ok().body(fineArtsAppliedSkillsCodeService.getFineArtsAppliedSkillsCode(fineArtsAppliedSkillsCode));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ca.bc.gov.educ.api.course.exception;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.IntStream;
Expand All @@ -17,6 +18,10 @@ public EntityNotFoundException(Class<?> clazz, String... searchParamsMap) {
super(EntityNotFoundException.generateMessage(clazz.getSimpleName(), toMap(String.class, String.class, searchParamsMap)));
}

public EntityNotFoundException(String message) {
super(message);
}

private static String generateMessage(String entity, Map<String, String> searchParams) {
return StringUtils.capitalize(entity) +
" was not found for parameters " +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package ca.bc.gov.educ.api.course.model.dto;

import ca.bc.gov.educ.api.course.model.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigInteger;
import java.sql.Date;

@Data
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "EQUIVALENT_OR_CHALLENGE_CODE")
public class EquivalentOrChallengeCode extends BaseEntity {

@Id
@Column(name = "EQUIVALENT_OR_CHALLENGE_CODE", nullable = false)
private String equivalentOrChallengeCode;

@Column(name = "LABEL", nullable = false, length = 50)
private String label;

@Column(name = "DESCRIPTION", nullable = false, length = 355)
private String description;

@Column(name = "DISPLAY_ORDER", nullable = false, precision = 0)
private BigInteger displayOrder;

@Column(name = "EFFECTIVE_DATE", nullable = false)
private Date effectiveDate;

@Column(name = "EXPIRY_DATE", nullable = true)
private Date expiryDate;

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

import ca.bc.gov.educ.api.course.model.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigInteger;
import java.sql.Date;

@Data
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "EXAM_SPECIAL_CASE_CODE")
public class ExamSpecialCaseCode extends BaseEntity {

@Id
@Column(name = "EXAM_SPECIAL_CASE_CODE", nullable = false)
private String examSpecialCaseCode;

@Column(name = "LABEL", nullable = false, length = 50)
private String label;

@Column(name = "DESCRIPTION", nullable = false, length = 355)
private String description;

@Column(name = "DISPLAY_ORDER", nullable = false, precision = 0)
private BigInteger displayOrder;

@Column(name = "EFFECTIVE_DATE", nullable = false)
private Date effectiveDate;

@Column(name = "EXPIRY_DATE", nullable = true)
private Date expiryDate;

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

import ca.bc.gov.educ.api.course.model.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigInteger;
import java.sql.Date;

@Data
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "FINE_ARTS_APPLIED_SKILLS_CODE")
public class FineArtsAppliedSkillsCode extends BaseEntity {

@Id
@Column(name = "FINE_ARTS_APPLIED_SKILLS_CODE", nullable = false)
private String fineArtsAppliedSkillsCode;

@Column(name = "LABEL", nullable = false, length = 50)
private String label;

@Column(name = "DESCRIPTION", nullable = false, length = 355)
private String description;

@Column(name = "DISPLAY_ORDER", nullable = false, precision = 0)
private BigInteger displayOrder;

@Column(name = "EFFECTIVE_DATE", nullable = false)
private Date effectiveDate;

@Column(name = "EXPIRY_DATE", nullable = true)
private Date expiryDate;

}
Loading

0 comments on commit 44fb861

Please sign in to comment.