From a127a9c3d2debd30e066e2420e38f7ca2727a9bf Mon Sep 17 00:00:00 2001 From: jannis Date: Fri, 16 Aug 2024 10:34:10 +0200 Subject: [PATCH 1/5] Added Stationary-Camera-Image entity --- .../fiware/model/StationaryCameraImage.java | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java diff --git a/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java b/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java new file mode 100644 index 0000000..16b1f83 --- /dev/null +++ b/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java @@ -0,0 +1,67 @@ +package de.app.fivegla.integration.fiware.model; + +import de.app.fivegla.integration.fiware.model.api.FiwareEntity; +import de.app.fivegla.integration.fiware.model.api.Validatable; +import de.app.fivegla.integration.fiware.model.internal.Attribute; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +/** + * Represents a Stationary Camera Image. + */ +@Slf4j +public record StationaryCameraImage( + String id, + String type, + Attribute group, + Attribute oid, + Attribute droneId, + Attribute transactionId, + Attribute imageChannel, + Attribute base64encodedImage, + Attribute imagePath, + Attribute dateCreated, + double latitude, + double longitude +) implements FiwareEntity, Validatable { + + @Override + public String asJson() { + validate(); + var json = "{" + + " \"id\":\"" + id.trim() + "\"," + + " \"type\":\"" + type.trim() + "\"," + + " \"customGroup\":" + group.asJson().trim() + "," + + " \"oid\":" + oid.asJson().trim() + "," + + " \"droneId\":" + droneId.asJson().trim() + "," + + " \"transactionId\":" + transactionId.asJson().trim() + "," + + " \"imageChannel\":" + imageChannel.asJson().trim() + "," + + " \"base64encodedImage\":" + base64encodedImage.asJson().trim() + "," + + " \"imagePath\":" + imagePath.asJson().trim() + "," + + " \"dateCreated\":" + dateCreated.asJson().trim() + "," + + " \"location\":" + locationAsJson(latitude, longitude).trim() + + "}"; + log.debug("{} as JSON: {}", this.getClass().getSimpleName(), json); + return json; + } + + @Override + public void validate() { + if (StringUtils.isBlank(id)) { + throw new IllegalArgumentException("The id of the device measurement must not be null or blank."); + } + if (StringUtils.isBlank(type)) { + throw new IllegalArgumentException("The type of the device measurement must not be null or blank."); + } + } + + @Override + public String getId() { + return id; + } + + @Override + public String getType() { + return type; + } +} From 3f1aaefbe3a05011eec19dfc59157679b2994abb Mon Sep 17 00:00:00 2001 From: jannis Date: Fri, 16 Aug 2024 10:48:53 +0200 Subject: [PATCH 2/5] adapted StationaryCameraImage class --- .../integration/fiware/model/MicaSenseImage.java | 4 ++-- .../fiware/model/StationaryCameraImage.java | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/app/fivegla/integration/fiware/model/MicaSenseImage.java b/src/main/java/de/app/fivegla/integration/fiware/model/MicaSenseImage.java index c713604..1da60b4 100644 --- a/src/main/java/de/app/fivegla/integration/fiware/model/MicaSenseImage.java +++ b/src/main/java/de/app/fivegla/integration/fiware/model/MicaSenseImage.java @@ -48,10 +48,10 @@ public String asJson() { @Override public void validate() { if (StringUtils.isBlank(id)) { - throw new IllegalArgumentException("The id of the device measurement must not be null or blank."); + throw new IllegalArgumentException("The id of the MicaSense image must not be blank."); } if (StringUtils.isBlank(type)) { - throw new IllegalArgumentException("The type of the device measurement must not be null or blank."); + throw new IllegalArgumentException("The type of the MicaSense image must not be blank."); } } diff --git a/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java b/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java index 16b1f83..eebbe3b 100644 --- a/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java +++ b/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java @@ -15,8 +15,7 @@ public record StationaryCameraImage( String type, Attribute group, Attribute oid, - Attribute droneId, - Attribute transactionId, + Attribute cameraId, Attribute imageChannel, Attribute base64encodedImage, Attribute imagePath, @@ -33,8 +32,7 @@ public String asJson() { " \"type\":\"" + type.trim() + "\"," + " \"customGroup\":" + group.asJson().trim() + "," + " \"oid\":" + oid.asJson().trim() + "," + - " \"droneId\":" + droneId.asJson().trim() + "," + - " \"transactionId\":" + transactionId.asJson().trim() + "," + + " \"droneId\":" + cameraId.asJson().trim() + "," + " \"imageChannel\":" + imageChannel.asJson().trim() + "," + " \"base64encodedImage\":" + base64encodedImage.asJson().trim() + "," + " \"imagePath\":" + imagePath.asJson().trim() + "," + @@ -48,10 +46,10 @@ public String asJson() { @Override public void validate() { if (StringUtils.isBlank(id)) { - throw new IllegalArgumentException("The id of the device measurement must not be null or blank."); + throw new IllegalArgumentException("The id of the stationary camera image must not be blank."); } if (StringUtils.isBlank(type)) { - throw new IllegalArgumentException("The type of the device measurement must not be null or blank."); + throw new IllegalArgumentException("The type of the stationary camera image must not be blank."); } } From 1e071b3bbde54d365798218c9e7c155b5d5bf125 Mon Sep 17 00:00:00 2001 From: BSO-Jannis Date: Fri, 16 Aug 2024 11:01:14 +0200 Subject: [PATCH 3/5] Update src/main/java/de/app/fivegla/integration/fiware/model/CameraImage.java Co-authored-by: Sascha Doemer --- .../de/app/fivegla/integration/fiware/model/CameraImage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/app/fivegla/integration/fiware/model/CameraImage.java b/src/main/java/de/app/fivegla/integration/fiware/model/CameraImage.java index 430d46e..bdf3c6d 100644 --- a/src/main/java/de/app/fivegla/integration/fiware/model/CameraImage.java +++ b/src/main/java/de/app/fivegla/integration/fiware/model/CameraImage.java @@ -51,7 +51,7 @@ public void validate() { throw new IllegalArgumentException("The id of the MicaSense image must not be blank."); } if (StringUtils.isBlank(type)) { - throw new IllegalArgumentException("The type of the MicaSense image must not be blank."); + throw new IllegalArgumentException("The type of the camera image must not be blank."); } } From 96b8d1d157bd3da75ea2bde49299e453af8e4228 Mon Sep 17 00:00:00 2001 From: BSO-Jannis Date: Fri, 16 Aug 2024 11:01:24 +0200 Subject: [PATCH 4/5] Update src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java Co-authored-by: Sascha Doemer --- .../fivegla/integration/fiware/model/StationaryCameraImage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java b/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java index eebbe3b..373ef92 100644 --- a/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java +++ b/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java @@ -32,7 +32,7 @@ public String asJson() { " \"type\":\"" + type.trim() + "\"," + " \"customGroup\":" + group.asJson().trim() + "," + " \"oid\":" + oid.asJson().trim() + "," + - " \"droneId\":" + cameraId.asJson().trim() + "," + + " \"cameraId\":" + cameraId.asJson().trim() + "," + " \"imageChannel\":" + imageChannel.asJson().trim() + "," + " \"base64encodedImage\":" + base64encodedImage.asJson().trim() + "," + " \"imagePath\":" + imagePath.asJson().trim() + "," + From be41775cb98cb6896dbd611548935145494ba93a Mon Sep 17 00:00:00 2001 From: BSO-Jannis Date: Fri, 16 Aug 2024 11:02:11 +0200 Subject: [PATCH 5/5] Update src/main/java/de/app/fivegla/integration/fiware/model/CameraImage.java Co-authored-by: Sascha Doemer --- .../de/app/fivegla/integration/fiware/model/CameraImage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/app/fivegla/integration/fiware/model/CameraImage.java b/src/main/java/de/app/fivegla/integration/fiware/model/CameraImage.java index bdf3c6d..deb3588 100644 --- a/src/main/java/de/app/fivegla/integration/fiware/model/CameraImage.java +++ b/src/main/java/de/app/fivegla/integration/fiware/model/CameraImage.java @@ -48,7 +48,7 @@ public String asJson() { @Override public void validate() { if (StringUtils.isBlank(id)) { - throw new IllegalArgumentException("The id of the MicaSense image must not be blank."); + throw new IllegalArgumentException("The id of the camera image must not be blank."); } if (StringUtils.isBlank(type)) { throw new IllegalArgumentException("The type of the camera image must not be blank.");