diff --git a/application/src/main/java/org/thingsboard/server/config/SwaggerConfiguration.java b/application/src/main/java/org/thingsboard/server/config/SwaggerConfiguration.java index 867efa67cc..6bdb1ae758 100644 --- a/application/src/main/java/org/thingsboard/server/config/SwaggerConfiguration.java +++ b/application/src/main/java/org/thingsboard/server/config/SwaggerConfiguration.java @@ -600,6 +600,22 @@ public class SwaggerConfiguration { if (baseType != null) { return baseType; } + + // Check if other oneOf items extend this candidate via allOf (parent-child without discriminator) + if (candidate != null) { + boolean isParent = oneOfSchemas.stream() + .filter(s -> s.get$ref() != null && !s.get$ref().equals(ref)) + .anyMatch(s -> { + String otherName = s.get$ref().substring(s.get$ref().lastIndexOf('/') + 1); + Schema otherSchema = schemas.get(otherName); + return otherSchema != null && otherSchema.getAllOf() != null && + otherSchema.getAllOf().stream().anyMatch( + a -> a.get$ref() != null && a.get$ref().endsWith("/" + refName)); + }); + if (isParent) { + return refName; + } + } } return null; } diff --git a/application/src/main/java/org/thingsboard/server/controller/UserController.java b/application/src/main/java/org/thingsboard/server/controller/UserController.java index 1796e959ab..b919b664e5 100644 --- a/application/src/main/java/org/thingsboard/server/controller/UserController.java +++ b/application/src/main/java/org/thingsboard/server/controller/UserController.java @@ -549,8 +549,7 @@ public class UserController extends BaseController { userSettingsService.deleteUserSettings(currentUser.getTenantId(), currentUser.getId(), type, Arrays.asList(paths.split(","))); } - @ApiOperation(value = "Get information about last visited and starred dashboards (getUserDashboardsInfo)", - notes = "Fetch the list of last visited and starred dashboards. Both lists are limited to 10 items." + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH) + @Hidden @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") @GetMapping(value = "/user/dashboards") public UserDashboardsInfo getUserDashboardsInfo() throws ThingsboardException { @@ -558,6 +557,14 @@ public class UserController extends BaseController { return userSettingsService.findUserDashboardsInfo(currentUser.getTenantId(), currentUser.getId()); } + @ApiOperation(value = "Get information about last visited and starred dashboards (getLastVisitedDashboards)", + notes = "Fetch the list of last visited and starred dashboards. Both lists are limited to 10 items." + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH) + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") + @GetMapping(value = "/user/lastVisitedDashboards") + public UserDashboardsInfo getLastVisitedDashboards() throws ThingsboardException { + return getUserDashboardsInfo(); + } + @ApiOperation(value = "Report action of User over the dashboard (reportUserDashboardAction)", notes = "Report action of User over the dashboard. " + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH) @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") diff --git a/application/src/main/java/org/thingsboard/server/controller/WidgetTypeController.java b/application/src/main/java/org/thingsboard/server/controller/WidgetTypeController.java index cfc50543a1..a89d870bf0 100644 --- a/application/src/main/java/org/thingsboard/server/controller/WidgetTypeController.java +++ b/application/src/main/java/org/thingsboard/server/controller/WidgetTypeController.java @@ -242,7 +242,7 @@ public class WidgetTypeController extends AutoCommitController { @ApiOperation(value = "Get all Widget types for specified Bundle (getBundleWidgetTypes)", notes = "Returns an array of Widget Type objects that belong to specified Widget Bundle." + WIDGET_TYPE_DESCRIPTION + " " + SYSTEM_OR_TENANT_AUTHORITY_PARAGRAPH) @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") - @GetMapping(value = "/widgetsBundles/{widgetsBundleId}/widgetTypes") + @GetMapping(value = "/widgetsBundle/{widgetsBundleId}/widgetTypes") public List getBundleWidgetTypes( @Parameter(description = "Widget Bundle Id", required = true) @PathVariable("widgetsBundleId") String strWidgetsBundleId) throws ThingsboardException { diff --git a/application/src/main/java/org/thingsboard/server/service/sync/ie/DefaultEntitiesExportImportService.java b/application/src/main/java/org/thingsboard/server/service/sync/ie/DefaultEntitiesExportImportService.java index cf8d9b1139..27bd88fc1a 100644 --- a/application/src/main/java/org/thingsboard/server/service/sync/ie/DefaultEntitiesExportImportService.java +++ b/application/src/main/java/org/thingsboard/server/service/sync/ie/DefaultEntitiesExportImportService.java @@ -64,7 +64,7 @@ public class DefaultEntitiesExportImportService implements EntitiesExportImportS private final RateLimitService rateLimitService; private final TbLogEntityActionService logEntityActionService; - protected static final List SUPPORTED_ENTITY_TYPES = List.of( + public static final List SUPPORTED_ENTITY_TYPES = List.of( EntityType.CUSTOMER, EntityType.RULE_CHAIN, EntityType.TB_RESOURCE, EntityType.DASHBOARD, EntityType.ASSET_PROFILE, EntityType.ASSET, EntityType.DEVICE_PROFILE, EntityType.OTA_PACKAGE, EntityType.DEVICE, @@ -131,7 +131,10 @@ public class DefaultEntitiesExportImportService implements EntitiesExportImportS @Override public Comparator getEntityTypeComparatorForImport() { - return Comparator.comparing(SUPPORTED_ENTITY_TYPES::indexOf); + return Comparator.comparingInt(type -> { + int index = SUPPORTED_ENTITY_TYPES.indexOf(type); + return index >= 0 ? index : Integer.MAX_VALUE; + }); } @SuppressWarnings("unchecked") diff --git a/application/src/test/java/org/thingsboard/server/client/CalculatedFieldApiClientTest.java b/application/src/test/java/org/thingsboard/server/client/CalculatedFieldApiClientTest.java index d17dd9d0f6..7594485c14 100644 --- a/application/src/test/java/org/thingsboard/server/client/CalculatedFieldApiClientTest.java +++ b/application/src/test/java/org/thingsboard/server/client/CalculatedFieldApiClientTest.java @@ -17,10 +17,8 @@ package org.thingsboard.server.client; import org.junit.Test; import org.thingsboard.client.model.AlarmCalculatedFieldConfiguration; -import org.thingsboard.client.model.AlarmConditionValueAlarmRuleSchedule; -import org.thingsboard.client.model.AlarmRuleDefinition; -import org.thingsboard.client.model.AlarmRuleSimpleCondition; -import org.thingsboard.client.model.AlarmRuleSpecificTimeSchedule; +import org.thingsboard.client.model.AlarmConditionValueAlarmSchedule; +import org.thingsboard.client.model.AlarmRule; import org.thingsboard.client.model.AlarmSeverity; import org.thingsboard.client.model.Argument; import org.thingsboard.client.model.ArgumentType; @@ -30,7 +28,9 @@ import org.thingsboard.client.model.Device; import org.thingsboard.client.model.EntityType; import org.thingsboard.client.model.PageDataCalculatedField; import org.thingsboard.client.model.ReferencedEntityKey; +import org.thingsboard.client.model.SimpleAlarmCondition; import org.thingsboard.client.model.SimpleCalculatedFieldConfiguration; +import org.thingsboard.client.model.SpecificTimeSchedule; import org.thingsboard.client.model.TbelAlarmConditionExpression; import org.thingsboard.client.model.TimeSeriesOutput; import org.thingsboard.server.dao.service.DaoSqlTest; @@ -198,12 +198,12 @@ public class CalculatedFieldApiClientTest extends AbstractApiClientTest { // create rule: HIGH_TEMPERATURE when temp > 50 (TBEL expression) TbelAlarmConditionExpression createExpression = new TbelAlarmConditionExpression(); createExpression.setExpression("return temp > 50;"); - AlarmRuleSimpleCondition createCondition = new AlarmRuleSimpleCondition(); + SimpleAlarmCondition createCondition = new SimpleAlarmCondition(); createCondition.setExpression(createExpression); - AlarmRuleSpecificTimeSchedule specificTimeSchedule = new AlarmRuleSpecificTimeSchedule().addDaysOfWeekItem(3); - AlarmConditionValueAlarmRuleSchedule schedule = new AlarmConditionValueAlarmRuleSchedule().staticValue(specificTimeSchedule); + SpecificTimeSchedule specificTimeSchedule = new SpecificTimeSchedule().addDaysOfWeekItem(3); + AlarmConditionValueAlarmSchedule schedule = new AlarmConditionValueAlarmSchedule().staticValue(specificTimeSchedule); createCondition.setSchedule(schedule); - AlarmRuleDefinition createRule = new AlarmRuleDefinition(); + AlarmRule createRule = new AlarmRule(); createRule.setCondition(createCondition); createRule.setAlarmDetails("Temperature is too high: ${temp}"); config.setCreateRules(Map.of( @@ -213,9 +213,9 @@ public class CalculatedFieldApiClientTest extends AbstractApiClientTest { // clear rule: when temp drops below 30 TbelAlarmConditionExpression clearExpression = new TbelAlarmConditionExpression(); clearExpression.setExpression("return temp < 30;"); - AlarmRuleSimpleCondition clearCondition = new AlarmRuleSimpleCondition(); + SimpleAlarmCondition clearCondition = new SimpleAlarmCondition(); clearCondition.setExpression(clearExpression); - AlarmRuleDefinition clearRule = new AlarmRuleDefinition(); + AlarmRule clearRule = new AlarmRule(); clearRule.setCondition(clearCondition); config.setClearRule(clearRule); @@ -236,8 +236,8 @@ public class CalculatedFieldApiClientTest extends AbstractApiClientTest { assertEquals(cf.getName(), created.getName()); assertEquals(CalculatedFieldType.ALARM, created.getType()); AlarmCalculatedFieldConfiguration configuration = (AlarmCalculatedFieldConfiguration) created.getConfiguration(); - AlarmConditionValueAlarmRuleSchedule createdSchedule = configuration.getCreateRules().get(AlarmSeverity.CRITICAL.name()).getCondition().getSchedule(); - AlarmRuleSpecificTimeSchedule staticSchedule = (AlarmRuleSpecificTimeSchedule) createdSchedule.getStaticValue(); + AlarmConditionValueAlarmSchedule createdSchedule = configuration.getCreateRules().get(AlarmSeverity.CRITICAL.name()).getCondition().getSchedule(); + SpecificTimeSchedule staticSchedule = (SpecificTimeSchedule) createdSchedule.getStaticValue(); assertEquals(Set.of(3), staticSchedule.getDaysOfWeek()); // get by id and verify configuration @@ -257,9 +257,9 @@ public class CalculatedFieldApiClientTest extends AbstractApiClientTest { // update: add a second create rule for CRITICAL_TEMPERATURE TbelAlarmConditionExpression criticalExpression = new TbelAlarmConditionExpression(); criticalExpression.setExpression("return temp > 80;"); - AlarmRuleSimpleCondition criticalCondition = new AlarmRuleSimpleCondition(); + SimpleAlarmCondition criticalCondition = new SimpleAlarmCondition(); criticalCondition.setExpression(criticalExpression); - AlarmRuleDefinition criticalRule = new AlarmRuleDefinition(); + AlarmRule criticalRule = new AlarmRule(); criticalRule.setCondition(criticalCondition); fetchedConfig.putCreateRulesItem(AlarmSeverity.INDETERMINATE.name(), criticalRule); fetched.setConfiguration(fetchedConfig); diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/OAuth2Client.java b/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/OAuth2Client.java index 23c0241d51..d5f61fdbeb 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/OAuth2Client.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/OAuth2Client.java @@ -93,7 +93,10 @@ public class OAuth2Client extends BaseDataWithAdditionalInfo imp @Schema(description = "List of platforms for which usage of the OAuth2 client is allowed (empty for all allowed)") @Length(fieldName = "platforms") private List platforms; - @Schema(description = "Additional info of OAuth2 client (e.g. providerName)", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "Additional info of OAuth2 client. " + + "Must include: 'providerName' (string, name of the OAuth2 provider).", + requiredMode = Schema.RequiredMode.REQUIRED, + example = "{\"providerName\":\"Google\"}") private JsonNode additionalInfo; public OAuth2Client() { @@ -128,4 +131,5 @@ public class OAuth2Client extends BaseDataWithAdditionalInfo imp public String getName() { return title; } + } diff --git a/pom.xml b/pom.xml index 84d3fdad47..24262c243f 100755 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ ${project.name} /var/log/${pkg.name} /usr/share/${pkg.name} - 4.4.0-SNAPSHOT + 4.3.1.2-SNAPSHOT 3.5.13 2.4.0-b180830.0359 0.12.5