Skip to content

Commit

Permalink
Merge pull request #324 from bcgov/grad-release
Browse files Browse the repository at this point in the history
Grad release 1.19.0
  • Loading branch information
githubmamatha authored May 23, 2024
2 parents 374ee38 + d297cab commit 23562a3
Show file tree
Hide file tree
Showing 35 changed files with 813 additions and 154 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/build.from.main.branch.deploy.to.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ env:
MAX_MEM: "2200Mi"
MIN_REPLICAS: "3"
MAX_REPLICAS: "5"
SOAM_KC_REALM_ID: "master"

on:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows
Expand Down Expand Up @@ -127,6 +128,16 @@ jobs:
${{ env.BUSINESS_NAMESPACE }} \
${{ secrets.SPLUNK_TOKEN }} \
${{ vars.APP_LOG_LEVEL }}
# UPDATE KC Client
curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-kc-client.sh \
| bash /dev/stdin \
dev \
${{ env.COMMON_NAMESPACE }} \
${{ env.SOAM_KC_REALM_ID }} \
${{ secrets.CLIENT_ID }} \
${{ env.BRANCH }} \
${{ env.REPO_NAME }}
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.SPRING_BOOT_IMAGE_NAME }} 2> /dev/null \
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/build.from.release.branch.deploy.to.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ env:
MAX_MEM: "2200Mi"
MIN_REPLICAS: "3"
MAX_REPLICAS: "5"
SOAM_KC_REALM_ID: "master"

on:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows
Expand Down Expand Up @@ -134,6 +135,16 @@ jobs:
${{ env.BUSINESS_NAMESPACE }} \
${{ secrets.SPLUNK_TOKEN }} \
${{ vars.APP_LOG_LEVEL }}
# UPDATE KC Client
curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-kc-client.sh \
| bash /dev/stdin \
dev \
${{ env.COMMON_NAMESPACE }} \
${{ env.SOAM_KC_REALM_ID }} \
${{ secrets.CLIENT_ID }} \
${{ env.BRANCH }} \
${{ env.REPO_NAME }}
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.SPRING_BOOT_IMAGE_NAME }} 2> /dev/null \
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ env:
MAX_MEM: "2200Mi"
MIN_REPLICAS: "3"
MAX_REPLICAS: "5"
SOAM_KC_REALM_ID: "master"

on:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows
Expand Down Expand Up @@ -83,6 +84,16 @@ jobs:
${{ secrets.SPLUNK_TOKEN }} \
${{ vars.APP_LOG_LEVEL }}
# UPDATE KC Client
curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-kc-client.sh \
| bash /dev/stdin \
prod \
${{ env.COMMON_NAMESPACE }} \
${{ env.SOAM_KC_REALM_ID }} \
${{ secrets.CLIENT_ID }} \
${{ env.BRANCH }} \
${{ env.REPO_NAME }}
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.SPRING_BOOT_IMAGE_NAME }} 2> /dev/null \
|| true && echo "Rollout in progress"
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/deploy_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ env:
MAX_MEM: "2200Mi"
MIN_REPLICAS: "3"
MAX_REPLICAS: "5"
SOAM_KC_REALM_ID: "master"

on:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows
Expand Down Expand Up @@ -83,6 +84,16 @@ jobs:
${{ secrets.SPLUNK_TOKEN }} \
${{ vars.APP_LOG_LEVEL }}
# UPDATE KC Client
curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-kc-client.sh \
| bash /dev/stdin \
test \
${{ env.COMMON_NAMESPACE }} \
${{ env.SOAM_KC_REALM_ID }} \
${{ secrets.CLIENT_ID }} \
${{ env.BRANCH }} \
${{ env.REPO_NAME }}
# Start rollout (if necessary) and follow it
oc rollout latest dc/${{ env.SPRING_BOOT_IMAGE_NAME }} 2> /dev/null \
|| true && echo "Rollout in progress"
Expand Down
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-trax-api</artifactId>
<version>1.8.53</version>
<version>1.8.54</version>
<name>educ-grad-trax-api</name>
<description>Ministry of Education GRAD TRAX API</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientProvider;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientProviderBuilder;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizedClientManager;
import org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository;
import org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.ExchangeStrategies;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.netty.http.client.HttpClient;

