Skip to content

Commit cef8f97

Browse files
committed
updated updateEntity
1 parent 2105acb commit cef8f97

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@
7272
<artifactId>spring-webmvc</artifactId>
7373
<version>5.3.23</version>
7474
</dependency>
75+
<dependency>
76+
<groupId>com.fasterxml.jackson.core</groupId>
77+
<artifactId>jackson-databind</artifactId>
78+
<version>2.15.2</version>
79+
</dependency>
80+
<dependency>
81+
<groupId>com.fasterxml.jackson.datatype</groupId>
82+
<artifactId>jackson-datatype-jsr310</artifactId>
83+
<version>2.15.2</version>
84+
</dependency>
7585
</dependencies>
7686

7787
<build>

src/main/java/city/makeour/moc/MocClient.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
import org.springframework.web.client.RestClient;
88
import org.springframework.web.client.RestClient.ResponseSpec;
99

10+
import com.fasterxml.jackson.databind.ObjectMapper;
11+
import com.fasterxml.jackson.databind.SerializationFeature;
12+
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
13+
import com.fasterxml.jackson.core.type.TypeReference;
14+
1015
import city.makeour.moc.ngsiv2.Ngsiv2Client;
1116
import city.makeour.ngsi.v2.api.EntitiesApi;
1217
import city.makeour.ngsi.v2.invoker.ApiClient;
@@ -193,6 +198,15 @@ public ResponseSpec updateEntity(String id, String type, Object attributesToUpda
193198
}
194199
}
195200
}
201+
202+
public ResponseSpec updateEntity(String id, String type, Object o) {
203+
ObjectMapper mapper = new ObjectMapper();
204+
mapper.registerModule(new JavaTimeModule());
205+
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
206+
207+
Map<String, Object> m = mapper.convertValue(o, new TypeReference<Map<String, Object>>() {});
208+
return updateEntity(id, type, m);
209+
}
196210

197211

198212

0 commit comments

Comments
 (0)