use of org.thingsboard.server.common.data.widget.WidgetType 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()));
}
}
use of org.thingsboard.server.common.data.widget.WidgetType 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;
}
use of org.thingsboard.server.common.data.widget.WidgetType 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;
}
use of org.thingsboard.server.common.data.widget.WidgetType in project thingsboard by thingsboard.
the class BaseWidgetTypeControllerTest method testFindWidgetTypeById.
@Test
public void testFindWidgetTypeById() throws Exception {
WidgetType widgetType = new WidgetType();
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setName("Widget Type");
widgetType.setDescriptor(new ObjectMapper().readValue("{ \"someKey\": \"someValue\" }", JsonNode.class));
WidgetType savedWidgetType = doPost("/api/widgetType", widgetType, WidgetType.class);
WidgetType foundWidgetType = doGet("/api/widgetType/" + savedWidgetType.getId().getId().toString(), WidgetType.class);
Assert.assertNotNull(foundWidgetType);
Assert.assertEquals(savedWidgetType, foundWidgetType);
}
use of org.thingsboard.server.common.data.widget.WidgetType in project thingsboard by thingsboard.
the class BaseWidgetTypeControllerTest method testSaveWidgetTypeWithEmptyDescriptor.
@Test
public void testSaveWidgetTypeWithEmptyDescriptor() throws Exception {
WidgetType widgetType = new WidgetType();
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setName("Widget Type");
widgetType.setDescriptor(new ObjectMapper().readValue("{}", JsonNode.class));
doPost("/api/widgetType", widgetType).andExpect(status().isBadRequest()).andExpect(statusReason(containsString("Widgets type descriptor can't be empty")));
}
Aggregations