|
|
|
@ -21,6 +21,7 @@ import com.google.common.base.Function; |
|
|
|
import com.google.common.util.concurrent.Futures; |
|
|
|
import com.google.common.util.concurrent.ListenableFuture; |
|
|
|
import com.google.common.util.concurrent.MoreExecutors; |
|
|
|
import jakarta.annotation.Nullable; |
|
|
|
import lombok.Getter; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.hibernate.exception.ConstraintViolationException; |
|
|
|
@ -31,7 +32,7 @@ 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.DataConstants; |
|
|
|
import org.thingsboard.server.common.data.AttributeScope; |
|
|
|
import org.thingsboard.server.common.data.EntitySubtype; |
|
|
|
import org.thingsboard.server.common.data.EntityType; |
|
|
|
import org.thingsboard.server.common.data.StringUtils; |
|
|
|
@ -71,7 +72,6 @@ import org.thingsboard.server.dao.service.Validator; |
|
|
|
import org.thingsboard.server.dao.timeseries.TimeseriesService; |
|
|
|
import org.thingsboard.server.dao.user.UserService; |
|
|
|
|
|
|
|
import jakarta.annotation.Nullable; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Comparator; |
|
|
|
@ -354,7 +354,7 @@ public class EdgeServiceImpl extends AbstractCachedEntityService<EdgeCacheKey, E |
|
|
|
return Futures.successfulAsList(futures); |
|
|
|
}, MoreExecutors.directExecutor()); |
|
|
|
|
|
|
|
edges = Futures.transform(edges, new Function<List<Edge>, List<Edge>>() { |
|
|
|
edges = Futures.transform(edges, new Function<>() { |
|
|
|
@Nullable |
|
|
|
@Override |
|
|
|
public List<Edge> apply(@Nullable List<Edge> edgeList) { |
|
|
|
@ -414,7 +414,7 @@ public class EdgeServiceImpl extends AbstractCachedEntityService<EdgeCacheKey, E |
|
|
|
} |
|
|
|
|
|
|
|
private PaginatedRemover<TenantId, Edge> tenantEdgesRemover = |
|
|
|
new PaginatedRemover<TenantId, Edge>() { |
|
|
|
new PaginatedRemover<>() { |
|
|
|
|
|
|
|
@Override |
|
|
|
protected PageData<Edge> findEntities(TenantId tenantId, TenantId id, PageLink pageLink) { |
|
|
|
@ -427,7 +427,7 @@ public class EdgeServiceImpl extends AbstractCachedEntityService<EdgeCacheKey, E |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
private PaginatedRemover<CustomerId, Edge> customerEdgeUnassigner = new PaginatedRemover<CustomerId, Edge>() { |
|
|
|
private PaginatedRemover<CustomerId, Edge> customerEdgeUnassigner = new PaginatedRemover<>() { |
|
|
|
|
|
|
|
@Override |
|
|
|
protected PageData<Edge> findEntities(TenantId tenantId, CustomerId id, PageLink pageLink) { |
|
|
|
@ -513,7 +513,7 @@ public class EdgeServiceImpl extends AbstractCachedEntityService<EdgeCacheKey, E |
|
|
|
@Override |
|
|
|
public String findMissingToRelatedRuleChains(TenantId tenantId, EdgeId edgeId, String tbRuleChainInputNodeClassName) { |
|
|
|
List<RuleChain> edgeRuleChains = findEdgeRuleChains(tenantId, edgeId); |
|
|
|
List<RuleChainId> edgeRuleChainIds = edgeRuleChains.stream().map(IdBased::getId).collect(Collectors.toList()); |
|
|
|
List<RuleChainId> edgeRuleChainIds = edgeRuleChains.stream().map(IdBased::getId).toList(); |
|
|
|
ObjectNode result = JacksonUtil.newObjectNode(); |
|
|
|
for (RuleChain edgeRuleChain : edgeRuleChains) { |
|
|
|
List<RuleNode> ruleNodes = |
|
|
|
@ -522,8 +522,7 @@ public class EdgeServiceImpl extends AbstractCachedEntityService<EdgeCacheKey, E |
|
|
|
List<RuleChainId> connectedRuleChains = |
|
|
|
ruleNodes.stream() |
|
|
|
.filter(rn -> rn.getType().equals(tbRuleChainInputNodeClassName)) |
|
|
|
.map(rn -> new RuleChainId(UUID.fromString(rn.getConfiguration().get("ruleChainId").asText()))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.map(rn -> new RuleChainId(UUID.fromString(rn.getConfiguration().get("ruleChainId").asText()))).toList(); |
|
|
|
List<String> missingRuleChains = new ArrayList<>(); |
|
|
|
for (RuleChainId connectedRuleChain : connectedRuleChains) { |
|
|
|
if (!edgeRuleChainIds.contains(connectedRuleChain)) { |
|
|
|
@ -549,7 +548,7 @@ public class EdgeServiceImpl extends AbstractCachedEntityService<EdgeCacheKey, E |
|
|
|
if (persistToTelemetry) { |
|
|
|
futureKvEntry = timeseriesService.findLatest(tenantId, edgeId, key); |
|
|
|
} else { |
|
|
|
futureKvEntry = attributesService.find(tenantId, edgeId, DataConstants.SERVER_SCOPE, key); |
|
|
|
futureKvEntry = attributesService.find(tenantId, edgeId, AttributeScope.SERVER_SCOPE, key); |
|
|
|
} |
|
|
|
return Futures.transformAsync(futureKvEntry, kvEntryOpt -> |
|
|
|
Futures.immediateFuture(kvEntryOpt.flatMap(KvEntry::getBooleanValue).orElse(false)), MoreExecutors.directExecutor()); |
|
|
|
|