Skip to content
Snippets Groups Projects
Commit 7afee78f authored by Neelesh Thakur's avatar Neelesh Thakur
Browse files

allow nested geo-points

parent 1eeebaef
No related branches found
No related tags found
1 merge request!182fix bug to allow indexing of nested geopoint
......@@ -17,7 +17,6 @@ package org.opengroup.osdu.indexer.service;
import com.google.common.base.Strings;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.internal.LinkedTreeMap;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Array;
import java.lang.reflect.Type;
......@@ -42,10 +41,6 @@ import org.springframework.web.context.annotation.RequestScope;
@RequestScope
public class AttributeParsingServiceImpl implements IAttributeParsingService {
private static final String GEOJSON = "GeoJSON";
private static final String GEOMETRY_COLLECTION = "geometrycollection";
private static final String GEOMETRIES = "geometries";
@Inject
private NumberParser numberParser;
@Inject
......@@ -159,9 +154,7 @@ public class AttributeParsingServiceImpl implements IAttributeParsingService {
}
@Override
public void tryParseGeopoint(String recordId, String attributeName, Map<String, Object> storageRecordData, Map<String, Object> dataMap) {
Object attributeVal = storageRecordData.get(attributeName);
public void tryParseGeopoint(String recordId, String attributeName, Object attributeVal, Map<String, Object> dataMap) {
try {
Type type = new TypeToken<Map<String, Double>>() {}.getType();
......@@ -174,16 +167,6 @@ public class AttributeParsingServiceImpl implements IAttributeParsingService {
if (position == null || position.isEmpty()) return;
dataMap.put(attributeName, position);
// check if geo shape is not there and if it is not then create it in the schema as well as create the data.
LinkedTreeMap<String, Object> map = (LinkedTreeMap) storageRecordData.get(GEOJSON);
if (map == null || map.isEmpty()) {
Map<String, Object> geometry = this.geometryConversionService.getGeopointGeoJson(positionMap);
if (geometry == null) return;
dataMap.put(DATA_GEOJSON_TAG, geometry);
}
} catch (JsonSyntaxException | IllegalArgumentException e) {
String parsingError = String.format("geo-point parsing error: %s attribute: %s | value: %s", e.getMessage(), attributeName, attributeVal);
jobStatus.addOrUpdateRecordStatus(recordId, IndexingStatus.WARN, HttpStatus.SC_BAD_REQUEST, parsingError, String.format("record-id: %s | %s", recordId, parsingError));
......
......@@ -21,7 +21,7 @@ public interface IAttributeParsingService {
void tryParseDate(String recordId, String attributeName, Object attributeVal, Map<String, Object> dataMap);
void tryParseGeopoint(String recordId, String attributeName, Map<String, Object> storageRecordData, Map<String, Object> dataMap);
void tryParseGeopoint(String recordId, String attributeName, Object storageRecordData, Map<String, Object> dataMap);
void tryParseGeojson(String recordId, String attributeName, Object attributeVal, Map<String, Object> dataMap);
......
......@@ -123,7 +123,7 @@ public class StorageIndexerPayloadMapper {
this.attributeParsingService.tryParseDate(recordId, schemaPropertyName, storageRecordValue, dataCollectorMap);
break;
case GEO_POINT:
this.attributeParsingService.tryParseGeopoint(recordId, schemaPropertyName, storageRecordData, dataCollectorMap);
this.attributeParsingService.tryParseGeopoint(recordId, schemaPropertyName, storageRecordValue, dataCollectorMap);
break;
case GEO_SHAPE:
this.attributeParsingService.tryParseGeojson(recordId, schemaPropertyName, storageRecordValue, dataCollectorMap);
......
......@@ -303,14 +303,11 @@ public class AttributeParsingServiceImplTest {
positionMap.put("longitude", 10.45);
positionMap.put("latitude", 90.0);
Map<String, Object> storageData = new HashMap<>();
storageData.put("location", positionMap);
when(this.geometryConversionService.tryGetGeopoint(positionMap)).thenReturn(positionMap);
Map<String, Object> dataMap = new HashMap<>();
this.sut.tryParseGeopoint("", "location", storageData, dataMap);
this.sut.tryParseGeopoint("", "location", positionMap, dataMap);
assertFalse(dataMap.isEmpty());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment