Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Feature/add controlled property as metadata (#35)
Browse files Browse the repository at this point in the history
* Update DeviceMeasurementBuilder to include metadata

An additional method was added to DeviceMeasurementBuilder to include metadata fields, adding flexibility for data inclusion in the attributes. A new "Text" key was also added to the FiwareTypes enumeration. These modifications will allow better handling of device measurements by carrying essential information about them.

* Remove metadata method from DeviceMeasurementBuilder

The metadata method that was responsible for setting the metadata fields in the DeviceMeasurementBuilder has been removed. This code change simplifies the DeviceMeasurementBuilder and removes potential redundancy as the metadata is currently not required in our use case.

* Remove metadata method from DeviceMeasurementBuilder

The metadata method that was responsible for setting the metadata fields in the DeviceMeasurementBuilder has been removed. This code change simplifies the DeviceMeasurementBuilder and removes potential redundancy as the metadata is currently not required in our use case.
  • Loading branch information
saschadoemer authored Feb 28, 2024
1 parent 3dc1571 commit 0d9b7d3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.app.5gla</groupId>
<artifactId>fiware-integration-layer</artifactId>
<version>9.0.0</version>
<version>9.1.0</version>

<name>5gLa FIWARE integration layer</name>
<url>https://github.com/vitrum-connect/5gla-fiware-integration-layer</url>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/de/app/fivegla/fiware/api/FiwareTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
@Getter
public enum FiwareTypes {
GEO_POINT("geo:point"),
DATE_TIME("DateTime");
DATE_TIME("DateTime"),
TEXT("Text");

private final String key;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,20 @@ public DeviceMeasurementBuilder withLocation(double latitude, double longitude)
* @param dateObserved the date observed of the measurement attribute
* @return the DeviceMeasurementBuilder instance with the updated measurement attribute
*/
public DeviceMeasurementBuilder withMeasurement(String name, String type, String value, Instant dateObserved) {
public DeviceMeasurementBuilder withMeasurement(String name, String type, String value, Instant dateObserved, String controlledProperty) {
var attribute = new Attribute();
attribute.setName(name);
attribute.setType(type);
attribute.setValue(value);
var metadata = new Metadata();
metadata.setName("dateObserved");
metadata.setType(FiwareTypes.DATE_TIME.getKey());
metadata.setValue(dateObserved.toString());
attribute.setMetadata(List.of(metadata));
var dateObservedMetadata = new Metadata();
dateObservedMetadata.setName("dateObservedMetadata");
dateObservedMetadata.setType(FiwareTypes.DATE_TIME.getKey());
dateObservedMetadata.setValue(dateObservedMetadata.toString());
var controlledPropertyMetadata = new Metadata();
controlledPropertyMetadata.setName("controlledProperty");
controlledPropertyMetadata.setType(FiwareTypes.TEXT.getKey());
controlledPropertyMetadata.setValue(controlledProperty);
attribute.setMetadata(List.of(dateObservedMetadata, controlledPropertyMetadata));
deviceMeasurement.setMeasurement(attribute);
return this;
}
Expand Down

0 comments on commit 0d9b7d3

Please sign in to comment.