rollback sorting in sql
This commit is contained in:
parent
f7af8e298c
commit
cfe47f88b6
@ -32,6 +32,7 @@ import org.thingsboard.server.dao.model.ToData;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -163,6 +164,7 @@ public abstract class DaoUtil {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated // used only in deprecated DAO api
|
||||||
public static List<EntitySubtype> convertTenantEntityInfosToDto(UUID tenantUUID, EntityType entityType, List<EntityInfo> entityInfos) {
|
public static List<EntitySubtype> convertTenantEntityInfosToDto(UUID tenantUUID, EntityType entityType, List<EntityInfo> entityInfos) {
|
||||||
if (CollectionUtils.isEmpty(entityInfos)) {
|
if (CollectionUtils.isEmpty(entityInfos)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@ -170,6 +172,7 @@ public abstract class DaoUtil {
|
|||||||
var tenantId = TenantId.fromUUID(tenantUUID);
|
var tenantId = TenantId.fromUUID(tenantUUID);
|
||||||
return entityInfos.stream()
|
return entityInfos.stream()
|
||||||
.map(info -> new EntitySubtype(tenantId, entityType, info.getName()))
|
.map(info -> new EntitySubtype(tenantId, entityType, info.getName()))
|
||||||
|
.sorted(Comparator.comparing(EntitySubtype::getType))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,9 +43,11 @@ import org.thingsboard.server.dao.service.PaginatedRemover;
|
|||||||
import org.thingsboard.server.dao.service.Validator;
|
import org.thingsboard.server.dao.service.Validator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.thingsboard.server.dao.service.Validator.validateId;
|
import static org.thingsboard.server.dao.service.Validator.validateId;
|
||||||
|
|
||||||
@ -323,7 +325,9 @@ public class AssetProfileServiceImpl extends AbstractCachedEntityService<AssetPr
|
|||||||
public List<EntityInfo> findAssetProfileNamesByTenantId(TenantId tenantId, boolean activeOnly) {
|
public List<EntityInfo> findAssetProfileNamesByTenantId(TenantId tenantId, boolean activeOnly) {
|
||||||
log.trace("Executing findAssetProfileNamesByTenantId, tenantId [{}]", tenantId);
|
log.trace("Executing findAssetProfileNamesByTenantId, tenantId [{}]", tenantId);
|
||||||
validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
|
validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
|
||||||
return assetProfileDao.findTenantAssetProfileNames(tenantId.getId(), activeOnly);
|
return assetProfileDao.findTenantAssetProfileNames(tenantId.getId(), activeOnly)
|
||||||
|
.stream().sorted(Comparator.comparing(EntityInfo::getName))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final PaginatedRemover<TenantId, AssetProfile> tenantAssetProfilesRemover =
|
private final PaginatedRemover<TenantId, AssetProfile> tenantAssetProfilesRemover =
|
||||||
|
|||||||
@ -58,11 +58,13 @@ import java.security.cert.Certificate;
|
|||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.CertificateFactory;
|
import java.security.cert.CertificateFactory;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.thingsboard.server.dao.service.Validator.validateId;
|
import static org.thingsboard.server.dao.service.Validator.validateId;
|
||||||
import static org.thingsboard.server.dao.service.Validator.validateString;
|
import static org.thingsboard.server.dao.service.Validator.validateString;
|
||||||
@ -378,7 +380,9 @@ public class DeviceProfileServiceImpl extends AbstractCachedEntityService<Device
|
|||||||
public List<EntityInfo> findDeviceProfileNamesByTenantId(TenantId tenantId, boolean activeOnly) {
|
public List<EntityInfo> findDeviceProfileNamesByTenantId(TenantId tenantId, boolean activeOnly) {
|
||||||
log.trace("Executing findDeviceProfileNamesByTenantId, tenantId [{}]", tenantId);
|
log.trace("Executing findDeviceProfileNamesByTenantId, tenantId [{}]", tenantId);
|
||||||
validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
|
validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
|
||||||
return deviceProfileDao.findTenantDeviceProfileNames(tenantId.getId(), activeOnly);
|
return deviceProfileDao.findTenantDeviceProfileNames(tenantId.getId(), activeOnly)
|
||||||
|
.stream().sorted(Comparator.comparing(EntityInfo::getName))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final PaginatedRemover<TenantId, DeviceProfile> tenantDeviceProfilesRemover =
|
private final PaginatedRemover<TenantId, DeviceProfile> tenantDeviceProfilesRemover =
|
||||||
|
|||||||
@ -74,11 +74,11 @@ public interface AssetProfileRepository extends JpaRepository<AssetProfileEntity
|
|||||||
|
|
||||||
@Query("SELECT new org.thingsboard.server.common.data.EntityInfo(ap.id, 'ASSET_PROFILE', ap.name) " +
|
@Query("SELECT new org.thingsboard.server.common.data.EntityInfo(ap.id, 'ASSET_PROFILE', ap.name) " +
|
||||||
"FROM AssetProfileEntity ap WHERE ap.tenantId = :tenantId AND EXISTS " +
|
"FROM AssetProfileEntity ap WHERE ap.tenantId = :tenantId AND EXISTS " +
|
||||||
"(SELECT 1 FROM AssetEntity a WHERE a.tenantId = :tenantId AND a.assetProfileId = ap.id) ORDER BY ap.name ASC")
|
"(SELECT 1 FROM AssetEntity a WHERE a.tenantId = :tenantId AND a.assetProfileId = ap.id)")
|
||||||
List<EntityInfo> findActiveTenantAssetProfileNames(@Param("tenantId") UUID tenantId);
|
List<EntityInfo> findActiveTenantAssetProfileNames(@Param("tenantId") UUID tenantId);
|
||||||
|
|
||||||
@Query("SELECT new org.thingsboard.server.common.data.EntityInfo(a.id, 'ASSET_PROFILE', a.name) " +
|
@Query("SELECT new org.thingsboard.server.common.data.EntityInfo(a.id, 'ASSET_PROFILE', a.name) " +
|
||||||
"FROM AssetProfileEntity a WHERE a.tenantId = :tenantId ORDER BY a.name ASC")
|
"FROM AssetProfileEntity a WHERE a.tenantId = :tenantId")
|
||||||
List<EntityInfo> findAllTenantAssetProfileNames(@Param("tenantId") UUID tenantId);
|
List<EntityInfo> findAllTenantAssetProfileNames(@Param("tenantId") UUID tenantId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,11 +85,11 @@ public interface DeviceProfileRepository extends JpaRepository<DeviceProfileEnti
|
|||||||
|
|
||||||
@Query("SELECT new org.thingsboard.server.common.data.EntityInfo(dp.id, 'DEVICE_PROFILE', dp.name) " +
|
@Query("SELECT new org.thingsboard.server.common.data.EntityInfo(dp.id, 'DEVICE_PROFILE', dp.name) " +
|
||||||
"FROM DeviceProfileEntity dp WHERE dp.tenantId = :tenantId AND EXISTS " +
|
"FROM DeviceProfileEntity dp WHERE dp.tenantId = :tenantId AND EXISTS " +
|
||||||
"(SELECT 1 FROM DeviceEntity dv WHERE dv.tenantId = :tenantId AND dv.deviceProfileId = dp.id) ORDER BY dp.name ASC")
|
"(SELECT 1 FROM DeviceEntity dv WHERE dv.tenantId = :tenantId AND dv.deviceProfileId = dp.id)")
|
||||||
List<EntityInfo> findActiveTenantDeviceProfileNames(@Param("tenantId") UUID tenantId);
|
List<EntityInfo> findActiveTenantDeviceProfileNames(@Param("tenantId") UUID tenantId);
|
||||||
|
|
||||||
@Query("SELECT new org.thingsboard.server.common.data.EntityInfo(d.id, 'DEVICE_PROFILE', d.name) " +
|
@Query("SELECT new org.thingsboard.server.common.data.EntityInfo(d.id, 'DEVICE_PROFILE', d.name) " +
|
||||||
"FROM DeviceProfileEntity d WHERE d.tenantId = :tenantId ORDER BY d.name ASC")
|
"FROM DeviceProfileEntity d WHERE d.tenantId = :tenantId")
|
||||||
List<EntityInfo> findAllTenantDeviceProfileNames(@Param("tenantId") UUID tenantId);
|
List<EntityInfo> findAllTenantDeviceProfileNames(@Param("tenantId") UUID tenantId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user