renamed saveZones to allowedZones

This commit is contained in:
dshvaika 2025-08-04 18:27:30 +03:00
parent 5e9921905f
commit 82cca8c665
4 changed files with 11 additions and 11 deletions

View File

@ -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_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.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.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; import static org.thingsboard.server.utils.CalculatedFieldUtils.toProto;
@TbRuleEngineComponent @TbRuleEngineComponent
@ -138,7 +138,7 @@ public class DefaultCalculatedFieldProcessingService implements CalculatedFieldP
switch (entry.getKey()) { switch (entry.getKey()) {
case ENTITY_ID_LATITUDE_ARGUMENT_KEY, ENTITY_ID_LONGITUDE_ARGUMENT_KEY -> case ENTITY_ID_LATITUDE_ARGUMENT_KEY, ENTITY_ID_LONGITUDE_ARGUMENT_KEY ->
argFutures.put(entry.getKey(), fetchKvEntry(ctx.getTenantId(), resolveEntityId(entityId, entry), entry.getValue())); 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); var resolvedEntityIdsFuture = resolveGeofencingEntityIds(ctx.getTenantId(), entityId, entry);
argFutures.put(entry.getKey(), Futures.transformAsync(resolvedEntityIdsFuture, resolvedEntityIds -> argFutures.put(entry.getKey(), Futures.transformAsync(resolvedEntityIdsFuture, resolvedEntityIds ->
fetchGeofencingKvEntry(ctx.getTenantId(), resolvedEntityIds, entry.getValue()), calculatedFieldCallbackExecutor)); fetchGeofencingKvEntry(ctx.getTenantId(), resolvedEntityIds, entry.getValue()), calculatedFieldCallbackExecutor));

View File

@ -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_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.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.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 @Data
public class GeofencingCalculatedFieldState implements CalculatedFieldState { public class GeofencingCalculatedFieldState implements CalculatedFieldState {
@ -48,7 +48,7 @@ public class GeofencingCalculatedFieldState implements CalculatedFieldState {
public GeofencingCalculatedFieldState() { 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) { public GeofencingCalculatedFieldState(List<String> argNames) {
@ -88,7 +88,7 @@ public class GeofencingCalculatedFieldState implements CalculatedFieldState {
arguments.put(key, singleValueArgumentEntry); arguments.put(key, singleValueArgumentEntry);
entryUpdated = true; entryUpdated = true;
break; break;
case SAVE_ZONES_ARGUMENT_KEY: case ALLOWED_ZONES_ARGUMENT_KEY:
case RESTRICTED_ZONES_ARGUMENT_KEY: case RESTRICTED_ZONES_ARGUMENT_KEY:
if (!(newEntry instanceof GeofencingArgumentEntry geofencingArgumentEntry)) { if (!(newEntry instanceof GeofencingArgumentEntry geofencingArgumentEntry)) {
throw new IllegalArgumentException(key + " argument must be a geofencing argument entry."); 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(); double longitude = (double) arguments.get(ENTITY_ID_LONGITUDE_ARGUMENT_KEY).getValue();
Coordinates entityCoordinates = new Coordinates(latitude, longitude); 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); GeofencingArgumentEntry zonesEntry = (GeofencingArgumentEntry) arguments.get(zoneKey);
for (var zoneEntry : zonesEntry.getZoneStates().entrySet()) { for (var zoneEntry : zonesEntry.getZoneStates().entrySet()) {

View File

@ -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_LATITUDE_ARGUMENT_KEY = "latitude";
public static final String ENTITY_ID_LONGITUDE_ARGUMENT_KEY = "longitude"; 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"; public static final String RESTRICTED_ZONES_ARGUMENT_KEY = "restrictedZones";
private static final Set<String> requiredKeys = Set.of( private static final Set<String> requiredKeys = Set.of(
ENTITY_ID_LATITUDE_ARGUMENT_KEY, ENTITY_ID_LATITUDE_ARGUMENT_KEY,
ENTITY_ID_LONGITUDE_ARGUMENT_KEY, ENTITY_ID_LONGITUDE_ARGUMENT_KEY,
SAVE_ZONES_ARGUMENT_KEY, ALLOWED_ZONES_ARGUMENT_KEY,
RESTRICTED_ZONES_ARGUMENT_KEY RESTRICTED_ZONES_ARGUMENT_KEY
); );
@ -68,11 +68,11 @@ public class GeofencingCalculatedFieldConfiguration extends BaseCalculatedFieldC
if (dynamicSource != null) { if (dynamicSource != null) {
String test = "test"; String test = "test";
throw new IllegalArgumentException("Dynamic source configuration is forbidden for '" + requiredKey + "' argument. " + 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."); "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())) { if (!ArgumentType.ATTRIBUTE.equals(refEntityKey.getType())) {
throw new IllegalArgumentException("Argument: '" + requiredKey + "' must be set to " + ArgumentType.ATTRIBUTE + " type!"); throw new IllegalArgumentException("Argument: '" + requiredKey + "' must be set to " + ArgumentType.ATTRIBUTE + " type!");
} }

View File

@ -909,7 +909,7 @@ message GeofencingZoneProto {
} }
message GeofencingArgumentProto { message GeofencingArgumentProto {
string argName = 1; // e.g., "restrictedZones" or "saveZones" string argName = 1; // e.g., "restrictedZones" or "allowedZones"
repeated GeofencingZoneProto zones = 2; repeated GeofencingZoneProto zones = 2;
} }