Skip to content

Commit

Permalink
Added Counts Endpoints for Notifications
Browse files Browse the repository at this point in the history
John-Wiens committed Apr 30, 2024
1 parent da4131c commit 65f3d05
Showing 1 changed file with 220 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -124,6 +124,25 @@ public ResponseEntity<List<Notification>> findActiveNotification(
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/active/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countActiveNotification(
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "notification_type", required = false) String notificationType,
@RequestParam(name = "key", required = false) String key,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {
if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = activeNotificationRepo.getQuery(intersectionID, roadRegulatorID, notificationType, key);
long count = activeNotificationRepo.getQueryResultCount(query);
logger.info("Found: " + count + " Active Notifications");
return ResponseEntity.ok(count);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@DeleteMapping(value = "/notifications/active")
@PreAuthorize("hasRole('ADMIN')")
@@ -166,6 +185,26 @@ public ResponseEntity<List<ConnectionOfTravelNotification>> findConnectionOfTrav
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/connection_of_travel/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countConnectionOfTravelNotification(
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {
if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = connectionOfTravelNotificationRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = connectionOfTravelNotificationRepo.getQueryResultCount(query);

logger.info("Found: " + count + " Connection of Travel Notifications");
return ResponseEntity.ok(count);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/intersection_reference_alignment", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
@@ -194,6 +233,28 @@ public ResponseEntity<List<IntersectionReferenceAlignmentNotification>> findInte
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/intersection_reference_alignment/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countIntersectionReferenceAlignmentNotification(
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {

if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = intersectionReferenceAlignmentNotificationRepo.getQuery(intersectionID, startTime, endTime,
latest);
long count = intersectionReferenceAlignmentNotificationRepo.getQueryResultCount(query);

logger.info("Found: " + count + " Intersection Reference Alignment");
return ResponseEntity.ok(count);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/lane_direction_of_travel", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
@@ -221,6 +282,28 @@ public ResponseEntity<List<LaneDirectionOfTravelNotification>> findLaneDirection
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/lane_direction_of_travel/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countLaneDirectionOfTravelNotification(
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {

if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = laneDirectionOfTravelNotificationRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = laneDirectionOfTravelNotificationRepo.getQueryResultCount(query);

logger.info("Found: " + count + " Lane Direction of Travel");
return ResponseEntity.ok(count);

}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/map_broadcast_rate_notification", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
@@ -248,6 +331,27 @@ public ResponseEntity<List<MapBroadcastRateNotification>> findMapBroadcastRateNo
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/map_broadcast_rate_notification/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countMapBroadcastRateNotification(
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {

if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = mapBroadcastRateNotificationRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = mapBroadcastRateNotificationRepo.getQueryResultCount(query);

logger.info("Found: " + count + " Map Broadcast Rate Notifications");
return ResponseEntity.ok(count);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/signal_group_alignment_notification", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
@@ -274,6 +378,25 @@ public ResponseEntity<List<SignalGroupAlignmentNotification>> findSignalGroupAli
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/signal_group_alignment_notification/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countSignalGroupAlignmentNotification(
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {
if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = signalGroupAlignmentNotificationRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = signalGroupAlignmentNotificationRepo.getQueryResultCount(query);
logger.info("Found: " + count + " Signal Group Alignment Notifications");
return ResponseEntity.ok(count);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/signal_state_conflict_notification", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
@@ -301,6 +424,26 @@ public ResponseEntity<List<SignalStateConflictNotification>> findSignalStateConf
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/signal_state_conflict_notification/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countSignalStateConflictNotification(
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {

if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = signalStateConflictNotificationRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = signalStateConflictNotificationRepo.getQueryResultCount(query);
logger.info("Found: " + count + " Signal State Conflict Noficiations");
return ResponseEntity.ok(count);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/spat_broadcast_rate_notification", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
@@ -328,6 +471,26 @@ public ResponseEntity<List<SpatBroadcastRateNotification>> findSpatBroadcastRate
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/spat_broadcast_rate_notification/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countSpatBroadcastRateNotification(
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {

if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = spatBroadcastRateNotificationRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = spatBroadcastRateNotificationRepo.getQueryResultCount(query);
logger.info("Found: " + count + " SPaT Broadcast Rate Notifications");
return ResponseEntity.ok(count);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/stop_line_stop", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
@@ -354,6 +517,25 @@ public ResponseEntity<List<StopLineStopNotification>> findStopLineStopNotificati
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/stop_line_stop/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countStopLineStopNotification(
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {
if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = stopLineStopNotificationRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = stopLineStopNotificationRepo.getQueryResultCount(query);
logger.info("Found: " + count + " Stop Line Stop Notifications");
return ResponseEntity.ok(count);
}
}


@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/stop_line_passage", method = RequestMethod.GET, produces = "application/json")
@@ -381,6 +563,25 @@ public ResponseEntity<List<StopLinePassageNotification>> findStopLinePassageNoti
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/stop_line_passage/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countStopLinePassageNotification(
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {
if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = stopLinePassageNotificationRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = stopLinePassageNotificationRepo.getQueryResultCount(query);
logger.info("Found: " + count + " Stop Line Passage Notifications");
return ResponseEntity.ok(count);
}
}


@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/time_change_details", method = RequestMethod.GET, produces = "application/json")
@@ -407,4 +608,23 @@ public ResponseEntity<List<TimeChangeDetailsNotification>> findTimeChangeDetails
}
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/notifications/time_change_details/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> countTimeChangeDetailsNotification(
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
@RequestParam(name = "start_time_utc_millis", required = false) Long startTime,
@RequestParam(name = "end_time_utc_millis", required = false) Long endTime,
@RequestParam(name = "latest", required = false, defaultValue = "false") boolean latest,
@RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) {
if (testData) {
return ResponseEntity.ok(1L);
} else {
Query query = timeChangeDetailsNotificationRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = timeChangeDetailsNotificationRepo.getQueryResultCount(query);
logger.info("Found: " + count + " Time Change Detail Notifications");
return ResponseEntity.ok(count);
}
}
}

0 comments on commit 65f3d05

Please sign in to comment.