|
|
|
@ -44,6 +44,7 @@ import org.thingsboard.script.api.tbel.TbelInvokeService; |
|
|
|
import org.thingsboard.server.common.data.EntityType; |
|
|
|
import org.thingsboard.server.common.data.EventInfo; |
|
|
|
import org.thingsboard.server.common.data.cf.CalculatedField; |
|
|
|
import org.thingsboard.server.common.data.cf.CalculatedFieldType; |
|
|
|
import org.thingsboard.server.common.data.cf.configuration.CalculatedFieldConfiguration; |
|
|
|
import org.thingsboard.server.common.data.event.EventType; |
|
|
|
import org.thingsboard.server.common.data.exception.ThingsboardException; |
|
|
|
@ -159,19 +160,27 @@ public class CalculatedFieldController extends BaseController { |
|
|
|
) |
|
|
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|
|
|
@GetMapping(value = "/{entityType}/{entityId}/calculatedFields", params = {"pageSize", "page"}) |
|
|
|
public PageData<CalculatedField> getCalculatedFieldsByEntityId( |
|
|
|
@Parameter(description = ENTITY_TYPE_PARAM_DESCRIPTION, required = true, schema = @Schema(defaultValue = "DEVICE")) @PathVariable("entityType") String entityType, |
|
|
|
@Parameter(description = ENTITY_ID_PARAM_DESCRIPTION, required = true) @PathVariable("entityId") String entityIdStr, |
|
|
|
@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true) @RequestParam int pageSize, |
|
|
|
@Parameter(description = PAGE_NUMBER_DESCRIPTION, required = true) @RequestParam int page, |
|
|
|
@Parameter(description = CF_TEXT_SEARCH_DESCRIPTION) @RequestParam(required = false) String textSearch, |
|
|
|
@Parameter(description = SORT_PROPERTY_DESCRIPTION, schema = @Schema(allowableValues = {"createdTime", "name"})) @RequestParam(required = false) String sortProperty, |
|
|
|
@Parameter(description = SORT_ORDER_DESCRIPTION, schema = @Schema(allowableValues = {"ASC", "DESC"})) @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
|
|
|
public PageData<CalculatedField> getCalculatedFieldsByEntityId(@Parameter(description = ENTITY_TYPE_PARAM_DESCRIPTION, required = true, schema = @Schema(defaultValue = "DEVICE")) |
|
|
|
@PathVariable("entityType") String entityType, |
|
|
|
@Parameter(description = ENTITY_ID_PARAM_DESCRIPTION, required = true) |
|
|
|
@PathVariable("entityId") String entityIdStr, |
|
|
|
@Parameter(description = PAGE_SIZE_DESCRIPTION, required = true) |
|
|
|
@RequestParam int pageSize, |
|
|
|
@Parameter(description = PAGE_NUMBER_DESCRIPTION, required = true) |
|
|
|
@RequestParam int page, |
|
|
|
@Parameter(description = "Calculated field type. If not specified, all types will be returned.") |
|
|
|
@RequestParam(required = false) CalculatedFieldType type, |
|
|
|
@Parameter(description = CF_TEXT_SEARCH_DESCRIPTION) |
|
|
|
@RequestParam(required = false) String textSearch, |
|
|
|
@Parameter(description = SORT_PROPERTY_DESCRIPTION, schema = @Schema(allowableValues = {"createdTime", "name"})) |
|
|
|
@RequestParam(required = false) String sortProperty, |
|
|
|
@Parameter(description = SORT_ORDER_DESCRIPTION, schema = @Schema(allowableValues = {"ASC", "DESC"})) |
|
|
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException { |
|
|
|
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
|
|
|
checkParameter("entityId", entityIdStr); |
|
|
|
EntityId entityId = EntityIdFactory.getByTypeAndUuid(entityType, entityIdStr); |
|
|
|
checkEntityId(entityId, Operation.READ_CALCULATED_FIELD); |
|
|
|
return checkNotNull(tbCalculatedFieldService.findAllByTenantIdAndEntityId(entityId, getCurrentUser(), pageLink)); |
|
|
|
return checkNotNull(tbCalculatedFieldService.findByTenantIdAndEntityId(getTenantId(), entityId, type, pageLink)); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation(value = "Delete Calculated Field (deleteCalculatedField)", |
|
|
|
|