|
|
|
@ -72,6 +72,8 @@ import org.thingsboard.server.common.data.alarm.AlarmSeverity; |
|
|
|
import org.thingsboard.server.common.data.alarm.AlarmStatus; |
|
|
|
import org.thingsboard.server.common.data.asset.Asset; |
|
|
|
import org.thingsboard.server.common.data.asset.AssetInfo; |
|
|
|
import org.thingsboard.server.common.data.asset.AssetProfile; |
|
|
|
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; |
|
|
|
@ -83,6 +85,7 @@ import org.thingsboard.server.common.data.edge.EdgeSearchQuery; |
|
|
|
import org.thingsboard.server.common.data.entityview.EntityViewSearchQuery; |
|
|
|
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.CustomerId; |
|
|
|
import org.thingsboard.server.common.data.id.DashboardId; |
|
|
|
import org.thingsboard.server.common.data.id.DeviceId; |
|
|
|
@ -532,13 +535,14 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { |
|
|
|
return assets.getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public PageData<AssetInfo> getTenantAssetInfos(PageLink pageLink, String assetType) { |
|
|
|
public PageData<AssetInfo> getTenantAssetInfos(String type, AssetProfileId assetProfileId, PageLink pageLink) { |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
params.put("type", assetType); |
|
|
|
params.put("type", type); |
|
|
|
params.put("assetProfileId", assetProfileId != null ? assetProfileId.toString() : null); |
|
|
|
addPageLinkToParam(params, pageLink); |
|
|
|
|
|
|
|
ResponseEntity<PageData<AssetInfo>> assets = restTemplate.exchange( |
|
|
|
baseURL + "/api/tenant/assetInfos?type={type}&" + getUrlParams(pageLink), |
|
|
|
baseURL + "/api/tenant/assetInfos?type={type}&assetProfileId={assetProfileId}&" + getUrlParams(pageLink), |
|
|
|
HttpMethod.GET, HttpEntity.EMPTY, |
|
|
|
new ParameterizedTypeReference<PageData<AssetInfo>>() { |
|
|
|
}, |
|
|
|
@ -575,14 +579,15 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { |
|
|
|
return assets.getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public PageData<AssetInfo> getCustomerAssetInfos(CustomerId customerId, PageLink pageLink, String assetType) { |
|
|
|
public PageData<AssetInfo> getCustomerAssetInfos(CustomerId customerId, String assetType, AssetProfileId assetProfileId, PageLink pageLink) { |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
params.put("customerId", customerId.getId().toString()); |
|
|
|
params.put("type", assetType); |
|
|
|
params.put("assetProfileId", assetProfileId != null ? assetProfileId.toString() : null); |
|
|
|
addPageLinkToParam(params, pageLink); |
|
|
|
|
|
|
|
ResponseEntity<PageData<AssetInfo>> assets = restTemplate.exchange( |
|
|
|
baseURL + "/api/customer/{customerId}/assetInfos?type={type}&" + getUrlParams(pageLink), |
|
|
|
baseURL + "/api/customer/{customerId}/assetInfos?type={type}&assetProfileId={assetProfileId}&" + getUrlParams(pageLink), |
|
|
|
HttpMethod.GET, |
|
|
|
HttpEntity.EMPTY, |
|
|
|
new ParameterizedTypeReference<PageData<AssetInfo>>() { |
|
|
|
@ -1483,6 +1488,70 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable { |
|
|
|
}, params).getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public Optional<AssetProfile> getAssetProfileById(AssetProfileId assetProfileId) { |
|
|
|
try { |
|
|
|
ResponseEntity<AssetProfile> assetProfile = restTemplate.getForEntity(baseURL + "/api/assetProfile/{assetProfileId}", AssetProfile.class, assetProfileId); |
|
|
|
return Optional.ofNullable(assetProfile.getBody()); |
|
|
|
} catch (HttpClientErrorException exception) { |
|
|
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
|
|
|
return Optional.empty(); |
|
|
|
} else { |
|
|
|
throw exception; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public Optional<AssetProfileInfo> getAssetProfileInfoById(AssetProfileId assetProfileId) { |
|
|
|
try { |
|
|
|
ResponseEntity<AssetProfileInfo> assetProfileInfo = restTemplate.getForEntity(baseURL + "/api/assetProfileInfo/{assetProfileId}", AssetProfileInfo.class, assetProfileId); |
|
|
|
return Optional.ofNullable(assetProfileInfo.getBody()); |
|
|
|
} catch (HttpClientErrorException exception) { |
|
|
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { |
|
|
|
return Optional.empty(); |
|
|
|
} else { |
|
|
|
throw exception; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public AssetProfileInfo getDefaultAssetProfileInfo() { |
|
|
|
return restTemplate.getForEntity(baseURL + "/api/assetProfileInfo/default", AssetProfileInfo.class).getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public AssetProfile saveAssetProfile(AssetProfile assetProfile) { |
|
|
|
return restTemplate.postForEntity(baseURL + "/api/assetProfile", assetProfile, AssetProfile.class).getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public void deleteAssetProfile(AssetProfileId assetProfileId) { |
|
|
|
restTemplate.delete(baseURL + "/api/assetProfile/{assetProfileId}", assetProfileId); |
|
|
|
} |
|
|
|
|
|
|
|
public AssetProfile setDefaultAssetProfile(AssetProfileId assetProfileId) { |
|
|
|
return restTemplate.postForEntity( |
|
|
|
baseURL + "/api/assetProfile/{assetProfileId}/default", |
|
|
|
HttpEntity.EMPTY, AssetProfile.class, assetProfileId).getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public PageData<AssetProfile> getAssetProfiles(PageLink pageLink) { |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
addPageLinkToParam(params, pageLink); |
|
|
|
return restTemplate.exchange( |
|
|
|
baseURL + "/api/assetProfiles?" + getUrlParams(pageLink), |
|
|
|
HttpMethod.GET, HttpEntity.EMPTY, |
|
|
|
new ParameterizedTypeReference<PageData<AssetProfile>>() { |
|
|
|
}, params).getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public PageData<AssetProfileInfo> getAssetProfileInfos(PageLink pageLink) { |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
addPageLinkToParam(params, pageLink); |
|
|
|
return restTemplate.exchange( |
|
|
|
baseURL + "/api/assetProfileInfos?" + getUrlParams(pageLink), |
|
|
|
HttpMethod.GET, HttpEntity.EMPTY, |
|
|
|
new ParameterizedTypeReference<PageData<AssetProfileInfo>>() { |
|
|
|
}, params).getBody(); |
|
|
|
} |
|
|
|
|
|
|
|
public Long countEntitiesByQuery(EntityCountQuery query) { |
|
|
|
return restTemplate.postForObject(baseURL + "/api/entitiesQuery/count", query, Long.class); |
|
|
|
} |
|
|
|
|