Search in sources :

Example 6 with JsonDataEntry

use of org.thingsboard.server.common.data.kv.JsonDataEntry in project thingsboard by thingsboard.

the class AbstractCassandraBaseTimeseriesDao method toKvEntry.

public static KvEntry toKvEntry(Row row, String key) {
    KvEntry kvEntry = null;
    String strV = row.get(ModelConstants.STRING_VALUE_COLUMN, String.class);
    if (strV != null) {
        kvEntry = new StringDataEntry(key, strV);
    } else {
        Long longV = row.get(ModelConstants.LONG_VALUE_COLUMN, Long.class);
        if (longV != null) {
            kvEntry = new LongDataEntry(key, longV);
        } else {
            Double doubleV = row.get(ModelConstants.DOUBLE_VALUE_COLUMN, Double.class);
            if (doubleV != null) {
                kvEntry = new DoubleDataEntry(key, doubleV);
            } else {
                Boolean boolV = row.get(ModelConstants.BOOLEAN_VALUE_COLUMN, Boolean.class);
                if (boolV != null) {
                    kvEntry = new BooleanDataEntry(key, boolV);
                } else {
                    String jsonV = row.get(ModelConstants.JSON_VALUE_COLUMN, String.class);
                    if (StringUtils.isNoneEmpty(jsonV)) {
                        kvEntry = new JsonDataEntry(key, jsonV);
                    } else {
                        log.warn("All values in key-value row are nullable ");
                    }
                }
            }
        }
    }
    return kvEntry;
}
Also used : DoubleDataEntry(org.thingsboard.server.common.data.kv.DoubleDataEntry) BooleanDataEntry(org.thingsboard.server.common.data.kv.BooleanDataEntry) StringDataEntry(org.thingsboard.server.common.data.kv.StringDataEntry) BasicTsKvEntry(org.thingsboard.server.common.data.kv.BasicTsKvEntry) TsKvEntry(org.thingsboard.server.common.data.kv.TsKvEntry) KvEntry(org.thingsboard.server.common.data.kv.KvEntry) LongDataEntry(org.thingsboard.server.common.data.kv.LongDataEntry) JsonDataEntry(org.thingsboard.server.common.data.kv.JsonDataEntry)

Aggregations

JsonDataEntry (org.thingsboard.server.common.data.kv.JsonDataEntry)6 BasicTsKvEntry (org.thingsboard.server.common.data.kv.BasicTsKvEntry)5 LongDataEntry (org.thingsboard.server.common.data.kv.LongDataEntry)5 BooleanDataEntry (org.thingsboard.server.common.data.kv.BooleanDataEntry)4 DoubleDataEntry (org.thingsboard.server.common.data.kv.DoubleDataEntry)4 StringDataEntry (org.thingsboard.server.common.data.kv.StringDataEntry)4 TsKvEntry (org.thingsboard.server.common.data.kv.TsKvEntry)4 AttributeKvEntry (org.thingsboard.server.common.data.kv.AttributeKvEntry)2 BaseAttributeKvEntry (org.thingsboard.server.common.data.kv.BaseAttributeKvEntry)2 KvEntry (org.thingsboard.server.common.data.kv.KvEntry)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 Collectors (java.util.stream.Collectors)1