Commit 4c275888ec840d18b7774825f4742a9df5fdd18d
Merge branch 'master' of github.com:thingsboard/thingsboard
Showing
5 changed files
with
38 additions
and
12 deletions
@@ -24,6 +24,8 @@ import java.io.Serializable; | @@ -24,6 +24,8 @@ import java.io.Serializable; | ||
24 | @Data | 24 | @Data |
25 | public class ClaimData implements Serializable { | 25 | public class ClaimData implements Serializable { |
26 | 26 | ||
27 | + private static final long serialVersionUID = -3922621193389915930L; | ||
28 | + | ||
27 | private final String secretKey; | 29 | private final String secretKey; |
28 | private final long expirationTime; | 30 | private final long expirationTime; |
29 | 31 |
@@ -39,6 +39,8 @@ import static org.thingsboard.server.common.data.SearchTextBasedWithAdditionalIn | @@ -39,6 +39,8 @@ import static org.thingsboard.server.common.data.SearchTextBasedWithAdditionalIn | ||
39 | @Slf4j | 39 | @Slf4j |
40 | public class TenantProfile extends SearchTextBased<TenantProfileId> implements HasName { | 40 | public class TenantProfile extends SearchTextBased<TenantProfileId> implements HasName { |
41 | 41 | ||
42 | + private static final long serialVersionUID = 3021989561267192281L; | ||
43 | + | ||
42 | @NoXss | 44 | @NoXss |
43 | @ApiModelProperty(position = 3, value = "Name of the tenant profile", example = "High Priority Tenants") | 45 | @ApiModelProperty(position = 3, value = "Name of the tenant profile", example = "High Priority Tenants") |
44 | private String name; | 46 | private String name; |
@@ -24,6 +24,8 @@ import java.util.Optional; | @@ -24,6 +24,8 @@ import java.util.Optional; | ||
24 | */ | 24 | */ |
25 | public class BaseAttributeKvEntry implements AttributeKvEntry { | 25 | public class BaseAttributeKvEntry implements AttributeKvEntry { |
26 | 26 | ||
27 | + private static final long serialVersionUID = -6460767583563159407L; | ||
28 | + | ||
27 | private final long lastUpdateTs; | 29 | private final long lastUpdateTs; |
28 | private final KvEntry kv; | 30 | private final KvEntry kv; |
29 | 31 |
@@ -25,6 +25,8 @@ import java.io.Serializable; | @@ -25,6 +25,8 @@ import java.io.Serializable; | ||
25 | @Data | 25 | @Data |
26 | public class SecuritySettings implements Serializable { | 26 | public class SecuritySettings implements Serializable { |
27 | 27 | ||
28 | + private static final long serialVersionUID = -1307613974597312465L; | ||
29 | + | ||
28 | @ApiModelProperty(position = 1, value = "The user password policy object." ) | 30 | @ApiModelProperty(position = 1, value = "The user password policy object." ) |
29 | private UserPasswordPolicy passwordPolicy; | 31 | private UserPasswordPolicy passwordPolicy; |
30 | @ApiModelProperty(position = 2, value = "Maximum number of failed login attempts allowed before user account is locked." ) | 32 | @ApiModelProperty(position = 2, value = "Maximum number of failed login attempts allowed before user account is locked." ) |
@@ -45,24 +45,42 @@ public class GeoUtil { | @@ -45,24 +45,42 @@ public class GeoUtil { | ||
45 | } | 45 | } |
46 | 46 | ||
47 | public static synchronized boolean contains(String polygon, Coordinates coordinates) { | 47 | public static synchronized boolean contains(String polygon, Coordinates coordinates) { |
48 | - ShapeFactory.PolygonBuilder polygonBuilder = jtsCtx.getShapeFactory().polygon(); | ||
49 | JsonArray polygonArray = new JsonParser().parse(polygon).getAsJsonArray(); | 48 | JsonArray polygonArray = new JsonParser().parse(polygon).getAsJsonArray(); |
50 | - boolean first = true; | 49 | + |
50 | + JsonArray arrayWithCoords = polygonArray; | ||
51 | + JsonArray innerArray = polygonArray.get(0).getAsJsonArray(); | ||
52 | + if (!containsPrimitives(innerArray)) { | ||
53 | + arrayWithCoords = innerArray; | ||
54 | + } | ||
55 | + | ||
56 | + Shape shape = buildPolygonFromJsonCoords(arrayWithCoords); | ||
57 | + Point point = jtsCtx.getShapeFactory().pointXY(coordinates.getLongitude(), coordinates.getLatitude()); | ||
58 | + return shape.relate(point).equals(SpatialRelation.CONTAINS); | ||
59 | + } | ||
60 | + | ||
61 | + private static Shape buildPolygonFromJsonCoords(JsonArray coordinates) { | ||
62 | + ShapeFactory.PolygonBuilder polygonBuilder = jtsCtx.getShapeFactory().polygon(); | ||
63 | + boolean isFirst = true; | ||
51 | double firstLat = 0.0; | 64 | double firstLat = 0.0; |
52 | double firstLng = 0.0; | 65 | double firstLng = 0.0; |
53 | - for (JsonElement jsonElement : polygonArray) { | ||
54 | - double lat = jsonElement.getAsJsonArray().get(0).getAsDouble(); | ||
55 | - double lng = jsonElement.getAsJsonArray().get(1).getAsDouble(); | ||
56 | - if (first) { | 66 | + for (JsonElement element : coordinates) { |
67 | + double lat = element.getAsJsonArray().get(0).getAsDouble(); | ||
68 | + double lng = element.getAsJsonArray().get(1).getAsDouble(); | ||
69 | + if (isFirst) { | ||
57 | firstLat = lat; | 70 | firstLat = lat; |
58 | firstLng = lng; | 71 | firstLng = lng; |
59 | - first = false; | 72 | + isFirst = false; |
60 | } | 73 | } |
61 | - polygonBuilder.pointXY(jtsCtx.getShapeFactory().normX(lng), jtsCtx.getShapeFactory().normY(lat)); | 74 | + polygonBuilder.pointXY(jtsCtx.getShapeFactory().normX(lng), jtsCtx.getShapeFactory().normX(lat)); |
62 | } | 75 | } |
63 | - polygonBuilder.pointXY(jtsCtx.getShapeFactory().normX(firstLng), jtsCtx.getShapeFactory().normY(firstLat)); | ||
64 | - Shape shape = polygonBuilder.buildOrRect(); | ||
65 | - Point point = jtsCtx.getShapeFactory().pointXY(coordinates.getLongitude(), coordinates.getLatitude()); | ||
66 | - return shape.relate(point).equals(SpatialRelation.CONTAINS); | 76 | + polygonBuilder.pointXY(jtsCtx.getShapeFactory().normX(firstLng), jtsCtx.getShapeFactory().normX(firstLat)); |
77 | + return polygonBuilder.buildOrRect(); | ||
78 | + } | ||
79 | + | ||
80 | + private static boolean containsPrimitives(JsonArray array) { | ||
81 | + for (JsonElement element : array) { | ||
82 | + return element.isJsonPrimitive(); | ||
83 | + } | ||
84 | + return false; | ||
67 | } | 85 | } |
68 | } | 86 | } |