Skip to content

Commit

Permalink
Added event model
Browse files Browse the repository at this point in the history
  • Loading branch information
chris.ditcher authored and chris.ditcher committed Aug 15, 2023
1 parent af41b08 commit 72cc55d
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package ca.bc.gov.educ.api.gradstudent.messaging.jetstream;

import ca.bc.gov.educ.api.gradstudent.exception.EntityNotFoundException;
import ca.bc.gov.educ.api.gradstudent.model.dc.Event;
import ca.bc.gov.educ.api.gradstudent.model.dto.ChoreographedEvent;
import ca.bc.gov.educ.api.gradstudent.service.GraduationStatusService;
import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants;
import ca.bc.gov.educ.api.gradstudent.util.JsonUtil;
import ca.bc.gov.educ.api.gradstudent.util.LogHelper;
import io.nats.client.*;
import lombok.val;
Expand Down Expand Up @@ -38,9 +41,11 @@ public void subscribe() {
@Override
public void onMessage(Message message) {
val eventString = new String(message.getData());
LogHelper.logMessagingEventDetails(eventString, constants.isSplunkLogHelperEnabled());
String response;
try {
UUID stdId = UUID.fromString(eventString);
Event event = JsonUtil.getJsonObjectFromString(Event.class, eventString);
UUID stdId = UUID.fromString(event.getEventPayload());
boolean hasStudentGraduated = graduationStatusService.hasStudentGraduated(stdId);
response = String.valueOf(hasStudentGraduated);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ca.bc.gov.educ.api.gradstudent.model.dc;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.UUID;

/**
* The type Event.
*/
@AllArgsConstructor
@Builder
@NoArgsConstructor
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Event {
/**
* The Event type.
*/
private EventType eventType;
/**
* The Event outcome.
*/
private EventOutcome eventOutcome;
/**
* The Saga id.
*/
private UUID sagaId;
/**
* The Reply to.
*/
private String replyTo;
/**
* The Event payload.
*/
private String eventPayload; // json string
/**
* The school batch ID
*/
private String sdcSchoolBatchID;
/**
* The student ID
*/
private String sdcSchoolStudentID;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ca.bc.gov.educ.api.gradstudent.model.dc;

/**
* The enum Event outcome.
*/
public enum EventOutcome {
VALIDATION_SUCCESS_NO_ERROR_WARNING,
VALIDATION_SUCCESS_WITH_ERROR,
PEN_MATCH_PROCESSED,
GRAD_STATUS_FETCHED,
GRAD_STATUS_RESULTS_PROCESSED,
PEN_MATCH_RESULTS_PROCESSED,
READ_FROM_TOPIC_SUCCESS,
INITIATE_SUCCESS,
SAGA_COMPLETED,
ENROLLED_PROGRAMS_WRITTEN,
ADDITIONAL_STUDENT_ATTRIBUTES_CALCULATED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ca.bc.gov.educ.api.gradstudent.model.dc;

/**
* The enum Event type.
*/
public enum EventType {
VALIDATE_SDC_STUDENT,
PROCESS_PEN_MATCH,
FETCH_GRAD_STATUS,
PROCESS_GRAD_STATUS_RESULT,
PROCESS_PEN_MATCH_RESULTS,
READ_FROM_TOPIC,
INITIATED,
MARK_SAGA_COMPLETE,
GET_PAGINATED_SCHOOLS,
WRITE_ENROLLED_PROGRAMS,
CALCULATE_ADDITIONAL_STUDENT_ATTRIBUTES
}

0 comments on commit 72cc55d

Please sign in to comment.