diff --git a/application/src/main/data/upgrade/basic/schema_update.sql b/application/src/main/data/upgrade/basic/schema_update.sql index add832ea6e..f0da7dcb47 100644 --- a/application/src/main/data/upgrade/basic/schema_update.sql +++ b/application/src/main/data/upgrade/basic/schema_update.sql @@ -43,4 +43,23 @@ DROP INDEX IF EXISTS idx_widgets_bundle_external_id; -- DROP INDEXES THAT DUPLICATE UNIQUE CONSTRAINT END -ALTER TABLE mobile_app ADD COLUMN IF NOT EXISTS title varchar(255); \ No newline at end of file +-- ADD NEW COLUMN TITLE TO MOBILE APP START + +ALTER TABLE mobile_app ADD COLUMN IF NOT EXISTS title varchar(255); + +-- ADD NEW COLUMN TITLE TO MOBILE APP END + +-- UPDATE TENANT PROFILE CONFIGURATION START + +UPDATE tenant_profile +SET profile_data = jsonb_set( + profile_data, + '{configuration}', + (profile_data -> 'configuration') || '{ + "minAllowedScheduledUpdateIntervalInSecForCF": 3600 + }'::jsonb, + false + ) +WHERE (profile_data -> 'configuration' -> 'minAllowedScheduledUpdateIntervalInSecForCF') IS NULL; + +-- UPDATE TENANT PROFILE CONFIGURATION END diff --git a/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/GeofencingZoneState.java b/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/GeofencingZoneState.java index 12493152dc..761245cb73 100644 --- a/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/GeofencingZoneState.java +++ b/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/GeofencingZoneState.java @@ -71,8 +71,7 @@ public class GeofencingZoneState { this.ts = newZoneState.getTs(); this.version = newVersion; this.perimeterDefinition = newZoneState.getPerimeterDefinition(); - // TODO: should we reinitialize state if zone changed? - // this.inside = null; + this.inside = null; return true; } return false; diff --git a/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingCalculatedFieldStateTest.java b/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingCalculatedFieldStateTest.java index cadb47c8f5..fe9444461e 100644 --- a/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingCalculatedFieldStateTest.java +++ b/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingCalculatedFieldStateTest.java @@ -160,7 +160,6 @@ public class GeofencingCalculatedFieldStateTest { assertThat(state.getArguments()).isEqualTo(newArgs); } - // TODO: write opposite test for this. See TODO in the GeofencingZoneState class. @Test void testUpdateStateWhenUpdateExistingGeofencingValueArgumentEntryWithTheSameValue() { state.arguments = new HashMap<>(Map.of("allowedZones", geofencingAllowedZoneArgEntry)); @@ -345,9 +344,6 @@ public class GeofencingCalculatedFieldStateTest { config.setZoneRelationType("CurrentZone"); config.setZoneRelationDirection(EntitySearchDirection.TO); - // TODO: Does CF possible to save with null? - config.setExpression("latitude + longitude"); - Output output = new Output(); output.setType(OutputType.TIME_SERIES); config.setOutput(output); diff --git a/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingValueArgumentEntryTest.java b/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingValueArgumentEntryTest.java index 4491716b19..aad9c4e29c 100644 --- a/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingValueArgumentEntryTest.java +++ b/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingValueArgumentEntryTest.java @@ -184,6 +184,4 @@ public class GeofencingValueArgumentEntryTest { assertThat(geofencingArgumentEntry.isEmpty()).isTrue(); } - // TODO: should we test to TBEL logic? - } diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/cf/configuration/Argument.java b/common/data/src/main/java/org/thingsboard/server/common/data/cf/configuration/Argument.java index 3b8ec3308a..52935c3411 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/cf/configuration/Argument.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/cf/configuration/Argument.java @@ -26,7 +26,6 @@ public class Argument { @Nullable private EntityId refEntityId; - // TODO: add upgrade in PE version -> CFArgumentDynamicSourceType to CFArgumentDynamicSourceConfiguration private CfArgumentDynamicSourceConfiguration refDynamicSourceConfiguration; private ReferencedEntityKey refEntityKey; private String defaultValue; diff --git a/common/data/src/test/java/org/thingsboard/server/common/data/cf/configuration/ArgumentTest.java b/common/data/src/test/java/org/thingsboard/server/common/data/cf/configuration/ArgumentTest.java new file mode 100644 index 0000000000..3039e36a05 --- /dev/null +++ b/common/data/src/test/java/org/thingsboard/server/common/data/cf/configuration/ArgumentTest.java @@ -0,0 +1,38 @@ +/** + * Copyright © 2016-2025 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.thingsboard.server.common.data.cf.configuration; + + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ArgumentTest { + + @Test + void validateShouldReturnFalseIfDynamicSourceConfigurationIsNull() { + var argument = new Argument(); + assertThat(argument.hasDynamicSource()).isFalse(); + } + + @Test + void validateShouldReturnTrueIfDynamicSourceConfigurationIsNotNull() { + var argument = new Argument(); + argument.setRefDynamicSourceConfiguration(new RelationQueryDynamicSourceConfiguration()); + assertThat(argument.hasDynamicSource()).isTrue(); + } + +} \ No newline at end of file