-
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 (#232)
Co-authored-by: jannis <jan.schenk@ostfalia.de> Co-authored-by: Sascha Doemer <Cf4ThQgxcnxAovOUXTNv@saschadoemer.de>
- Loading branch information
1 parent
fb897b4
commit 81c23b7
Showing
2 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
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
65 changes: 65 additions & 0 deletions
65
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,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; | ||
} | ||
} |