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 | 156 | } finally { |
157 | 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 | 160 | if (!result.isEmpty()) { |
161 | 161 | persistAndNotify(tenantState, result); |
162 | 162 | } |
... | ... | @@ -256,7 +256,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { |
256 | 256 | } |
257 | 257 | } |
258 | 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 | 266 | long ts = System.currentTimeMillis(); |
267 | 267 | List<TsKvEntry> stateTelemetry = new ArrayList<>(); |
268 | 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 | 272 | private void checkStartOfNextCycle() { | ... | ... |
... | ... | @@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
23 | 23 | import org.thingsboard.server.common.data.EntityInfo; |
24 | 24 | import org.thingsboard.server.common.data.Tenant; |
25 | 25 | import org.thingsboard.server.common.data.TenantProfile; |
26 | +import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration; | |
26 | 27 | import org.thingsboard.server.common.data.tenant.profile.TenantProfileData; |
27 | 28 | import org.thingsboard.server.common.data.id.TenantId; |
28 | 29 | import org.thingsboard.server.common.data.page.PageData; |
... | ... | @@ -285,7 +286,9 @@ public abstract class BaseTenantProfileControllerTest extends AbstractController |
285 | 286 | TenantProfile tenantProfile = new TenantProfile(); |
286 | 287 | tenantProfile.setName(name); |
287 | 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 | 292 | tenantProfile.setDefault(false); |
290 | 293 | tenantProfile.setIsolatedTbCore(false); |
291 | 294 | tenantProfile.setIsolatedTbRuleEngine(false); | ... | ... |
... | ... | @@ -27,7 +27,7 @@ import java.util.Arrays; |
27 | 27 | @RunWith(ClasspathSuite.class) |
28 | 28 | @ClasspathSuite.ClassnameFilters({ |
29 | 29 | // "org.thingsboard.server.controller.sql.WebsocketApiSqlTest", |
30 | -// "org.thingsboard.server.controller.sql.EntityQueryControllerSqlTest", | |
30 | +// "org.thingsboard.server.controller.sql.TenantProfileControllerSqlTest", | |
31 | 31 | "org.thingsboard.server.controller.sql.*Test", |
32 | 32 | }) |
33 | 33 | public class ControllerSqlTestSuite { | ... | ... |
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 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 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
... | ... | @@ -216,6 +216,12 @@ public class TenantProfileServiceImpl extends AbstractEntityService implements T |
216 | 216 | if (StringUtils.isEmpty(tenantProfile.getName())) { |
217 | 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 | 225 | if (tenantProfile.isDefault()) { |
220 | 226 | TenantProfile defaultTenantProfile = findDefaultTenantProfile(tenantId); |
221 | 227 | if (defaultTenantProfile != null && !defaultTenantProfile.getId().equals(tenantProfile.getId())) { | ... | ... |
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 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 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ... | ... |
... | ... | @@ -99,6 +99,10 @@ class AlarmRuleState { |
99 | 99 | } |
100 | 100 | } |
101 | 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 | 106 | if (entityKeys.contains(key)) { |
103 | 107 | return true; |
104 | 108 | } | ... | ... |