Expand All @@ -44,6 +52,33 @@ public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}

@Bean("traxClient")
public WebClient getTraxClientWebClient(OAuth2AuthorizedClientManager authorizedClientManager) {
ServletOAuth2AuthorizedClientExchangeFilterFunction filter = new ServletOAuth2AuthorizedClientExchangeFilterFunction(authorizedClientManager);
filter.setDefaultClientRegistrationId("traxclient");
return WebClient.builder()
.exchangeStrategies(ExchangeStrategies
.builder()
.codecs(codecs -> codecs
.defaultCodecs()
.maxInMemorySize(50 * 1024 * 1024))
.build())
.apply(filter.oauth2Configuration())
.build();
}
@Bean
public OAuth2AuthorizedClientManager authorizedClientManager(
ClientRegistrationRepository clientRegistrationRepository,
OAuth2AuthorizedClientRepository authorizedClientRepository) {
OAuth2AuthorizedClientProvider authorizedClientProvider = OAuth2AuthorizedClientProviderBuilder.builder()
.clientCredentials()
.build();
DefaultOAuth2AuthorizedClientManager authorizedClientManager = new DefaultOAuth2AuthorizedClientManager(
clientRegistrationRepository, authorizedClientRepository);
authorizedClientManager.setAuthorizedClientProvider(authorizedClientProvider);
return authorizedClientManager;
}

