Skip to content

Commit

Permalink
Added Stationary-Camera-Image entity (#232)
Browse files Browse the repository at this point in the history
Co-authored-by: jannis <jan.schenk@ostfalia.de>
Co-authored-by: Sascha Doemer <Cf4ThQgxcnxAovOUXTNv@saschadoemer.de>
  • Loading branch information
3 people authored Aug 16, 2024
1 parent fb897b4 commit 81c23b7
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 81c23b7

Please sign in to comment.