diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/AttributeParsingServiceImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/AttributeParsingServiceImpl.java index 66d47186931a086c5cf952da892612da185a6fd5..b912825864ea2c780af67fa5fe537ce26f0b78dc 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/AttributeParsingServiceImpl.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/AttributeParsingServiceImpl.java @@ -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)); diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IAttributeParsingService.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IAttributeParsingService.java index a658cc6a1f289d5140cabb39d94864d4f173ef00..51648af975c380e08a91534b5646bcdb3b131fbf 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IAttributeParsingService.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IAttributeParsingService.java @@ -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); diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/StorageIndexerPayloadMapper.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/StorageIndexerPayloadMapper.java index e550d4e0949cf2afb6458a341713d3b713106558..55759face83e4ba6cff8b67d3c97b41829eac5d5 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/StorageIndexerPayloadMapper.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/StorageIndexerPayloadMapper.java @@ -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); diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/AttributeParsingServiceImplTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/AttributeParsingServiceImplTest.java index 67362f02c6c74f2768e825a0f8063d4d9409ee4d..1372a8c45330ee2d8ecb600f664502776d456e6b 100644 --- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/AttributeParsingServiceImplTest.java +++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/AttributeParsingServiceImplTest.java @@ -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()); }