From e17130ede35aed1eb9467d45d58b037d4b3c83b4 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Tue, 11 May 2021 10:28:54 +0200 Subject: [PATCH] use equals with getAsString --- .../telefonica/iot/cygnus/sinks/NGSIMongoSink.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIMongoSink.java b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIMongoSink.java index c81b916f8..fe9f81823 100644 --- a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIMongoSink.java +++ b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIMongoSink.java @@ -235,17 +235,19 @@ private void persistAggregation(NGSIGenericAggregator aggregator) throws CygnusP JsonElement attType; if (rowAttrPersistence) { attType = aggregator.getAggregation().get(NGSIConstants.ATTR_TYPE).get(i); - if ( (attType != null) && - (attType.toString().contains("ISO8601") || - attType.toString().contains("DateTime")) ) { + if ( (attType != null && + attType.isJsonPrimitive()) && + (attType.getAsString().equals("ISO8601") || + attType.getAsString().equals("DateTime")) ) { basicDBObject = castDate(NGSIConstants.ATTR_VALUE, basicDBObject); } } else { for (String key : basicDBObject.keySet()) { attType = aggregator.getAggregation().get(key + NGSIConstants.AUTOGENERATED_ATTR_TYPE).get(i); - if ( (attType != null) && - (attType.toString().contains("ISO8601") || - attType.toString().contains("DateTime")) ) { + if ( (attType != null && + attType.isJsonPrimitive()) && + (attType.getAsString().equals("ISO8601") || + attType.getAsString().equals("DateTime")) ) { basicDBObject = castDate(key, basicDBObject); } }