|
|
|
@ -55,9 +55,9 @@ import org.thingsboard.server.common.data.EntityType; |
|
|
|
import org.thingsboard.server.common.data.EntityView; |
|
|
|
import org.thingsboard.server.common.data.EntityViewInfo; |
|
|
|
import org.thingsboard.server.common.data.EventInfo; |
|
|
|
import org.thingsboard.server.common.data.ResourceExportData; |
|
|
|
import org.thingsboard.server.common.data.OtaPackage; |
|
|
|
import org.thingsboard.server.common.data.OtaPackageInfo; |
|
|
|
import org.thingsboard.server.common.data.ResourceExportData; |
|
|
|
import org.thingsboard.server.common.data.ResourceSubType; |
|
|
|
import org.thingsboard.server.common.data.SaveDeviceWithCredentialsRequest; |
|
|
|
import org.thingsboard.server.common.data.StringUtils; |
|
|
|
@ -86,6 +86,7 @@ import org.thingsboard.server.common.data.asset.AssetProfileInfo; |
|
|
|
import org.thingsboard.server.common.data.asset.AssetSearchQuery; |
|
|
|
import org.thingsboard.server.common.data.audit.ActionType; |
|
|
|
import org.thingsboard.server.common.data.audit.AuditLog; |
|
|
|
import org.thingsboard.server.common.data.cf.CalculatedField; |
|
|
|
import org.thingsboard.server.common.data.device.DeviceSearchQuery; |
|
|
|
import org.thingsboard.server.common.data.domain.Domain; |
|
|
|
import org.thingsboard.server.common.data.domain.DomainInfo; |
|
|
|
@ -99,6 +100,7 @@ import org.thingsboard.server.common.data.id.AlarmCommentId; |
|
|
|
import org.thingsboard.server.common.data.id.AlarmId; |
|
|
|
import org.thingsboard.server.common.data.id.AssetId; |
|
|
|
import org.thingsboard.server.common.data.id.AssetProfileId; |
|
|
|
import org.thingsboard.server.common.data.id.CalculatedFieldId; |
|
|
|
import org.thingsboard.server.common.data.id.CustomerId; |
|
|
|
import org.thingsboard.server.common.data.id.DashboardId; |
|
|
|
import org.thingsboard.server.common.data.id.DeviceId; |
|
|
|
@ -3765,7 +3767,7 @@ public class RestClient implements Closeable { |
|
|
|
} |
|
|
|
|
|
|
|
public PageData<TbResourceInfo> getImages(PageLink pageLink, boolean includeSystemImages) { |
|
|
|
return this.getImages(pageLink, null, includeSystemImages); |
|
|
|
return this.getImages(pageLink, null, includeSystemImages); |
|
|
|
} |
|
|
|
|
|
|
|
public PageData<TbResourceInfo> getImages(PageLink pageLink, ResourceSubType imageSubType, boolean includeSystemImages) { |
|
|
|
@ -4056,6 +4058,65 @@ public class RestClient implements Closeable { |
|
|
|
timeout).getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public CalculatedField saveCalculatedField(CalculatedField calculatedField) { |
|
|
|
return restTemplate.postForEntity(baseURL + "/api/calculatedField", calculatedField, CalculatedField.class).getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public Optional<CalculatedField> getCalculatedFieldById(CalculatedFieldId calculatedFieldId) { |
|
|
|
try { |
|
|
|
ResponseEntity<CalculatedField> calculatedField = restTemplate.getForEntity(baseURL + "/api/calculatedField/{calculatedFieldId}", CalculatedField.class, calculatedFieldId.getId()); |
|
|
|
return Optional.ofNullable(calculatedField.getBody()); |
|
|
|
} catch (HttpClientErrorException exception) { |
|
|
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
|
|
|
return Optional.empty(); |
|
|
|
} else { |
|
|
|
throw exception; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public PageData<CalculatedField> getCalculatedFieldsByEntityId(EntityId entityId, PageLink pageLink) { |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
params.put("entityType", entityId.getEntityType().name()); |
|
|
|
params.put("entityId", entityId.getId().toString()); |
|
|
|
addPageLinkToParam(params, pageLink); |
|
|
|
return restTemplate.exchange( |
|
|
|
baseURL + "/api/{entityType}/{entityId}/calculatedFields?" + getUrlParams(pageLink), |
|
|
|
HttpMethod.GET, HttpEntity.EMPTY, |
|
|
|
new ParameterizedTypeReference<PageData<CalculatedField>>() { |
|
|
|
}, params).getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public void deleteCalculatedField(CalculatedFieldId calculatedFieldId) { |
|
|
|
restTemplate.delete(baseURL + "/api/calculatedField/{calculatedFieldId}", calculatedFieldId.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
public Optional<JsonNode> getLatestCalculatedFieldDebugEvent(CalculatedFieldId calculatedFieldId) { |
|
|
|
try { |
|
|
|
ResponseEntity<JsonNode> jsonNode = restTemplate.getForEntity(baseURL + "/api/calculatedField/{calculatedFieldId}/debug", JsonNode.class, calculatedFieldId.getId()); |
|
|
|
return Optional.ofNullable(jsonNode.getBody()); |
|
|
|
} catch (HttpClientErrorException exception) { |
|
|
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
|
|
|
return Optional.empty(); |
|
|
|
} else { |
|
|
|
throw exception; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public Optional<JsonNode> testCalculatedFieldScript(JsonNode inputParams) { |
|
|
|
try { |
|
|
|
ResponseEntity<JsonNode> jsonNode = restTemplate.postForEntity(baseURL + "/api/calculatedField/testScript", inputParams, JsonNode.class); |
|
|
|
return Optional.ofNullable(jsonNode.getBody()); |
|
|
|
} catch (HttpClientErrorException exception) { |
|
|
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
|
|
|
return Optional.empty(); |
|
|
|
} else { |
|
|
|
throw exception; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String getTimeUrlParams(TimePageLink pageLink) { |
|
|
|
String urlParams = getUrlParams(pageLink); |
|
|
|
if (pageLink.getStartTime() != null) { |
|
|
|
|