Search in sources :

Example 41 with TextPageLink

use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.

the class PluginController method getTenantPlugins.

@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/plugin", params = { "limit" }, method = RequestMethod.GET)
@ResponseBody
public TextPageData<PluginMetaData> getTenantPlugins(@RequestParam int limit, @RequestParam(required = false) String textSearch, @RequestParam(required = false) String idOffset, @RequestParam(required = false) String textOffset) throws ThingsboardException {
    try {
        TenantId tenantId = getCurrentUser().getTenantId();
        TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset);
        return checkNotNull(pluginService.findTenantPlugins(tenantId, pageLink));
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) TextPageLink(org.thingsboard.server.common.data.page.TextPageLink) ThingsboardException(org.thingsboard.server.exception.ThingsboardException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 42 with TextPageLink

use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.

the class UserController method getTenantAdmins.

@PreAuthorize("hasAuthority('SYS_ADMIN')")
@RequestMapping(value = "/tenant/{tenantId}/users", params = { "limit" }, method = RequestMethod.GET)
@ResponseBody
public TextPageData<User> getTenantAdmins(@PathVariable("tenantId") String strTenantId, @RequestParam int limit, @RequestParam(required = false) String textSearch, @RequestParam(required = false) String idOffset, @RequestParam(required = false) String textOffset) throws ThingsboardException {
    checkParameter("tenantId", strTenantId);
    try {
        TenantId tenantId = new TenantId(toUUID(strTenantId));
        TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset);
        return checkNotNull(userService.findTenantAdmins(tenantId, pageLink));
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) TextPageLink(org.thingsboard.server.common.data.page.TextPageLink) ThingsboardException(org.thingsboard.server.exception.ThingsboardException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 43 with TextPageLink

use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.

the class DashboardController method getTenantDashboards.

@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/tenant/dashboards", params = { "limit" }, method = RequestMethod.GET)
@ResponseBody
public TextPageData<DashboardInfo> getTenantDashboards(@RequestParam int limit, @RequestParam(required = false) String textSearch, @RequestParam(required = false) String idOffset, @RequestParam(required = false) String textOffset) throws ThingsboardException {
    try {
        TenantId tenantId = getCurrentUser().getTenantId();
        TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset);
        return checkNotNull(dashboardService.findDashboardsByTenantId(tenantId, pageLink));
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) TextPageLink(org.thingsboard.server.common.data.page.TextPageLink) ThingsboardException(org.thingsboard.server.exception.ThingsboardException) IncorrectParameterException(org.thingsboard.server.dao.exception.IncorrectParameterException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 44 with TextPageLink

use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.

the class DeviceController method getTenantDevices.

@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/tenant/devices", params = { "limit" }, method = RequestMethod.GET)
@ResponseBody
public TextPageData<Device> getTenantDevices(@RequestParam int limit, @RequestParam(required = false) String type, @RequestParam(required = false) String textSearch, @RequestParam(required = false) String idOffset, @RequestParam(required = false) String textOffset) throws ThingsboardException {
    try {
        TenantId tenantId = getCurrentUser().getTenantId();
        TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset);
        if (type != null && type.trim().length() > 0) {
            return checkNotNull(deviceService.findDevicesByTenantIdAndType(tenantId, type, pageLink));
        } else {
            return checkNotNull(deviceService.findDevicesByTenantId(tenantId, pageLink));
        }
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) TextPageLink(org.thingsboard.server.common.data.page.TextPageLink) IncorrectParameterException(org.thingsboard.server.dao.exception.IncorrectParameterException) ThingsboardException(org.thingsboard.server.exception.ThingsboardException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 45 with TextPageLink

use of org.thingsboard.server.common.data.page.TextPageLink in project thingsboard by thingsboard.

the class RuleController method getTenantRules.

@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/rule", params = { "limit" }, method = RequestMethod.GET)
@ResponseBody
public TextPageData<RuleMetaData> getTenantRules(@RequestParam int limit, @RequestParam(required = false) String textSearch, @RequestParam(required = false) String idOffset, @RequestParam(required = false) String textOffset) throws ThingsboardException {
    try {
        TenantId tenantId = getCurrentUser().getTenantId();
        TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset);
        return checkNotNull(ruleService.findTenantRules(tenantId, pageLink));
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) TextPageLink(org.thingsboard.server.common.data.page.TextPageLink) ThingsboardException(org.thingsboard.server.exception.ThingsboardException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

TextPageLink (org.thingsboard.server.common.data.page.TextPageLink)93 Test (org.junit.Test)75 ArrayList (java.util.ArrayList)58 TenantId (org.thingsboard.server.common.data.id.TenantId)37 TypeReference (com.fasterxml.jackson.core.type.TypeReference)27 Tenant (org.thingsboard.server.common.data.Tenant)24 CustomerId (org.thingsboard.server.common.data.id.CustomerId)19 Customer (org.thingsboard.server.common.data.Customer)18 AbstractJpaDaoTest (org.thingsboard.server.dao.AbstractJpaDaoTest)18 UUID (java.util.UUID)15 Asset (org.thingsboard.server.common.data.asset.Asset)14 Matchers.containsString (org.hamcrest.Matchers.containsString)13 User (org.thingsboard.server.common.data.User)13 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)11 PluginMetaData (org.thingsboard.server.common.data.plugin.PluginMetaData)11 WidgetsBundle (org.thingsboard.server.common.data.widget.WidgetsBundle)11 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)10 RuleMetaData (org.thingsboard.server.common.data.rule.RuleMetaData)10 ThingsboardException (org.thingsboard.server.exception.ThingsboardException)10 Device (org.thingsboard.server.common.data.Device)7