Skip to content

Commit

Permalink
Fixes for duplicates logic
Browse files Browse the repository at this point in the history
  • Loading branch information
arcshiftsolutions committed Jun 5, 2024
1 parent cc991d9 commit 29d7679
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,6 @@ public Set<SdcSchoolCollectionStudentEnrolledProgramEntity> getSdcStudentEnrolle
}

public int getUniqueObjectHash() {
return Objects.hash(localID, studentPen, legalFirstName, legalMiddleNames, legalLastName, usualFirstName, usualMiddleNames, usualLastName, dob, gender, specialEducationCategoryCode, schoolFundingCode, nativeAncestryInd, homeLanguageSpokenCode, otherCourses, supportBlocks, enrolledGradeCode, enrolledProgramCodes, careerProgramCode, numberOfCourses, bandCode, postalCode);
return Objects.hash(sdcSchoolCollection.getSdcSchoolCollectionID(), localID, studentPen, legalFirstName, legalMiddleNames, legalLastName, usualFirstName, usualMiddleNames, usualLastName, dob, gender, specialEducationCategoryCode, schoolFundingCode, nativeAncestryInd, homeLanguageSpokenCode, otherCourses, supportBlocks, enrolledGradeCode, enrolledProgramCodes, careerProgramCode, numberOfCourses, bandCode, postalCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public interface SdcDuplicateRepository extends JpaRepository<SdcDuplicateEntity

Optional<SdcDuplicateEntity> findBySdcDuplicateID(UUID sdcDuplicateID);

void deleteAllBySdcDuplicateStudentEntities_SdcSchoolCollectionID(UUID sdcSchoolCollectionID);

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ public SdcSchoolCollectionService(SdcSchoolCollectionRepository sdcSchoolCollect

@Transactional(propagation = Propagation.MANDATORY)
public SdcSchoolCollectionEntity saveSdcSchoolCollection(SdcSchoolCollectionEntity curSDCSchoolEntity, List<SdcSchoolCollectionStudentEntity> finalStudents, List<UUID> removedStudents) {
log.debug("Removing duplicate records by sdcSchoolCollectionStudentIDs: {}", removedStudents);
var duplicatesToDelete = this.sdcDuplicateRepository.findAllBySdcDuplicateStudentEntities_SdcSchoolCollectionStudentEntity_SdcSchoolCollectionStudentIDIn(removedStudents);
log.debug("Removing {} duplicate records from SDC school collection: {}", duplicatesToDelete.size(), curSDCSchoolEntity.getSdcSchoolCollectionID());
this.sdcDuplicateRepository.deleteAll(duplicatesToDelete);
log.debug("Removing duplicate records for SDC school collection: {}", curSDCSchoolEntity.getSdcSchoolCollectionID());
this.sdcDuplicateRepository.deleteAllBySdcDuplicateStudentEntities_SdcSchoolCollectionID(curSDCSchoolEntity.getSdcSchoolCollectionID());

List<SdcSchoolCollectionStudentEntity> newStudents = finalStudents.stream().filter(sdcSchoolCollectionStudentEntity -> sdcSchoolCollectionStudentEntity.getSdcSchoolCollectionStudentID() == null).toList();
curSDCSchoolEntity.getSDCSchoolStudentEntities().clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ void testProcessSdcFileReUploadCompareWithDups_givenValidPayload_ShouldReturnSta
stud1.setUpdateDate(LocalDateTime.now());

SdcDuplicateStudentEntity stud2 = new SdcDuplicateStudentEntity();
stud2.setSdcSchoolCollectionID(UUID.randomUUID());
stud2.setSdcSchoolCollectionID(result.get(0).getSdcSchoolCollectionID());
stud2.setSdcDuplicateEntity(dup);
stud2.setSdcSchoolCollectionStudentEntity(students.get(1));
stud2.setCreateUser("ABC");
Expand Down

0 comments on commit 29d7679

Please sign in to comment.