fix_bug: Entity delete with delete relations
This commit is contained in:
parent
dea933d906
commit
34814e8d8a
@ -24,6 +24,7 @@ import com.google.common.util.concurrent.MoreExecutors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.thingsboard.common.util.ThingsBoardThreadFactory;
|
||||
import org.thingsboard.server.common.data.alarm.Alarm;
|
||||
@ -142,6 +143,7 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public AlarmOperationResult deleteAlarm(TenantId tenantId, AlarmId alarmId) {
|
||||
try {
|
||||
log.debug("Deleting Alarm Id: {}", alarmId);
|
||||
|
||||
@ -20,10 +20,9 @@ import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.util.Pair;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.event.TransactionalEventListener;
|
||||
import org.thingsboard.server.common.data.EntitySubtype;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
@ -150,6 +149,7 @@ public class BaseAssetService extends AbstractCachedEntityService<AssetCacheKey,
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteAsset(TenantId tenantId, AssetId assetId) {
|
||||
log.trace("Executing deleteAsset [{}]", assetId);
|
||||
validateId(assetId, INCORRECT_ASSET_ID + assetId);
|
||||
|
||||
@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.thingsboard.server.common.data.Customer;
|
||||
import org.thingsboard.server.common.data.id.CustomerId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -110,6 +111,7 @@ public class CustomerServiceImpl extends AbstractEntityService implements Custom
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteCustomer(TenantId tenantId, CustomerId customerId) {
|
||||
log.trace("Executing deleteCustomer [{}]", customerId);
|
||||
Validator.validateId(customerId, INCORRECT_CUSTOMER_ID + customerId);
|
||||
|
||||
@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.thingsboard.server.common.data.Customer;
|
||||
import org.thingsboard.server.common.data.Dashboard;
|
||||
import org.thingsboard.server.common.data.DashboardInfo;
|
||||
@ -158,6 +159,7 @@ public class DashboardServiceImpl extends AbstractEntityService implements Dashb
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteDashboard(TenantId tenantId, DashboardId dashboardId) {
|
||||
log.trace("Executing deleteDashboard [{}]", dashboardId);
|
||||
Validator.validateId(dashboardId, INCORRECT_DASHBOARD_ID + dashboardId);
|
||||
|
||||
@ -20,6 +20,7 @@ import org.hibernate.exception.ConstraintViolationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.event.TransactionalEventListener;
|
||||
import org.thingsboard.server.common.data.Device;
|
||||
import org.thingsboard.server.common.data.DeviceProfile;
|
||||
@ -36,7 +37,6 @@ import org.thingsboard.server.common.data.id.DeviceProfileId;
|
||||
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.queue.Queue;
|
||||
import org.thingsboard.server.dao.entity.AbstractCachedEntityService;
|
||||
import org.thingsboard.server.dao.exception.DataValidationException;
|
||||
import org.thingsboard.server.dao.queue.QueueService;
|
||||
@ -159,7 +159,8 @@ public class DeviceProfileServiceImpl extends AbstractCachedEntityService<Device
|
||||
this.removeDeviceProfile(tenantId, deviceProfile);
|
||||
}
|
||||
|
||||
private void removeDeviceProfile(TenantId tenantId, DeviceProfile deviceProfile) {
|
||||
@Transactional
|
||||
void removeDeviceProfile(TenantId tenantId, DeviceProfile deviceProfile) {
|
||||
DeviceProfileId deviceProfileId = deviceProfile.getId();
|
||||
try {
|
||||
deviceProfileDao.removeById(tenantId, deviceProfileId.getId());
|
||||
|
||||
@ -25,6 +25,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.event.TransactionalEventListener;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.common.data.EntitySubtype;
|
||||
@ -182,6 +183,7 @@ public class EdgeServiceImpl extends AbstractCachedEntityService<EdgeCacheKey, E
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteEdge(TenantId tenantId, EdgeId edgeId) {
|
||||
log.trace("Executing deleteEdge [{}]", edgeId);
|
||||
validateId(edgeId, INCORRECT_EDGE_ID + edgeId);
|
||||
|
||||
@ -22,6 +22,7 @@ import com.google.common.util.concurrent.MoreExecutors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.event.TransactionalEventListener;
|
||||
import org.thingsboard.server.common.data.EntitySubtype;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
@ -294,6 +295,7 @@ public class EntityViewServiceImpl extends AbstractCachedEntityService<EntityVie
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteEntityView(TenantId tenantId, EntityViewId entityViewId) {
|
||||
log.trace("Executing deleteEntityView [{}]", entityViewId);
|
||||
validateId(entityViewId, INCORRECT_ENTITY_VIEW_ID + entityViewId);
|
||||
|
||||
@ -748,6 +748,7 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteRuleNodes(TenantId tenantId, RuleChainId ruleChainId) {
|
||||
List<EntityRelation> nodeRelations = getRuleChainToNodeRelations(tenantId, ruleChainId);
|
||||
for (EntityRelation relation : nodeRelations) {
|
||||
|
||||
@ -19,7 +19,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.event.TransactionalEventListener;
|
||||
import org.thingsboard.server.common.data.EntityInfo;
|
||||
@ -112,7 +111,8 @@ public class TenantProfileServiceImpl extends AbstractCachedEntityService<Tenant
|
||||
this.removeTenantProfile(tenantId, tenantProfileId, false);
|
||||
}
|
||||
|
||||
private void removeTenantProfile(TenantId tenantId, TenantProfileId tenantProfileId, boolean isDefault) {
|
||||
@Transactional
|
||||
void removeTenantProfile(TenantId tenantId, TenantProfileId tenantProfileId, boolean isDefault) {
|
||||
try {
|
||||
tenantProfileDao.removeById(tenantId, tenantProfileId.getId());
|
||||
} catch (Exception t) {
|
||||
|
||||
@ -171,6 +171,7 @@ public class TenantServiceImpl extends AbstractCachedEntityService<TenantId, Ten
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteTenant(TenantId tenantId) {
|
||||
log.trace("Executing deleteTenant [{}]", tenantId);
|
||||
Validator.validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
|
||||
|
||||
@ -26,6 +26,7 @@ import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.security.authentication.DisabledException;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.common.data.StringUtils;
|
||||
import org.thingsboard.server.common.data.User;
|
||||
@ -201,6 +202,7 @@ public class UserServiceImpl extends AbstractEntityService implements UserServic
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteUser(TenantId tenantId, UserId userId) {
|
||||
log.trace("Executing deleteUser [{}]", userId);
|
||||
validateId(userId, INCORRECT_USER_ID + userId);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user