use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class UserController method getCustomerUsers.
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/customer/{customerId}/users", params = { "limit" }, method = RequestMethod.GET)
@ResponseBody
public TextPageData<User> getCustomerUsers(@PathVariable("customerId") String strCustomerId, @RequestParam int limit, @RequestParam(required = false) String textSearch, @RequestParam(required = false) String idOffset, @RequestParam(required = false) String textOffset) throws ThingsboardException {
checkParameter("customerId", strCustomerId);
try {
CustomerId customerId = new CustomerId(toUUID(strCustomerId));
checkCustomerId(customerId);
TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset);
TenantId tenantId = getCurrentUser().getTenantId();
return checkNotNull(userService.findCustomerUsers(tenantId, customerId, pageLink));
} catch (Exception e) {
throw handleException(e);
}
}
use of org.thingsboard.server.common.data.page.TextPageLink 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.page.TextPageLink 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.page.TextPageLink in project thingsboard by thingsboard.
the class BaseRuleService method findAllTenantRulesByTenantId.
@Override
public List<RuleMetaData> findAllTenantRulesByTenantId(TenantId tenantId) {
log.trace("Executing findAllTenantRulesByTenantId, tenantId [{}]", tenantId);
Validator.validateId(tenantId, "Incorrect tenantId " + tenantId);
List<RuleMetaData> rules = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(300);
TextPageData<RuleMetaData> pageData = null;
do {
pageData = findAllTenantRulesByTenantIdAndPageLink(tenantId, pageLink);
rules.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
return rules;
}
use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.
the class PaginatedRemover method removeEntities.
public void removeEntities(I id) {
TextPageLink pageLink = new TextPageLink(DEFAULT_LIMIT);
boolean hasNext = true;
while (hasNext) {
List<D> entities = findEntities(id, pageLink);
for (D entity : entities) {
removeEntity(entity);
}
hasNext = entities.size() == pageLink.getLimit();
if (hasNext) {
int index = entities.size() - 1;
UUID idOffset = entities.get(index).getUuidId();
pageLink.setIdOffset(idOffset);
}
}
}
Aggregations