CB-1127 fix filtering geometry (#714)

This commit is contained in:
Ainur
2022-03-17 09:39:52 +03:00
committed by GitHub
parent eef91edb88
commit 7db8dd0727
2 changed files with 20 additions and 3 deletions
@@ -39,5 +39,7 @@ public class WebSQLConstants {
public static final String ATTR_TEXT = "text";
public static final String ATTR_BINARY = "binary";
public static final String ATTR_DATA = "data";
public static final String ATTR_SRID = "srid";
public static final String ATTR_PROPERTIES = "properties";
}
@@ -16,6 +16,7 @@
*/
package io.cloudbeaver.service.sql;
import org.jkiss.dbeaver.model.gis.DBGeometry;
import org.jkiss.utils.CommonUtils;
import java.util.Map;
@@ -36,13 +37,27 @@ public class WebSQLDataFilterConstraint {
public WebSQLDataFilterConstraint(Map<String, Object> map) {
this.attributePosition = CommonUtils.toInt(map.get("attributePosition"));
this.orderPosition = map.containsKey("orderPosition") ?
CommonUtils.toInt(map.get("orderPosition")) + 1 : // Use position + 1 because 0 means no ordering (because of legacy compatibility)
null;
CommonUtils.toInt(map.get("orderPosition")) + 1 : // Use position + 1 because 0 means no ordering (because of legacy compatibility)
null;
this.orderAsc = map.containsKey("orderAsc") ? CommonUtils.toBoolean(map.get("orderAsc")) : null;
this.criteria = CommonUtils.toString(map.get("criteria"), null);
this.operator = CommonUtils.toString(map.get("operator"), null);
this.value = CommonUtils.toString(map.get("value"), null);
Object value = map.get("value");
if (value instanceof Map) {
Map mappedValue = (Map) value;
//creates new geometry object if the type of the value is "geometry"
if (WebSQLConstants.VALUE_TYPE_GEOMETRY.equals(mappedValue.get(WebSQLConstants.VALUE_TYPE_ATTR))) {
this.value = new DBGeometry(
mappedValue.get(WebSQLConstants.ATTR_TEXT),
CommonUtils.toInt(mappedValue.get(WebSQLConstants.ATTR_SRID)),
(Map<String, Object>) mappedValue.get(WebSQLConstants.ATTR_PROPERTIES));
}
} else {
this.value = CommonUtils.toString(value, null);
}
}
public Integer getAttributePosition() {