Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Stationary-Camera-Image entity #232

Merged
merged 8 commits into from
Aug 16, 2024
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 MicaSense image must not be blank.");
BSO-Jannis marked this conversation as resolved.
Show resolved Hide resolved
}
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.");
BSO-Jannis marked this conversation as resolved.
Show resolved Hide resolved
}
}

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() + "," +
" \"droneId\":" + cameraId.asJson().trim() + "," +
BSO-Jannis marked this conversation as resolved.
Show resolved Hide resolved
" \"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;
}
}