Skip to content

Commit

Permalink
Merge pull request #243 from bcgov/feature/fundingGroups
Browse files Browse the repository at this point in the history
Updates to return school funding groups.
  • Loading branch information
alexmcdermid authored Aug 7, 2024
2 parents 11f50d9 + c133336 commit 9364b7c
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
import ca.bc.gov.educ.api.institute.exception.EntityNotFoundException;
import ca.bc.gov.educ.api.institute.exception.InvalidPayloadException;
import ca.bc.gov.educ.api.institute.exception.errors.ApiError;
import ca.bc.gov.educ.api.institute.mapper.v1.NoteMapper;
import ca.bc.gov.educ.api.institute.mapper.v1.SchoolContactMapper;
import ca.bc.gov.educ.api.institute.mapper.v1.SchoolMapper;
import ca.bc.gov.educ.api.institute.mapper.v1.SchoolTombstoneMapper;
import ca.bc.gov.educ.api.institute.mapper.v1.*;
import ca.bc.gov.educ.api.institute.messaging.jetstream.Publisher;
import ca.bc.gov.educ.api.institute.model.v1.InstituteEvent;
import ca.bc.gov.educ.api.institute.model.v1.SchoolContactTombstoneEntity;
import ca.bc.gov.educ.api.institute.model.v1.SchoolEntity;
import ca.bc.gov.educ.api.institute.model.v1.SchoolHistoryEntity;
Expand Down Expand Up @@ -55,13 +51,18 @@ public class SchoolAPIController implements SchoolAPIEndpoint {

private static final SchoolTombstoneMapper tombstoneMapper = SchoolTombstoneMapper.mapper;

private static final IndependentSchoolFundingGroupMapper independentSchoolFundingGroupMapper = IndependentSchoolFundingGroupMapper.mapper;

private static final SchoolContactMapper schoolContactMapper = SchoolContactMapper.mapper;

private static final NoteMapper noteMapper = NoteMapper.mapper;

@Getter(AccessLevel.PRIVATE)
private final SchoolService schoolService;

@Getter(AccessLevel.PRIVATE)
private final SchoolFundingGroupService schoolFundingGroupService;

@Getter(AccessLevel.PRIVATE)
private final SchoolContactSearchService schoolContactSearchService;

Expand All @@ -79,9 +80,10 @@ public class SchoolAPIController implements SchoolAPIEndpoint {

private final NotePayloadValidator notePayloadValidator;
@Autowired
public SchoolAPIController(Publisher publisher, final SchoolService schoolService, SchoolContactSearchService schoolContactSearchService, final SchoolHistoryService schoolHistoryService, SchoolSearchService schoolSearchService, SchoolHistorySearchService schoolHistorySearchService, final SchoolPayloadValidator payloadValidator, SchoolContactPayloadValidator contactPayloadValidator, NotePayloadValidator notePayloadValidator) {
public SchoolAPIController(Publisher publisher, final SchoolService schoolService, SchoolFundingGroupService schoolFundingGroupService, SchoolContactSearchService schoolContactSearchService, final SchoolHistoryService schoolHistoryService, SchoolSearchService schoolSearchService, SchoolHistorySearchService schoolHistorySearchService, final SchoolPayloadValidator payloadValidator, SchoolContactPayloadValidator contactPayloadValidator, NotePayloadValidator notePayloadValidator) {
this.publisher = publisher;
this.schoolService = schoolService;
this.schoolFundingGroupService = schoolFundingGroupService;
this.schoolContactSearchService = schoolContactSearchService;
this.schoolHistoryService = schoolHistoryService;
this.schoolSearchService = schoolSearchService;
Expand Down Expand Up @@ -143,7 +145,7 @@ private void validatePayload(Supplier<List<FieldError>> validator) {

@Override
public List<SchoolTombstone> getAllSchools() {
return getSchoolService().getAllSchoolsList().stream().map(tombstoneMapper::toStructure).collect(Collectors.toList());
return getSchoolService().getAllSchoolsList().stream().map(tombstoneMapper::toStructure).toList();
}

@Override
Expand Down Expand Up @@ -211,6 +213,11 @@ public CompletableFuture<Page<SchoolContact>> findAllContacts(Integer pageNumber
return this.schoolContactSearchService.findAll(schoolSpecs, pageNumber, pageSize, sorts).thenApplyAsync(schoolEntities -> schoolEntities.map(schoolContactMapper::toStructure));
}

@Override
public List<IndependentSchoolFundingGroup> getAllSchoolFundingGroups() {
return getSchoolFundingGroupService().getAllSchoolFundingGroups().stream().map(independentSchoolFundingGroupMapper::toStructure).toList();
}

@Override
public Note updateSchoolNote(UUID schoolId, UUID noteId, Note note) {
validatePayload(() -> this.notePayloadValidator.validateUpdatePayload(note));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,12 @@ CompletableFuture<Page<SchoolContact>> findAllContacts(@RequestParam(name = "pag
@RequestParam(name = "sort", defaultValue = "") String sortCriteriaJson,
@RequestParam(name = "searchCriteriaList", required = false) String searchCriteriaListJson);

@GetMapping("/funding-groups")
@PreAuthorize("hasAuthority('SCOPE_READ_SCHOOL')")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
@Transactional(readOnly = true)
@Tag(name = "School Entity", description = "Endpoints for school entity.")
@Schema(name = "IndependentSchoolFundingGroup", implementation = IndependentSchoolFundingGroup.class)
List<IndependentSchoolFundingGroup> getAllSchoolFundingGroups();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ca.bc.gov.educ.api.institute.service.v1;

import ca.bc.gov.educ.api.institute.model.v1.IndependentSchoolFundingGroupEntity;
import ca.bc.gov.educ.api.institute.repository.v1.IndependentSchoolFundingGroupRepository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SchoolFundingGroupService {

private final IndependentSchoolFundingGroupRepository independentSchoolFundingGroupRepository;

public SchoolFundingGroupService(IndependentSchoolFundingGroupRepository independentSchoolFundingGroupRepository) {
this.independentSchoolFundingGroupRepository = independentSchoolFundingGroupRepository;
}

public List<IndependentSchoolFundingGroupEntity> getAllSchoolFundingGroups() {
return independentSchoolFundingGroupRepository.findAll();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ca.bc.gov.educ.api.institute.struct.v1;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@SuppressWarnings("squid:S1700")
public class SchoolFundingGroup implements Serializable {

private static final long serialVersionUID = 6118916290604876032L;

private String schoolId;

private String schoolFundingGroupCode;

private String label;

private String description;

private Integer displayOrder;

private String effectiveDate;

private String expiryDate;
}
Loading

0 comments on commit 9364b7c

Please sign in to comment.