-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added update cache for school and district UD events. * Updated test cases for School and District CD * Added Create District functionality * Added Create District to event handler * Added thread sleep for not fully processed school moved events. * Changed exception handling * Reducing code duplication --------- Co-authored-by: chris.ditcher <[email protected]>
- Loading branch information
Showing
16 changed files
with
289 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
api/src/main/java/ca/bc/gov/educ/api/trax/service/DistrictContactCreatedService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
api/src/main/java/ca/bc/gov/educ/api/trax/service/DistrictContactDeletedService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
api/src/main/java/ca/bc/gov/educ/api/trax/service/DistrictContactEventBaseService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ca.bc.gov.educ.api.trax.service; | ||
|
||
|
||
import ca.bc.gov.educ.api.trax.exception.ServiceException; | ||
import ca.bc.gov.educ.api.trax.model.dto.DistrictContact; | ||
import ca.bc.gov.educ.api.trax.model.entity.EventEntity; | ||
import ca.bc.gov.educ.api.trax.service.institute.DistrictService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public abstract class DistrictContactEventBaseService extends EventBaseService<DistrictContact> { | ||
|
||
protected DistrictService districtService; | ||
|
||
protected DistrictContactEventBaseService(DistrictService districtService) { | ||
this.districtService = districtService; | ||
} | ||
|
||
@Override | ||
public void processEvent(DistrictContact districtContact, EventEntity eventEntity) {log.debug("Processing {}", eventEntity.getEventType()); | ||
try { | ||
districtService.updateDistrictCache(districtContact.getDistrictId()); | ||
this.updateEvent(eventEntity); | ||
} catch (ServiceException e) { | ||
// do not mark eventEntity as processed | ||
log.error(e.getMessage()); | ||
} | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
api/src/main/java/ca/bc/gov/educ/api/trax/service/DistrictCreatedService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package ca.bc.gov.educ.api.trax.service; | ||
|
||
import ca.bc.gov.educ.api.trax.constant.EventType; | ||
import ca.bc.gov.educ.api.trax.exception.ServiceException; | ||
import ca.bc.gov.educ.api.trax.model.dto.institute.District; | ||
import ca.bc.gov.educ.api.trax.model.entity.EventEntity; | ||
import ca.bc.gov.educ.api.trax.service.institute.DistrictService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public class DistrictCreatedService extends EventBaseService<District> { | ||
|
||
DistrictService districtService; | ||
|
||
@Autowired | ||
public DistrictCreatedService(DistrictService districtService) { | ||
this.districtService = districtService; | ||
} | ||
|
||
@Override | ||
public void processEvent(final District district, EventEntity eventEntity) { | ||
log.debug("Processing District Created"); | ||
try{ | ||
districtService.updateDistrictCache(district.getDistrictId()); | ||
this.updateEvent(eventEntity); | ||
} catch (ServiceException e) { | ||
log.error(e.getMessage()); | ||
} | ||
} | ||
|
||
@Override | ||
public String getEventType() { | ||
return EventType.CREATE_DISTRICT.toString(); | ||
} | ||
|
||
} |
14 changes: 6 additions & 8 deletions
14
api/src/main/java/ca/bc/gov/educ/api/trax/service/SchoolContactCreatedService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 7 additions & 8 deletions
15
api/src/main/java/ca/bc/gov/educ/api/trax/service/SchoolContactDeletedService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
api/src/main/java/ca/bc/gov/educ/api/trax/service/SchoolContactEventBaseService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ca.bc.gov.educ.api.trax.service; | ||
|
||
|
||
import ca.bc.gov.educ.api.trax.exception.ServiceException; | ||
import ca.bc.gov.educ.api.trax.model.dto.SchoolContact; | ||
import ca.bc.gov.educ.api.trax.model.entity.EventEntity; | ||
import ca.bc.gov.educ.api.trax.service.institute.SchoolService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public abstract class SchoolContactEventBaseService extends EventBaseService<SchoolContact> { | ||
|
||
protected SchoolService schoolService; | ||
|
||
protected SchoolContactEventBaseService(SchoolService schoolService) { | ||
this.schoolService = schoolService; | ||
} | ||
|
||
@Override | ||
public void processEvent(SchoolContact schoolContact, EventEntity eventEntity) { | ||
log.debug("Processing {}", eventEntity.getEventType()); | ||
try { | ||
schoolService.updateSchoolCache(schoolContact.getSchoolId()); | ||
this.updateEvent(eventEntity); | ||
} catch (ServiceException e) { | ||
// do not mark eventEntity as processed | ||
log.error(e.getMessage()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.