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

Commit

Permalink
Feature/fix json format to create valid entities (#45)
Browse files Browse the repository at this point in the history
* Refactor JSON output in Attribute model

The JSON output methods in the Attribute class have been refactored to improve readability and structure. The 'dateCreatedAsJson' and 'locationAsJson' methods now return their respective attributes enclosed in individual objects, enhancing the modularity and understanding of the output.

* Update version number in pom.xml

The version number in pom.xml file has been updated from 10.7.0 to 10.8.0, indicating a new release. This change marks the completion of new features, bug fixes, or improvements in the software, thus warranting a version increase.
  • Loading branch information
saschadoemer committed Mar 2, 2024
1 parent 5d6fc04 commit 4e672fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 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>10.7.0</version>
<version>10.8.0</version>

<name>5gLa FIWARE integration layer</name>
<url>https://github.com/vitrum-connect/5gla-fiware-integration-layer</url>
Expand Down
21 changes: 14 additions & 7 deletions src/main/java/de/app/fivegla/fiware/model/generic/Attribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,29 @@ public class Attribute {
private double longitude;

public String asJson() {
return " {" +
return "{" +
" \"name\":\"" + name + "\"," +
" \"type\":\"" + type + "\"," +
" \"value\":" + value + "," +
" \"metadata\": {" +
" \"dateCreated\": {" + dateCreatedAsJson() + "}," +
" \"location\": {" + locationAsJson() + "}" +
" }" +
" \"dateCreated\":" + dateCreatedAsJson() + "," +
" \"location\":" + locationAsJson() +
"}";
}

private String dateCreatedAsJson() {
return "\"type\":\"" + FiwareType.DATE_TIME.getKey() + "\",\"value\":\"" + formatter.format(dateCreated) + "\"";
return "{" +
" \"type\":\"" + FiwareType.DATE_TIME.getKey() + "\"," +
" \"value\":\"" + formatter.format(dateCreated) + "\"" +
"}";
}

private String locationAsJson() {
return "\"type\":\"" + FiwareType.GEO_POINT.getKey() + "\",\"value\":{\"type\":\"Point\",\"coordinates\":[" + longitude + "," + latitude + "]}";
return "{" +
" \"type\":\"" + FiwareType.GEO_POINT.getKey() + "\"," +
" \"value\": {" +
" \"type\":\"Point\"," +
" \"coordinates\": [" + longitude + "," + latitude + "]" +
" }" +
"}";
}
}

0 comments on commit 4e672fd

Please sign in to comment.