Search in sources :

Example 6 with TenantId

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

the class AbstractServiceTest method generateEvent.

protected Event generateEvent(TenantId tenantId, EntityId entityId, String eventType, String eventUid) throws IOException {
    if (tenantId == null) {
        tenantId = new TenantId(UUIDs.timeBased());
    }
    Event event = new Event();
    event.setTenantId(tenantId);
    event.setEntityId(entityId);
    event.setType(eventType);
    event.setUid(eventUid);
    event.setBody(readFromResource("TestJsonData.json"));
    return event;
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) Event(org.thingsboard.server.common.data.Event)

Example 7 with TenantId

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

the class BaseAssetServiceTest method testSaveAssetWithInvalidTenant.

@Test(expected = DataValidationException.class)
public void testSaveAssetWithInvalidTenant() {
    Asset asset = new Asset();
    asset.setName("My asset");
    asset.setType("default");
    asset.setTenantId(new TenantId(UUIDs.timeBased()));
    assetService.saveAsset(asset);
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) Asset(org.thingsboard.server.common.data.asset.Asset) Test(org.junit.Test)

Example 8 with TenantId

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

the class BasicRpcSessionListener method deserialize.

private static ToPluginRpcResponseDeviceMsg deserialize(ServerAddress serverAddress, ClusterAPIProtos.ToPluginRpcResponseRpcMessage msg) {
    ClusterAPIProtos.PluginAddress address = msg.getAddress();
    TenantId pluginTenantId = new TenantId(toUUID(address.getTenantId()));
    PluginId pluginId = new PluginId(toUUID(address.getPluginId()));
    RpcError error = !StringUtils.isEmpty(msg.getError()) ? RpcError.valueOf(msg.getError()) : null;
    FromDeviceRpcResponse response = new FromDeviceRpcResponse(toUUID(msg.getMsgId()), msg.getResponse(), error);
    return new ToPluginRpcResponseDeviceMsg(pluginId, pluginTenantId, response);
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) ClusterAPIProtos(org.thingsboard.server.gen.cluster.ClusterAPIProtos) PluginId(org.thingsboard.server.common.data.id.PluginId)

Example 9 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(getId()));
    dashboardInfo.setCreatedTime(UUIDs.unixTimestamp(getId()));
    if (tenantId != null) {
        dashboardInfo.setTenantId(new TenantId(toUUID(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 10 with TenantId

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

the class PluginMetaDataEntity method toData.

@Override
public PluginMetaData toData() {
    PluginMetaData data = new PluginMetaData(new PluginId(getId()));
    data.setTenantId(new TenantId(fromString(tenantId)));
    data.setCreatedTime(UUIDs.unixTimestamp(getId()));
    data.setName(name);
    data.setClazz(clazz);
    data.setPublicAccess(publicAccess);
    data.setState(state);
    data.setApiToken(apiToken);
    data.setConfiguration(configuration);
    data.setAdditionalInfo(additionalInfo);
    return data;
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) PluginMetaData(org.thingsboard.server.common.data.plugin.PluginMetaData) PluginId(org.thingsboard.server.common.data.id.PluginId)

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