Search in sources :

Example 1 with DASHBOARD_TEXT_SEARCH_DESCRIPTION

use of org.thingsboard.server.controller.ControllerConstants.DASHBOARD_TEXT_SEARCH_DESCRIPTION in project thingsboard by thingsboard.

the class DashboardController method getEdgeDashboards.

@ApiOperation(value = "Get Edge Dashboards (getEdgeDashboards)", notes = "Returns a page of dashboard info objects assigned to the specified edge. " + DASHBOARD_INFO_DEFINITION + " " + PAGE_DATA_PARAMETERS + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/edge/{edgeId}/dashboards", params = { "pageSize", "page" }, method = RequestMethod.GET)
@ResponseBody
public PageData<DashboardInfo> getEdgeDashboards(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true) @PathVariable(EDGE_ID) String strEdgeId, @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) @RequestParam int pageSize, @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) @RequestParam int page, @ApiParam(value = DASHBOARD_TEXT_SEARCH_DESCRIPTION) @RequestParam(required = false) String textSearch, @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES) @RequestParam(required = false) String sortProperty, @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) @RequestParam(required = false) String sortOrder) throws ThingsboardException {
    checkParameter("edgeId", strEdgeId);
    try {
        TenantId tenantId = getCurrentUser().getTenantId();
        EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
        checkEdgeId(edgeId, Operation.READ);
        PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
        PageData<DashboardInfo> nonFilteredResult = dashboardService.findDashboardsByTenantIdAndEdgeId(tenantId, edgeId, pageLink);
        List<DashboardInfo> filteredDashboards = nonFilteredResult.getData().stream().filter(dashboardInfo -> {
            try {
                accessControlService.checkPermission(getCurrentUser(), Resource.DASHBOARD, Operation.READ, dashboardInfo.getId(), dashboardInfo);
                return true;
            } catch (ThingsboardException e) {
                return false;
            }
        }).collect(Collectors.toList());
        PageData<DashboardInfo> filteredResult = new PageData<>(filteredDashboards, nonFilteredResult.getTotalPages(), nonFilteredResult.getTotalElements(), nonFilteredResult.hasNext());
        return checkNotNull(filteredResult);
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH(org.thingsboard.server.controller.ControllerConstants.TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH) PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) Edge(org.thingsboard.server.common.data.edge.Edge) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Customer(org.thingsboard.server.common.data.Customer) DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES(org.thingsboard.server.controller.ControllerConstants.DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES) SORT_ORDER_ALLOWABLE_VALUES(org.thingsboard.server.controller.ControllerConstants.SORT_ORDER_ALLOWABLE_VALUES) ApiParam(io.swagger.annotations.ApiParam) CUSTOMER_ID_PARAM_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.CUSTOMER_ID_PARAM_DESCRIPTION) TenantId(org.thingsboard.server.common.data.id.TenantId) ApiOperation(io.swagger.annotations.ApiOperation) EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_RECEIVE_STEP_DESCRIPTION) Example(io.swagger.annotations.Example) EntityType(org.thingsboard.server.common.data.EntityType) CUSTOMER_ID(org.thingsboard.server.controller.ControllerConstants.CUSTOMER_ID) JsonNode(com.fasterxml.jackson.databind.JsonNode) EdgeId(org.thingsboard.server.common.data.id.EdgeId) Dashboard(org.thingsboard.server.common.data.Dashboard) TENANT_ID(org.thingsboard.server.controller.ControllerConstants.TENANT_ID) PageLink(org.thingsboard.server.common.data.page.PageLink) DashboardInfo(org.thingsboard.server.common.data.DashboardInfo) TENANT_AUTHORITY_PARAGRAPH(org.thingsboard.server.controller.ControllerConstants.TENANT_AUTHORITY_PARAGRAPH) MediaType(org.springframework.http.MediaType) SecurityUser(org.thingsboard.server.service.security.model.SecurityUser) EDGE_ID(org.thingsboard.server.controller.ControllerConstants.EDGE_ID) PAGE_DATA_PARAMETERS(org.thingsboard.server.controller.ControllerConstants.PAGE_DATA_PARAMETERS) UUID_WIKI_LINK(org.thingsboard.server.controller.ControllerConstants.UUID_WIKI_LINK) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Set(java.util.Set) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) EdgeEventActionType(org.thingsboard.server.common.data.edge.EdgeEventActionType) List(java.util.List) EDGE_ID_PARAM_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.EDGE_ID_PARAM_DESCRIPTION) Operation(org.thingsboard.server.service.security.permission.Operation) SORT_ORDER_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.SORT_ORDER_DESCRIPTION) TENANT_ID_PARAM_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.TENANT_ID_PARAM_DESCRIPTION) PAGE_NUMBER_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.PAGE_NUMBER_DESCRIPTION) CustomerId(org.thingsboard.server.common.data.id.CustomerId) SORT_PROPERTY_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.SORT_PROPERTY_DESCRIPTION) JacksonUtil(org.thingsboard.common.util.JacksonUtil) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ShortCustomerInfo(org.thingsboard.server.common.data.ShortCustomerInfo) Tenant(org.thingsboard.server.common.data.Tenant) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Value(org.springframework.beans.factory.annotation.Value) RequestBody(org.springframework.web.bind.annotation.RequestBody) HashSet(java.util.HashSet) DASHBOARD_ID_PARAM_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.DASHBOARD_ID_PARAM_DESCRIPTION) User(org.thingsboard.server.common.data.User) HomeDashboard(org.thingsboard.server.common.data.HomeDashboard) ActionType(org.thingsboard.server.common.data.audit.ActionType) TbCoreComponent(org.thingsboard.server.queue.util.TbCoreComponent) PAGE_SIZE_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.PAGE_SIZE_DESCRIPTION) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) HomeDashboardInfo(org.thingsboard.server.common.data.HomeDashboardInfo) DashboardId(org.thingsboard.server.common.data.id.DashboardId) DASHBOARD_TEXT_SEARCH_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.DASHBOARD_TEXT_SEARCH_DESCRIPTION) ThingsboardException(org.thingsboard.server.common.data.exception.ThingsboardException) EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_ASYNC_FIRST_STEP_DESCRIPTION) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) SYSTEM_AUTHORITY_PARAGRAPH(org.thingsboard.server.controller.ControllerConstants.SYSTEM_AUTHORITY_PARAGRAPH) HttpStatus(org.springframework.http.HttpStatus) EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.EDGE_ASSIGN_RECEIVE_STEP_DESCRIPTION) EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION(org.thingsboard.server.controller.ControllerConstants.EDGE_UNASSIGN_ASYNC_FIRST_STEP_DESCRIPTION) ApiResponse(io.swagger.annotations.ApiResponse) ExampleProperty(io.swagger.annotations.ExampleProperty) PageData(org.thingsboard.server.common.data.page.PageData) Resource(org.thingsboard.server.service.security.permission.Resource) TenantId(org.thingsboard.server.common.data.id.TenantId) PageData(org.thingsboard.server.common.data.page.PageData) EdgeId(org.thingsboard.server.common.data.id.EdgeId) PageLink(org.thingsboard.server.common.data.page.PageLink) ThingsboardException(org.thingsboard.server.common.data.exception.ThingsboardException) ThingsboardException(org.thingsboard.server.common.data.exception.ThingsboardException) DashboardInfo(org.thingsboard.server.common.data.DashboardInfo) HomeDashboardInfo(org.thingsboard.server.common.data.HomeDashboardInfo) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiParam (io.swagger.annotations.ApiParam)1 ApiResponse (io.swagger.annotations.ApiResponse)1 Example (io.swagger.annotations.Example)1 ExampleProperty (io.swagger.annotations.ExampleProperty)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Value (org.springframework.beans.factory.annotation.Value)1 HttpStatus (org.springframework.http.HttpStatus)1 MediaType (org.springframework.http.MediaType)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 PathVariable (org.springframework.web.bind.annotation.PathVariable)1 RequestBody (org.springframework.web.bind.annotation.RequestBody)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)1 RequestParam (org.springframework.web.bind.annotation.RequestParam)1