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;
|
package org.thingsboard.server.common.data.query;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
public class DynamicValue<T> {
|
public class DynamicValue<T> {
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private T resolvedValue;
|
private T resolvedValue;
|
||||||
|
|
||||||
|
public DynamicValue(DynamicValueSourceType sourceType, String sourceAttribute) {
|
||||||
|
this.sourceAttribute = sourceAttribute;
|
||||||
|
this.sourceType = sourceType;
|
||||||
|
this.useInherit = false;
|
||||||
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final DynamicValueSourceType sourceType;
|
private final DynamicValueSourceType sourceType;
|
||||||
@Getter
|
@Getter
|
||||||
private final String sourceAttribute;
|
private final String sourceAttribute;
|
||||||
|
@Getter
|
||||||
|
private final boolean useInherit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -393,6 +393,9 @@ class AlarmRuleState {
|
|||||||
break;
|
break;
|
||||||
case CURRENT_CUSTOMER:
|
case CURRENT_CUSTOMER:
|
||||||
ekv = dynamicPredicateValueCtx.getCustomerValue(value.getDynamicValue().getSourceAttribute());
|
ekv = dynamicPredicateValueCtx.getCustomerValue(value.getDynamicValue().getSourceAttribute());
|
||||||
|
if(ekv == null && value.getDynamicValue().getUseInherit()) {
|
||||||
|
ekv = dynamicPredicateValueCtx.getTenantValue(value.getDynamicValue().getSourceAttribute());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CURRENT_DEVICE:
|
case CURRENT_DEVICE:
|
||||||
ekv = data.getValue(new EntityKey(EntityKeyType.ATTRIBUTE, value.getDynamicValue().getSourceAttribute()));
|
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;
|
return ekv;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user