Skip to content

Commit

Permalink
96, 97 school condition fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SodhiA1 committed Nov 30, 2023
1 parent ef3c3b3 commit 25742df
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ private SchoolEntity createSchoolHelper(School school) {
schoolEntity.setSchoolNumber(schoolNumberGenerationService.generateSchoolNumber(district.get().getDistrictNumber(),
school.getFacilityTypeCode(), school.getSchoolCategoryCode(),
school.getIndependentAuthorityId()));
} else {
throw new EntityNotFoundException(DistrictTombstoneEntity.class, school.getDistrictId());
}

schoolEntity.getAddresses().stream().forEach(address -> {
Expand Down Expand Up @@ -445,24 +447,22 @@ private SchoolEntity moveSchoolHelper(School school, School existingSchool) {
UUID.fromString(school.getDistrictId()));
if (district.isPresent()) {
schoolEntity.setDistrictEntity(district.get());
}

if (district.isPresent()) {
List<SchoolEntity> schools = schoolRepository.findBySchoolNumberAndDistrictID(
school.getSchoolNumber(), UUID.fromString(school.getDistrictId()));

if(school.getSchoolCategoryCode().equals(existingSchool.getSchoolCategoryCode()) &&
!school.getSchoolCategoryCode().equals(Constants.INDEPENDENT) && !school.getSchoolCategoryCode().equals(Constants.NONINDEPENDENT)
&& !school.getSchoolCategoryCode().equals(Constants.INDEPENDENTFNS) && !school.getSchoolCategoryCode().equals(Constants.OFFSHORE)
&& schools.isEmpty()) {
if(school.getSchoolCategoryCode().equals(existingSchool.getSchoolCategoryCode()) && schools.isEmpty()) {
schoolEntity.setSchoolNumber(school.getSchoolNumber());
} else {
schoolEntity.setSchoolNumber(
schoolNumberGenerationService.generateSchoolNumber(district.get().getDistrictNumber(),
school.getFacilityTypeCode(), school.getSchoolCategoryCode(),
school.getIndependentAuthorityId()));
}
} else {
throw new EntityNotFoundException(DistrictTombstoneEntity.class, school.getDistrictId());
}

schoolEntity.getAddresses().stream().forEach(address -> {
RequestUtil.setAuditColumnsForAddress(address);
TransformUtil.uppercaseFields(address);
Expand Down

0 comments on commit 25742df

Please sign in to comment.