Search in sources :

Example 1 with PageDataIterableByTenant

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

the class RuleChainController method getAutoAssignToEdgeRuleChains.

// TODO: @voba refactor this - add new config to edge rule chain to set it as auto-assign
@ApiOperation(value = "Get Auto Assign To Edge Rule Chains (getAutoAssignToEdgeRuleChains)", notes = "Returns a list of Rule Chains that will be assigned to a newly created edge. " + RULE_CHAIN_DESCRIPTION + TENANT_AUTHORITY_PARAGRAPH)
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/ruleChain/autoAssignToEdgeRuleChains", method = RequestMethod.GET)
@ResponseBody
public List<RuleChain> getAutoAssignToEdgeRuleChains() throws ThingsboardException {
    try {
        TenantId tenantId = getCurrentUser().getTenantId();
        List<RuleChain> result = new ArrayList<>();
        PageDataIterableByTenant<RuleChain> autoAssignRuleChainsIterator = new PageDataIterableByTenant<>(ruleChainService::findAutoAssignToEdgeRuleChainsByTenantId, tenantId, DEFAULT_PAGE_SIZE);
        for (RuleChain ruleChain : autoAssignRuleChainsIterator) {
            result.add(ruleChain);
        }
        return checkNotNull(result);
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : TenantId(org.thingsboard.server.common.data.id.TenantId) RuleChain(org.thingsboard.server.common.data.rule.RuleChain) ArrayList(java.util.ArrayList) PageDataIterableByTenant(org.thingsboard.server.common.data.page.PageDataIterableByTenant) ThingsboardException(org.thingsboard.server.common.data.exception.ThingsboardException) 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

ApiOperation (io.swagger.annotations.ApiOperation)1 ArrayList (java.util.ArrayList)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 ThingsboardException (org.thingsboard.server.common.data.exception.ThingsboardException)1 TenantId (org.thingsboard.server.common.data.id.TenantId)1 PageDataIterableByTenant (org.thingsboard.server.common.data.page.PageDataIterableByTenant)1 RuleChain (org.thingsboard.server.common.data.rule.RuleChain)1