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

Bugfix/fix invalid json #39

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>10.1.0</version>
<version>10.2.0</version>

<name>5gLa FIWARE integration layer</name>
<url>https://github.com/vitrum-connect/5gla-fiware-integration-layer</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import de.app.fivegla.fiware.model.generic.Metadata;

import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;

/**
Expand All @@ -16,6 +18,11 @@
public final class DeviceMeasurementBuilder {

private final DeviceMeasurement deviceMeasurement;
private final DateTimeFormatter formatter = DateTimeFormatter
// The supported format for the FIWARE Context Broker is "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'".
// 2017-06-17T07:21:24.238Z
.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
.withZone(ZoneId.systemDefault());

/**
* The DeviceMeasurementBuilder class is responsible for building instances of the DeviceMeasurement class.
Expand Down Expand Up @@ -46,8 +53,9 @@ public DeviceMeasurementBuilder withId(String id) {
*/
public DeviceMeasurementBuilder withLocation(double latitude, double longitude) {
var attribute = new Attribute();
attribute.setValue("{\"type\":\"Point\",\"coordinates\":[" + longitude + "," + latitude + "]}");
attribute.setName("location");
attribute.setType(FiwareTypes.GEO_POINT.getKey());
attribute.setValue("{\"type\":\"Point\",\"coordinates\":[" + longitude + "," + latitude + "]}");
deviceMeasurement.setLocation(attribute);
return this;
}
Expand All @@ -68,9 +76,9 @@ public DeviceMeasurementBuilder withMeasurement(String name, String type, String
measurement.setValue(value);
var metadata = new ArrayList<Metadata>();
var dateObservedMetadata = new Metadata();
dateObservedMetadata.setName("dateObservedMetadata");
dateObservedMetadata.setName("dateObserved");
dateObservedMetadata.setType(FiwareTypes.DATE_TIME.getKey());
dateObservedMetadata.setValue(dateObservedMetadata.toString());
dateObservedMetadata.setValue(formatter.format(dateObserved));
metadata.add(dateObservedMetadata);
if (null != metadataEntries && metadataEntries.length > 0) {
for (var metadataEntry : metadataEntries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public class Metadata {
private String value;

public String asJson() {
return "{\"name\":\"" + name + "\",\"type\":\"" + type + "\",\"value\":" + value + "}";
return "{\"name\":\"" + name + "\",\"type\":\"" + type + "\",\"value\":\"" + value + "\"}";
}
}
Loading