diff --git a/indexer-core-plus/src/main/resources/application.properties b/indexer-core-plus/src/main/resources/application.properties index 2f1c6c98b8bf64380cb22325a88753578b3571eb..5d827e4f1d8523166867b8c158f8f00d5a227964 100644 --- a/indexer-core-plus/src/main/resources/application.properties +++ b/indexer-core-plus/src/main/resources/application.properties @@ -63,6 +63,7 @@ rabbitmq-retry-limit=5 # Feature flag settings featureFlag.strategy=dataPartition +featureFlag.mapBooleanToString.enabled=true featureFlag.asIngestedCoordinates.enabled=false featureFlag.keywordLower.enabled=false featureFlag.bagOfWords.enabled=false diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/config/IndexerConfigurationProperties.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/config/IndexerConfigurationProperties.java index 0b7efbc6e977abeb0fdfac645254485f96cbe6f6..a8afb4a134135fccd5b8a6b743af6ae6293f9544 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/config/IndexerConfigurationProperties.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/config/IndexerConfigurationProperties.java @@ -13,6 +13,7 @@ import org.springframework.context.annotation.Configuration; @Getter @Setter public class IndexerConfigurationProperties { + public static final String MAP_BOOL2STRING_FEATURE_NAME = "featureFlag.mapBooleanToString.enabled"; public static final String KEYWORD_LOWER_FEATURE_NAME = "featureFlag.keywordLower.enabled"; public static final String BAG_OF_WORDS_FEATURE_NAME = "featureFlag.bagOfWords.enabled"; public static final String COLLABORATIONS_FEATURE_NAME = "collaborations-enabled"; diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/config/SchemaConverterPropertiesConfig.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/config/SchemaConverterPropertiesConfig.java index c09339260cb7711869671e85ae93895d273ce863..5058a08fd62d153fc9a4723dff557685e2e239d6 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/config/SchemaConverterPropertiesConfig.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/config/SchemaConverterPropertiesConfig.java @@ -7,9 +7,13 @@ import java.util.Map; import java.util.Set; import lombok.Getter; import lombok.Setter; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; +import org.opengroup.osdu.core.common.feature.IFeatureFlag; +import static org.opengroup.osdu.indexer.config.IndexerConfigurationProperties.MAP_BOOL2STRING_FEATURE_NAME; + @Configuration @ConfigurationProperties(prefix = "schema.converter") @Getter @@ -23,6 +27,8 @@ public class SchemaConverterPropertiesConfig implements SchemaConverterConfig { private Set<String> processedArraysTypes = getDefaultArraysTypesForProcessing(); private String defaultObjectArraysType = getObjectArraysDefaultType(); + @Autowired + private IFeatureFlag featureFlagChecker; private Set<String> getDefaultSkippedDefinitions() { return new HashSet<>(Arrays.asList("AbstractAnyCrsFeatureCollection", @@ -46,11 +52,16 @@ public class SchemaConverterPropertiesConfig implements SchemaConverterConfig { private Map<String, String> getDefaultPrimitiveTypesMap() { Map<String, String> defaultPrimitiveTypesMap = new HashMap<>(); - // in the earlier versions boolean was translated to bool and - // this caused mapping boolean values like text as entry in StorageType entry in map is boolean - // in some places boolean is still presented as bool so here both are normalized to boolean - defaultPrimitiveTypesMap.put("boolean", "boolean"); - defaultPrimitiveTypesMap.put("bool", "boolean"); + if (this.featureFlagChecker.isFeatureEnabled(MAP_BOOL2STRING_FEATURE_NAME)) { + // in the earlier versions boolean was translated to bool and + // this caused mapping boolean values like text as entry in StorageType entry in map is boolean + // in some places boolean is still presented as bool so here both are normalized to boolean + defaultPrimitiveTypesMap.put("boolean", "boolean"); + defaultPrimitiveTypesMap.put("bool", "boolean"); + } else { + defaultPrimitiveTypesMap.put("boolean", "bool"); + } + defaultPrimitiveTypesMap.put("number", "double"); defaultPrimitiveTypesMap.put("date-time", "datetime"); defaultPrimitiveTypesMap.put("date", "datetime"); diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessorTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessorTest.java index 478448df046cd425e11d440157ba9e655f6a6cf8..88ae2eb824d303690fde4dc47f16d544ef85a5a8 100644 --- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessorTest.java +++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessorTest.java @@ -30,12 +30,20 @@ import java.util.Map; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.opengroup.osdu.indexer.config.IndexerConfigurationProperties.MAP_BOOL2STRING_FEATURE_NAME; +import org.opengroup.osdu.core.common.feature.IFeatureFlag; +import org.springframework.beans.factory.annotation.Autowired; + +import static org.opengroup.osdu.indexer.config.IndexerConfigurationProperties.MAP_BOOL2STRING_FEATURE_NAME; public class PropertiesProcessorTest { private static final String PATH = "given_path"; private static final String DEFINITIONS_PREFIX = "#/definitions/"; + @Autowired + private IFeatureFlag featureFlagChecker; + @Test public void should_fail_on_bad_reference_definition() { PropertiesProcessor propertiesProcessor = new PropertiesProcessor(Mockito.mock(Definitions.class), new SchemaConverterPropertiesConfig()); @@ -121,7 +129,8 @@ public class PropertiesProcessorTest { String res = new PropertiesProcessor(Mockito.mock(Definitions.class), new SchemaConverterPropertiesConfig()) .processItem(allOfItem).map(Object::toString).reduce("", String::concat); - assertEquals("{path=" + PATH + ", kind=boolean}", res); + String preferredType = (this.featureFlagChecker.isFeatureEnabled(MAP_BOOL2STRING_FEATURE_NAME))?"string":"boolean"; + assertEquals("{{path=${PATH}, kind=${preferredType}}}", res); } @Test @@ -246,4 +255,4 @@ public class PropertiesProcessorTest { .processItem(allOfItem).map(Object::toString).reduce("", String::concat); assertEquals("{path="+ PATH + ", kind=[]int}",res); } -} \ No newline at end of file +}