@Bean
public WebClient webClient() {
//extend buffer to 50MB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public enum EventType {
NEWSTUDENT,
UPD_DEMOG,
UPD_GRAD,
UPD_STD_STATUS,
XPROGRAM,
ASSESSMENT,
COURSE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
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;
Expand All @@ -28,10 +26,6 @@
security = {@SecurityRequirement(name = "OAUTH2", scopes = {"READ_GRAD_SCHOOL_DATA"})})
public class DistrictController {

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

private static final String BEARER = "Bearer ";

@Autowired
DistrictService districtService;

Expand Down Expand Up @@ -61,7 +55,7 @@ public ResponseEntity<District> getDistrictDetails(@PathVariable String distCode
@Operation(summary = "Check school existence by Mincode", description = "Check school existence by Mincode", tags = { "School" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "204", description = "NO CONTENT")})
public ResponseEntity<List<District>> getDistrictBySchoolCategory(@RequestParam(required = false) String schoolCategory, @RequestHeader(name="Authorization") String accessToken) {
return response.GET(districtService.getDistrictBySchoolCategory(schoolCategory, accessToken.replace(BEARER, "")));
public ResponseEntity<List<District>> getDistrictBySchoolCategory(@RequestParam(required = false) String schoolCategory) {
return response.GET(districtService.getDistrictBySchoolCategory(schoolCategory));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.bc.gov.educ.api.trax.controller;

import ca.bc.gov.educ.api.trax.model.dto.CommonSchool;
import ca.bc.gov.educ.api.trax.model.dto.School;
import ca.bc.gov.educ.api.trax.service.SchoolService;
import ca.bc.gov.educ.api.trax.util.EducGradTraxApiConstants;
Expand All @@ -12,6 +13,7 @@
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 lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -23,30 +25,32 @@

@CrossOrigin
@RestController
@Slf4j
@RequestMapping(EducGradTraxApiConstants.GRAD_SCHOOL_URL_MAPPING)
@OpenAPIDefinition(info = @Info(title = "API for School Data.", description = "This Read API is for Reading school data.", version = "1"),
security = {@SecurityRequirement(name = "OAUTH2", scopes = {"READ_GRAD_SCHOOL_DATA"})})
public class SchoolController {

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

private static final String BEARER = "Bearer ";

@Autowired

SchoolService schoolService;

@Autowired
GradValidation validation;

@Autowired
ResponseHelper response;

@Autowired
public SchoolController(SchoolService schoolService, GradValidation validation, ResponseHelper response) {
this.schoolService = schoolService;
this.validation = validation;
this.response = response;
}

@GetMapping
@PreAuthorize(PermissionsConstants.READ_SCHOOL_DATA)
@Operation(summary = "Find All Schools", description = "Get All Schools", tags = { "School" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public List<School> getAllSchools() {
logger.debug("getAllSchools : ");
log.debug("getAllSchools : ");
return schoolService.getSchoolList();
}

Expand All @@ -57,14 +61,36 @@ public List<School> getAllSchools() {
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "204", description = "NO CONTENT")})
public ResponseEntity<School> getSchoolDetails(@PathVariable String minCode, @RequestHeader(name="Authorization") String accessToken) {
logger.debug("getSchoolDetails : ");
log.debug("getSchoolDetails : ");
School schoolResponse = schoolService.getSchoolDetails(minCode, accessToken.replace(BEARER, ""));
if(schoolResponse != null) {
return response.GET(schoolResponse);
}else {
return response.NOT_FOUND();
}
}

@GetMapping(EducGradTraxApiConstants.GET_COMMON_SCHOOLS)
@PreAuthorize(PermissionsConstants.READ_SCHOOL_DATA)
@Operation(summary = "Get all common schools", description = "Get a list of all common schools", tags = { "School" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
public ResponseEntity<List<CommonSchool>> getAllCommonSchool() {
return response.GET(schoolService.getCommonSchools());
}

@GetMapping(EducGradTraxApiConstants.GET_COMMON_SCHOOL_BY_CODE_MAPPING)
@PreAuthorize(PermissionsConstants.READ_SCHOOL_DATA)
@Operation(summary = "Find a Common School by Mincode", description = "Get a Common School by Mincode", tags = { "School" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "NOT FOUND")})
public ResponseEntity<CommonSchool> getCommonSchool(@PathVariable String minCode) {
CommonSchool schoolResponse = schoolService.getCommonSchool(minCode);
if(schoolResponse != null) {
return response.GET(schoolResponse);
}else {
return response.NOT_FOUND();
}
}

@GetMapping(EducGradTraxApiConstants.GET_SCHOOL_SEARCH_MAPPING)
@PreAuthorize(PermissionsConstants.READ_SCHOOL_DATA)
Expand Down Expand Up @@ -94,6 +120,6 @@ public ResponseEntity<Boolean> checkSchoolExists(@PathVariable String minCode) {
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "204", description = "NO CONTENT")})
public ResponseEntity<List<School>> getSchoolsBySchoolCategory(@RequestParam(required = false) String schoolCategory, @RequestHeader(name="Authorization") String accessToken) {
return response.GET(schoolService.getSchoolsBySchoolCategory(schoolCategory, accessToken.replace(BEARER, "")));
return response.GET(schoolService.getSchoolsBySchoolCategory(schoolCategory));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ public class TraxGraduationUpdateDTO extends TraxStudentUpdateDTO {
private String slpDate;
// STUD_CITIZ
private String citizenship;
// STUD_STATUS
private String studentStatus;
// ARCHIVE_FLAG
private String archiveFlag;

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class DistrictService {
private SchoolService schoolService;

@SuppressWarnings("unused")
private static Logger logger = LoggerFactory.getLogger(DistrictService.class);
private static final Logger logger = LoggerFactory.getLogger(DistrictService.class);

public District getDistrictDetails(String districtCode) {
Optional<DistrictEntity> distEntityOptional = districtRepository.findById(districtCode);
Expand All @@ -41,13 +41,13 @@ public List<District> getDistrictsByActiveFlag(String activeFlag) {
return districtTransformer.transformToDTO(districtRepository.findByActiveFlag(activeFlag));
}

public List<District> getDistrictBySchoolCategory(String schoolCategoryCode, String accessToken) {
public List<District> getDistrictBySchoolCategory(String schoolCategoryCode) {
List<District> result = new ArrayList<>();
if(StringUtils.isBlank(schoolCategoryCode)) {
return getDistrictsByActiveFlag("Y");
} else {
List<String> controlList = new ArrayList<>();
List<CommonSchool> schools = schoolService.getCommonSchools(accessToken);
List<CommonSchool> schools = schoolService.getCommonSchools();
for (CommonSchool s : schools) {
if (StringUtils.equalsIgnoreCase(schoolCategoryCode, s.getSchoolCategoryCode()) && !controlList.contains(s.getDistNo())) {
controlList.add(s.getDistNo());
Expand Down
Loading

0 comments on commit 23562a3

Please sign in to comment.