-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Stationary-Camera-Image entity
- Loading branch information
jannis
committed
Aug 16, 2024
1 parent
777e034
commit a127a9c
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
src/main/java/de/app/fivegla/integration/fiware/model/StationaryCameraImage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |