use of org.thingsboard.server.common.data.widget.WidgetsBundle in project thingsboard by thingsboard.
the class WidgetsBundleServiceImpl method findSystemWidgetsBundles.
@Override
public List<WidgetsBundle> findSystemWidgetsBundles() {
log.trace("Executing findSystemWidgetsBundles");
List<WidgetsBundle> widgetsBundles = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(DEFAULT_WIDGETS_BUNDLE_LIMIT);
TextPageData<WidgetsBundle> pageData;
do {
pageData = findSystemWidgetsBundlesByPageLink(pageLink);
widgetsBundles.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
return widgetsBundles;
}
use of org.thingsboard.server.common.data.widget.WidgetsBundle in project thingsboard by thingsboard.
the class WidgetsBundleServiceImpl method findAllTenantWidgetsBundlesByTenantId.
@Override
public List<WidgetsBundle> findAllTenantWidgetsBundlesByTenantId(TenantId tenantId) {
log.trace("Executing findAllTenantWidgetsBundlesByTenantId, tenantId [{}]", tenantId);
Validator.validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
List<WidgetsBundle> widgetsBundles = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(DEFAULT_WIDGETS_BUNDLE_LIMIT);
TextPageData<WidgetsBundle> pageData;
do {
pageData = findAllTenantWidgetsBundlesByTenantIdAndPageLink(tenantId, pageLink);
widgetsBundles.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
return widgetsBundles;
}
use of org.thingsboard.server.common.data.widget.WidgetsBundle in project thingsboard by thingsboard.
the class WidgetsBundleServiceImpl method deleteWidgetsBundle.
@Override
public void deleteWidgetsBundle(WidgetsBundleId widgetsBundleId) {
log.trace("Executing deleteWidgetsBundle [{}]", widgetsBundleId);
Validator.validateId(widgetsBundleId, "Incorrect widgetsBundleId " + widgetsBundleId);
WidgetsBundle widgetsBundle = findWidgetsBundleById(widgetsBundleId);
if (widgetsBundle == null) {
throw new IncorrectParameterException("Unable to delete non-existent widgets bundle.");
}
widgetTypeService.deleteWidgetTypesByTenantIdAndBundleAlias(widgetsBundle.getTenantId(), widgetsBundle.getAlias());
widgetsBundleDao.removeById(widgetsBundleId.getId());
}
use of org.thingsboard.server.common.data.widget.WidgetsBundle 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;
}
use of org.thingsboard.server.common.data.widget.WidgetsBundle in project thingsboard by thingsboard.
the class BaseWidgetTypeServiceTest method testFindWidgetTypeById.
@Test
public void testFindWidgetTypeById() throws IOException {
WidgetsBundle widgetsBundle = new WidgetsBundle();
widgetsBundle.setTenantId(tenantId);
widgetsBundle.setTitle("Widgets bundle");
WidgetsBundle savedWidgetsBundle = widgetsBundleService.saveWidgetsBundle(widgetsBundle);
WidgetType widgetType = new WidgetType();
widgetType.setTenantId(tenantId);
widgetType.setBundleAlias(savedWidgetsBundle.getAlias());
widgetType.setName("Widget Type");
widgetType.setDescriptor(new ObjectMapper().readValue("{ \"someKey\": \"someValue\" }", JsonNode.class));
WidgetType savedWidgetType = widgetTypeService.saveWidgetType(widgetType);
WidgetType foundWidgetType = widgetTypeService.findWidgetTypeById(savedWidgetType.getId());
Assert.assertNotNull(foundWidgetType);
Assert.assertEquals(savedWidgetType, foundWidgetType);
widgetsBundleService.deleteWidgetsBundle(savedWidgetsBundle.getId());
}
Aggregations