renamed saveZones to allowedZones
This commit is contained in:
parent
5e9921905f
commit
82cca8c665
@ -96,7 +96,7 @@ import static org.thingsboard.server.common.data.DataConstants.SCOPE;
|
||||
import static org.thingsboard.server.common.data.cf.configuration.GeofencingCalculatedFieldConfiguration.ENTITY_ID_LATITUDE_ARGUMENT_KEY;
|
||||
import static org.thingsboard.server.common.data.cf.configuration.GeofencingCalculatedFieldConfiguration.ENTITY_ID_LONGITUDE_ARGUMENT_KEY;
|
||||
import static org.thingsboard.server.common.data.cf.configuration.GeofencingCalculatedFieldConfiguration.RESTRICTED_ZONES_ARGUMENT_KEY;
|
||||
import static org.thingsboard.server.common.data.cf.configuration.GeofencingCalculatedFieldConfiguration.SAVE_ZONES_ARGUMENT_KEY;
|
||||
import static org.thingsboard.server.common.data.cf.configuration.GeofencingCalculatedFieldConfiguration.ALLOWED_ZONES_ARGUMENT_KEY;
|
||||
import static org.thingsboard.server.utils.CalculatedFieldUtils.toProto;
|
||||
|
||||
@TbRuleEngineComponent
|
||||
@ -138,7 +138,7 @@ public class DefaultCalculatedFieldProcessingService implements CalculatedFieldP
|
||||
switch (entry.getKey()) {
|
||||
case ENTITY_ID_LATITUDE_ARGUMENT_KEY, ENTITY_ID_LONGITUDE_ARGUMENT_KEY ->
|
||||
argFutures.put(entry.getKey(), fetchKvEntry(ctx.getTenantId(), resolveEntityId(entityId, entry), entry.getValue()));
|
||||
case SAVE_ZONES_ARGUMENT_KEY, RESTRICTED_ZONES_ARGUMENT_KEY -> {
|
||||
case ALLOWED_ZONES_ARGUMENT_KEY, RESTRICTED_ZONES_ARGUMENT_KEY -> {
|
||||
var resolvedEntityIdsFuture = resolveGeofencingEntityIds(ctx.getTenantId(), entityId, entry);
|
||||
argFutures.put(entry.getKey(), Futures.transformAsync(resolvedEntityIdsFuture, resolvedEntityIds ->
|
||||
fetchGeofencingKvEntry(ctx.getTenantId(), resolvedEntityIds, entry.getValue()), calculatedFieldCallbackExecutor));
|
||||
|
||||
@ -34,7 +34,7 @@ import java.util.Map;
|
||||
import static org.thingsboard.server.common.data.cf.configuration.GeofencingCalculatedFieldConfiguration.ENTITY_ID_LATITUDE_ARGUMENT_KEY;
|
||||
import static org.thingsboard.server.common.data.cf.configuration.GeofencingCalculatedFieldConfiguration.ENTITY_ID_LONGITUDE_ARGUMENT_KEY;
|
||||
import static org.thingsboard.server.common.data.cf.configuration.GeofencingCalculatedFieldConfiguration.RESTRICTED_ZONES_ARGUMENT_KEY;
|
||||
import static org.thingsboard.server.common.data.cf.configuration.GeofencingCalculatedFieldConfiguration.SAVE_ZONES_ARGUMENT_KEY;
|
||||
import static org.thingsboard.server.common.data.cf.configuration.GeofencingCalculatedFieldConfiguration.ALLOWED_ZONES_ARGUMENT_KEY;
|
||||
|
||||
@Data
|
||||
public class GeofencingCalculatedFieldState implements CalculatedFieldState {
|
||||
@ -48,7 +48,7 @@ public class GeofencingCalculatedFieldState implements CalculatedFieldState {
|
||||
|
||||
|
||||
public GeofencingCalculatedFieldState() {
|
||||
this(List.of(ENTITY_ID_LATITUDE_ARGUMENT_KEY, ENTITY_ID_LONGITUDE_ARGUMENT_KEY, SAVE_ZONES_ARGUMENT_KEY, RESTRICTED_ZONES_ARGUMENT_KEY));
|
||||
this(List.of(ENTITY_ID_LATITUDE_ARGUMENT_KEY, ENTITY_ID_LONGITUDE_ARGUMENT_KEY, ALLOWED_ZONES_ARGUMENT_KEY, RESTRICTED_ZONES_ARGUMENT_KEY));
|
||||
}
|
||||
|
||||
public GeofencingCalculatedFieldState(List<String> argNames) {
|
||||
@ -88,7 +88,7 @@ public class GeofencingCalculatedFieldState implements CalculatedFieldState {
|
||||
arguments.put(key, singleValueArgumentEntry);
|
||||
entryUpdated = true;
|
||||
break;
|
||||
case SAVE_ZONES_ARGUMENT_KEY:
|
||||
case ALLOWED_ZONES_ARGUMENT_KEY:
|
||||
case RESTRICTED_ZONES_ARGUMENT_KEY:
|
||||
if (!(newEntry instanceof GeofencingArgumentEntry geofencingArgumentEntry)) {
|
||||
throw new IllegalArgumentException(key + " argument must be a geofencing argument entry.");
|
||||
@ -143,7 +143,7 @@ public class GeofencingCalculatedFieldState implements CalculatedFieldState {
|
||||
double longitude = (double) arguments.get(ENTITY_ID_LONGITUDE_ARGUMENT_KEY).getValue();
|
||||
|
||||
Coordinates entityCoordinates = new Coordinates(latitude, longitude);
|
||||
String zoneKey = restricted ? RESTRICTED_ZONES_ARGUMENT_KEY : SAVE_ZONES_ARGUMENT_KEY;
|
||||
String zoneKey = restricted ? RESTRICTED_ZONES_ARGUMENT_KEY : ALLOWED_ZONES_ARGUMENT_KEY;
|
||||
GeofencingArgumentEntry zonesEntry = (GeofencingArgumentEntry) arguments.get(zoneKey);
|
||||
|
||||
for (var zoneEntry : zonesEntry.getZoneStates().entrySet()) {
|
||||
|
||||
@ -29,13 +29,13 @@ public class GeofencingCalculatedFieldConfiguration extends BaseCalculatedFieldC
|
||||
|
||||
public static final String ENTITY_ID_LATITUDE_ARGUMENT_KEY = "latitude";
|
||||
public static final String ENTITY_ID_LONGITUDE_ARGUMENT_KEY = "longitude";
|
||||
public static final String SAVE_ZONES_ARGUMENT_KEY = "saveZones";
|
||||
public static final String ALLOWED_ZONES_ARGUMENT_KEY = "allowedZones";
|
||||
public static final String RESTRICTED_ZONES_ARGUMENT_KEY = "restrictedZones";
|
||||
|
||||
private static final Set<String> requiredKeys = Set.of(
|
||||
ENTITY_ID_LATITUDE_ARGUMENT_KEY,
|
||||
ENTITY_ID_LONGITUDE_ARGUMENT_KEY,
|
||||
SAVE_ZONES_ARGUMENT_KEY,
|
||||
ALLOWED_ZONES_ARGUMENT_KEY,
|
||||
RESTRICTED_ZONES_ARGUMENT_KEY
|
||||
);
|
||||
|
||||
@ -68,11 +68,11 @@ public class GeofencingCalculatedFieldConfiguration extends BaseCalculatedFieldC
|
||||
if (dynamicSource != null) {
|
||||
String test = "test";
|
||||
throw new IllegalArgumentException("Dynamic source configuration is forbidden for '" + requiredKey + "' argument. " +
|
||||
"Only '" + SAVE_ZONES_ARGUMENT_KEY + "' and '" + RESTRICTED_ZONES_ARGUMENT_KEY + "' " +
|
||||
"Only '" + ALLOWED_ZONES_ARGUMENT_KEY + "' and '" + RESTRICTED_ZONES_ARGUMENT_KEY + "' " +
|
||||
"may use dynamic source configuration.");
|
||||
}
|
||||
}
|
||||
case SAVE_ZONES_ARGUMENT_KEY, RESTRICTED_ZONES_ARGUMENT_KEY -> {
|
||||
case ALLOWED_ZONES_ARGUMENT_KEY, RESTRICTED_ZONES_ARGUMENT_KEY -> {
|
||||
if (!ArgumentType.ATTRIBUTE.equals(refEntityKey.getType())) {
|
||||
throw new IllegalArgumentException("Argument: '" + requiredKey + "' must be set to " + ArgumentType.ATTRIBUTE + " type!");
|
||||
}
|
||||
|
||||
@ -909,7 +909,7 @@ message GeofencingZoneProto {
|
||||
}
|
||||
|
||||
message GeofencingArgumentProto {
|
||||
string argName = 1; // e.g., "restrictedZones" or "saveZones"
|
||||
string argName = 1; // e.g., "restrictedZones" or "allowedZones"
|
||||
repeated GeofencingZoneProto zones = 2;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user