Logic for inheritance in DynamicValue added
This commit is contained in:
parent
5e990da0ba
commit
1c78a59fb2
@ -16,18 +16,28 @@
|
||||
package org.thingsboard.server.common.data.query;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class DynamicValue<T> {
|
||||
|
||||
@JsonIgnore
|
||||
private T resolvedValue;
|
||||
|
||||
public DynamicValue(DynamicValueSourceType sourceType, String sourceAttribute) {
|
||||
this.sourceAttribute = sourceAttribute;
|
||||
this.sourceType = sourceType;
|
||||
this.useInherit = false;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private final DynamicValueSourceType sourceType;
|
||||
@Getter
|
||||
private final String sourceAttribute;
|
||||
@Getter
|
||||
private final boolean useInherit;
|
||||
|
||||
}
|
||||
|
||||
@ -393,6 +393,9 @@ class AlarmRuleState {
|
||||
break;
|
||||
case CURRENT_CUSTOMER:
|
||||
ekv = dynamicPredicateValueCtx.getCustomerValue(value.getDynamicValue().getSourceAttribute());
|
||||
if(ekv == null && value.getDynamicValue().getUseInherit()) {
|
||||
ekv = dynamicPredicateValueCtx.getTenantValue(value.getDynamicValue().getSourceAttribute());
|
||||
}
|
||||
break;
|
||||
case CURRENT_DEVICE:
|
||||
ekv = data.getValue(new EntityKey(EntityKeyType.ATTRIBUTE, value.getDynamicValue().getSourceAttribute()));
|
||||
@ -405,6 +408,12 @@ class AlarmRuleState {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ekv == null && value.getDynamicValue().getUseInherit()) {
|
||||
ekv = dynamicPredicateValueCtx.getCustomerValue(value.getDynamicValue().getSourceAttribute());
|
||||
if(ekv == null) {
|
||||
ekv = dynamicPredicateValueCtx.getTenantValue(value.getDynamicValue().getSourceAttribute());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ekv;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user