generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CNDIT-1671: Add Kafka listener for Notification changing event (#36)
- Loading branch information
Showing
35 changed files
with
748 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
common-util/src/main/java/gov/cdc/etldatapipeline/commonutil/UtilHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package gov.cdc.etldatapipeline.commonutil; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
@Slf4j | ||
public class UtilHelper { | ||
private static final ObjectMapper objectMapper = new ObjectMapper() | ||
.registerModule(new JavaTimeModule()); | ||
|
||
private UtilHelper() { | ||
throw new IllegalStateException("Utility class"); | ||
} | ||
|
||
public static <T> T deserializePayload(String jsonString, Class<T> type) { | ||
try { | ||
if (jsonString == null) return null; | ||
return objectMapper.readValue(jsonString, type); | ||
} catch (JsonProcessingException e) { | ||
log.error("JsonProcessingException: ", e); | ||
} | ||
return null; | ||
} | ||
|
||
public static String extractUid(String value, String uidName) throws Exception { | ||
JsonNode jsonNode = objectMapper.readTree(value); | ||
JsonNode payloadNode = jsonNode.get("payload").path("after"); | ||
if (!payloadNode.isMissingNode() && payloadNode.has(uidName)) { | ||
return payloadNode.get(uidName).asText(); | ||
} else { | ||
throw new NoSuchElementException("The " + uidName + " field is missing in the message payload."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...n/java/gov/cdc/etldatapipeline/investigation/repository/model/dto/NotificationUpdate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package gov.cdc.etldatapipeline.investigation.repository.model.dto; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import lombok.Data; | ||
|
||
@Entity | ||
@Data | ||
public class NotificationUpdate { | ||
|
||
@Id | ||
@Column(name = "notification_uid") | ||
private Long notificationUid; | ||
|
||
@Column(name = "investigation_notifications") | ||
private String investigationNotifications; | ||
|
||
@Column(name = "notification_history") | ||
private String notificationHistory; | ||
} |
2 changes: 1 addition & 1 deletion
2
...epository/model/dto/InvestigationKey.java → ...ory/model/reporting/InvestigationKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...in/java/gov/cdc/etldatapipeline/investigation/repository/odse/NotificationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package gov.cdc.etldatapipeline.investigation.repository.odse; | ||
|
||
import gov.cdc.etldatapipeline.investigation.repository.model.dto.NotificationUpdate; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.Optional; | ||
|
||
public interface NotificationRepository extends JpaRepository<NotificationUpdate, String> { | ||
|
||
@Query(nativeQuery = true, value = "execute sp_notification_event :notification_uids") | ||
Optional<NotificationUpdate> computeNotifications(@Param("notification_uids") String notificationUids); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.