Search in sources :

Example 1 with EventEntity

use of org.thingsboard.server.dao.model.nosql.EventEntity in project thingsboard by thingsboard.

the class CassandraBaseEventDao method saveIfNotExists.

@Override
public Optional<Event> saveIfNotExists(Event event) {
    if (event.getTenantId() == null) {
        log.trace("Save system event with predefined id {}", systemTenantId);
        event.setTenantId(systemTenantId);
    }
    if (event.getId() == null) {
        event.setId(new EventId(UUIDs.timeBased()));
    }
    return save(new EventEntity(event), true);
}
Also used : EventEntity(org.thingsboard.server.dao.model.nosql.EventEntity) EventId(org.thingsboard.server.common.data.id.EventId)

Example 2 with EventEntity

use of org.thingsboard.server.dao.model.nosql.EventEntity in project thingsboard by thingsboard.

the class CassandraBaseEventDao method findEvent.

@Override
public Event findEvent(UUID tenantId, EntityId entityId, String eventType, String eventUid) {
    log.debug("Search event entity by [{}][{}][{}][{}]", tenantId, entityId, eventType, eventUid);
    Select.Where query = select().from(getColumnFamilyName()).where(eq(ModelConstants.EVENT_TENANT_ID_PROPERTY, tenantId)).and(eq(ModelConstants.EVENT_ENTITY_TYPE_PROPERTY, entityId.getEntityType())).and(eq(ModelConstants.EVENT_ENTITY_ID_PROPERTY, entityId.getId())).and(eq(ModelConstants.EVENT_TYPE_PROPERTY, eventType)).and(eq(ModelConstants.EVENT_UID_PROPERTY, eventUid));
    log.trace("Execute query [{}]", query);
    EventEntity entity = findOneByStatement(query);
    if (log.isTraceEnabled()) {
        log.trace("Search result: [{}] for event entity [{}]", entity != null, entity);
    } else {
        log.debug("Search result: [{}]", entity != null);
    }
    return DaoUtil.getData(entity);
}
Also used : Select(com.datastax.driver.core.querybuilder.Select) EventEntity(org.thingsboard.server.dao.model.nosql.EventEntity)

Example 3 with EventEntity

use of org.thingsboard.server.dao.model.nosql.EventEntity in project thingsboard by thingsboard.

the class CassandraBaseEventDao method save.

@Override
public Event save(Event event) {
    log.debug("Save event [{}] ", event);
    if (event.getTenantId() == null) {
        log.trace("Save system event with predefined id {}", systemTenantId);
        event.setTenantId(systemTenantId);
    }
    if (event.getId() == null) {
        event.setId(new EventId(UUIDs.timeBased()));
    }
    if (StringUtils.isEmpty(event.getUid())) {
        event.setUid(event.getId().toString());
    }
    return save(new EventEntity(event), false).orElse(null);
}
Also used : EventEntity(org.thingsboard.server.dao.model.nosql.EventEntity) EventId(org.thingsboard.server.common.data.id.EventId)

Aggregations

EventEntity (org.thingsboard.server.dao.model.nosql.EventEntity)3 EventId (org.thingsboard.server.common.data.id.EventId)2 Select (com.datastax.driver.core.querybuilder.Select)1