Search in sources :

Example 1 with WidgetTypeId

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

the class WidgetTypeServiceImpl method deleteWidgetTypesByTenantIdAndBundleAlias.

@Override
public void deleteWidgetTypesByTenantIdAndBundleAlias(TenantId tenantId, String bundleAlias) {
    log.trace("Executing deleteWidgetTypesByTenantIdAndBundleAlias, tenantId [{}], bundleAlias [{}]", tenantId, bundleAlias);
    Validator.validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
    Validator.validateString(bundleAlias, INCORRECT_BUNDLE_ALIAS + bundleAlias);
    List<WidgetType> widgetTypes = widgetTypeDao.findWidgetTypesByTenantIdAndBundleAlias(tenantId.getId(), bundleAlias);
    for (WidgetType widgetType : widgetTypes) {
        deleteWidgetType(new WidgetTypeId(widgetType.getUuidId()));
    }
}
Also used : WidgetTypeId(org.thingsboard.server.common.data.id.WidgetTypeId) WidgetType(org.thingsboard.server.common.data.widget.WidgetType)

Example 2 with WidgetTypeId

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

the class WidgetTypeEntity method toData.

@Override
public WidgetType toData() {
    WidgetType widgetType = new WidgetType(new WidgetTypeId(id));
    widgetType.setCreatedTime(UUIDs.unixTimestamp(id));
    if (tenantId != null) {
        widgetType.setTenantId(new TenantId(tenantId));
    }
    widgetType.setBundleAlias(bundleAlias);
    widgetType.setAlias(alias);
    widgetType.setName(name);
    widgetType.setDescriptor(descriptor);
    return widgetType;
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) WidgetTypeId(org.thingsboard.server.common.data.id.WidgetTypeId) WidgetType(org.thingsboard.server.common.data.widget.WidgetType)

Example 3 with WidgetTypeId

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

the class WidgetTypeEntity method toData.

@Override
public WidgetType toData() {
    WidgetType widgetType = new WidgetType(new WidgetTypeId(getId()));
    widgetType.setCreatedTime(UUIDs.unixTimestamp(getId()));
    if (tenantId != null) {
        widgetType.setTenantId(new TenantId(toUUID(tenantId)));
    }
    widgetType.setBundleAlias(bundleAlias);
    widgetType.setAlias(alias);
    widgetType.setName(name);
    widgetType.setDescriptor(descriptor);
    return widgetType;
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) WidgetTypeId(org.thingsboard.server.common.data.id.WidgetTypeId) WidgetType(org.thingsboard.server.common.data.widget.WidgetType)

Example 4 with WidgetTypeId

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

the class WidgetTypeController method deleteWidgetType.

@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
@RequestMapping(value = "/widgetType/{widgetTypeId}", method = RequestMethod.DELETE)
@ResponseStatus(value = HttpStatus.OK)
public void deleteWidgetType(@PathVariable("widgetTypeId") String strWidgetTypeId) throws ThingsboardException {
    checkParameter("widgetTypeId", strWidgetTypeId);
    try {
        WidgetTypeId widgetTypeId = new WidgetTypeId(toUUID(strWidgetTypeId));
        checkWidgetTypeId(widgetTypeId, true);
        widgetTypeService.deleteWidgetType(widgetTypeId);
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : WidgetTypeId(org.thingsboard.server.common.data.id.WidgetTypeId) ThingsboardException(org.thingsboard.server.exception.ThingsboardException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

WidgetTypeId (org.thingsboard.server.common.data.id.WidgetTypeId)4 WidgetType (org.thingsboard.server.common.data.widget.WidgetType)3 TenantId (org.thingsboard.server.common.data.id.TenantId)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 ThingsboardException (org.thingsboard.server.exception.ThingsboardException)1