Search in sources :

Example 61 with TenantId

use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.

the class BasicRpcSessionListener method convert.

private static PluginRpcMsg convert(ServerAddress serverAddress, ClusterAPIProtos.ToPluginRpcMessage msg) {
    ClusterAPIProtos.PluginAddress address = msg.getAddress();
    TenantId tenantId = new TenantId(toUUID(address.getTenantId()));
    PluginId pluginId = new PluginId(toUUID(address.getPluginId()));
    RpcMsg rpcMsg = new RpcMsg(serverAddress, msg.getClazz(), msg.getData().toByteArray());
    return new PluginRpcMsg(tenantId, pluginId, rpcMsg);
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) ClusterAPIProtos(org.thingsboard.server.gen.cluster.ClusterAPIProtos) PluginRpcMsg(org.thingsboard.server.extensions.api.plugins.rpc.PluginRpcMsg) PluginRpcMsg(org.thingsboard.server.extensions.api.plugins.rpc.PluginRpcMsg) RpcMsg(org.thingsboard.server.extensions.api.plugins.rpc.RpcMsg) PluginId(org.thingsboard.server.common.data.id.PluginId)

Example 62 with TenantId

use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.

the class BasicRpcSessionListener method deserialize.

private static ToDeviceRpcRequestPluginMsg deserialize(ServerAddress serverAddress, ClusterAPIProtos.ToDeviceRpcRequestRpcMessage msg) {
    ClusterAPIProtos.PluginAddress address = msg.getAddress();
    TenantId pluginTenantId = new TenantId(toUUID(address.getTenantId()));
    PluginId pluginId = new PluginId(toUUID(address.getPluginId()));
    TenantId deviceTenantId = new TenantId(toUUID(msg.getDeviceTenantId()));
    DeviceId deviceId = new DeviceId(toUUID(msg.getDeviceId()));
    ToDeviceRpcRequestBody requestBody = new ToDeviceRpcRequestBody(msg.getMethod(), msg.getParams());
    ToDeviceRpcRequest request = new ToDeviceRpcRequest(toUUID(msg.getMsgId()), null, deviceTenantId, deviceId, msg.getOneway(), msg.getExpTime(), requestBody);
    return new ToDeviceRpcRequestPluginMsg(serverAddress, pluginId, pluginTenantId, request);
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) ClusterAPIProtos(org.thingsboard.server.gen.cluster.ClusterAPIProtos) DeviceId(org.thingsboard.server.common.data.id.DeviceId) PluginId(org.thingsboard.server.common.data.id.PluginId)

Example 63 with TenantId

use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.

the class DashboardInfoEntity method toData.

@Override
public DashboardInfo toData() {
    DashboardInfo dashboardInfo = new DashboardInfo(new DashboardId(id));
    dashboardInfo.setCreatedTime(UUIDs.unixTimestamp(id));
    if (tenantId != null) {
        dashboardInfo.setTenantId(new TenantId(tenantId));
    }
    dashboardInfo.setTitle(title);
    if (!StringUtils.isEmpty(assignedCustomers)) {
        try {
            dashboardInfo.setAssignedCustomers(objectMapper.readValue(assignedCustomers, assignedCustomersType));
        } catch (IOException e) {
            log.warn("Unable to parse assigned customers!", e);
        }
    }
    return dashboardInfo;
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) DashboardId(org.thingsboard.server.common.data.id.DashboardId) IOException(java.io.IOException) DashboardInfo(org.thingsboard.server.common.data.DashboardInfo)

Example 64 with TenantId

use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.

the class DeviceEntity method toData.

@Override
public Device toData() {
    Device device = new Device(new DeviceId(id));
    device.setCreatedTime(UUIDs.unixTimestamp(id));
    if (tenantId != null) {
        device.setTenantId(new TenantId(tenantId));
    }
    if (customerId != null) {
        device.setCustomerId(new CustomerId(customerId));
    }
    device.setName(name);
    device.setType(type);
    device.setAdditionalInfo(additionalInfo);
    return device;
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) Device(org.thingsboard.server.common.data.Device) DeviceId(org.thingsboard.server.common.data.id.DeviceId) CustomerId(org.thingsboard.server.common.data.id.CustomerId)

Example 65 with TenantId

use of org.thingsboard.server.common.data.id.TenantId in project thingsboard by thingsboard.

the class EventEntity method toData.

@Override
public Event toData() {
    Event event = new Event(new EventId(id));
    event.setCreatedTime(UUIDs.unixTimestamp(id));
    event.setTenantId(new TenantId(tenantId));
    event.setEntityId(EntityIdFactory.getByTypeAndUuid(entityType, entityId));
    event.setBody(body);
    event.setType(eventType);
    event.setUid(eventUid);
    return event;
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) Event(org.thingsboard.server.common.data.Event) EventId(org.thingsboard.server.common.data.id.EventId)

Aggregations

TenantId (org.thingsboard.server.common.data.id.TenantId)119 Test (org.junit.Test)44 TextPageLink (org.thingsboard.server.common.data.page.TextPageLink)38 CustomerId (org.thingsboard.server.common.data.id.CustomerId)30 ArrayList (java.util.ArrayList)26 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)24 Tenant (org.thingsboard.server.common.data.Tenant)23 ThingsboardException (org.thingsboard.server.exception.ThingsboardException)23 PluginMetaData (org.thingsboard.server.common.data.plugin.PluginMetaData)16 Customer (org.thingsboard.server.common.data.Customer)14 User (org.thingsboard.server.common.data.User)14 WidgetsBundle (org.thingsboard.server.common.data.widget.WidgetsBundle)13 DeviceId (org.thingsboard.server.common.data.id.DeviceId)10 RuleMetaData (org.thingsboard.server.common.data.rule.RuleMetaData)10 IncorrectParameterException (org.thingsboard.server.dao.exception.IncorrectParameterException)10 AbstractServiceTest (org.thingsboard.server.dao.service.AbstractServiceTest)10 UserId (org.thingsboard.server.common.data.id.UserId)8 TimePageLink (org.thingsboard.server.common.data.page.TimePageLink)8 IOException (java.io.IOException)7 PluginId (org.thingsboard.server.common.data.id.PluginId)7