Postgres version #1

Merged
c4181 merged 17 commits from postgres-version into main 2025-11-19 17:38:10 +00:00
4 changed files with 17 additions and 5 deletions
Showing only changes of commit e01e9a9484 - Show all commits

View file

@ -3,6 +3,8 @@ package com.c4181.camel;
import com.c4181.model.JsoCall;
import com.c4181.model.JsoCallDecoder;
import com.c4181.properties.AppProperties;
import io.quarkus.logging.Log;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.commons.lang3.StringUtils;
@ -26,7 +28,8 @@ public class CamelConfiguration extends RouteBuilder {
public void configure() {
errorHandler(deadLetterChannel(appProperties.deadLetterRoute())
.log("Failed to process message. Sending to dead letter queue")
.onExceptionOccurred(exchange ->
Log.warnf("Failed to parse message in route %s. Sending to Dead Letter queue.", exchange.getProperty(Exchange.TO_ENDPOINT, String.class)))
.useOriginalMessage());
from(appProperties.jsoCadUpdateRouteIn())
@ -61,6 +64,7 @@ public class CamelConfiguration extends RouteBuilder {
.to(appProperties.jsoCadUpdateRouteOut());
from("direct:processedCalls")
.errorHandler(deadLetterChannel("log:dead?level=ERROR"))
.filter(exchange -> exchange.getIn().getBody(JsoCall.class).getPoint() != null)
.process(exchange -> {
JsoCall jsoCall = exchange.getIn().getBody(JsoCall.class);

View file

@ -34,13 +34,13 @@ public class JsoCallDecoder {
.map(String::trim)
.toList();
String pattern = "(\\d+)\\s+(\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2})\\s+(.+)\\s+( \\d+\\s?[\\w\\d]*)\\s+(\\D+)";
String pattern = "(\\d+)\\s+(\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2})\\s+(.+)\\s+( \\d+\\s?[\\w\\d]*)\\s+(.+)";
Pattern p = Pattern.compile(pattern);
List<JsoCall> jsoCalls = new ArrayList<>();
for (String call : newCalls) {
Matcher m = p.matcher(call);
if (!m.matches() && m.groupCount() != 5) {
if (!m.matches() || m.groupCount() != 5) {
Log.warnf("Failed to parse call\n%s", call);
continue;
}

View file

@ -27,7 +27,7 @@ class JsoCallDecoderTest {
JsoCallDecoder decoder = new JsoCallDecoder();
List<JsoCall> calls = decoder.decodeJsoCallUpdates(data);
assertEquals(5, calls.size());
assertEquals(6, calls.size());
JsoCall firstCall = calls.get(0);
assertEquals("202200769492", firstCall.getIncidentNumber());
@ -63,5 +63,12 @@ class JsoCallDecoderTest {
assertEquals("BULLS BAY HWY / BEAVER ST W", fifthCall.getAddress());
assertEquals("0 13", fifthCall.getSignal());
assertEquals("ARMED SUSPICIOUS PERSON", fifthCall.getCallDescription());
JsoCall sixthCall = calls.get(5);
assertEquals("202300004560", sixthCall.getIncidentNumber());
assertNotNull(sixthCall.getDispatchedTime());
assertEquals("3700 TOLEDO RD", sixthCall.getAddress());
assertEquals("37", sixthCall.getSignal());
assertEquals("UNVERIFIED 911 CALL", sixthCall.getCallDescription());
}
}

View file

@ -19,4 +19,5 @@ JSO CAD
(added ) 202200769474 12-31 12:19 9100 MERRILL RD 4 AUTO CRASH
(added ) 202200769409 12-31 11:18 1000 ST CLAIR ST 21CT BURGLARY CONVEYANCE TELESERVE
(added ) 202300004101 1-3 08:29 12000 ATLANTIC BLVD 1050 TRAFFIC STOP
(added ) 202300004011 1-3 07:37 BULLS BAY HWY / BEAVER ST W 0 13 ARMED SUSPICIOUS PERSON
(added ) 202300004011 1-3 07:37 BULLS BAY HWY / BEAVER ST W 0 13 ARMED SUSPICIOUS PERSON
(added ) 202300004560 1-3 11:44 3700 TOLEDO RD 37 UNVERIFIED 911 CALL