Skip to content

Commit

Permalink
Merge pull request #74 from bcgov/feature/iosas
Browse files Browse the repository at this point in the history
testing iosas integration
  • Loading branch information
arcshiftsolutions authored Apr 5, 2024
2 parents 0a8e1be + 95999dc commit fe11b1e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ public enum EventOutcome {

SCHOOL_UPDATED_IN_IOSAS,

SCHOOL_UPDATE_SKIPPED_IN_IOSAS,

SCHOOL_CREATED_IN_ISFS,

SCHOOL_UPDATED_IN_ISFS,

SCHOOL_UPDATE_SKIPPED_IN_ISFS,


DISTRICT_UPDATED,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class AuthorityUpdateOrchestrator extends BaseOrchestrator<AuthorityUpdat
public static final String RESPONDED_VIA_NATS_TO_FOR_EVENT = "responded via NATS to {} for {} Event. :: {}";
private final RestUtils restUtils;

private AuthorityMasterRepository authorityMasterRepository = null;
private AuthorityMapperHelper authorityMapperHelper = null;
private AuthorityMasterRepository authorityMasterRepository;
private AuthorityMapperHelper authorityMapperHelper;
private static final AuthorityMapper authorityMapper = AuthorityMapper.mapper;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,33 +123,54 @@ private void updateSchoolInIOSAS(final Event event, final Saga saga, final Schoo
saga.setSagaState(UPDATE_SCHOOL_IN_IOSAS.toString());
final SagaEvent eventStates = this.createEventState(saga, event.getEventType(), event.getEventOutcome(), event.getEventPayload());
this.getSagaService().updateAttachedSagaWithEvents(saga, eventStates);
if (StringUtils.equalsAnyIgnoreCase("INDEPEND", schoolCreateSagaData.getSchool().getSchoolCategoryCode().toString()) || StringUtils.equalsAnyIgnoreCase("INDP_FNS", schoolCreateSagaData.getSchool().getSchoolCategoryCode().toString())) {
restUtils.createOrUpdateSchoolInIndependentSchoolSystem(schoolCreateSagaData.getSchool(), IndependentSchoolSystem.IOSAS);

restUtils.createOrUpdateSchoolInIndependentSchoolSystem(schoolCreateSagaData.getSchool(), IndependentSchoolSystem.IOSAS);

val nextEvent = Event.builder().sagaId(saga.getSagaId())
.eventType(UPDATE_SCHOOL_IN_IOSAS)
.eventOutcome(SCHOOL_UPDATED_IN_IOSAS)
.eventPayload(JsonUtil.getJsonStringFromObject(schoolCreateSagaData.getSchool()))
.build();
this.postMessageToTopic(this.getTopicToSubscribe().getCode(), nextEvent); // this will make it async and use pub/sub flow even though it is sending message to itself
log.info(RESPONDED_VIA_NATS_TO_FOR_EVENT, this.getTopicToSubscribe(), UPDATE_SCHOOL_IN_IOSAS, saga.getSagaId());
val nextEvent = Event.builder().sagaId(saga.getSagaId())
.eventType(UPDATE_SCHOOL_IN_IOSAS)
.eventOutcome(SCHOOL_UPDATED_IN_IOSAS)
.eventPayload(JsonUtil.getJsonStringFromObject(schoolCreateSagaData.getSchool()))
.build();
this.postMessageToTopic(this.getTopicToSubscribe().getCode(), nextEvent); // this will make it async and use pub/sub flow even though it is sending message to itself
log.info(RESPONDED_VIA_NATS_TO_FOR_EVENT, this.getTopicToSubscribe(), UPDATE_SCHOOL_IN_IOSAS, saga.getSagaId());
} else {
val nextEvent = Event.builder().sagaId(saga.getSagaId())
.eventType(UPDATE_SCHOOL_IN_IOSAS)
.eventOutcome(SCHOOL_UPDATE_SKIPPED_IN_IOSAS)
.eventPayload(JsonUtil.getJsonStringFromObject(schoolCreateSagaData.getSchool()))
.build();
this.postMessageToTopic(this.getTopicToSubscribe().getCode(), nextEvent); // this will make it async and use pub/sub flow even though it is sending message to itself
log.info(RESPONDED_VIA_NATS_TO_FOR_EVENT, this.getTopicToSubscribe(), UPDATE_SCHOOL_IN_IOSAS, saga.getSagaId());
}
}


private void updateSchoolInISFS(final Event event, final Saga saga, final SchoolUpdateSagaData schoolCreateSagaData) throws JsonProcessingException {
saga.setSagaState(UPDATE_SCHOOL_IN_ISFS.toString());
final SagaEvent eventStates = this.createEventState(saga, event.getEventType(), event.getEventOutcome(), event.getEventPayload());
this.getSagaService().updateAttachedSagaWithEvents(saga, eventStates);
if (StringUtils.equalsAnyIgnoreCase("INDEPEND", schoolCreateSagaData.getSchool().getSchoolCategoryCode().toString()) || StringUtils.equalsAnyIgnoreCase("INDP_FNS", schoolCreateSagaData.getSchool().getSchoolCategoryCode().toString())) {
restUtils.createOrUpdateSchoolInIndependentSchoolSystem(schoolCreateSagaData.getSchool(), IndependentSchoolSystem.ISFS);

restUtils.createOrUpdateSchoolInIndependentSchoolSystem(schoolCreateSagaData.getSchool(), IndependentSchoolSystem.ISFS);
val nextEvent = Event.builder().sagaId(saga.getSagaId())
.eventType(UPDATE_SCHOOL_IN_ISFS)
.eventOutcome(SCHOOL_UPDATED_IN_ISFS)
.eventPayload(JsonUtil.getJsonStringFromObject(schoolCreateSagaData.getSchool()))
.build();
this.postMessageToTopic(this.getTopicToSubscribe().getCode(), nextEvent); // this will make it async and use pub/sub flow even though it is sending message to itself
log.info(RESPONDED_VIA_NATS_TO_FOR_EVENT, this.getTopicToSubscribe(), UPDATE_SCHOOL_IN_ISFS, saga.getSagaId());
} else {
val nextEvent = Event.builder().sagaId(saga.getSagaId())
.eventType(UPDATE_SCHOOL_IN_ISFS)
.eventOutcome(SCHOOL_UPDATE_SKIPPED_IN_ISFS)
.eventPayload(JsonUtil.getJsonStringFromObject(schoolCreateSagaData.getSchool()))
.build();
this.postMessageToTopic(this.getTopicToSubscribe().getCode(), nextEvent); // this will make it async and use pub/sub flow even though it is sending message to itself
log.info(RESPONDED_VIA_NATS_TO_FOR_EVENT, this.getTopicToSubscribe(), UPDATE_SCHOOL_IN_ISFS, saga.getSagaId());

val nextEvent = Event.builder().sagaId(saga.getSagaId())
.eventType(UPDATE_SCHOOL_IN_ISFS)
.eventOutcome(SCHOOL_UPDATED_IN_ISFS)
.eventPayload(JsonUtil.getJsonStringFromObject(schoolCreateSagaData.getSchool()))
.build();
this.postMessageToTopic(this.getTopicToSubscribe().getCode(), nextEvent); // this will make it async and use pub/sub flow even though it is sending message to itself
log.info(RESPONDED_VIA_NATS_TO_FOR_EVENT, this.getTopicToSubscribe(), UPDATE_SCHOOL_IN_ISFS, saga.getSagaId());
}
}


}

0 comments on commit fe11b1e

Please sign in to comment.