fixed edqs sorting
This commit is contained in:
parent
8615dd4ce5
commit
1e0bdc9032
@ -35,12 +35,12 @@ public class ApiUsageStateData extends BaseEntityData<ApiUsageStateFields> {
|
||||
|
||||
@Override
|
||||
public String getEntityName() {
|
||||
return getEntityOwnerName();
|
||||
return getOwnerName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityOwnerName() {
|
||||
return repo.getOwnerName(fields.getEntityId());
|
||||
public String getOwnerName() {
|
||||
return repo.getOwnerEntityName(fields.getEntityId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -98,8 +98,13 @@ public abstract class BaseEntityData<T extends EntityFields> implements EntityDa
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getOwnerType() {
|
||||
return customerId != null ? EntityType.CUSTOMER : EntityType.TENANT;
|
||||
public String getOwnerName() {
|
||||
return repo.getOwnerEntityName(isTenantEntity() ? repo.getTenantId() : new CustomerId(getCustomerId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwnerType() {
|
||||
return isTenantEntity() ? EntityType.TENANT.name() : EntityType.CUSTOMER.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -132,22 +137,21 @@ public abstract class BaseEntityData<T extends EntityFields> implements EntityDa
|
||||
}
|
||||
return switch (name) {
|
||||
case "name" -> getEntityName();
|
||||
case "ownerName" -> getEntityOwnerName();
|
||||
case "ownerType" -> customerId != null ? EntityType.CUSTOMER.name() : EntityType.TENANT.name();
|
||||
case "ownerName" -> getOwnerName();
|
||||
case "ownerType" -> getOwnerType();
|
||||
case "entityType" -> Optional.ofNullable(getEntityType()).map(EntityType::name).orElse("");
|
||||
default -> fields.getAsString(name);
|
||||
};
|
||||
}
|
||||
|
||||
public String getEntityOwnerName() {
|
||||
return repo.getOwnerName(getCustomerId() == null || CustomerId.NULL_UUID.equals(getCustomerId()) ? null :
|
||||
new CustomerId(getCustomerId()));
|
||||
}
|
||||
|
||||
public String getEntityName() {
|
||||
return getFields().getName();
|
||||
}
|
||||
|
||||
private boolean isTenantEntity() {
|
||||
return getCustomerId() == null || CustomerId.NULL_UUID.equals(getCustomerId());
|
||||
}
|
||||
|
||||
private String getRelatedParentId(QueryContext ctx) {
|
||||
return Optional.ofNullable(ctx.getRelatedParentIdMap().get(getId()))
|
||||
.map(UUID::toString)
|
||||
|
||||
@ -54,7 +54,9 @@ public interface EntityData<T extends EntityFields> {
|
||||
|
||||
boolean removeTs(Integer keyId);
|
||||
|
||||
EntityType getOwnerType();
|
||||
String getOwnerName();
|
||||
|
||||
String getOwnerType();
|
||||
|
||||
DataPoint getDataPoint(DataKey key, QueryContext queryContext);
|
||||
|
||||
|
||||
@ -421,14 +421,7 @@ public class TenantRepo {
|
||||
return relations.computeIfAbsent(relationTypeGroup, type -> new RelationsRepo());
|
||||
}
|
||||
|
||||
public String getOwnerName(EntityId ownerId) {
|
||||
if (ownerId == null || (ownerId.getEntityType() == EntityType.CUSTOMER && ownerId.isNullUid())) {
|
||||
return getOwnerEntityName(tenantId);
|
||||
}
|
||||
return getOwnerEntityName(ownerId);
|
||||
}
|
||||
|
||||
private String getOwnerEntityName(EntityId entityId) {
|
||||
public String getOwnerEntityName(EntityId entityId) {
|
||||
EntityType entityType = entityId.getEntityType();
|
||||
return switch (entityType) {
|
||||
case CUSTOMER, TENANT -> {
|
||||
|
||||
@ -67,10 +67,10 @@ import static org.thingsboard.server.common.data.query.ComplexFilterPredicate.Co
|
||||
@Slf4j
|
||||
public class RepositoryUtils {
|
||||
|
||||
public static final Comparator<SortableEntityData> SORT_ASC = Comparator.comparing((SortableEntityData sed) -> Optional.ofNullable(sed.getSortValue()).orElse(""))
|
||||
public static final Comparator<SortableEntityData> SORT_ASC = Comparator.comparing((SortableEntityData sed) -> Optional.ofNullable(sed.getSortValue()).orElse(""), String.CASE_INSENSITIVE_ORDER)
|
||||
.thenComparing(sp -> sp.getId().toString());
|
||||
|
||||
public static final Comparator<SortableEntityData> SORT_DESC = Comparator.comparing((SortableEntityData sed) -> Optional.ofNullable(sed.getSortValue()).orElse(""))
|
||||
public static final Comparator<SortableEntityData> SORT_DESC = Comparator.comparing((SortableEntityData sed) -> Optional.ofNullable(sed.getSortValue()).orElse(""), String.CASE_INSENSITIVE_ORDER)
|
||||
.thenComparing(sp -> sp.getId().toString()).reversed();
|
||||
|
||||
public static EntityType resolveEntityType(EntityFilter entityFilter) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user