use of org.thingsboard.server.common.data.HasCustomerId in project thingsboard by thingsboard.
the class BaseEntityService method fetchEntityCustomerId.
@Override
public CustomerId fetchEntityCustomerId(TenantId tenantId, EntityId entityId) {
log.trace("Executing fetchEntityCustomerId [{}]", entityId);
HasCustomerId hasCustomerId = null;
switch(entityId.getEntityType()) {
case TENANT:
case RULE_CHAIN:
case RULE_NODE:
case DASHBOARD:
case WIDGETS_BUNDLE:
case WIDGET_TYPE:
case TENANT_PROFILE:
case DEVICE_PROFILE:
case API_USAGE_STATE:
case TB_RESOURCE:
case OTA_PACKAGE:
break;
case CUSTOMER:
hasCustomerId = () -> new CustomerId(entityId.getId());
break;
case USER:
hasCustomerId = userService.findUserById(tenantId, new UserId(entityId.getId()));
break;
case ASSET:
hasCustomerId = assetService.findAssetById(tenantId, new AssetId(entityId.getId()));
break;
case DEVICE:
hasCustomerId = deviceService.findDeviceById(tenantId, new DeviceId(entityId.getId()));
break;
case ALARM:
try {
hasCustomerId = alarmService.findAlarmByIdAsync(tenantId, new AlarmId(entityId.getId())).get();
} catch (Exception e) {
}
break;
case ENTITY_VIEW:
hasCustomerId = entityViewService.findEntityViewById(tenantId, new EntityViewId(entityId.getId()));
break;
case EDGE:
hasCustomerId = edgeService.findEdgeById(tenantId, new EdgeId(entityId.getId()));
break;
}
return hasCustomerId != null ? hasCustomerId.getCustomerId() : new CustomerId(NULL_UUID);
}
Aggregations