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);
}
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);
}
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);
}
Aggregations