Search in sources :

Example 36 with CustomerId

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

the class CustomerController method getCustomerTitleById.

@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/customer/{customerId}/title", method = RequestMethod.GET, produces = "application/text")
@ResponseBody
public String getCustomerTitleById(@PathVariable(CUSTOMER_ID) String strCustomerId) throws ThingsboardException {
    checkParameter(CUSTOMER_ID, strCustomerId);
    try {
        CustomerId customerId = new CustomerId(toUUID(strCustomerId));
        Customer customer = checkCustomerId(customerId);
        return customer.getTitle();
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : Customer(org.thingsboard.server.common.data.Customer) CustomerId(org.thingsboard.server.common.data.id.CustomerId) ThingsboardException(org.thingsboard.server.exception.ThingsboardException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 37 with CustomerId

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

the class DashboardController method getCustomerDashboards.

@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/customer/{customerId}/dashboards", params = { "limit" }, method = RequestMethod.GET)
@ResponseBody
public TimePageData<DashboardInfo> getCustomerDashboards(@PathVariable("customerId") String strCustomerId, @RequestParam int limit, @RequestParam(required = false) Long startTime, @RequestParam(required = false) Long endTime, @RequestParam(required = false, defaultValue = "false") boolean ascOrder, @RequestParam(required = false) String offset) throws ThingsboardException {
    checkParameter("customerId", strCustomerId);
    try {
        TenantId tenantId = getCurrentUser().getTenantId();
        CustomerId customerId = new CustomerId(toUUID(strCustomerId));
        checkCustomerId(customerId);
        TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
        return checkNotNull(dashboardService.findDashboardsByTenantIdAndCustomerId(tenantId, customerId, pageLink).get());
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) CustomerId(org.thingsboard.server.common.data.id.CustomerId) TimePageLink(org.thingsboard.server.common.data.page.TimePageLink) ThingsboardException(org.thingsboard.server.exception.ThingsboardException) IncorrectParameterException(org.thingsboard.server.dao.exception.IncorrectParameterException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 38 with CustomerId

use of org.thingsboard.server.common.data.id.CustomerId 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 39 with CustomerId

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

the class UserEntity method toData.

@Override
public User toData() {
    User user = new User(new UserId(id));
    user.setCreatedTime(UUIDs.unixTimestamp(id));
    user.setAuthority(authority);
    if (tenantId != null) {
        user.setTenantId(new TenantId(tenantId));
    }
    if (customerId != null) {
        user.setCustomerId(new CustomerId(customerId));
    }
    user.setEmail(email);
    user.setFirstName(firstName);
    user.setLastName(lastName);
    user.setAdditionalInfo(additionalInfo);
    return user;
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) User(org.thingsboard.server.common.data.User) UserId(org.thingsboard.server.common.data.id.UserId) CustomerId(org.thingsboard.server.common.data.id.CustomerId)

Example 40 with CustomerId

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

the class AssetEntity method toData.

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

Aggregations

CustomerId (org.thingsboard.server.common.data.id.CustomerId)59 TenantId (org.thingsboard.server.common.data.id.TenantId)30 Customer (org.thingsboard.server.common.data.Customer)24 ArrayList (java.util.ArrayList)22 Test (org.junit.Test)22 TextPageLink (org.thingsboard.server.common.data.page.TextPageLink)21 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)18 ThingsboardException (org.thingsboard.server.exception.ThingsboardException)17 IncorrectParameterException (org.thingsboard.server.dao.exception.IncorrectParameterException)12 Asset (org.thingsboard.server.common.data.asset.Asset)11 User (org.thingsboard.server.common.data.User)10 TypeReference (com.fasterxml.jackson.core.type.TypeReference)9 UserId (org.thingsboard.server.common.data.id.UserId)9 Device (org.thingsboard.server.common.data.Device)8 Tenant (org.thingsboard.server.common.data.Tenant)7 DashboardId (org.thingsboard.server.common.data.id.DashboardId)6 TimePageLink (org.thingsboard.server.common.data.page.TimePageLink)6 SecurityUser (org.thingsboard.server.service.security.model.SecurityUser)6 List (java.util.List)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4