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 5ac365f..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,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 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 camera 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 new file mode 100644 index 0000000..373ef92 --- /dev/null +++ b/src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java @@ -0,0 +1,65 @@ +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 cameraId, + 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() + "," + + " \"cameraId\":" + cameraId.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 stationary camera image must not be blank."); + } + if (StringUtils.isBlank(type)) { + throw new IllegalArgumentException("The type of the stationary camera image must not be blank."); + } + } + + @Override + public String getId() { + return id; + } + + @Override + public String getType() { + return type; + } +}