Viacheslav Klimov
6 months ago
Failed to extract signature
3 changed files with
12 additions and
5 deletions
-
common/data/src/main/java/org/thingsboard/server/common/data/rule/RuleChainDetails.java
-
common/util/src/main/java/org/thingsboard/common/util/JacksonUtil.java
-
dao/src/main/java/org/thingsboard/server/dao/model/sql/RuleChainDetailsEntity.java
|
|
|
@ -20,6 +20,7 @@ import io.swagger.v3.oas.annotations.media.Schema; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.EqualsAndHashCode; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Data |
|
|
|
@ -40,7 +41,7 @@ public class RuleChainDetails extends RuleChain { |
|
|
|
|
|
|
|
public RuleChainDetails(RuleChainDetails ruleChainDetails) { |
|
|
|
super(ruleChainDetails); |
|
|
|
this.notes = ruleChainDetails.getNotes(); |
|
|
|
this.notes = ruleChainDetails.getNotes() != null ? new ArrayList<>(ruleChainDetails.getNotes()) : null; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -243,6 +243,14 @@ public class JacksonUtil { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static <T> T treeToValue(JsonNode node, TypeReference<T> type) { |
|
|
|
try { |
|
|
|
return OBJECT_MAPPER.treeToValue(node, type); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new IllegalArgumentException("Can't convert value: " + node.toString(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static JsonNode toJsonNode(String value) { |
|
|
|
return toJsonNode(value, OBJECT_MAPPER); |
|
|
|
} |
|
|
|
|
|
|
|
@ -15,6 +15,7 @@ |
|
|
|
*/ |
|
|
|
package org.thingsboard.server.dao.model.sql; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference; |
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import jakarta.persistence.Column; |
|
|
|
import jakarta.persistence.Convert; |
|
|
|
@ -25,12 +26,9 @@ import lombok.EqualsAndHashCode; |
|
|
|
import org.thingsboard.common.util.JacksonUtil; |
|
|
|
import org.thingsboard.server.common.data.rule.RuleChain; |
|
|
|
import org.thingsboard.server.common.data.rule.RuleChainDetails; |
|
|
|
import org.thingsboard.server.common.data.rule.RuleChainNote; |
|
|
|
import org.thingsboard.server.dao.model.ModelConstants; |
|
|
|
import org.thingsboard.server.dao.util.mapping.JsonConverter; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
@Data |
|
|
|
@EqualsAndHashCode(callSuper = true) |
|
|
|
@Entity |
|
|
|
@ -57,7 +55,7 @@ public class RuleChainDetailsEntity extends AbstractRuleChainEntity<RuleChainDet |
|
|
|
RuleChain ruleChain = super.toRuleChain(); |
|
|
|
RuleChainDetails details = new RuleChainDetails(ruleChain); |
|
|
|
if (notes != null && notes.isArray()) { |
|
|
|
details.setNotes(Arrays.asList(JacksonUtil.treeToValue(notes, RuleChainNote[].class))); |
|
|
|
details.setNotes(JacksonUtil.treeToValue(notes, new TypeReference<>() {})); |
|
|
|
} |
|
|
|
return details; |
|
|
|
} |
|
|
|
|