Search in sources :

Example 1 with WidgetsBundleId

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

the class WidgetsBundleEntity method toData.

@Override
public WidgetsBundle toData() {
    WidgetsBundle widgetsBundle = new WidgetsBundle(new WidgetsBundleId(UUIDConverter.fromString(id)));
    widgetsBundle.setCreatedTime(UUIDs.unixTimestamp(UUIDConverter.fromString(id)));
    if (tenantId != null) {
        widgetsBundle.setTenantId(new TenantId(UUIDConverter.fromString(tenantId)));
    }
    widgetsBundle.setAlias(alias);
    widgetsBundle.setTitle(title);
    return widgetsBundle;
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) WidgetsBundleId(org.thingsboard.server.common.data.id.WidgetsBundleId) WidgetsBundle(org.thingsboard.server.common.data.widget.WidgetsBundle)

Example 2 with WidgetsBundleId

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

the class WidgetsBundleController method deleteWidgetsBundle.

@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/widgetsBundle/{widgetsBundleId}", method = RequestMethod.DELETE)
@ResponseStatus(value = HttpStatus.OK)
public void deleteWidgetsBundle(@PathVariable("widgetsBundleId") String strWidgetsBundleId) throws ThingsboardException {
    checkParameter("widgetsBundleId", strWidgetsBundleId);
    try {
        WidgetsBundleId widgetsBundleId = new WidgetsBundleId(toUUID(strWidgetsBundleId));
        checkWidgetsBundleId(widgetsBundleId, true);
        widgetsBundleService.deleteWidgetsBundle(widgetsBundleId);
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : WidgetsBundleId(org.thingsboard.server.common.data.id.WidgetsBundleId) ThingsboardException(org.thingsboard.server.exception.ThingsboardException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 3 with WidgetsBundleId

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

the class WidgetsBundleEntity method toData.

@Override
public WidgetsBundle toData() {
    WidgetsBundle widgetsBundle = new WidgetsBundle(new WidgetsBundleId(id));
    widgetsBundle.setCreatedTime(UUIDs.unixTimestamp(id));
    if (tenantId != null) {
        widgetsBundle.setTenantId(new TenantId(tenantId));
    }
    widgetsBundle.setAlias(alias);
    widgetsBundle.setTitle(title);
    if (image != null) {
        byte[] imageByteArray = new byte[image.remaining()];
        image.get(imageByteArray);
        widgetsBundle.setImage(imageByteArray);
    }
    return widgetsBundle;
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) WidgetsBundleId(org.thingsboard.server.common.data.id.WidgetsBundleId) WidgetsBundle(org.thingsboard.server.common.data.widget.WidgetsBundle)

Example 4 with WidgetsBundleId

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

the class JpaWidgetsBundleDaoTest method createSystemWidgetBundles.

private void createSystemWidgetBundles(int count, String prefix) {
    for (int i = 0; i < count; i++) {
        WidgetsBundle widgetsBundle = new WidgetsBundle();
        widgetsBundle.setAlias(prefix + i);
        widgetsBundle.setTitle(prefix + i);
        widgetsBundle.setTenantId(new TenantId(NULL_UUID));
        widgetsBundle.setId(new WidgetsBundleId(UUIDs.timeBased()));
        widgetsBundleDao.save(widgetsBundle);
    }
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) WidgetsBundleId(org.thingsboard.server.common.data.id.WidgetsBundleId) WidgetsBundle(org.thingsboard.server.common.data.widget.WidgetsBundle)

Example 5 with WidgetsBundleId

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

the class JpaWidgetsBundleDaoTest method createWidgetBundles.

private void createWidgetBundles(int count, UUID tenantId, String prefix) {
    for (int i = 0; i < count; i++) {
        WidgetsBundle widgetsBundle = new WidgetsBundle();
        widgetsBundle.setAlias(prefix + i);
        widgetsBundle.setTitle(prefix + i);
        widgetsBundle.setId(new WidgetsBundleId(UUIDs.timeBased()));
        widgetsBundle.setTenantId(new TenantId(tenantId));
        widgetsBundleDao.save(widgetsBundle);
    }
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) WidgetsBundleId(org.thingsboard.server.common.data.id.WidgetsBundleId) WidgetsBundle(org.thingsboard.server.common.data.widget.WidgetsBundle)

Aggregations

WidgetsBundleId (org.thingsboard.server.common.data.id.WidgetsBundleId)5 TenantId (org.thingsboard.server.common.data.id.TenantId)4 WidgetsBundle (org.thingsboard.server.common.data.widget.WidgetsBundle)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 ThingsboardException (org.thingsboard.server.exception.ThingsboardException)1