diff --git a/pom.xml b/pom.xml index 772ce3210..6a9bfde8e 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ opensrp-server-core jar - 2.14.3-SNAPSHOT + 2.14.4-SNAPSHOT opensrp-server-core OpenSRP Server Core module https://github.com/OpenSRP/opensrp-server-core diff --git a/src/main/java/org/opensrp/repository/postgres/EventsRepositoryImpl.java b/src/main/java/org/opensrp/repository/postgres/EventsRepositoryImpl.java index 44bd2c2b6..748f438ee 100644 --- a/src/main/java/org/opensrp/repository/postgres/EventsRepositoryImpl.java +++ b/src/main/java/org/opensrp/repository/postgres/EventsRepositoryImpl.java @@ -52,7 +52,7 @@ public Event get(String id) { @Override public void add(Event entity) { if (entity == null || entity.getBaseEntityId() == null) { - return; + throw new IllegalArgumentException("Empty event or missing baseEntityId"); } if (retrievePrimaryKey(entity) != null) { // Event already added diff --git a/src/main/java/org/opensrp/service/EventService.java b/src/main/java/org/opensrp/service/EventService.java index fb04b6c7f..73063c71a 100644 --- a/src/main/java/org/opensrp/service/EventService.java +++ b/src/main/java/org/opensrp/service/EventService.java @@ -223,16 +223,22 @@ && getByBaseEntityAndFormSubmissionId(event.getBaseEntityId(), event.getFormSubm */ public synchronized Event processOutOfArea(Event event) { try { - String identifier = StringUtils.isBlank(event.getIdentifier(Client.ZEIR_ID)) ? - event.getIdentifier(OPENSRP_ID) : event.getIdentifier(Client.ZEIR_ID); + String programClientId = event.getDetails() != null + ? event.getDetails().getOrDefault("program_client_id", "") + : ""; + + String identifier = StringUtils.isBlank(event.getIdentifier(Client.ZEIR_ID)) + ? (StringUtils.isBlank(event.getIdentifier(OPENSRP_ID)) ? programClientId : event.getIdentifier(OPENSRP_ID)) + : event.getIdentifier(Client.ZEIR_ID); + + logger.info("Processing out of area event: baseEntityId=" + event.getBaseEntityId() + "; identifier=" + identifier); if (StringUtils.isNotBlank(event.getBaseEntityId()) || StringUtils.isBlank(identifier)) { return event; } - List clients = - identifier.startsWith(CARD_ID_PREFIX) ? clientService - .findAllByAttribute(NFC_CARD_IDENTIFIER, identifier.substring(CARD_ID_PREFIX.length())) + List clients = identifier.startsWith(CARD_ID_PREFIX) + ? clientService.findAllByAttribute(NFC_CARD_IDENTIFIER, identifier.substring(CARD_ID_PREFIX.length())) : getClientByIdentifier(identifier); if (clients == null || clients.isEmpty()) { @@ -240,7 +246,6 @@ public synchronized Event processOutOfArea(Event event) { } for (org.smartregister.domain.Client client : clients) { - List existingEvents = findByBaseEntityAndType(client.getBaseEntityId(), BIRTH_REGISTRATION_EVENT); if (existingEvents == null || existingEvents.isEmpty()) { @@ -557,7 +562,6 @@ public List findEventsByConceptAndValue(String concept, String conceptVal public List findByBaseEntityAndType(String baseEntityId, String eventType) { return allEvents.findByBaseEntityAndType(baseEntityId, eventType); - } private Event getUniqueEventFromEventList(List events) throws IllegalArgumentException {