Minor refactoring
This commit is contained in:
parent
cca7a87c19
commit
bbdd0fd6b8
@ -460,14 +460,7 @@ public class RuleChainController extends BaseController {
|
||||
@ApiParam(value = "Enables overwrite for existing rule chains with the same name.")
|
||||
@RequestParam(required = false, defaultValue = "false") boolean overwrite) throws ThingsboardException {
|
||||
TenantId tenantId = getCurrentUser().getTenantId();
|
||||
List<RuleChainImportResult> importResults = ruleChainService.importTenantRuleChains(tenantId, ruleChainData, overwrite, tbRuleChainService::updateRuleNodeConfiguration);
|
||||
for (RuleChainImportResult importResult : importResults) {
|
||||
if (importResult.getError() == null) {
|
||||
tbClusterService.broadcastEntityStateChangeEvent(importResult.getTenantId(), importResult.getRuleChainId(),
|
||||
importResult.isUpdated() ? ComponentLifecycleEvent.UPDATED : ComponentLifecycleEvent.CREATED);
|
||||
}
|
||||
}
|
||||
return importResults;
|
||||
return ruleChainService.importTenantRuleChains(tenantId, ruleChainData, overwrite, tbRuleChainService::updateRuleNodeConfiguration);
|
||||
}
|
||||
|
||||
private String msgToOutput(TbMsg msg) throws Exception {
|
||||
|
||||
@ -24,15 +24,15 @@ public enum EdgeEventActionType {
|
||||
UPDATED(ActionType.UPDATED),
|
||||
DELETED(ActionType.DELETED),
|
||||
POST_ATTRIBUTES(null),
|
||||
ATTRIBUTES_UPDATED(null),
|
||||
ATTRIBUTES_DELETED(null),
|
||||
TIMESERIES_UPDATED(null),
|
||||
ATTRIBUTES_UPDATED(ActionType.ATTRIBUTES_UPDATED),
|
||||
ATTRIBUTES_DELETED(ActionType.ATTRIBUTES_DELETED),
|
||||
TIMESERIES_UPDATED(ActionType.TIMESERIES_UPDATED),
|
||||
CREDENTIALS_UPDATED(ActionType.CREDENTIALS_UPDATED),
|
||||
ASSIGNED_TO_CUSTOMER(ActionType.ASSIGNED_TO_CUSTOMER),
|
||||
UNASSIGNED_FROM_CUSTOMER(ActionType.UNASSIGNED_FROM_CUSTOMER),
|
||||
RELATION_ADD_OR_UPDATE(ActionType.RELATION_ADD_OR_UPDATE),
|
||||
RELATION_DELETED(ActionType.RELATION_DELETED),
|
||||
RPC_CALL(null),
|
||||
RPC_CALL(ActionType.RPC_CALL),
|
||||
ALARM_ACK(ActionType.ALARM_ACK),
|
||||
ALARM_CLEAR(ActionType.ALARM_CLEAR),
|
||||
ALARM_ASSIGNED(ActionType.ALARM_ASSIGNED),
|
||||
|
||||
@ -107,12 +107,12 @@ public class DeviceCredentialsServiceImpl extends AbstractCachedEntityService<St
|
||||
oldDeviceCredentials = deviceCredentialsDao.findByDeviceId(tenantId, deviceCredentials.getDeviceId().getId());
|
||||
}
|
||||
try {
|
||||
DeviceCredentials result = deviceCredentialsDao.saveAndFlush(tenantId, deviceCredentials);
|
||||
publishEvictEvent(new DeviceCredentialsEvictEvent(result.getCredentialsId(), oldDeviceCredentials != null ? oldDeviceCredentials.getCredentialsId() : null));
|
||||
var value = deviceCredentialsDao.saveAndFlush(tenantId, deviceCredentials);
|
||||
publishEvictEvent(new DeviceCredentialsEvictEvent(value.getCredentialsId(), oldDeviceCredentials != null ? oldDeviceCredentials.getCredentialsId() : null));
|
||||
if (oldDeviceCredentials != null) {
|
||||
eventPublisher.publishEvent(ActionEntityEvent.builder().tenantId(tenantId).entity(result).entityId(result.getDeviceId()).actionType(ActionType.CREDENTIALS_UPDATED).build());
|
||||
eventPublisher.publishEvent(ActionEntityEvent.builder().tenantId(tenantId).entity(value).entityId(value.getDeviceId()).actionType(ActionType.CREDENTIALS_UPDATED).build());
|
||||
}
|
||||
return result;
|
||||
return value;
|
||||
} catch (Exception t) {
|
||||
handleEvictEvent(new DeviceCredentialsEvictEvent(deviceCredentials.getCredentialsId(), oldDeviceCredentials != null ? oldDeviceCredentials.getCredentialsId() : null));
|
||||
ConstraintViolationException e = extractConstraintViolationException(t).orElse(null);
|
||||
|
||||
@ -197,6 +197,8 @@ public class TenantServiceImpl extends AbstractCachedEntityService<TenantId, Ten
|
||||
boolean create = tenant.getId() == null;
|
||||
Tenant savedTenant = tenantDao.save(tenant.getId(), tenant);
|
||||
publishEvictEvent(new TenantEvictEvent(savedTenant.getId(), create));
|
||||
eventPublisher.publishEvent(SaveEntityEvent.builder().tenantId(TenantId.SYS_TENANT_ID)
|
||||
.entityId(savedTenant.getId()).entity(savedTenant).added(create).build());
|
||||
if (tenant.getId() == null) {
|
||||
deviceProfileService.createDefaultDeviceProfile(savedTenant.getId());
|
||||
assetProfileService.createDefaultAssetProfile(savedTenant.getId());
|
||||
@ -207,8 +209,6 @@ public class TenantServiceImpl extends AbstractCachedEntityService<TenantId, Ten
|
||||
log.error("Failed to create default notification configs for tenant {}", savedTenant.getId(), e);
|
||||
}
|
||||
}
|
||||
eventPublisher.publishEvent(SaveEntityEvent.builder().tenantId(TenantId.SYS_TENANT_ID)
|
||||
.entityId(savedTenant.getId()).entity(savedTenant).added(create).build());
|
||||
return savedTenant;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user