Search in sources :

Example 1 with RuleChainData

use of org.thingsboard.server.common.data.rule.RuleChainData in project thingsboard by thingsboard.

the class BaseRuleChainService method exportTenantRuleChains.

@Override
public RuleChainData exportTenantRuleChains(TenantId tenantId, PageLink pageLink) {
    Validator.validateId(tenantId, "Incorrect tenant id for search rule chain request.");
    Validator.validatePageLink(pageLink);
    PageData<RuleChain> ruleChainData = ruleChainDao.findRuleChainsByTenantId(tenantId.getId(), pageLink);
    List<RuleChain> ruleChains = ruleChainData.getData();
    List<RuleChainMetaData> metadata = ruleChains.stream().map(rc -> loadRuleChainMetaData(tenantId, rc.getId())).collect(Collectors.toList());
    RuleChainData rcData = new RuleChainData();
    rcData.setRuleChains(ruleChains);
    rcData.setMetadata(metadata);
    setRandomRuleChainIds(rcData);
    resetRuleNodeIds(metadata);
    return rcData;
}
Also used : Edge(org.thingsboard.server.common.data.edge.Edge) BaseData(org.thingsboard.server.common.data.BaseData) RuleChainMetaData(org.thingsboard.server.common.data.rule.RuleChainMetaData) Autowired(org.springframework.beans.factory.annotation.Autowired) RuleNodeId(org.thingsboard.server.common.data.id.RuleNodeId) TenantId(org.thingsboard.server.common.data.id.TenantId) DataValidator(org.thingsboard.server.dao.service.DataValidator) EntityRelation(org.thingsboard.server.common.data.relation.EntityRelation) Uuids(com.datastax.oss.driver.api.core.uuid.Uuids) Map(java.util.Map) EntityType(org.thingsboard.server.common.data.EntityType) RuleChainConnectionInfo(org.thingsboard.server.common.data.rule.RuleChainConnectionInfo) JsonNode(com.fasterxml.jackson.databind.JsonNode) EdgeId(org.thingsboard.server.common.data.id.EdgeId) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) PageLink(org.thingsboard.server.common.data.page.PageLink) Collection(java.util.Collection) Set(java.util.Set) RuleChainData(org.thingsboard.server.common.data.rule.RuleChainData) Collectors(java.util.stream.Collectors) DataValidationException(org.thingsboard.server.dao.exception.DataValidationException) Slf4j(lombok.extern.slf4j.Slf4j) AbstractEntityService(org.thingsboard.server.dao.entity.AbstractEntityService) List(java.util.List) PaginatedRemover(org.thingsboard.server.dao.service.PaginatedRemover) Optional(java.util.Optional) RuleChainId(org.thingsboard.server.common.data.id.RuleChainId) TENANT(org.thingsboard.server.common.data.DataConstants.TENANT) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) RuleChainImportResult(org.thingsboard.server.common.data.rule.RuleChainImportResult) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) JacksonUtil(org.thingsboard.common.util.JacksonUtil) HashMap(java.util.HashMap) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) RuleChainUpdateResult(org.thingsboard.server.common.data.rule.RuleChainUpdateResult) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Validator.validateId(org.thingsboard.server.dao.service.Validator.validateId) Validator.validateString(org.thingsboard.server.dao.service.Validator.validateString) RuleNodeUpdateResult(org.thingsboard.server.common.data.rule.RuleNodeUpdateResult) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) EntityId(org.thingsboard.server.common.data.id.EntityId) Iterator(java.util.Iterator) RuleChainType(org.thingsboard.server.common.data.rule.RuleChainType) RuleNode(org.thingsboard.server.common.data.rule.RuleNode) ConstraintValidator(org.thingsboard.server.dao.service.ConstraintValidator) Validator(org.thingsboard.server.dao.service.Validator) PageData(org.thingsboard.server.common.data.page.PageData) RuleChain(org.thingsboard.server.common.data.rule.RuleChain) RelationTypeGroup(org.thingsboard.server.common.data.relation.RelationTypeGroup) NodeConnectionInfo(org.thingsboard.server.common.data.rule.NodeConnectionInfo) Transactional(org.springframework.transaction.annotation.Transactional) RuleChain(org.thingsboard.server.common.data.rule.RuleChain) RuleChainMetaData(org.thingsboard.server.common.data.rule.RuleChainMetaData) RuleChainData(org.thingsboard.server.common.data.rule.RuleChainData)

Aggregations

Uuids (com.datastax.oss.driver.api.core.uuid.Uuids)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1 ExceptionUtils (org.apache.commons.lang3.exception.ExceptionUtils)1 ConstraintViolationException (org.hibernate.exception.ConstraintViolationException)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1