added missing WidgetTypeController APIs to RestClient
This commit is contained in:
parent
67a8f70957
commit
431d8d92e2
@ -209,6 +209,7 @@ public class WidgetTypeController extends AutoCommitController {
|
|||||||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/widgetTypes", params = {"isSystem", "bundleAlias"}, method = RequestMethod.GET)
|
@RequestMapping(value = "/widgetTypes", params = {"isSystem", "bundleAlias"}, method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@Deprecated
|
||||||
public List<WidgetType> getBundleWidgetTypesByBundleAlias(
|
public List<WidgetType> getBundleWidgetTypesByBundleAlias(
|
||||||
@ApiParam(value = "System or Tenant", required = true)
|
@ApiParam(value = "System or Tenant", required = true)
|
||||||
@RequestParam boolean isSystem,
|
@RequestParam boolean isSystem,
|
||||||
@ -241,6 +242,7 @@ public class WidgetTypeController extends AutoCommitController {
|
|||||||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN')")
|
||||||
@RequestMapping(value = "/widgetTypesDetails", params = {"isSystem", "bundleAlias"}, method = RequestMethod.GET)
|
@RequestMapping(value = "/widgetTypesDetails", params = {"isSystem", "bundleAlias"}, method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@Deprecated
|
||||||
public List<WidgetTypeDetails> getBundleWidgetTypesDetailsByBundleAlias(
|
public List<WidgetTypeDetails> getBundleWidgetTypesDetailsByBundleAlias(
|
||||||
@ApiParam(value = "System or Tenant", required = true)
|
@ApiParam(value = "System or Tenant", required = true)
|
||||||
@RequestParam boolean isSystem,
|
@RequestParam boolean isSystem,
|
||||||
@ -256,7 +258,7 @@ public class WidgetTypeController extends AutoCommitController {
|
|||||||
return checkNotNull(widgetTypeService.findWidgetTypesDetailsByWidgetsBundleId(getTenantId(), widgetsBundle.getId()));
|
return checkNotNull(widgetTypeService.findWidgetTypesDetailsByWidgetsBundleId(getTenantId(), widgetsBundle.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "Get all Widget types details for specified Bundle (getBundleWidgetTypes)",
|
@ApiOperation(value = "Get all Widget types details for specified Bundle (getBundleWidgetTypesDetails)",
|
||||||
notes = "Returns an array of Widget Type Details objects that belong to specified Widget Bundle." + WIDGET_TYPE_DETAILS_DESCRIPTION + " " + SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH)
|
notes = "Returns an array of Widget Type Details objects that belong to specified Widget Bundle." + WIDGET_TYPE_DETAILS_DESCRIPTION + " " + SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH)
|
||||||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/widgetTypesDetails", params = {"widgetsBundleId"}, method = RequestMethod.GET)
|
@RequestMapping(value = "/widgetTypesDetails", params = {"widgetsBundleId"}, method = RequestMethod.GET)
|
||||||
@ -292,6 +294,7 @@ public class WidgetTypeController extends AutoCommitController {
|
|||||||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/widgetTypesInfos", params = {"isSystem", "bundleAlias"}, method = RequestMethod.GET)
|
@RequestMapping(value = "/widgetTypesInfos", params = {"isSystem", "bundleAlias"}, method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@Deprecated
|
||||||
public List<WidgetTypeInfo> getBundleWidgetTypesInfosByBundleAlias(
|
public List<WidgetTypeInfo> getBundleWidgetTypesInfosByBundleAlias(
|
||||||
@ApiParam(value = "System or Tenant", required = true)
|
@ApiParam(value = "System or Tenant", required = true)
|
||||||
@RequestParam boolean isSystem,
|
@RequestParam boolean isSystem,
|
||||||
@ -345,6 +348,7 @@ public class WidgetTypeController extends AutoCommitController {
|
|||||||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/widgetType", params = {"isSystem", "bundleAlias", "alias"}, method = RequestMethod.GET)
|
@RequestMapping(value = "/widgetType", params = {"isSystem", "bundleAlias", "alias"}, method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@Deprecated
|
||||||
public WidgetType getWidgetTypeByBundleAliasAndTypeAlias(
|
public WidgetType getWidgetTypeByBundleAliasAndTypeAlias(
|
||||||
@ApiParam(value = "System or Tenant", required = true)
|
@ApiParam(value = "System or Tenant", required = true)
|
||||||
@RequestParam boolean isSystem,
|
@RequestParam boolean isSystem,
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.http.client.support.HttpRequestWrapper;
|
import org.springframework.http.client.support.HttpRequestWrapper;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
@ -160,6 +161,7 @@ import org.thingsboard.server.common.data.sync.vc.VersionLoadResult;
|
|||||||
import org.thingsboard.server.common.data.sync.vc.VersionedEntityInfo;
|
import org.thingsboard.server.common.data.sync.vc.VersionedEntityInfo;
|
||||||
import org.thingsboard.server.common.data.sync.vc.request.create.VersionCreateRequest;
|
import org.thingsboard.server.common.data.sync.vc.request.create.VersionCreateRequest;
|
||||||
import org.thingsboard.server.common.data.sync.vc.request.load.VersionLoadRequest;
|
import org.thingsboard.server.common.data.sync.vc.request.load.VersionLoadRequest;
|
||||||
|
import org.thingsboard.server.common.data.widget.DeprecatedFilter;
|
||||||
import org.thingsboard.server.common.data.widget.WidgetType;
|
import org.thingsboard.server.common.data.widget.WidgetType;
|
||||||
import org.thingsboard.server.common.data.widget.WidgetTypeDetails;
|
import org.thingsboard.server.common.data.widget.WidgetTypeDetails;
|
||||||
import org.thingsboard.server.common.data.widget.WidgetTypeInfo;
|
import org.thingsboard.server.common.data.widget.WidgetTypeInfo;
|
||||||
@ -2751,6 +2753,19 @@ public class RestClient implements Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<WidgetTypeInfo> getWidgetTypeInfoById(WidgetTypeId widgetTypeId) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<WidgetTypeInfo> widgetTypeInfo =
|
||||||
|
restTemplate.getForEntity(baseURL + "/api/widgetTypeInfo/{widgetTypeId}", WidgetTypeInfo.class, widgetTypeId.getId());
|
||||||
|
return Optional.ofNullable(widgetTypeInfo.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public WidgetTypeDetails saveWidgetType(WidgetTypeDetails widgetTypeDetails) {
|
public WidgetTypeDetails saveWidgetType(WidgetTypeDetails widgetTypeDetails) {
|
||||||
return restTemplate.postForEntity(baseURL + "/api/widgetType", widgetTypeDetails, WidgetTypeDetails.class).getBody();
|
return restTemplate.postForEntity(baseURL + "/api/widgetType", widgetTypeDetails, WidgetTypeDetails.class).getBody();
|
||||||
}
|
}
|
||||||
@ -2759,6 +2774,22 @@ public class RestClient implements Closeable {
|
|||||||
restTemplate.delete(baseURL + "/api/widgetType/{widgetTypeId}", widgetTypeId.getId());
|
restTemplate.delete(baseURL + "/api/widgetType/{widgetTypeId}", widgetTypeId.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageData<WidgetTypeInfo> getWidgetTypes(PageLink pageLink, Boolean tenantOnly, Boolean fullSearch,
|
||||||
|
DeprecatedFilter deprecatedFilter, List<String> widgetTypeList) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
addWidgetInfoFiltersToParams(tenantOnly, fullSearch, deprecatedFilter, widgetTypeList, params);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/widgetTypes?" + getUrlParams(pageLink) +
|
||||||
|
getWidgetTypeInfoPageRequestUrlParams(tenantOnly, fullSearch, deprecatedFilter, widgetTypeList),
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<WidgetTypeInfo>>() {
|
||||||
|
},
|
||||||
|
params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated // current name in the controller: getBundleWidgetTypesByBundleAlias
|
||||||
public List<WidgetType> getBundleWidgetTypes(boolean isSystem, String bundleAlias) {
|
public List<WidgetType> getBundleWidgetTypes(boolean isSystem, String bundleAlias) {
|
||||||
return restTemplate.exchange(
|
return restTemplate.exchange(
|
||||||
baseURL + "/api/widgetTypes?isSystem={isSystem}&bundleAlias={bundleAlias}",
|
baseURL + "/api/widgetTypes?isSystem={isSystem}&bundleAlias={bundleAlias}",
|
||||||
@ -2770,6 +2801,17 @@ public class RestClient implements Closeable {
|
|||||||
bundleAlias).getBody();
|
bundleAlias).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<WidgetType> getBundleWidgetTypes(WidgetsBundleId widgetsBundleId) {
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/widgetTypes?widgetsBundleId={widgetsBundleId}",
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<List<WidgetType>>() {
|
||||||
|
},
|
||||||
|
widgetsBundleId.getId()).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated // current name in the controller: getBundleWidgetTypesDetailsByBundleAlias
|
||||||
public List<WidgetTypeDetails> getBundleWidgetTypesDetails(boolean isSystem, String bundleAlias) {
|
public List<WidgetTypeDetails> getBundleWidgetTypesDetails(boolean isSystem, String bundleAlias) {
|
||||||
return restTemplate.exchange(
|
return restTemplate.exchange(
|
||||||
baseURL + "/api/widgetTypesDetails?isSystem={isSystem}&bundleAlias={bundleAlias}",
|
baseURL + "/api/widgetTypesDetails?isSystem={isSystem}&bundleAlias={bundleAlias}",
|
||||||
@ -2781,6 +2823,28 @@ public class RestClient implements Closeable {
|
|||||||
bundleAlias).getBody();
|
bundleAlias).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<WidgetTypeDetails> getBundleWidgetTypesDetails(WidgetsBundleId widgetsBundleId, boolean inlineImages) {
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/widgetTypesDetails?widgetsBundleId={widgetsBundleId}&inlineImages={inlineImages}",
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<List<WidgetTypeDetails>>() {
|
||||||
|
},
|
||||||
|
widgetsBundleId.getId(),
|
||||||
|
inlineImages).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getBundleWidgetTypeFqns(WidgetsBundleId widgetsBundleId) {
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/widgetTypeFqns?widgetsBundleId={widgetsBundleId}",
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<List<String>>() {
|
||||||
|
},
|
||||||
|
widgetsBundleId.getId()).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated // current name in the controller: getBundleWidgetTypesInfosByBundleAlias
|
||||||
public List<WidgetTypeInfo> getBundleWidgetTypesInfos(boolean isSystem, String bundleAlias) {
|
public List<WidgetTypeInfo> getBundleWidgetTypesInfos(boolean isSystem, String bundleAlias) {
|
||||||
return restTemplate.exchange(
|
return restTemplate.exchange(
|
||||||
baseURL + "/api/widgetTypesInfos?isSystem={isSystem}&bundleAlias={bundleAlias}",
|
baseURL + "/api/widgetTypesInfos?isSystem={isSystem}&bundleAlias={bundleAlias}",
|
||||||
@ -2792,6 +2856,24 @@ public class RestClient implements Closeable {
|
|||||||
bundleAlias).getBody();
|
bundleAlias).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PageData<WidgetTypeInfo> getBundleWidgetTypesInfos(WidgetsBundleId widgetsBundleId, PageLink pageLink,
|
||||||
|
Boolean tenantOnly, Boolean fullSearch,
|
||||||
|
DeprecatedFilter deprecatedFilter, List<String> widgetTypeList) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("widgetsBundleId", widgetsBundleId.getId().toString());
|
||||||
|
addPageLinkToParam(params, pageLink);
|
||||||
|
addWidgetInfoFiltersToParams(tenantOnly, fullSearch, deprecatedFilter, widgetTypeList, params);
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/widgetTypesInfos?widgetsBundleId={widgetsBundleId}&" + getUrlParams(pageLink) +
|
||||||
|
getWidgetTypeInfoPageRequestUrlParams(tenantOnly, fullSearch, deprecatedFilter, widgetTypeList),
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<PageData<WidgetTypeInfo>>() {
|
||||||
|
},
|
||||||
|
params).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated // current name in the controller: getWidgetTypeByBundleAliasAndTypeAlias
|
||||||
public Optional<WidgetType> getWidgetType(boolean isSystem, String bundleAlias, String alias) {
|
public Optional<WidgetType> getWidgetType(boolean isSystem, String bundleAlias, String alias) {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<WidgetType> widgetType =
|
ResponseEntity<WidgetType> widgetType =
|
||||||
@ -2811,6 +2893,22 @@ public class RestClient implements Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<WidgetType> getWidgetType(String fqn) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<WidgetType> widgetType =
|
||||||
|
restTemplate.getForEntity(
|
||||||
|
baseURL + "/api/widgetType?fqn={fqn}",
|
||||||
|
WidgetType.class,
|
||||||
|
fqn);
|
||||||
|
return Optional.ofNullable(widgetType.getBody());
|
||||||
|
} catch (HttpClientErrorException exception) {
|
||||||
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean isEdgesSupportEnabled() {
|
public Boolean isEdgesSupportEnabled() {
|
||||||
return restTemplate.getForEntity(baseURL + "/api/edges/enabled", Boolean.class).getBody();
|
return restTemplate.getForEntity(baseURL + "/api/edges/enabled", Boolean.class).getBody();
|
||||||
}
|
}
|
||||||
@ -3645,6 +3743,25 @@ public class RestClient implements Closeable {
|
|||||||
return urlParams;
|
return urlParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getWidgetTypeInfoPageRequestUrlParams(Boolean tenantOnly, Boolean fullSearch,
|
||||||
|
DeprecatedFilter deprecatedFilter,
|
||||||
|
List<String> widgetTypeList) {
|
||||||
|
String urlParams = "";
|
||||||
|
if (tenantOnly != null) {
|
||||||
|
urlParams = "&tenantOnly={tenantOnly}";
|
||||||
|
}
|
||||||
|
if (fullSearch != null) {
|
||||||
|
urlParams += "&fullSearch={fullSearch}";
|
||||||
|
}
|
||||||
|
if (deprecatedFilter != null) {
|
||||||
|
urlParams += "&deprecatedFilter={deprecatedFilter}";
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(widgetTypeList)) {
|
||||||
|
urlParams += "&widgetTypeList={widgetTypeList}";
|
||||||
|
}
|
||||||
|
return urlParams;
|
||||||
|
}
|
||||||
|
|
||||||
private void addTimePageLinkToParam(Map<String, String> params, TimePageLink pageLink) {
|
private void addTimePageLinkToParam(Map<String, String> params, TimePageLink pageLink) {
|
||||||
this.addPageLinkToParam(params, pageLink);
|
this.addPageLinkToParam(params, pageLink);
|
||||||
if (pageLink.getStartTime() != null) {
|
if (pageLink.getStartTime() != null) {
|
||||||
@ -3667,6 +3784,22 @@ public class RestClient implements Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addWidgetInfoFiltersToParams(Boolean tenantOnly, Boolean fullSearch, DeprecatedFilter deprecatedFilter,
|
||||||
|
List<String> widgetTypeList, Map<String, String> params) {
|
||||||
|
if (tenantOnly != null) {
|
||||||
|
params.put("tenantOnly", tenantOnly.toString());
|
||||||
|
}
|
||||||
|
if (fullSearch != null) {
|
||||||
|
params.put("fullSearch", fullSearch.toString());
|
||||||
|
}
|
||||||
|
if (deprecatedFilter != null) {
|
||||||
|
params.put("deprecatedFilter", deprecatedFilter.name());
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(widgetTypeList)) {
|
||||||
|
params.put("widgetTypeList", listToString(widgetTypeList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String listToString(List<String> list) {
|
private String listToString(List<String> list) {
|
||||||
return String.join(",", list);
|
return String.join(",", list);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user