Skip to content

Commit

Permalink
Interim commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
arcshiftsolutions committed Oct 17, 2024
1 parent f35bded commit 22c0db7
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ca.bc.gov.educ.eas.api.constants.EventOutcome;
import ca.bc.gov.educ.eas.api.constants.EventType;
import ca.bc.gov.educ.eas.api.mappers.v1.AssessmentStudentMapper;
import ca.bc.gov.educ.eas.api.model.v1.AssessmentStudentEntity;
import ca.bc.gov.educ.eas.api.model.v1.EasEventEntity;
import ca.bc.gov.educ.eas.api.repository.v1.AssessmentStudentRepository;
import ca.bc.gov.educ.eas.api.repository.v1.EasEventRepository;
Expand All @@ -12,10 +11,10 @@
import ca.bc.gov.educ.eas.api.struct.v1.AssessmentStudent;
import ca.bc.gov.educ.eas.api.struct.v1.AssessmentStudentGet;
import ca.bc.gov.educ.eas.api.util.JsonUtil;
import ca.bc.gov.educ.eas.api.util.RequestUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
Expand Down Expand Up @@ -72,17 +71,6 @@ public Pair<byte[], EasEventEntity> handleCreateStudentRegistrationEvent(Event e
log.trace(EVENT_PAYLOAD, event);
AssessmentStudent student = JsonUtil.getJsonObjectFromString(AssessmentStudent.class, event.getEventPayload());
val optionalStudent = assessmentStudentRepository.findByAssessmentIDAndStudentID(UUID.fromString(student.getAssessmentID()), student.getStudentID());
if (optionalStudent.isPresent()) {
event.setEventOutcome(EventOutcome.STUDENT_ALREADY_EXIST);
event.setEventPayload(optionalStudent.get().getStudentID().toString()); // return the student ID in response.
} else {
RequestUtil.setAuditColumnsForCreate(student);
var studentPair = assessmentStudentService.createStudent(assessmentStudentMapper.toModel(student));
AssessmentStudentEntity entity = studentPair.getLeft();
choreographyEvent = studentPair.getRight();
event.setEventOutcome(EventOutcome.STUDENT_CREATED);
event.setEventPayload(JsonUtil.getJsonStringFromObject(studentMapper.toStructure(entity)));// need to convert to structure MANDATORY otherwise jackson will break.
}
easEvent = createAssessmentStudentEventRecord(event);
} else {
log.info(RECORD_FOUND_FOR_SAGA_ID_EVENT_TYPE);
Expand Down

0 comments on commit 22c0db7

Please sign in to comment.