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

Updates to return school funding groups. #243

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading