|
|
|
@ -16,7 +16,6 @@ |
|
|
|
package org.thingsboard.server.dao.asset; |
|
|
|
|
|
|
|
|
|
|
|
import com.google.common.base.Function; |
|
|
|
import com.google.common.util.concurrent.Futures; |
|
|
|
import com.google.common.util.concurrent.ListenableFuture; |
|
|
|
import com.google.common.util.concurrent.MoreExecutors; |
|
|
|
@ -46,11 +45,10 @@ import org.thingsboard.server.common.data.id.EntityId; |
|
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
|
import org.thingsboard.server.common.data.page.PageData; |
|
|
|
import org.thingsboard.server.common.data.page.PageLink; |
|
|
|
import org.thingsboard.server.common.data.page.TimePageLink; |
|
|
|
import org.thingsboard.server.common.data.relation.EntityRelation; |
|
|
|
import org.thingsboard.server.common.data.relation.EntitySearchDirection; |
|
|
|
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration; |
|
|
|
import org.thingsboard.server.common.data.relation.RelationTypeGroup; |
|
|
|
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration; |
|
|
|
import org.thingsboard.server.dao.customer.CustomerDao; |
|
|
|
import org.thingsboard.server.dao.entity.AbstractEntityService; |
|
|
|
import org.thingsboard.server.dao.exception.DataValidationException; |
|
|
|
@ -59,8 +57,8 @@ import org.thingsboard.server.dao.service.PaginatedRemover; |
|
|
|
import org.thingsboard.server.dao.tenant.TbTenantProfileCache; |
|
|
|
import org.thingsboard.server.dao.tenant.TenantDao; |
|
|
|
|
|
|
|
import javax.annotation.Nullable; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.List; |
|
|
|
@ -180,15 +178,16 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ |
|
|
|
throw new RuntimeException("Exception while finding entity views for assetId [" + assetId + "]", e); |
|
|
|
} |
|
|
|
|
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
list.add(asset.getTenantId()); |
|
|
|
list.add(asset.getName()); |
|
|
|
Cache cache = cacheManager.getCache(ASSET_CACHE); |
|
|
|
cache.evict(list); |
|
|
|
removeAssetFromCacheByName(asset.getTenantId(), asset.getName()); |
|
|
|
|
|
|
|
assetDao.removeById(tenantId, assetId.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
private void removeAssetFromCacheByName(TenantId tenantId, String name) { |
|
|
|
Cache cache = cacheManager.getCache(ASSET_CACHE); |
|
|
|
cache.evict(Arrays.asList(tenantId, name)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<Asset> findAssetsByTenantId(TenantId tenantId, PageLink pageLink) { |
|
|
|
log.trace("Executing findAssetsByTenantId, tenantId [{}], pageLink [{}]", tenantId, pageLink); |
|
|
|
@ -397,6 +396,13 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void validateUpdate(TenantId tenantId, Asset asset) { |
|
|
|
Asset old = assetDao.findById(asset.getTenantId(), asset.getId().getId()); |
|
|
|
if (old == null) { |
|
|
|
throw new DataValidationException("Can't update non existing asset!"); |
|
|
|
} |
|
|
|
if (!old.getName().equals(asset.getName())) { |
|
|
|
removeAssetFromCacheByName(tenantId, old.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|