Commit a64c4e3e203e1854c0ced8349dfb56e948a24ded
1 parent
6d5d9a55
DeviceProfileNode fix for conditions based on the attributes
Showing
6 changed files
with
20 additions
and
7 deletions
application/src/main/java/org/thingsboard/server/service/apiusage/DefaultTbApiUsageStateService.java
@@ -156,7 +156,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { | @@ -156,7 +156,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { | ||
156 | } finally { | 156 | } finally { |
157 | updateLock.unlock(); | 157 | updateLock.unlock(); |
158 | } | 158 | } |
159 | - tsWsService.saveAndNotify(tenantId, tenantState.getApiUsageState().getId(), updatedEntries, 0L, VOID_CALLBACK); | 159 | + tsWsService.saveAndNotifyInternal(tenantId, tenantState.getApiUsageState().getId(), updatedEntries, 0L, VOID_CALLBACK); |
160 | if (!result.isEmpty()) { | 160 | if (!result.isEmpty()) { |
161 | persistAndNotify(tenantState, result); | 161 | persistAndNotify(tenantState, result); |
162 | } | 162 | } |
@@ -256,7 +256,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { | @@ -256,7 +256,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { | ||
256 | } | 256 | } |
257 | } | 257 | } |
258 | if (!profileThresholds.isEmpty()) { | 258 | if (!profileThresholds.isEmpty()) { |
259 | - tsWsService.saveAndNotify(tenantId, id, profileThresholds, 0L, VOID_CALLBACK); | 259 | + tsWsService.saveAndNotifyInternal(tenantId, id, profileThresholds, 0L, VOID_CALLBACK); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
@@ -266,7 +266,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { | @@ -266,7 +266,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { | ||
266 | long ts = System.currentTimeMillis(); | 266 | long ts = System.currentTimeMillis(); |
267 | List<TsKvEntry> stateTelemetry = new ArrayList<>(); | 267 | List<TsKvEntry> stateTelemetry = new ArrayList<>(); |
268 | result.forEach(((apiFeature, aState) -> stateTelemetry.add(new BasicTsKvEntry(ts, new BooleanDataEntry(apiFeature.getApiStateKey(), aState))))); | 268 | result.forEach(((apiFeature, aState) -> stateTelemetry.add(new BasicTsKvEntry(ts, new BooleanDataEntry(apiFeature.getApiStateKey(), aState))))); |
269 | - tsWsService.saveAndNotify(state.getTenantId(), state.getApiUsageState().getId(), stateTelemetry, 0L, VOID_CALLBACK); | 269 | + tsWsService.saveAndNotifyInternal(state.getTenantId(), state.getApiUsageState().getId(), stateTelemetry, 0L, VOID_CALLBACK); |
270 | } | 270 | } |
271 | 271 | ||
272 | private void checkStartOfNextCycle() { | 272 | private void checkStartOfNextCycle() { |
@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
23 | import org.thingsboard.server.common.data.EntityInfo; | 23 | import org.thingsboard.server.common.data.EntityInfo; |
24 | import org.thingsboard.server.common.data.Tenant; | 24 | import org.thingsboard.server.common.data.Tenant; |
25 | import org.thingsboard.server.common.data.TenantProfile; | 25 | import org.thingsboard.server.common.data.TenantProfile; |
26 | +import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration; | ||
26 | import org.thingsboard.server.common.data.tenant.profile.TenantProfileData; | 27 | import org.thingsboard.server.common.data.tenant.profile.TenantProfileData; |
27 | import org.thingsboard.server.common.data.id.TenantId; | 28 | import org.thingsboard.server.common.data.id.TenantId; |
28 | import org.thingsboard.server.common.data.page.PageData; | 29 | import org.thingsboard.server.common.data.page.PageData; |
@@ -285,7 +286,9 @@ public abstract class BaseTenantProfileControllerTest extends AbstractController | @@ -285,7 +286,9 @@ public abstract class BaseTenantProfileControllerTest extends AbstractController | ||
285 | TenantProfile tenantProfile = new TenantProfile(); | 286 | TenantProfile tenantProfile = new TenantProfile(); |
286 | tenantProfile.setName(name); | 287 | tenantProfile.setName(name); |
287 | tenantProfile.setDescription(name + " Test"); | 288 | tenantProfile.setDescription(name + " Test"); |
288 | - tenantProfile.setProfileData(new TenantProfileData()); | 289 | + TenantProfileData tenantProfileData = new TenantProfileData(); |
290 | + tenantProfileData.setConfiguration(new DefaultTenantProfileConfiguration()); | ||
291 | + tenantProfile.setProfileData(tenantProfileData); | ||
289 | tenantProfile.setDefault(false); | 292 | tenantProfile.setDefault(false); |
290 | tenantProfile.setIsolatedTbCore(false); | 293 | tenantProfile.setIsolatedTbCore(false); |
291 | tenantProfile.setIsolatedTbRuleEngine(false); | 294 | tenantProfile.setIsolatedTbRuleEngine(false); |
@@ -27,7 +27,7 @@ import java.util.Arrays; | @@ -27,7 +27,7 @@ import java.util.Arrays; | ||
27 | @RunWith(ClasspathSuite.class) | 27 | @RunWith(ClasspathSuite.class) |
28 | @ClasspathSuite.ClassnameFilters({ | 28 | @ClasspathSuite.ClassnameFilters({ |
29 | // "org.thingsboard.server.controller.sql.WebsocketApiSqlTest", | 29 | // "org.thingsboard.server.controller.sql.WebsocketApiSqlTest", |
30 | -// "org.thingsboard.server.controller.sql.EntityQueryControllerSqlTest", | 30 | +// "org.thingsboard.server.controller.sql.TenantProfileControllerSqlTest", |
31 | "org.thingsboard.server.controller.sql.*Test", | 31 | "org.thingsboard.server.controller.sql.*Test", |
32 | }) | 32 | }) |
33 | public class ControllerSqlTestSuite { | 33 | public class ControllerSqlTestSuite { |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at | 6 | * You may obtain a copy of the License at |
7 | * | 7 | * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * | 9 | * |
10 | * Unless required by applicable law or agreed to in writing, software | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
@@ -216,6 +216,12 @@ public class TenantProfileServiceImpl extends AbstractEntityService implements T | @@ -216,6 +216,12 @@ public class TenantProfileServiceImpl extends AbstractEntityService implements T | ||
216 | if (StringUtils.isEmpty(tenantProfile.getName())) { | 216 | if (StringUtils.isEmpty(tenantProfile.getName())) { |
217 | throw new DataValidationException("Tenant profile name should be specified!"); | 217 | throw new DataValidationException("Tenant profile name should be specified!"); |
218 | } | 218 | } |
219 | + if (tenantProfile.getProfileData() == null) { | ||
220 | + throw new DataValidationException("Tenant profile data should be specified!"); | ||
221 | + } | ||
222 | + if (tenantProfile.getProfileData().getConfiguration() == null) { | ||
223 | + throw new DataValidationException("Tenant profile data configuration should be specified!"); | ||
224 | + } | ||
219 | if (tenantProfile.isDefault()) { | 225 | if (tenantProfile.isDefault()) { |
220 | TenantProfile defaultTenantProfile = findDefaultTenantProfile(tenantId); | 226 | TenantProfile defaultTenantProfile = findDefaultTenantProfile(tenantId); |
221 | if (defaultTenantProfile != null && !defaultTenantProfile.getId().equals(tenantProfile.getId())) { | 227 | if (defaultTenantProfile != null && !defaultTenantProfile.getId().equals(tenantProfile.getId())) { |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at | 6 | * You may obtain a copy of the License at |
7 | * | 7 | * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * | 9 | * |
10 | * Unless required by applicable law or agreed to in writing, software | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
@@ -99,6 +99,10 @@ class AlarmRuleState { | @@ -99,6 +99,10 @@ class AlarmRuleState { | ||
99 | } | 99 | } |
100 | } | 100 | } |
101 | for (EntityKey key : changedKeys) { | 101 | for (EntityKey key : changedKeys) { |
102 | + EntityKeyType keyType = key.getType(); | ||
103 | + if (EntityKeyType.CLIENT_ATTRIBUTE.equals(keyType) || EntityKeyType.SERVER_ATTRIBUTE.equals(keyType) || EntityKeyType.SHARED_ATTRIBUTE.equals(keyType)) { | ||
104 | + key = new EntityKey(EntityKeyType.ATTRIBUTE, key.getKey()); | ||
105 | + } | ||
102 | if (entityKeys.contains(key)) { | 106 | if (entityKeys.contains(key)) { |
103 | return true; | 107 | return true; |
104 | } | 108 | } |