refactoring
This commit is contained in:
parent
720eab396c
commit
2d4b8a85f9
@ -145,7 +145,7 @@ public class AssetController extends BaseController {
|
||||
"UNIQUIFY policy appends a suffix to the entity name, if a name conflict occurs.")
|
||||
@RequestParam(name = "policy", defaultValue = "FAIL") NameConflictPolicy policy,
|
||||
@Parameter(description = "Optional value of name suffix separator used by UNIQUIFY policy. By default, underscore separator is used. " +
|
||||
"For example, strategy is UNIQUIFY, separator is '-'; if a name conflict occurs for customer asset 'Office A', " +
|
||||
"For example, strategy is UNIQUIFY, separator is '-'; if a name conflict occurs for asset 'Office A', " +
|
||||
"created asset will have name like 'Office A-7fsh4f'.")
|
||||
@RequestParam(name = "separator", defaultValue = "_") String separator) throws Exception {
|
||||
asset.setTenantId(getTenantId());
|
||||
|
||||
@ -130,7 +130,7 @@ public class DeviceBulkImportService extends AbstractBulkImportService<Device> {
|
||||
}
|
||||
device.setDeviceProfileId(deviceProfile.getId());
|
||||
|
||||
return tbDeviceService.saveDeviceWithCredentials(device, deviceCredentials, NameConflictStrategy.DEFAULT, user);
|
||||
return tbDeviceService.saveDeviceWithCredentials(device, deviceCredentials, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.thingsboard.server.service.entitiy;
|
||||
|
||||
import org.thingsboard.server.common.data.NameConflictStrategy;
|
||||
import org.thingsboard.server.common.data.User;
|
||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
|
||||
@ -27,10 +26,6 @@ public interface SimpleTbEntityService<T> {
|
||||
|
||||
T save(T entity, SecurityUser user) throws Exception;
|
||||
|
||||
default T save(T entity, NameConflictStrategy nameConflictPolicy, SecurityUser user) throws Exception {
|
||||
return save(entity, null);
|
||||
}
|
||||
|
||||
void delete(T entity, User user);
|
||||
|
||||
}
|
||||
|
||||
@ -16,8 +16,12 @@
|
||||
package org.thingsboard.server.service.entitiy.customer;
|
||||
|
||||
import org.thingsboard.server.common.data.Customer;
|
||||
import org.thingsboard.server.common.data.NameConflictStrategy;
|
||||
import org.thingsboard.server.service.entitiy.SimpleTbEntityService;
|
||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
|
||||
public interface TbCustomerService extends SimpleTbEntityService<Customer> {
|
||||
|
||||
Customer save(Customer customer, NameConflictStrategy nameConflictStrategy, SecurityUser user) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@ -55,6 +55,11 @@ public class DefaultTbDeviceService extends AbstractTbEntityService implements T
|
||||
private final DeviceCredentialsService deviceCredentialsService;
|
||||
private final ClaimDevicesService claimDevicesService;
|
||||
|
||||
@Override
|
||||
public Device save(Device device, String accessToken, User user) throws Exception {
|
||||
return save(device, accessToken, NameConflictStrategy.DEFAULT, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device save(Device device, String accessToken, NameConflictStrategy nameConflictStrategy, User user) throws Exception {
|
||||
ActionType actionType = device.getId() == null ? ActionType.ADDED : ActionType.UPDATED;
|
||||
@ -72,6 +77,11 @@ public class DefaultTbDeviceService extends AbstractTbEntityService implements T
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device saveDeviceWithCredentials(Device device, DeviceCredentials credentials, User user) throws ThingsboardException {
|
||||
return saveDeviceWithCredentials(device, credentials, NameConflictStrategy.DEFAULT, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device saveDeviceWithCredentials(Device device, DeviceCredentials credentials, NameConflictStrategy nameConflictStrategy, User user) throws ThingsboardException {
|
||||
ActionType actionType = device.getId() == null ? ActionType.ADDED : ActionType.UPDATED;
|
||||
|
||||
@ -32,8 +32,12 @@ import org.thingsboard.server.dao.device.claim.ReclaimResult;
|
||||
|
||||
public interface TbDeviceService {
|
||||
|
||||
Device save(Device device, String accessToken, User user) throws Exception;
|
||||
|
||||
Device save(Device device, String accessToken, NameConflictStrategy nameConflictStrategy, User user) throws Exception;
|
||||
|
||||
Device saveDeviceWithCredentials(Device device, DeviceCredentials deviceCredentials, User user) throws ThingsboardException;
|
||||
|
||||
Device saveDeviceWithCredentials(Device device, DeviceCredentials deviceCredentials, NameConflictStrategy nameConflictStrategy, User user) throws ThingsboardException;
|
||||
|
||||
void delete(Device device, User user);
|
||||
|
||||
@ -79,6 +79,11 @@ public class DefaultTbEntityViewService extends AbstractTbEntityService implemen
|
||||
|
||||
final Map<TenantId, Map<EntityId, List<EntityView>>> localCache = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public EntityView save(EntityView entityView, EntityView existingEntityView, User user) throws Exception {
|
||||
return save(entityView, existingEntityView, NameConflictStrategy.DEFAULT, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityView save(EntityView entityView, EntityView existingEntityView, NameConflictStrategy nameConflictStrategy, User user) throws Exception {
|
||||
ActionType actionType = entityView.getId() == null ? ActionType.ADDED : ActionType.UPDATED;
|
||||
|
||||
@ -32,6 +32,8 @@ import java.util.List;
|
||||
|
||||
public interface TbEntityViewService extends ComponentLifecycleListener {
|
||||
|
||||
EntityView save(EntityView entityView, EntityView existingEntityView, User user) throws Exception;
|
||||
|
||||
EntityView save(EntityView entityView, EntityView existingEntityView, NameConflictStrategy nameConflictStrategy, User user) throws Exception;
|
||||
|
||||
void updateEntityViewAttributes(TenantId tenantId, EntityView savedEntityView, EntityView oldEntityView, User user) throws ThingsboardException;
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
package org.thingsboard.server.dao.asset;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import org.thingsboard.server.common.data.EntityInfo;
|
||||
import org.thingsboard.server.common.data.EntitySubtype;
|
||||
import org.thingsboard.server.common.data.ProfileEntityIdInfo;
|
||||
import org.thingsboard.server.common.data.asset.Asset;
|
||||
|
||||
@ -21,7 +21,6 @@ import org.thingsboard.server.common.data.DeviceIdInfo;
|
||||
import org.thingsboard.server.common.data.DeviceInfo;
|
||||
import org.thingsboard.server.common.data.DeviceInfoFilter;
|
||||
import org.thingsboard.server.common.data.DeviceTransportType;
|
||||
import org.thingsboard.server.common.data.EntityInfo;
|
||||
import org.thingsboard.server.common.data.EntitySubtype;
|
||||
import org.thingsboard.server.common.data.ProfileEntityIdInfo;
|
||||
import org.thingsboard.server.common.data.id.DeviceId;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user