Browse Source
Merge pull request #14182 from dashevchenko/entitySaveCacheIssueFix
Fixed entity save methods
pull/14199/head
Viacheslav Klimov
11 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
4 additions and
4 deletions
-
dao/src/main/java/org/thingsboard/server/dao/asset/BaseAssetService.java
-
dao/src/main/java/org/thingsboard/server/dao/customer/CustomerServiceImpl.java
-
dao/src/main/java/org/thingsboard/server/dao/device/DeviceServiceImpl.java
-
dao/src/main/java/org/thingsboard/server/dao/entityview/EntityViewServiceImpl.java
|
|
|
@ -160,7 +160,7 @@ public class BaseAssetService extends AbstractCachedEntityService<AssetCacheKey, |
|
|
|
|
|
|
|
private Asset saveAsset(Asset asset, boolean doValidate, NameConflictStrategy nameConflictStrategy) { |
|
|
|
log.trace("Executing saveAsset [{}]", asset); |
|
|
|
Asset oldAsset = (asset.getId() != null) ? findAssetById(asset.getTenantId(), asset.getId()) : null; |
|
|
|
Asset oldAsset = (asset.getId() != null) ? assetDao.findById(asset.getTenantId(), asset.getId().getId()) : null; |
|
|
|
if (nameConflictStrategy.policy() == NameConflictPolicy.UNIQUIFY && (oldAsset == null || !oldAsset.getName().equals(asset.getName()))) { |
|
|
|
uniquifyEntityName(asset, oldAsset, asset::setName, EntityType.ASSET, nameConflictStrategy); |
|
|
|
} |
|
|
|
|
|
|
|
@ -156,7 +156,7 @@ public class CustomerServiceImpl extends AbstractCachedEntityService<CustomerCac |
|
|
|
|
|
|
|
private Customer saveCustomer(Customer customer, boolean doValidate, NameConflictStrategy nameConflictStrategy) { |
|
|
|
log.trace("Executing saveCustomer [{}]", customer); |
|
|
|
Customer oldCustomer = (customer.getId() != null) ? findCustomerById(customer.getTenantId(), customer.getId()) : null; |
|
|
|
Customer oldCustomer = (customer.getId() != null) ? customerDao.findById(customer.getTenantId(), customer.getId().getId()) : null; |
|
|
|
if (nameConflictStrategy.policy() == NameConflictPolicy.UNIQUIFY && (oldCustomer == null || !oldCustomer.getTitle().equals(customer.getTitle()))) { |
|
|
|
uniquifyEntityName(customer, oldCustomer, customer::setTitle, EntityType.CUSTOMER, nameConflictStrategy); |
|
|
|
} |
|
|
|
|
|
|
|
@ -229,7 +229,7 @@ public class DeviceServiceImpl extends CachedVersionedEntityService<DeviceCacheK |
|
|
|
|
|
|
|
private Device saveDeviceWithoutCredentials(Device device, boolean doValidate, NameConflictStrategy nameConflictStrategy) { |
|
|
|
log.trace("Executing saveDevice [{}]", device); |
|
|
|
Device oldDevice = (device.getId() != null) ? findDeviceById(device.getTenantId(), device.getId()) : null; |
|
|
|
Device oldDevice = (device.getId() != null) ? deviceDao.findById(device.getTenantId(), device.getId().getId()) : null; |
|
|
|
if (nameConflictStrategy.policy() == NameConflictPolicy.UNIQUIFY && (oldDevice == null || !oldDevice.getName().equals(device.getName()))) { |
|
|
|
uniquifyEntityName(device, oldDevice, device::setName, EntityType.DEVICE, nameConflictStrategy); |
|
|
|
} |
|
|
|
|
|
|
|
@ -124,7 +124,7 @@ public class EntityViewServiceImpl extends CachedVersionedEntityService<EntityVi |
|
|
|
|
|
|
|
private EntityView saveEntityView(EntityView entityView, boolean doValidate, NameConflictStrategy nameConflictStrategy) { |
|
|
|
log.trace("Executing save entity view [{}]", entityView); |
|
|
|
EntityView old = (entityView.getId() != null) ? findEntityViewById(entityView.getTenantId(), entityView.getId(), false) : null; |
|
|
|
EntityView old = (entityView.getId() != null) ? entityViewDao.findById(entityView.getTenantId(), entityView.getId().getId()) : null; |
|
|
|
if (nameConflictStrategy.policy() == NameConflictPolicy.UNIQUIFY && (old == null || !entityView.getName().equals(old.getName()))) { |
|
|
|
uniquifyEntityName(entityView, old, entityView::setName, EntityType.ENTITY_VIEW, nameConflictStrategy); |
|
|
|
} |
|
|
|
|