...
Class | Module | Notes | ||||||
---|---|---|---|---|---|---|---|---|
ApplicationStartupListener | opensrp-web | This is an implementation of the Spring ApplicationListener that listens for the web app context refresh event. It's in this class that an events processing repeating schedule is wired with the event subject EVENTS-SCHEDULE. Using MotechSchedulerService class a repeating job is started here to run every two minutes. After every two minutes the job emits the "EVENTS-SCHECULE" event subject which is consumed by the EventsListener class. | ||||||
EventsListener | opensrp-core | This class consumes the event emitted by the repeating job configured in the ApplicationStartupListener class by adding @MotechListener(subjects =AllConstants.EVENTS_SCHEDULE_SUBJECT) annotation to the processEvent method. It's in this method that the latest events are fetched and forwarded to the EventsRouter. To keep track of the last processed events, an app_state_token(EVENTS_PARSER_LAST_PROCESSED_EVENT) is created in the ConfigService and set to save the last processed event version value in the couch database. | ||||||
| opensrp-core | In this class IHandlerMapper implementation (EventsHandlerMapper in opensrp-register module) is injected. EventsHandlerMapper contains a Java util map of schedule handlers instances whereby the key is the name of the handler class and the value is the autowired instance of the handler class. Having loaded the events handlermapper, in the route(Event _event) method of the EventsRouter class, getScheduleConfigs() method is called to iterate through the schedule configs folder and read all the files concatenating them into a JSONArray object for easier processing. With the scheduleconfigs JSONArray, the route method iterates through this array to retrieve each of the scheduleconfig JSON objects (either the enroll, unenroll or fulfill JSON object) passing the object to processScheduleConfigEvents() which compares the events specified in the types JSON key with the current event from the EventsListener class. If a match is found, the event from the EventsListener class is forwarded to the respective schedule handler in the handlermap for processing. | ||||||
| opensrp-register | ScheduleHandlers are the classes that have the logic that determines further if an event qualifies a client to joining a schedule and extend BaseScheduleHandler abstract class. The handle method has two parameters: event (the event from couchdb) and scheduleConfigEvent (the JSON object from the scheduleconfig file events key). Using these two params, evaluateEvent() method in the BaseScheduleHandler is called to determine if the conditions specified in the scheduleconfigs enrollment/fulfillment fields are met. The evaluateEvent() method returns a boolean value true if all the conditions are met and respective schedule service is called to accomplish the specified action in the scheduleconfigs. | ||||||
HealthSchedulerService | opensrp-core | This class has the common methods used in handling enrollments, fulfillments, unenrolments and the alertFor() method which is called by ECAlertCreationAction class when creating actions for a client when motech issues an alert notification and further calls ActionService to save the action/alert in couchdb. | ||||||
ScheduleService | opensrp-core | This class builds Motech EnrollmentRequests that are passed to Motech ScheduleTrackingService enroll method. For OpenSRP EC alerts processing the enrollmentrequest should have the following values:
For more info about Motech see: http://modules.motechproject.org/en/latest/schedule_tracking.html#schedule-tracking-module, http://modules.motechproject.org/en/latest/schedule_tracking/sample_schedule.html#sample-schedule-definition | ||||||
AlertRouter | opensrp-core | |||||||
ECAlertCreationAction | opensrp-core | |||||||
ActionService | opensrp-core |