Skip to content
Snippets Groups Projects
Commit 72df3aa4 authored by Zhibin Mai's avatar Zhibin Mai
Browse files

Merge branch 'augmenter_renaming' into 'master'

Rename some classes and variables to improve readable

See merge request !625
parents 3d30fcd6 1c780515
No related branches found
No related tags found
1 merge request!625Rename some classes and variables to improve readable
Pipeline #214732 failed
Showing
with 329 additions and 211 deletions
...@@ -16,26 +16,26 @@ ...@@ -16,26 +16,26 @@
package org.opengroup.osdu.indexer.cache; package org.opengroup.osdu.indexer.cache;
import org.opengroup.osdu.core.common.cache.VmCache; import org.opengroup.osdu.core.common.cache.VmCache;
import org.opengroup.osdu.indexer.cache.interfaces.IPropertyConfigurationsCache; import org.opengroup.osdu.indexer.cache.interfaces.IAugmenterConfigurationCache;
import org.opengroup.osdu.indexer.model.Constants; import org.opengroup.osdu.indexer.model.Constants;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations; import org.opengroup.osdu.indexer.model.indexproperty.AugmenterConfiguration;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public class PropertyConfigurationsCacheVmImpl implements IPropertyConfigurationsCache { public class AugmenterConfigurationCacheVmImpl implements IAugmenterConfigurationCache {
private VmCache<String, PropertyConfigurations> cache; private VmCache<String, AugmenterConfiguration> cache;
public PropertyConfigurationsCacheVmImpl() { public AugmenterConfigurationCacheVmImpl() {
cache = new VmCache<>(Constants.SPEC_CACHE_EXPIRATION, Constants.SPEC_MAX_CACHE_SIZE); cache = new VmCache<>(Constants.SPEC_CACHE_EXPIRATION, Constants.SPEC_MAX_CACHE_SIZE);
} }
@Override @Override
public void put(String s, PropertyConfigurations o) { public void put(String s, AugmenterConfiguration o) {
this.cache.put(s, o); this.cache.put(s, o);
} }
@Override @Override
public PropertyConfigurations get(String s) { public AugmenterConfiguration get(String s) {
return this.cache.get(s); return this.cache.get(s);
} }
......
...@@ -16,15 +16,15 @@ ...@@ -16,15 +16,15 @@
package org.opengroup.osdu.indexer.cache; package org.opengroup.osdu.indexer.cache;
import org.opengroup.osdu.core.common.cache.VmCache; import org.opengroup.osdu.core.common.cache.VmCache;
import org.opengroup.osdu.indexer.cache.interfaces.IPropertyConfigurationsEnabledCache; import org.opengroup.osdu.indexer.cache.interfaces.IAugmenterConfigurationEnabledCache;
import org.opengroup.osdu.indexer.model.Constants; import org.opengroup.osdu.indexer.model.Constants;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public class PropertyConfigurationsEnabledCacheVmImpl implements IPropertyConfigurationsEnabledCache { public class AugmenterConfigurationEnabledCacheVmImpl implements IAugmenterConfigurationEnabledCache {
private VmCache<String, Boolean> cache; private VmCache<String, Boolean> cache;
public PropertyConfigurationsEnabledCacheVmImpl() { public AugmenterConfigurationEnabledCacheVmImpl() {
cache = new VmCache<>(Constants.SPEC_CACHE_EXPIRATION, Constants.SPEC_MAX_CACHE_SIZE); cache = new VmCache<>(Constants.SPEC_CACHE_EXPIRATION, Constants.SPEC_MAX_CACHE_SIZE);
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
package org.opengroup.osdu.indexer.cache.interfaces; package org.opengroup.osdu.indexer.cache.interfaces;
import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.cache.ICache;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations; import org.opengroup.osdu.indexer.model.indexproperty.AugmenterConfiguration;
public interface IPropertyConfigurationsCache extends ICache<String, PropertyConfigurations> { public interface IAugmenterConfigurationCache extends ICache<String, AugmenterConfiguration> {
} }
...@@ -17,5 +17,5 @@ package org.opengroup.osdu.indexer.cache.interfaces; ...@@ -17,5 +17,5 @@ package org.opengroup.osdu.indexer.cache.interfaces;
import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.cache.ICache;
public interface IPropertyConfigurationsEnabledCache extends ICache<String, Boolean> { public interface IAugmenterConfigurationEnabledCache extends ICache<String, Boolean> {
} }
...@@ -15,24 +15,24 @@ ...@@ -15,24 +15,24 @@
package org.opengroup.osdu.indexer.cache.partitionsafe; package org.opengroup.osdu.indexer.cache.partitionsafe;
import org.opengroup.osdu.indexer.cache.interfaces.IPropertyConfigurationsCache; import org.opengroup.osdu.indexer.cache.interfaces.IAugmenterConfigurationCache;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations; import org.opengroup.osdu.indexer.model.indexproperty.AugmenterConfiguration;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.inject.Inject; import javax.inject.Inject;
@Component @Component
public class PropertyConfigurationsCache extends AbstractPartitionSafeCache<String,PropertyConfigurations> { public class AugmenterConfigurationCache extends AbstractPartitionSafeCache<String, AugmenterConfiguration> {
@Inject @Inject
private IPropertyConfigurationsCache cache; private IAugmenterConfigurationCache cache;
@Override @Override
public void put(String s, PropertyConfigurations o) { public void put(String s, AugmenterConfiguration o) {
this.cache.put(cacheKey(s), o); this.cache.put(cacheKey(s), o);
} }
@Override @Override
public PropertyConfigurations get(String s) { public AugmenterConfiguration get(String s) {
return this.cache.get(cacheKey(s)); return this.cache.get(cacheKey(s));
} }
......
...@@ -15,15 +15,15 @@ ...@@ -15,15 +15,15 @@
package org.opengroup.osdu.indexer.cache.partitionsafe; package org.opengroup.osdu.indexer.cache.partitionsafe;
import org.opengroup.osdu.indexer.cache.interfaces.IPropertyConfigurationsEnabledCache; import org.opengroup.osdu.indexer.cache.interfaces.IAugmenterConfigurationEnabledCache;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.inject.Inject; import javax.inject.Inject;
@Component @Component
public class ConfigurationsEnabledCache extends AbstractPartitionSafeCache<String,Boolean> { public class AugmenterConfigurationEnabledCache extends AbstractPartitionSafeCache<String,Boolean> {
@Inject @Inject
private IPropertyConfigurationsEnabledCache cache; private IAugmenterConfigurationEnabledCache cache;
@Override @Override
public void put(String s, Boolean o) { public void put(String s, Boolean o) {
......
...@@ -26,12 +26,19 @@ import java.util.ArrayList; ...@@ -26,12 +26,19 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@Data @Data
@ToString @ToString
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class PropertyConfigurations { public class AugmenterConfiguration {
// Version must be ended with dot and major version only
// e.g. "Code": "osdu:wks:master-data--Well:1."
private static final String KIND_WITH_MAJOR_VERSION_PATTERN = "[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.$";
@JsonProperty("Name") @JsonProperty("Name")
private String name; private String name;
...@@ -69,14 +76,14 @@ public class PropertyConfigurations { ...@@ -69,14 +76,14 @@ public class PropertyConfigurations {
return false; return false;
} }
String[] parts = this.code.split(":"); try {
if(parts.length != 4) { Pattern pattern = Pattern.compile(KIND_WITH_MAJOR_VERSION_PATTERN);
Matcher matcher = pattern.matcher(this.code);
return matcher.find();
}
catch(PatternSyntaxException ex) {
return false; return false;
} }
// Version must be ended with dot and major version only
// e.g. "Code": "osdu:wks:master-data--Well:1."
String version = parts[3];
return (version.length() > 1 && version.indexOf(".") == version.length() - 1);
} }
public boolean hasValidConfigurations() { public boolean hasValidConfigurations() {
......
...@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.DeserializationContext; ...@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyPath; import org.opengroup.osdu.indexer.model.indexproperty.PropertyPath;
import org.opengroup.osdu.indexer.model.indexproperty.RelatedCondition;
import org.opengroup.osdu.indexer.model.indexproperty.RelatedObjectsSpec; import org.opengroup.osdu.indexer.model.indexproperty.RelatedObjectsSpec;
import org.opengroup.osdu.indexer.model.indexproperty.ValueExtraction; import org.opengroup.osdu.indexer.model.indexproperty.ValueExtraction;
...@@ -26,7 +27,7 @@ public class PropertyPathDeserializer extends JsonDeserializer<PropertyPath> { ...@@ -26,7 +27,7 @@ public class PropertyPathDeserializer extends JsonDeserializer<PropertyPath> {
private final String VALUE_EXTRACTION_RELATED_CONDITION_MATCHES = "ValueExtraction.RelatedConditionMatches"; private final String VALUE_EXTRACTION_RELATED_CONDITION_MATCHES = "ValueExtraction.RelatedConditionMatches";
@Override @Override
public PropertyPath deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException { public PropertyPath deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
PropertyPath propertyPath = new PropertyPath(); PropertyPath propertyPath = new PropertyPath();
ObjectCodec codec = jsonParser.getCodec(); ObjectCodec codec = jsonParser.getCodec();
JsonNode node = codec.readTree(jsonParser); JsonNode node = codec.readTree(jsonParser);
...@@ -64,16 +65,7 @@ public class PropertyPathDeserializer extends JsonDeserializer<PropertyPath> { ...@@ -64,16 +65,7 @@ public class PropertyPathDeserializer extends JsonDeserializer<PropertyPath> {
if(isNotNull(relatedObjectID)) { if(isNotNull(relatedObjectID)) {
relatedObjectsSpec.setRelatedObjectID(relatedObjectID.asText()); relatedObjectsSpec.setRelatedObjectID(relatedObjectID.asText());
} }
if(isNotNull(relatedConditionProperty)) { setRelatedCondition(relatedObjectsSpec, relatedConditionProperty, relatedConditionMatches);
relatedObjectsSpec.setRelatedConditionProperty(relatedConditionProperty.asText());
}
if(isNotNull(relatedConditionMatches) && relatedConditionMatches.isArray()) {
List<String> conditionMatches = new ArrayList<>();
for (JsonNode subNode : relatedConditionMatches) {
conditionMatches.add(subNode.asText());
}
relatedObjectsSpec.setRelatedConditionMatches(conditionMatches);
}
return relatedObjectsSpec; return relatedObjectsSpec;
} }
...@@ -92,22 +84,26 @@ public class PropertyPathDeserializer extends JsonDeserializer<PropertyPath> { ...@@ -92,22 +84,26 @@ public class PropertyPathDeserializer extends JsonDeserializer<PropertyPath> {
if(isNotNull(valuePath)) { if(isNotNull(valuePath)) {
valueExtraction.setValuePath(valuePath.asText()); valueExtraction.setValuePath(valuePath.asText());
} }
if(isNotNull(relatedConditionProperty)) { setRelatedCondition(valueExtraction, relatedConditionProperty, relatedConditionMatches);
valueExtraction.setRelatedConditionProperty(relatedConditionProperty.asText());
}
if(isNotNull(relatedConditionMatches) && relatedConditionMatches.isArray()) {
List<String> conditionMatches = new ArrayList<>();
for (JsonNode subNode : relatedConditionMatches) {
conditionMatches.add(subNode.asText());
}
valueExtraction.setRelatedConditionMatches(conditionMatches);
}
return valueExtraction; return valueExtraction;
} }
return null; return null;
} }
private void setRelatedCondition(RelatedCondition relatedCondition, JsonNode relatedConditionProperty, JsonNode relatedConditionMatches) {
if(isNotNull(relatedConditionProperty)) {
relatedCondition.setRelatedConditionProperty(relatedConditionProperty.asText());
}
if(isNotNull(relatedConditionMatches) && relatedConditionMatches.isArray()) {
List<String> conditionMatches = new ArrayList<>();
for (JsonNode subNode : relatedConditionMatches) {
conditionMatches.add(subNode.asText());
}
relatedCondition.setRelatedConditionMatches(conditionMatches);
}
}
private boolean isNotNull(JsonNode node) { private boolean isNotNull(JsonNode node) {
return node != null && !node.isNull(); return node != null && !node.isNull();
} }
......
...@@ -18,19 +18,19 @@ package org.opengroup.osdu.indexer.service; ...@@ -18,19 +18,19 @@ package org.opengroup.osdu.indexer.service;
import org.opengroup.osdu.core.common.model.search.RecordChangedMessages; import org.opengroup.osdu.core.common.model.search.RecordChangedMessages;
import org.opengroup.osdu.core.common.model.storage.Schema; import org.opengroup.osdu.core.common.model.storage.Schema;
import org.opengroup.osdu.core.common.model.storage.SchemaItem; import org.opengroup.osdu.core.common.model.storage.SchemaItem;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations; import org.opengroup.osdu.indexer.model.indexproperty.AugmenterConfiguration;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface PropertyConfigurationsService { public interface AugmenterConfigurationService {
boolean isPropertyConfigurationsEnabled(String kind); boolean isConfigurationEnabled(String kind);
PropertyConfigurations getPropertyConfigurations(String kind); AugmenterConfiguration getConfiguration(String kind);
Map<String, Object> getExtendedProperties(String objectId, Map<String, Object> originalDataMap, PropertyConfigurations propertyConfigurations); Map<String, Object> getExtendedProperties(String objectId, Map<String, Object> originalDataMap, AugmenterConfiguration propertyConfigurations);
List<SchemaItem> getExtendedSchemaItems(Schema originalSchema, Map<String, Schema> relatedObjectKindSchemas, PropertyConfigurations propertyConfigurations); List<SchemaItem> getExtendedSchemaItems(Schema originalSchema, Map<String, Schema> relatedObjectKindSchemas, AugmenterConfiguration propertyConfigurations);
String resolveConcreteKind(String kind); String resolveConcreteKind(String kind);
......
...@@ -45,7 +45,7 @@ import java.util.*; ...@@ -45,7 +45,7 @@ import java.util.*;
@Component @Component
public class PropertyConfigurationsServiceImpl implements PropertyConfigurationsService { public class AugmenterConfigurationServiceImpl implements AugmenterConfigurationService {
private static final String ASSOCIATED_IDENTITIES_PROPERTY = "AssociatedIdentities"; private static final String ASSOCIATED_IDENTITIES_PROPERTY = "AssociatedIdentities";
private static final String VERSION_PROPERTY = "version"; private static final String VERSION_PROPERTY = "version";
private static final String ASSOCIATED_IDENTITIES_PROPERTY_STORAGE_FORMAT_TYPE = "[]string"; private static final String ASSOCIATED_IDENTITIES_PROPERTY_STORAGE_FORMAT_TYPE = "[]string";
...@@ -67,7 +67,7 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -67,7 +67,7 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
private static final String STRING_ARRAY_KIND = "[]string"; private static final String STRING_ARRAY_KIND = "[]string";
private static final PropertyConfigurations EMPTY_CONFIGURATIONS = new PropertyConfigurations(); private static final AugmenterConfiguration EMPTY_AUGMENTER_CONFIGURATION = new AugmenterConfiguration();
private static final String SEARCH_GENERAL_ERROR = "Failed to call search service."; private static final String SEARCH_GENERAL_ERROR = "Failed to call search service.";
private final Gson gson = new Gson(); private final Gson gson = new Gson();
...@@ -76,9 +76,9 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -76,9 +76,9 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
@Inject @Inject
private IndexerConfigurationProperties configurationProperties; private IndexerConfigurationProperties configurationProperties;
@Inject @Inject
private PropertyConfigurationsCache propertyConfigurationCache; private AugmenterConfigurationCache augmenterConfigurationCache;
@Inject @Inject
private ConfigurationsEnabledCache propertyConfigurationsEnabledCache; private AugmenterConfigurationEnabledCache augmenterConfigurationEnabledCache;
@Inject @Inject
private ChildRelationshipSpecsCache parentChildRelationshipSpecsCache; private ChildRelationshipSpecsCache parentChildRelationshipSpecsCache;
@Inject @Inject
...@@ -101,12 +101,12 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -101,12 +101,12 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
private JaxRsDpsLog jaxRsDpsLog; private JaxRsDpsLog jaxRsDpsLog;
@Override @Override
public boolean isPropertyConfigurationsEnabled(String kind) { public boolean isConfigurationEnabled(String kind) {
kind = PropertyUtil.getKindWithMajor(kind); kind = PropertyUtil.getKindWithMajor(kind);
if (Strings.isNullOrEmpty(kind)) if (Strings.isNullOrEmpty(kind))
return false; return false;
Boolean enabled = propertyConfigurationsEnabledCache.get(kind); Boolean enabled = augmenterConfigurationEnabledCache.get(kind);
if(enabled == null) { if(enabled == null) {
SearchRequest searchRequest = new SearchRequest(); SearchRequest searchRequest = new SearchRequest();
searchRequest.setKind(INDEX_PROPERTY_PATH_CONFIGURATION_KIND); searchRequest.setKind(INDEX_PROPERTY_PATH_CONFIGURATION_KIND);
...@@ -118,69 +118,69 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -118,69 +118,69 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
else { else {
enabled = false; enabled = false;
} }
propertyConfigurationsEnabledCache.put(kind, enabled); augmenterConfigurationEnabledCache.put(kind, enabled);
} }
return enabled; return enabled;
} }
@Override @Override
public PropertyConfigurations getPropertyConfigurations(String kind) { public AugmenterConfiguration getConfiguration(String kind) {
kind = PropertyUtil.getKindWithMajor(kind); kind = PropertyUtil.getKindWithMajor(kind);
if (Strings.isNullOrEmpty(kind)) if (Strings.isNullOrEmpty(kind))
return null; return null;
PropertyConfigurations configuration = propertyConfigurationCache.get(kind); AugmenterConfiguration augmenterConfiguration = augmenterConfigurationCache.get(kind);
if (configuration == null) { if (augmenterConfiguration == null) {
configuration = searchConfigurations(kind); augmenterConfiguration = searchConfiguration(kind);
if (configuration != null) { if (augmenterConfiguration != null) {
if(configuration.isValid()) { if(augmenterConfiguration.isValid()) {
// Log for debug // Log for debug
if(configuration.hasInvalidConfigurations()) { if(augmenterConfiguration.hasInvalidConfigurations()) {
String msg = String.format("PropertyConfigurations: it has invalid PropertyConfiguration for configurations with name '%s':", configuration.getName()); String msg = String.format("PropertyConfigurations: it has invalid PropertyConfiguration for configurations with name '%s':", augmenterConfiguration.getName());
this.jaxRsDpsLog.warning(msg); this.jaxRsDpsLog.warning(msg);
} }
} }
else { else {
// Log for debug // Log for debug
StringBuilder msgBuilder = new StringBuilder(); StringBuilder msgBuilder = new StringBuilder();
msgBuilder.append(String.format("PropertyConfigurations: it is invalid for configurations with name '%s':", configuration.getName())); msgBuilder.append(String.format("PropertyConfigurations: it is invalid for configurations with name '%s':", augmenterConfiguration.getName()));
if(!configuration.hasValidCode()) { if(!augmenterConfiguration.hasValidCode()) {
msgBuilder.append(System.lineSeparator()); msgBuilder.append(System.lineSeparator());
msgBuilder.append(String.format("The code '%s' is invalid. It should be a valid kind with major version ended with '.'", configuration.getCode())); msgBuilder.append(String.format("The code '%s' is invalid. It should be a valid kind with major version ended with '.'", augmenterConfiguration.getCode()));
} }
if(!configuration.hasValidConfigurations()) { if(!augmenterConfiguration.hasValidConfigurations()) {
msgBuilder.append(System.lineSeparator()); msgBuilder.append(System.lineSeparator());
msgBuilder.append("It does not have any valid PropertyConfiguration"); msgBuilder.append("It does not have any valid PropertyConfiguration");
} }
this.jaxRsDpsLog.warning(msgBuilder.toString()); this.jaxRsDpsLog.warning(msgBuilder.toString());
configuration = EMPTY_CONFIGURATIONS; // reset augmenterConfiguration = EMPTY_AUGMENTER_CONFIGURATION; // reset
} }
propertyConfigurationCache.put(kind, configuration); augmenterConfigurationCache.put(kind, augmenterConfiguration);
} else { } else {
// It is common that a kind does not have extended property. So we need to cache an empty configuration // It is common that a kind does not have extended property. So we need to cache an empty augmenterConfiguration
// to avoid unnecessary search // to avoid unnecessary search
propertyConfigurationCache.put(kind, EMPTY_CONFIGURATIONS); augmenterConfigurationCache.put(kind, EMPTY_AUGMENTER_CONFIGURATION);
} }
} }
if (!isNullOrEmptyConfigurations(configuration)) { if (!isEmptyConfiguration(augmenterConfiguration)) {
return configuration; return augmenterConfiguration;
} }
return null; return null;
} }
@Override @Override
public Map<String, Object> getExtendedProperties(String objectId, Map<String, Object> originalDataMap, PropertyConfigurations propertyConfigurations) { public Map<String, Object> getExtendedProperties(String objectId, Map<String, Object> originalDataMap, AugmenterConfiguration augmenterConfiguration) {
// Get all data maps of the related objects in one query in order to improve the performance. // Get all data maps of the related objects in one query in order to improve the performance.
Map<String, Map<String, Object>> idObjectDataMap = getRelatedObjectsData(originalDataMap, propertyConfigurations); Map<String, Map<String, Object>> idObjectDataMap = getRelatedObjectsData(originalDataMap, augmenterConfiguration);
Set<String> associatedIdentities = new HashSet<>(); Set<String> associatedIdentities = new HashSet<>();
Map<String, Object> extendedDataMap = new HashMap<>(); Map<String, Object> extendedDataMap = new HashMap<>();
for (PropertyConfiguration configuration : propertyConfigurations.getConfigurations().stream().filter(c -> c.isValid()).toList()) { for (PropertyConfiguration configuration : augmenterConfiguration.getConfigurations().stream().filter(c -> c.isValid()).toList()) {
String extendedPropertyName = configuration.getExtendedPropertyName(); String extendedPropertyName = configuration.getExtendedPropertyName();
if (originalDataMap.containsKey(extendedPropertyName) && originalDataMap.get(extendedPropertyName) != null) { if (originalDataMap.containsKey(extendedPropertyName) && originalDataMap.get(extendedPropertyName) != null) {
// If the original record already has the property, then we should not override. // If the original record already has the property, then we should not override.
...@@ -249,10 +249,10 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -249,10 +249,10 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
} }
@Override @Override
public List<SchemaItem> getExtendedSchemaItems(Schema originalSchema, Map<String, Schema> relatedObjectKindSchemas, PropertyConfigurations propertyConfigurations) { public List<SchemaItem> getExtendedSchemaItems(Schema originalSchema, Map<String, Schema> relatedObjectKindSchemas, AugmenterConfiguration augmenterConfiguration) {
List<SchemaItem> extendedSchemaItems = new ArrayList<>(); List<SchemaItem> extendedSchemaItems = new ArrayList<>();
boolean hasChildToParentRelationship = false; boolean hasChildToParentRelationship = false;
for (PropertyConfiguration configuration : propertyConfigurations.getConfigurations().stream().filter(c -> c.isValid()).toList()) { for (PropertyConfiguration configuration : augmenterConfiguration.getConfigurations().stream().filter(c -> c.isValid()).toList()) {
Schema schema = null; Schema schema = null;
PropertyPath propertyPath = null; PropertyPath propertyPath = null;
for (PropertyPath path : configuration.getPaths().stream().filter(p -> p.hasValidRelatedObjectsSpec()).toList()) { for (PropertyPath path : configuration.getPaths().stream().filter(p -> p.hasValidRelatedObjectsSpec()).toList()) {
...@@ -365,7 +365,7 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -365,7 +365,7 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
} }
/******************************************************** Private methods **************************************************************/ /******************************************************** Private methods **************************************************************/
private boolean isNullOrEmptyConfigurations(PropertyConfigurations configuration) { private boolean isEmptyConfiguration(AugmenterConfiguration configuration) {
return configuration == null || Strings.isNullOrEmpty(configuration.getCode()); return configuration == null || Strings.isNullOrEmpty(configuration.getCode());
} }
...@@ -427,10 +427,10 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -427,10 +427,10 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
return data; return data;
} }
private Map<String, Map<String, Object>> getRelatedObjectsData(Map<String, Object> originalDataMap, PropertyConfigurations propertyConfigurations) { private Map<String, Map<String, Object>> getRelatedObjectsData(Map<String, Object> originalDataMap, AugmenterConfiguration augmenterConfiguration) {
Map<String, Map<String, Object>> idData = new HashMap<>(); Map<String, Map<String, Object>> idData = new HashMap<>();
Map<String, Set<String>> kindIds = new HashMap<>(); Map<String, Set<String>> kindIds = new HashMap<>();
for (PropertyConfiguration configuration : propertyConfigurations.getConfigurations().stream().filter(c -> c.isValid()).toList()) { for (PropertyConfiguration configuration : augmenterConfiguration.getConfigurations().stream().filter(c -> c.isValid()).toList()) {
for (PropertyPath path : configuration.getPaths().stream().filter(p -> p.hasValidValueExtraction()).toList()) { for (PropertyPath path : configuration.getPaths().stream().filter(p -> p.hasValidValueExtraction()).toList()) {
if (path.hasValidRelatedObjectsSpec()) { if (path.hasValidRelatedObjectsSpec()) {
RelatedObjectsSpec relatedObjectsSpec = path.getRelatedObjectsSpec(); RelatedObjectsSpec relatedObjectsSpec = path.getRelatedObjectsSpec();
...@@ -706,7 +706,7 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -706,7 +706,7 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
if(childrenKinds == null) { if(childrenKinds == null) {
childrenKinds = new ChildrenKinds(); childrenKinds = new ChildrenKinds();
Set<String> kinds = new HashSet<>(); Set<String> kinds = new HashSet<>();
for (PropertyConfigurations propertyConfigurations: searchChildrenKindConfigurations(parentKindWithMajor)) { for (AugmenterConfiguration propertyConfigurations: searchChildrenKindConfigurations(parentKindWithMajor)) {
kinds.add(propertyConfigurations.getCode()); kinds.add(propertyConfigurations.getCode());
} }
childrenKinds.setKinds(new ArrayList<>(kinds)); childrenKinds.setKinds(new ArrayList<>(kinds));
...@@ -725,16 +725,16 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -725,16 +725,16 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
specs = new ParentChildRelationshipSpecs(); specs = new ParentChildRelationshipSpecs();
specs.setSpecList(specsList); specs.setSpecList(specsList);
List<PropertyConfigurations> configurationsList = searchParentKindConfigurations((childKindWithMajor)); List<AugmenterConfiguration> augmenterConfigurations = searchParentKindConfigurations((childKindWithMajor));
for (PropertyConfigurations configurations : configurationsList) { for (AugmenterConfiguration augmenterConfiguration : augmenterConfigurations) {
for (PropertyConfiguration configuration : configurations.getConfigurations()) { for (PropertyConfiguration propertyConfiguration : augmenterConfiguration.getConfigurations()) {
List<PropertyPath> matchedPropertyPaths = configuration.getPaths().stream().filter(p -> List<PropertyPath> matchedPropertyPaths = propertyConfiguration.getPaths().stream().filter(p ->
p.hasValidRelatedObjectsSpec() && p.hasValidRelatedObjectsSpec() &&
p.getRelatedObjectsSpec().isParentToChildren() && p.getRelatedObjectsSpec().isParentToChildren() &&
p.getRelatedObjectsSpec().getRelatedObjectKind().contains(childKindWithMajor)) p.getRelatedObjectsSpec().getRelatedObjectKind().contains(childKindWithMajor))
.toList(); .toList();
for(PropertyPath propertyPath: matchedPropertyPaths) { for(PropertyPath propertyPath: matchedPropertyPaths) {
ParentChildRelationshipSpec spec = toParentChildRelationshipSpec(propertyPath, configurations.getCode(), childKindWithMajor); ParentChildRelationshipSpec spec = toParentChildRelationshipSpec(propertyPath, augmenterConfiguration.getCode(), childKindWithMajor);
boolean merged = false; boolean merged = false;
for(ParentChildRelationshipSpec sp: specsList) { for(ParentChildRelationshipSpec sp: specsList) {
if(sp.equals(spec)) { if(sp.equals(spec)) {
...@@ -840,9 +840,9 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -840,9 +840,9 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
return true; return true;
} }
PropertyConfigurations propertyConfigurations = this.getPropertyConfigurations(childKind); AugmenterConfiguration augmenterConfiguration = this.getConfiguration(childKind);
if(propertyConfigurations != null) { if(augmenterConfiguration != null) {
for (PropertyConfiguration propertyConfiguration : propertyConfigurations.getConfigurations()) { for (PropertyConfiguration propertyConfiguration : augmenterConfiguration.getConfigurations()) {
for (PropertyPath propertyPath : propertyConfiguration.getPaths().stream().filter( for (PropertyPath propertyPath : propertyConfiguration.getPaths().stream().filter(
p -> p.hasValidValueExtraction() && p.hasValidRelatedObjectsSpec()).toList()) { p -> p.hasValidValueExtraction() && p.hasValidRelatedObjectsSpec()).toList()) {
String relatedObjectKind = propertyPath.getRelatedObjectsSpec().getRelatedObjectKind(); String relatedObjectKind = propertyPath.getRelatedObjectsSpec().getRelatedObjectKind();
...@@ -949,7 +949,7 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -949,7 +949,7 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
return searchRequest; return searchRequest;
} }
private PropertyConfigurations searchConfigurations(String kind) { private AugmenterConfiguration searchConfiguration(String kind) {
String query = String.format("data.Code: \"%s\"", kind); String query = String.format("data.Code: \"%s\"", kind);
SearchRequest searchRequest = createSearchRequest(INDEX_PROPERTY_PATH_CONFIGURATION_KIND, query); SearchRequest searchRequest = createSearchRequest(INDEX_PROPERTY_PATH_CONFIGURATION_KIND, query);
// If there is more than PropertyConfigurations, pick the one that was last modified. // If there is more than PropertyConfigurations, pick the one that was last modified.
...@@ -959,42 +959,42 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations ...@@ -959,42 +959,42 @@ public class PropertyConfigurationsServiceImpl implements PropertyConfigurations
sort.setField(Arrays.asList(VERSION_PROPERTY)); sort.setField(Arrays.asList(VERSION_PROPERTY));
sort.setOrder(Arrays.asList(SortOrder.DESC)); sort.setOrder(Arrays.asList(SortOrder.DESC));
searchRequest.setSort(sort); searchRequest.setSort(sort);
List<PropertyConfigurations> propertyConfigurationsList = searchConfigurations(searchRequest); List<AugmenterConfiguration> augmenterConfigurations = searchConfigurations(searchRequest);
if(!propertyConfigurationsList.isEmpty()) { if(!augmenterConfigurations.isEmpty()) {
if(propertyConfigurationsList.size() > 1) { if(augmenterConfigurations.size() > 1) {
jaxRsDpsLog.warning(String.format("There is more than one PropertyConfigurations for kind: %s", kind)); jaxRsDpsLog.warning(String.format("There is more than one PropertyConfigurations for kind: %s", kind));
} }
return propertyConfigurationsList.get(0); return augmenterConfigurations.get(0);
} }
return null; return null;
} }
private List<PropertyConfigurations> searchParentKindConfigurations(String childKind) { private List<AugmenterConfiguration> searchParentKindConfigurations(String childKind) {
String query = String.format(PARENT_CHILDREN_CONFIGURATION_QUERY_FORMAT, childKind); String query = String.format(PARENT_CHILDREN_CONFIGURATION_QUERY_FORMAT, childKind);
SearchRequest searchRequest = createSearchRequest(INDEX_PROPERTY_PATH_CONFIGURATION_KIND, query); SearchRequest searchRequest = createSearchRequest(INDEX_PROPERTY_PATH_CONFIGURATION_KIND, query);
return searchConfigurations(searchRequest); return searchConfigurations(searchRequest);
} }
private List<PropertyConfigurations> searchChildrenKindConfigurations(String parentKind) { private List<AugmenterConfiguration> searchChildrenKindConfigurations(String parentKind) {
String query = String.format(CHILDREN_PARENT_CONFIGURATION_QUERY_FORMAT, parentKind); String query = String.format(CHILDREN_PARENT_CONFIGURATION_QUERY_FORMAT, parentKind);
SearchRequest searchRequest = createSearchRequest(INDEX_PROPERTY_PATH_CONFIGURATION_KIND, query); SearchRequest searchRequest = createSearchRequest(INDEX_PROPERTY_PATH_CONFIGURATION_KIND, query);
return searchConfigurations(searchRequest); return searchConfigurations(searchRequest);
} }
private List<PropertyConfigurations> searchConfigurations(SearchRequest searchRequest) { private List<AugmenterConfiguration> searchConfigurations(SearchRequest searchRequest) {
List<PropertyConfigurations> configurationsList = new ArrayList<>(); List<AugmenterConfiguration> augmenterConfigurations = new ArrayList<>();
for (SearchRecord searchRecord : searchRecords(searchRequest)) { for (SearchRecord searchRecord : searchRecords(searchRequest)) {
try { try {
String data = objectMapper.writeValueAsString(searchRecord.getData()); String data = objectMapper.writeValueAsString(searchRecord.getData());
PropertyConfigurations configurations = objectMapper.readValue(data, PropertyConfigurations.class); AugmenterConfiguration configurations = objectMapper.readValue(data, AugmenterConfiguration.class);
String kind = PropertyUtil.getKindWithMajor(configurations.getCode()); String kind = PropertyUtil.getKindWithMajor(configurations.getCode());
propertyConfigurationCache.put(kind, configurations); augmenterConfigurationCache.put(kind, configurations);
configurationsList.add(configurations); augmenterConfigurations.add(configurations);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
jaxRsDpsLog.error("failed to deserialize PropertyConfigurations object", e); jaxRsDpsLog.error("failed to deserialize PropertyConfigurations object", e);
} }
} }
return configurationsList; return augmenterConfigurations;
} }
private List<SearchRecord> searchRelatedRecords(List<String> relatedObjectKinds, List<String> relatedObjectIds) { private List<SearchRecord> searchRelatedRecords(List<String> relatedObjectKinds, List<String> relatedObjectIds) {
......
...@@ -33,7 +33,7 @@ import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver; ...@@ -33,7 +33,7 @@ import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver;
import org.opengroup.osdu.indexer.cache.partitionsafe.FlattenedSchemaCache; import org.opengroup.osdu.indexer.cache.partitionsafe.FlattenedSchemaCache;
import org.opengroup.osdu.indexer.cache.partitionsafe.SchemaCache; import org.opengroup.osdu.indexer.cache.partitionsafe.SchemaCache;
import org.opengroup.osdu.indexer.model.Kind; import org.opengroup.osdu.indexer.model.Kind;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations; import org.opengroup.osdu.indexer.model.indexproperty.AugmenterConfiguration;
import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException; import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException;
import org.opengroup.osdu.indexer.schema.converter.interfaces.IVirtualPropertiesSchemaCache; import org.opengroup.osdu.indexer.schema.converter.interfaces.IVirtualPropertiesSchemaCache;
import org.opengroup.osdu.indexer.util.AugmenterSetting; import org.opengroup.osdu.indexer.util.AugmenterSetting;
...@@ -71,7 +71,7 @@ public class IndexSchemaServiceImpl implements IndexSchemaService { ...@@ -71,7 +71,7 @@ public class IndexSchemaServiceImpl implements IndexSchemaService {
@Inject @Inject
private IVirtualPropertiesSchemaCache virtualPropertiesSchemaCache; private IVirtualPropertiesSchemaCache virtualPropertiesSchemaCache;
@Inject @Inject
private PropertyConfigurationsService propertyConfigurationsService; private AugmenterConfigurationService augmenterConfigurationService;
@Inject @Inject
private AugmenterSetting augmenterSetting; private AugmenterSetting augmenterSetting;
...@@ -178,9 +178,9 @@ public class IndexSchemaServiceImpl implements IndexSchemaService { ...@@ -178,9 +178,9 @@ public class IndexSchemaServiceImpl implements IndexSchemaService {
if(augmenterSetting.isEnabled()) { if(augmenterSetting.isEnabled()) {
try { try {
// Merge schema of the extended properties if needed // Merge schema of the extended properties if needed
PropertyConfigurations propertyConfigurations = propertyConfigurationsService.getPropertyConfigurations(kind); AugmenterConfiguration augmenterConfiguration = augmenterConfigurationService.getConfiguration(kind);
if (propertyConfigurations != null) { if (augmenterConfiguration != null) {
schema = mergeSchemaFromPropertyConfiguration(schema, propertyConfigurations); schema = mergeSchemaFromPropertyConfiguration(schema, augmenterConfiguration);
} }
} }
catch(Exception ex) { catch(Exception ex) {
...@@ -212,10 +212,10 @@ public class IndexSchemaServiceImpl implements IndexSchemaService { ...@@ -212,10 +212,10 @@ public class IndexSchemaServiceImpl implements IndexSchemaService {
return flatSchemaObj; return flatSchemaObj;
} }
private String mergeSchemaFromPropertyConfiguration(String originalSchemaStr, PropertyConfigurations propertyConfigurations) throws UnsupportedEncodingException, URISyntaxException { private String mergeSchemaFromPropertyConfiguration(String originalSchemaStr, AugmenterConfiguration augmenterConfiguration) throws UnsupportedEncodingException, URISyntaxException {
Map<String, Schema> relatedObjectKindSchemas = getSchemaOfRelatedObjectKinds(propertyConfigurations); Map<String, Schema> relatedObjectKindSchemas = getSchemaOfRelatedObjectKinds(augmenterConfiguration);
Schema originalSchema = gson.fromJson(originalSchemaStr, Schema.class); Schema originalSchema = gson.fromJson(originalSchemaStr, Schema.class);
List<SchemaItem> extendedSchemaItems = propertyConfigurationsService.getExtendedSchemaItems(originalSchema, relatedObjectKindSchemas, propertyConfigurations); List<SchemaItem> extendedSchemaItems = augmenterConfigurationService.getExtendedSchemaItems(originalSchema, relatedObjectKindSchemas, augmenterConfiguration);
if (!extendedSchemaItems.isEmpty()) { if (!extendedSchemaItems.isEmpty()) {
List<SchemaItem> originalSchemaItems = new ArrayList<>(Arrays.asList(originalSchema.getSchema())); List<SchemaItem> originalSchemaItems = new ArrayList<>(Arrays.asList(originalSchema.getSchema()));
originalSchemaItems.addAll(extendedSchemaItems); originalSchemaItems.addAll(extendedSchemaItems);
...@@ -226,13 +226,13 @@ public class IndexSchemaServiceImpl implements IndexSchemaService { ...@@ -226,13 +226,13 @@ public class IndexSchemaServiceImpl implements IndexSchemaService {
} }
} }
private Map<String, Schema> getSchemaOfRelatedObjectKinds(PropertyConfigurations propertyConfigurations) throws UnsupportedEncodingException, URISyntaxException { private Map<String, Schema> getSchemaOfRelatedObjectKinds(AugmenterConfiguration augmenterConfiguration) throws UnsupportedEncodingException, URISyntaxException {
List<String> relatedObjectKinds = propertyConfigurations.getUniqueRelatedObjectKinds(); List<String> relatedObjectKinds = augmenterConfiguration.getUniqueRelatedObjectKinds();
Map<String, Schema> relatedObjectKindSchemas = new HashMap<>(); Map<String, Schema> relatedObjectKindSchemas = new HashMap<>();
for (String relatedObjectKind : relatedObjectKinds) { for (String relatedObjectKind : relatedObjectKinds) {
// The relatedObjectKind defined in property configuration can be kind having major version only // The relatedObjectKind defined in property configuration can be kind having major version only
// e.g. "RelatedObjectKind": "osdu:wks:master-data--Wellbore:1." // e.g. "RelatedObjectKind": "osdu:wks:master-data--Wellbore:1."
String concreteRelatedObjectKind = propertyConfigurationsService.resolveConcreteKind(relatedObjectKind); String concreteRelatedObjectKind = augmenterConfigurationService.resolveConcreteKind(relatedObjectKind);
if (Strings.isNullOrEmpty(concreteRelatedObjectKind)) if (Strings.isNullOrEmpty(concreteRelatedObjectKind))
continue; continue;
......
...@@ -44,7 +44,7 @@ import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo; ...@@ -44,7 +44,7 @@ import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo;
import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver; import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver;
import org.opengroup.osdu.indexer.logging.AuditLogger; import org.opengroup.osdu.indexer.logging.AuditLogger;
import org.opengroup.osdu.indexer.model.BulkRequestResult; import org.opengroup.osdu.indexer.model.BulkRequestResult;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations; import org.opengroup.osdu.indexer.model.indexproperty.AugmenterConfiguration;
import org.opengroup.osdu.indexer.provider.interfaces.IPublisher; import org.opengroup.osdu.indexer.provider.interfaces.IPublisher;
import org.opengroup.osdu.indexer.util.AugmenterSetting; import org.opengroup.osdu.indexer.util.AugmenterSetting;
import org.opengroup.osdu.indexer.util.ElasticClientHandler; import org.opengroup.osdu.indexer.util.ElasticClientHandler;
...@@ -106,7 +106,7 @@ public class IndexerServiceImpl implements IndexerService { ...@@ -106,7 +106,7 @@ public class IndexerServiceImpl implements IndexerService {
@Inject @Inject
private JobStatus jobStatus; private JobStatus jobStatus;
@Inject @Inject
private PropertyConfigurationsService propertyConfigurationsService; private AugmenterConfigurationService augmenterConfigurationService;
@Inject @Inject
private AugmenterSetting augmenterSetting; private AugmenterSetting augmenterSetting;
...@@ -162,7 +162,7 @@ public class IndexerServiceImpl implements IndexerService { ...@@ -162,7 +162,7 @@ public class IndexerServiceImpl implements IndexerService {
Map<String, List<String>> upsertKindIds = getUpsertRecordIdsForConfigurationsEnabledKinds(upsertRecordMap, retryRecordIds); Map<String, List<String>> upsertKindIds = getUpsertRecordIdsForConfigurationsEnabledKinds(upsertRecordMap, retryRecordIds);
Map<String, List<String>> deleteKindIds = getDeleteRecordIdsForConfigurationsEnabledKinds(deleteRecordMap, retryRecordIds); Map<String, List<String>> deleteKindIds = getDeleteRecordIdsForConfigurationsEnabledKinds(deleteRecordMap, retryRecordIds);
if (!upsertKindIds.isEmpty() || !deleteKindIds.isEmpty()) { if (!upsertKindIds.isEmpty() || !deleteKindIds.isEmpty()) {
propertyConfigurationsService.updateAssociatedRecords(message, upsertKindIds, deleteKindIds); augmenterConfigurationService.updateAssociatedRecords(message, upsertKindIds, deleteKindIds);
} }
} }
catch(Exception ex) { catch(Exception ex) {
...@@ -207,7 +207,7 @@ public class IndexerServiceImpl implements IndexerService { ...@@ -207,7 +207,7 @@ public class IndexerServiceImpl implements IndexerService {
Map<String, List<String>> upsertKindIds = new HashMap<>(); Map<String, List<String>> upsertKindIds = new HashMap<>();
for (Map.Entry<String, Map<String, OperationType>> entry : upsertRecordMap.entrySet()) { for (Map.Entry<String, Map<String, OperationType>> entry : upsertRecordMap.entrySet()) {
String kind = entry.getKey(); String kind = entry.getKey();
if(propertyConfigurationsService.isPropertyConfigurationsEnabled(kind)) { if(augmenterConfigurationService.isConfigurationEnabled(kind)) {
List<String> processedIds = entry.getValue().keySet().stream().filter(id -> !retryRecordIds.contains(id)).collect(Collectors.toList()); List<String> processedIds = entry.getValue().keySet().stream().filter(id -> !retryRecordIds.contains(id)).collect(Collectors.toList());
if (!processedIds.isEmpty()) { if (!processedIds.isEmpty()) {
upsertKindIds.put(kind, processedIds); upsertKindIds.put(kind, processedIds);
...@@ -221,7 +221,7 @@ public class IndexerServiceImpl implements IndexerService { ...@@ -221,7 +221,7 @@ public class IndexerServiceImpl implements IndexerService {
Map<String, List<String>> deletedRecordKindIdsMap = new HashMap<>(); Map<String, List<String>> deletedRecordKindIdsMap = new HashMap<>();
for (Map.Entry<String, List<String>> entry : deleteRecordMap.entrySet()) { for (Map.Entry<String, List<String>> entry : deleteRecordMap.entrySet()) {
String kind = entry.getKey(); String kind = entry.getKey();
if(propertyConfigurationsService.isPropertyConfigurationsEnabled(kind)) { if(augmenterConfigurationService.isConfigurationEnabled(kind)) {
List<String> processedIds = entry.getValue().stream().filter(id -> !retryRecordIds.contains(id)).collect(Collectors.toList()); List<String> processedIds = entry.getValue().stream().filter(id -> !retryRecordIds.contains(id)).collect(Collectors.toList());
if (!processedIds.isEmpty()) { if (!processedIds.isEmpty()) {
deletedRecordKindIdsMap.put(kind, processedIds); deletedRecordKindIdsMap.put(kind, processedIds);
...@@ -352,14 +352,14 @@ public class IndexerServiceImpl implements IndexerService { ...@@ -352,14 +352,14 @@ public class IndexerServiceImpl implements IndexerService {
if(this.augmenterSetting.isEnabled()) { if(this.augmenterSetting.isEnabled()) {
try { try {
if (propertyConfigurationsService.isPropertyConfigurationsEnabled(storageRecord.getKind())) { if (augmenterConfigurationService.isConfigurationEnabled(storageRecord.getKind())) {
PropertyConfigurations propertyConfigurations = propertyConfigurationsService.getPropertyConfigurations(storageRecord.getKind()); AugmenterConfiguration augmenterConfiguration = augmenterConfigurationService.getConfiguration(storageRecord.getKind());
if (propertyConfigurations != null) { if (augmenterConfiguration != null) {
// Merge extended properties // Merge extended properties
dataMap = mergeDataFromPropertyConfiguration(storageRecord.getId(), dataMap, propertyConfigurations); dataMap = mergeDataFromPropertyConfiguration(storageRecord.getId(), dataMap, augmenterConfiguration);
} }
// We cache the dataMap in case the update of this object will trigger update of the related objects. // We cache the dataMap in case the update of this object will trigger update of the related objects.
propertyConfigurationsService.cacheDataRecord(storageRecord.getId(), storageRecord.getKind(), dataMap); augmenterConfigurationService.cacheDataRecord(storageRecord.getId(), storageRecord.getKind(), dataMap);
} }
} }
catch(Exception ex) { catch(Exception ex) {
...@@ -420,8 +420,8 @@ public class IndexerServiceImpl implements IndexerService { ...@@ -420,8 +420,8 @@ public class IndexerServiceImpl implements IndexerService {
return document; return document;
} }
private Map<String, Object> mergeDataFromPropertyConfiguration(String objectId, Map<String, Object> originalDataMap, PropertyConfigurations propertyConfigurations) { private Map<String, Object> mergeDataFromPropertyConfiguration(String objectId, Map<String, Object> originalDataMap, AugmenterConfiguration augmenterConfiguration) {
Map<String, Object> extendedDataMap = propertyConfigurationsService.getExtendedProperties(objectId, originalDataMap, propertyConfigurations); Map<String, Object> extendedDataMap = augmenterConfigurationService.getExtendedProperties(objectId, originalDataMap, augmenterConfiguration);
if (!extendedDataMap.isEmpty()) { if (!extendedDataMap.isEmpty()) {
originalDataMap.putAll(extendedDataMap); originalDataMap.putAll(extendedDataMap);
} }
......
...@@ -31,75 +31,75 @@ import java.util.ArrayList; ...@@ -31,75 +31,75 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
public class PropertyConfigurationsTest { public class AugmenterConfigurationTest {
private PropertyConfigurations configurations; private AugmenterConfiguration augmenterConfiguration;
@Before @Before
public void setup() throws JsonProcessingException { public void setup() throws JsonProcessingException {
String jsonText = getJsonFromFile("well_configuration_record.json"); String jsonText = getJsonFromFile("well_configuration_record.json");
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
configurations = objectMapper.readValue(jsonText, PropertyConfigurations.class); augmenterConfiguration = objectMapper.readValue(jsonText, AugmenterConfiguration.class);
} }
@Test @Test
public void isValid() { public void isValid() {
Assert.assertTrue(configurations.hasValidCode()); Assert.assertTrue(augmenterConfiguration.hasValidCode());
Assert.assertTrue(configurations.hasValidConfigurations()); Assert.assertTrue(augmenterConfiguration.hasValidConfigurations());
Assert.assertFalse(configurations.hasInvalidConfigurations()); Assert.assertFalse(augmenterConfiguration.hasInvalidConfigurations());
Assert.assertTrue(configurations.isValid()); Assert.assertTrue(augmenterConfiguration.isValid());
} }
@Test @Test
public void hasInvalidCode() { public void hasInvalidCode() {
String code = configurations.getCode(); String code = augmenterConfiguration.getCode();
configurations.setCode(code + "0.0"); augmenterConfiguration.setCode(code + "0.0");
Assert.assertFalse(configurations.hasValidCode()); Assert.assertFalse(augmenterConfiguration.hasValidCode());
Assert.assertFalse(configurations.isValid()); Assert.assertFalse(augmenterConfiguration.isValid());
configurations.setCode("a:b:1."); augmenterConfiguration.setCode("a:b:1.");
Assert.assertFalse(configurations.hasValidCode()); Assert.assertFalse(augmenterConfiguration.hasValidCode());
Assert.assertFalse(configurations.isValid()); Assert.assertFalse(augmenterConfiguration.isValid());
configurations.setCode(""); augmenterConfiguration.setCode("");
Assert.assertFalse(configurations.hasValidCode()); Assert.assertFalse(augmenterConfiguration.hasValidCode());
Assert.assertFalse(configurations.isValid()); Assert.assertFalse(augmenterConfiguration.isValid());
configurations.setCode(null); augmenterConfiguration.setCode(null);
Assert.assertFalse(configurations.hasValidCode()); Assert.assertFalse(augmenterConfiguration.hasValidCode());
Assert.assertFalse(configurations.isValid()); Assert.assertFalse(augmenterConfiguration.isValid());
} }
@Test @Test
public void hasNoValidConfigurations() { public void hasNoValidConfigurations() {
List<PropertyConfiguration> propertyConfigurations = configurations.getConfigurations(); List<PropertyConfiguration> propertyConfigurations = augmenterConfiguration.getConfigurations();
configurations.setConfigurations(new ArrayList<>()); augmenterConfiguration.setConfigurations(new ArrayList<>());
Assert.assertFalse(configurations.hasValidConfigurations()); Assert.assertFalse(augmenterConfiguration.hasValidConfigurations());
Assert.assertFalse(configurations.hasInvalidConfigurations()); Assert.assertFalse(augmenterConfiguration.hasInvalidConfigurations());
Assert.assertFalse(configurations.isValid()); Assert.assertFalse(augmenterConfiguration.isValid());
configurations.setConfigurations(null); augmenterConfiguration.setConfigurations(null);
Assert.assertFalse(configurations.hasValidConfigurations()); Assert.assertFalse(augmenterConfiguration.hasValidConfigurations());
Assert.assertFalse(configurations.hasInvalidConfigurations()); Assert.assertFalse(augmenterConfiguration.hasInvalidConfigurations());
Assert.assertFalse(configurations.isValid()); Assert.assertFalse(augmenterConfiguration.isValid());
propertyConfigurations.forEach(p -> p.setPolicy("")); propertyConfigurations.forEach(p -> p.setPolicy(""));
configurations.setConfigurations(propertyConfigurations); augmenterConfiguration.setConfigurations(propertyConfigurations);
Assert.assertFalse(configurations.hasValidConfigurations()); Assert.assertFalse(augmenterConfiguration.hasValidConfigurations());
Assert.assertTrue(configurations.hasInvalidConfigurations()); Assert.assertTrue(augmenterConfiguration.hasInvalidConfigurations());
Assert.assertFalse(configurations.isValid()); Assert.assertFalse(augmenterConfiguration.isValid());
} }
@Test @Test
public void hasPartialValidConfigurations() { public void hasPartialValidConfigurations() {
List<PropertyConfiguration> propertyConfigurations = configurations.getConfigurations(); List<PropertyConfiguration> propertyConfigurations = augmenterConfiguration.getConfigurations();
Assert.assertEquals(2, propertyConfigurations.size()); Assert.assertEquals(2, propertyConfigurations.size());
propertyConfigurations.get(0).setPolicy(""); propertyConfigurations.get(0).setPolicy("");
Assert.assertTrue(configurations.hasValidConfigurations()); Assert.assertTrue(augmenterConfiguration.hasValidConfigurations());
Assert.assertTrue(configurations.hasInvalidConfigurations()); Assert.assertTrue(augmenterConfiguration.hasInvalidConfigurations());
Assert.assertTrue(configurations.isValid()); Assert.assertTrue(augmenterConfiguration.isValid());
} }
@SneakyThrows @SneakyThrows
......
...@@ -22,7 +22,7 @@ import org.junit.Assert; ...@@ -22,7 +22,7 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfiguration; import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfiguration;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations; import org.opengroup.osdu.indexer.model.indexproperty.AugmenterConfiguration;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyPath; import org.opengroup.osdu.indexer.model.indexproperty.PropertyPath;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
...@@ -36,11 +36,11 @@ public class PropertyPathDeserializerTest { ...@@ -36,11 +36,11 @@ public class PropertyPathDeserializerTest {
public void deserialize_configurations_test() throws JsonProcessingException { public void deserialize_configurations_test() throws JsonProcessingException {
String jsonText = getJsonFromFile("well_configuration_record.json"); String jsonText = getJsonFromFile("well_configuration_record.json");
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
PropertyConfigurations configurations = objectMapper.readValue(jsonText, PropertyConfigurations.class); AugmenterConfiguration augmenterConfiguration = objectMapper.readValue(jsonText, AugmenterConfiguration.class);
Assert.assertNotNull(configurations); Assert.assertNotNull(augmenterConfiguration);
Assert.assertEquals(2, configurations.getConfigurations().size()); Assert.assertEquals(2, augmenterConfiguration.getConfigurations().size());
PropertyConfiguration countryNameConfiguration = configurations.getConfigurations().get(0); PropertyConfiguration countryNameConfiguration = augmenterConfiguration.getConfigurations().get(0);
PropertyConfiguration wellUWIConfiguration = configurations.getConfigurations().get(1); PropertyConfiguration wellUWIConfiguration = augmenterConfiguration.getConfigurations().get(1);
Assert.assertEquals("CountryNames", countryNameConfiguration.getName()); Assert.assertEquals("CountryNames", countryNameConfiguration.getName());
Assert.assertEquals(1, countryNameConfiguration.getPaths().size()); Assert.assertEquals(1, countryNameConfiguration.getPaths().size());
......
...@@ -40,7 +40,7 @@ import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo; ...@@ -40,7 +40,7 @@ import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo;
import org.opengroup.osdu.indexer.cache.partitionsafe.*; import org.opengroup.osdu.indexer.cache.partitionsafe.*;
import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties;
import org.opengroup.osdu.indexer.model.*; import org.opengroup.osdu.indexer.model.*;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations; import org.opengroup.osdu.indexer.model.indexproperty.AugmenterConfiguration;
import org.opengroup.osdu.indexer.util.IndexerQueueTaskBuilder; import org.opengroup.osdu.indexer.util.IndexerQueueTaskBuilder;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
...@@ -57,18 +57,18 @@ import static org.mockito.ArgumentMatchers.eq; ...@@ -57,18 +57,18 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
public class PropertyConfigurationsServiceImplTest { public class AugmenterConfigurationServiceImplTest {
private final Gson gson = new Gson(); private final Gson gson = new Gson();
@InjectMocks @InjectMocks
private PropertyConfigurationsServiceImpl sut; private AugmenterConfigurationServiceImpl sut;
@Mock @Mock
private IndexerConfigurationProperties configurationProperties; private IndexerConfigurationProperties configurationProperties;
@Mock @Mock
private PropertyConfigurationsCache propertyConfigurationCache; private AugmenterConfigurationCache augmenterConfigurationCache;
@Mock @Mock
private ConfigurationsEnabledCache propertyConfigurationsEnabledCache; private AugmenterConfigurationEnabledCache augmenterConfigurationEnabledCache;
@Mock @Mock
private ChildRelationshipSpecsCache parentChildRelationshipSpecsCache; private ChildRelationshipSpecsCache parentChildRelationshipSpecsCache;
@Mock @Mock
...@@ -90,89 +90,89 @@ public class PropertyConfigurationsServiceImplTest { ...@@ -90,89 +90,89 @@ public class PropertyConfigurationsServiceImplTest {
@Mock @Mock
private JaxRsDpsLog jaxRsDpsLog; private JaxRsDpsLog jaxRsDpsLog;
private final String propertyConfigurationKind = "osdu:wks:reference-data--IndexPropertyPathConfiguration:*"; private final String augmenterConfigurationKind = "osdu:wks:reference-data--IndexPropertyPathConfiguration:*";
private String childKind; private String childKind;
private String childId; private String childId;
private String parentKind; private String parentKind;
private String parentId; private String parentId;
@Test @Test
public void isPropertyConfigurationsEnabled_invalid_kind() { public void isAugmenterConfigurationEnabled_invalid_kind() {
Assert.assertFalse(sut.isPropertyConfigurationsEnabled(null)); Assert.assertFalse(sut.isConfigurationEnabled(null));
Assert.assertFalse(sut.isPropertyConfigurationsEnabled("")); Assert.assertFalse(sut.isConfigurationEnabled(""));
Assert.assertFalse(sut.isPropertyConfigurationsEnabled("anyAuth:anySource:anyEntity")); Assert.assertFalse(sut.isConfigurationEnabled("anyAuth:anySource:anyEntity"));
} }
@Test @Test
public void isPropertyConfigurationsEnabled_with_value_true_in_cache() { public void isAugmenterConfigurationEnabled_with_value_true_in_cache() {
String kind = "anyAuth:anySource:anyEntity:1."; String kind = "anyAuth:anySource:anyEntity:1.";
when(this.propertyConfigurationsEnabledCache.get(any())).thenReturn(true); when(this.augmenterConfigurationEnabledCache.get(any())).thenReturn(true);
Assert.assertTrue(sut.isPropertyConfigurationsEnabled(kind)); Assert.assertTrue(sut.isConfigurationEnabled(kind));
verify(this.propertyConfigurationsEnabledCache, times(0)).put(any(), any()); verify(this.augmenterConfigurationEnabledCache, times(0)).put(any(), any());
} }
@Test @Test
public void isPropertyConfigurationsEnabled_with_value_false_in_cache() { public void isAugmenterConfigurationEnabled_with_value_false_in_cache() {
String kind = "anyAuth:anySource:anyEntity:1."; String kind = "anyAuth:anySource:anyEntity:1.";
when(this.propertyConfigurationsEnabledCache.get(any())).thenReturn(false); when(this.augmenterConfigurationEnabledCache.get(any())).thenReturn(false);
Assert.assertFalse(sut.isPropertyConfigurationsEnabled(kind)); Assert.assertFalse(sut.isConfigurationEnabled(kind));
verify(this.propertyConfigurationsEnabledCache, times(0)).put(any(), any()); verify(this.augmenterConfigurationEnabledCache, times(0)).put(any(), any());
} }
@Test @Test
public void isPropertyConfigurationsEnabled_with_result_from_search() throws URISyntaxException { public void isAugmenterConfigurationEnabled_with_result_from_search() throws URISyntaxException {
String kind = "anyAuth:anySource:anyEntity:1."; String kind = "anyAuth:anySource:anyEntity:1.";
SearchResponse response = new SearchResponse(); SearchResponse response = new SearchResponse();
response.setResults(Arrays.asList(new SearchRecord())); response.setResults(Arrays.asList(new SearchRecord()));
when(this.propertyConfigurationsEnabledCache.get(any())).thenReturn(null); when(this.augmenterConfigurationEnabledCache.get(any())).thenReturn(null);
when(this.searchService.query(any())).thenReturn(response); when(this.searchService.query(any())).thenReturn(response);
Assert.assertTrue(sut.isPropertyConfigurationsEnabled(kind)); Assert.assertTrue(sut.isConfigurationEnabled(kind));
verify(this.propertyConfigurationsEnabledCache, times(1)).put(any(), any()); verify(this.augmenterConfigurationEnabledCache, times(1)).put(any(), any());
} }
@Test @Test
public void isPropertyConfigurationsEnabled_without_result_from_search() throws URISyntaxException { public void isAugmenterConfigurationEnabled_without_result_from_search() throws URISyntaxException {
String kind = "anyAuth:anySource:anyEntity:1."; String kind = "anyAuth:anySource:anyEntity:1.";
SearchResponse response = new SearchResponse(); SearchResponse response = new SearchResponse();
when(this.propertyConfigurationsEnabledCache.get(any())).thenReturn(null); when(this.augmenterConfigurationEnabledCache.get(any())).thenReturn(null);
when(this.searchService.query(any())).thenReturn(response); when(this.searchService.query(any())).thenReturn(response);
Assert.assertFalse(sut.isPropertyConfigurationsEnabled(kind)); Assert.assertFalse(sut.isConfigurationEnabled(kind));
verify(this.propertyConfigurationsEnabledCache, times(1)).put(any(), any()); verify(this.augmenterConfigurationEnabledCache, times(1)).put(any(), any());
} }
@Test @Test
public void getPropertyConfigurations_invalid_kind() { public void getAugmenterConfiguration_invalid_kind() {
Assert.assertNull(sut.getPropertyConfigurations(null)); Assert.assertNull(sut.getConfiguration(null));
Assert.assertNull(sut.getPropertyConfigurations("")); Assert.assertNull(sut.getConfiguration(""));
Assert.assertNull(sut.getPropertyConfigurations("anyAuth:anySource:anyEntity")); Assert.assertNull(sut.getConfiguration("anyAuth:anySource:anyEntity"));
} }
@Test @Test
public void getPropertyConfigurations_with_configuration_in_cache() { public void getAugmenterConfiguration_with_configuration_in_cache() {
String code = "anyAuth:anySource:anyEntity:1."; String code = "anyAuth:anySource:anyEntity:1.";
String kind = "anyAuth:anySource:anyEntity:1.0.0"; String kind = "anyAuth:anySource:anyEntity:1.0.0";
PropertyConfigurations configuration = new PropertyConfigurations(); AugmenterConfiguration configuration = new AugmenterConfiguration();
configuration.setCode(code); configuration.setCode(code);
when(this.propertyConfigurationCache.get(eq(code))).thenReturn(configuration); when(this.augmenterConfigurationCache.get(eq(code))).thenReturn(configuration);
PropertyConfigurations configuration2 = sut.getPropertyConfigurations(kind); AugmenterConfiguration configuration2 = sut.getConfiguration(kind);
Assert.assertNotNull(configuration2); Assert.assertNotNull(configuration2);
Assert.assertEquals(code, configuration2.getCode()); Assert.assertEquals(code, configuration2.getCode());
} }
@Test @Test
public void getPropertyConfigurations_with_empty_configuration_in_cache() { public void getAugmenterConfiguration_with_empty_configuration_in_cache() {
String code = "anyAuth:anySource:anyEntity:1."; String code = "anyAuth:anySource:anyEntity:1.";
String kind = "anyAuth:anySource:anyEntity:1.0.0"; String kind = "anyAuth:anySource:anyEntity:1.0.0";
PropertyConfigurations configuration = new PropertyConfigurations(); AugmenterConfiguration configuration = new AugmenterConfiguration();
when(this.propertyConfigurationCache.get(eq(code))).thenReturn(configuration); when(this.augmenterConfigurationCache.get(eq(code))).thenReturn(configuration);
PropertyConfigurations configuration2 = sut.getPropertyConfigurations(kind); AugmenterConfiguration configuration2 = sut.getConfiguration(kind);
Assert.assertNull(configuration2); Assert.assertNull(configuration2);
} }
@Test @Test
public void getPropertyConfigurations_with_result_from_search() throws URISyntaxException { public void getAugmenterConfiguration_with_result_from_search() throws URISyntaxException {
Map<String, Object> data = this.getDataMap("well_configuration_record.json"); Map<String, Object> data = this.getDataMap("well_configuration_record.json");
SearchRecord searchRecord = new SearchRecord(); SearchRecord searchRecord = new SearchRecord();
searchRecord.setData(data); searchRecord.setData(data);
...@@ -183,32 +183,32 @@ public class PropertyConfigurationsServiceImplTest { ...@@ -183,32 +183,32 @@ public class PropertyConfigurationsServiceImplTest {
when(this.searchService.query(any())).thenReturn(searchResponse); when(this.searchService.query(any())).thenReturn(searchResponse);
String kind = "osdu:wks:master-data--Well:1.0.0"; String kind = "osdu:wks:master-data--Well:1.0.0";
String code = "osdu:wks:master-data--Well:1."; String code = "osdu:wks:master-data--Well:1.";
PropertyConfigurations configuration = sut.getPropertyConfigurations(kind); AugmenterConfiguration configuration = sut.getConfiguration(kind);
ArgumentCaptor<PropertyConfigurations> argumentCaptor = ArgumentCaptor.forClass(PropertyConfigurations.class); ArgumentCaptor<AugmenterConfiguration> argumentCaptor = ArgumentCaptor.forClass(AugmenterConfiguration.class);
// If we mock the implementation of propertyConfigurationCache, it should be called once // If we mock the implementation of propertyConfigurationCache, it should be called once
verify(this.propertyConfigurationCache, times(2)).put(any(), argumentCaptor.capture()); verify(this.augmenterConfigurationCache, times(2)).put(any(), argumentCaptor.capture());
Assert.assertNotNull(configuration); Assert.assertNotNull(configuration);
Assert.assertEquals(code, configuration.getCode()); Assert.assertEquals(code, configuration.getCode());
Assert.assertEquals(code, argumentCaptor.getValue().getCode()); Assert.assertEquals(code, argumentCaptor.getValue().getCode());
} }
@Test @Test
public void getPropertyConfigurations_without_result_from_search() throws URISyntaxException { public void getAugmenterConfiguration_without_result_from_search() throws URISyntaxException {
when(this.searchService.query(any())).thenReturn(new SearchResponse()); when(this.searchService.query(any())).thenReturn(new SearchResponse());
String kind = "osdu:wks:master-data--Well:1.0.0"; String kind = "osdu:wks:master-data--Well:1.0.0";
PropertyConfigurations configuration = sut.getPropertyConfigurations(kind); AugmenterConfiguration configuration = sut.getConfiguration(kind);
ArgumentCaptor<PropertyConfigurations> argumentCaptor = ArgumentCaptor.forClass(PropertyConfigurations.class); ArgumentCaptor<AugmenterConfiguration> argumentCaptor = ArgumentCaptor.forClass(AugmenterConfiguration.class);
verify(this.propertyConfigurationCache, times(1)).put(any(), argumentCaptor.capture()); verify(this.augmenterConfigurationCache, times(1)).put(any(), argumentCaptor.capture());
Assert.assertNull(configuration); Assert.assertNull(configuration);
Assert.assertNull(argumentCaptor.getValue().getCode()); Assert.assertNull(argumentCaptor.getValue().getCode());
} }
@Test @Test
public void getExtendedProperties_from_children_objects() throws JsonProcessingException, URISyntaxException { public void getExtendedProperties_from_children_objects() throws JsonProcessingException, URISyntaxException {
PropertyConfigurations propertyConfigurations = getConfigurations("wellbore_configuration_record.json"); AugmenterConfiguration propertyConfigurations = getConfiguration("wellbore_configuration_record.json");
Map<String, Object> originalDataMap = getDataMap("wellbore_data.json"); Map<String, Object> originalDataMap = getDataMap("wellbore_data.json");
String jsonText = getJsonFromFile("welllog_search_records.json"); String jsonText = getJsonFromFile("welllog_search_records.json");
Type type = new TypeToken<List<SearchRecord>>() {}.getType(); Type type = new TypeToken<List<SearchRecord>>() {}.getType();
...@@ -224,7 +224,7 @@ public class PropertyConfigurationsServiceImplTest { ...@@ -224,7 +224,7 @@ public class PropertyConfigurationsServiceImplTest {
@Test @Test
public void getExtendedProperties_from_self_and_parent_objects() throws JsonProcessingException, URISyntaxException { public void getExtendedProperties_from_self_and_parent_objects() throws JsonProcessingException, URISyntaxException {
PropertyConfigurations propertyConfigurations = getConfigurations("welllog_configuration_record.json"); AugmenterConfiguration propertyConfigurations = getConfiguration("welllog_configuration_record.json");
Map<String, Object> originalDataMap = getDataMap("welllog_original_data.json"); Map<String, Object> originalDataMap = getDataMap("welllog_original_data.json");
SearchResponse searchResponse = new SearchResponse(); SearchResponse searchResponse = new SearchResponse();
...@@ -282,14 +282,14 @@ public class PropertyConfigurationsServiceImplTest { ...@@ -282,14 +282,14 @@ public class PropertyConfigurationsServiceImplTest {
@Test @Test
public void getExtendedSchemaItems_from_self_and_parent_object_kind() throws JsonProcessingException { public void getExtendedSchemaItems_from_self_and_parent_object_kind() throws JsonProcessingException {
PropertyConfigurations propertyConfigurations = getConfigurations("well_configuration_record.json"); AugmenterConfiguration augmenterConfiguration = getConfiguration("well_configuration_record.json");
Schema originalSchema = getSchema("well_storage_schema.json"); Schema originalSchema = getSchema("well_storage_schema.json");
Schema geoPoliticalEntitySchema = getSchema("geo_political_entity_storage_schema.json"); Schema geoPoliticalEntitySchema = getSchema("geo_political_entity_storage_schema.json");
String relatedObjectKind = "osdu:wks:master-data--GeoPoliticalEntity:1."; String relatedObjectKind = "osdu:wks:master-data--GeoPoliticalEntity:1.";
Map<String, Schema> relatedObjectKindSchemas = new HashMap<>(); Map<String, Schema> relatedObjectKindSchemas = new HashMap<>();
relatedObjectKindSchemas.put(relatedObjectKind, geoPoliticalEntitySchema); relatedObjectKindSchemas.put(relatedObjectKind, geoPoliticalEntitySchema);
List<SchemaItem> extendedSchemaItems = this.sut.getExtendedSchemaItems(originalSchema, relatedObjectKindSchemas, propertyConfigurations); List<SchemaItem> extendedSchemaItems = this.sut.getExtendedSchemaItems(originalSchema, relatedObjectKindSchemas, augmenterConfiguration);
Assert.assertEquals(3, extendedSchemaItems.size()); Assert.assertEquals(3, extendedSchemaItems.size());
SchemaItem countryNameItem = extendedSchemaItems.stream().filter(item -> item.getPath().equals("CountryNames")).findFirst().orElse(null); SchemaItem countryNameItem = extendedSchemaItems.stream().filter(item -> item.getPath().equals("CountryNames")).findFirst().orElse(null);
Assert.assertNotNull(countryNameItem); Assert.assertNotNull(countryNameItem);
...@@ -306,7 +306,7 @@ public class PropertyConfigurationsServiceImplTest { ...@@ -306,7 +306,7 @@ public class PropertyConfigurationsServiceImplTest {
@Test @Test
public void getExtendedSchemaItems_from_multiple_object_kinds() throws JsonProcessingException { public void getExtendedSchemaItems_from_multiple_object_kinds() throws JsonProcessingException {
PropertyConfigurations propertyConfigurations = getConfigurations("welllog_configuration_record.json"); AugmenterConfiguration augmenterConfiguration = getConfiguration("welllog_configuration_record.json");
Schema originalSchema = getSchema("welllog_storage_schema.json"); Schema originalSchema = getSchema("welllog_storage_schema.json");
Map<String, Schema> relatedObjectKindSchemas = new HashMap<>(); Map<String, Schema> relatedObjectKindSchemas = new HashMap<>();
Schema wellboreSchema = getSchema("wellbore_storage_schema.json"); Schema wellboreSchema = getSchema("wellbore_storage_schema.json");
...@@ -318,7 +318,7 @@ public class PropertyConfigurationsServiceImplTest { ...@@ -318,7 +318,7 @@ public class PropertyConfigurationsServiceImplTest {
Type type = new TypeToken<List<SchemaItem>>() {}.getType(); Type type = new TypeToken<List<SchemaItem>>() {}.getType();
List<SchemaItem> expectedExtendedSchemaItems = gson.fromJson(jsonText, type); List<SchemaItem> expectedExtendedSchemaItems = gson.fromJson(jsonText, type);
List<SchemaItem> extendedSchemaItems = this.sut.getExtendedSchemaItems(originalSchema, relatedObjectKindSchemas, propertyConfigurations); List<SchemaItem> extendedSchemaItems = this.sut.getExtendedSchemaItems(originalSchema, relatedObjectKindSchemas, augmenterConfiguration);
Assert.assertEquals(expectedExtendedSchemaItems.size(), extendedSchemaItems.size()); Assert.assertEquals(expectedExtendedSchemaItems.size(), extendedSchemaItems.size());
for(int i = 0; i < expectedExtendedSchemaItems.size(); i++) { for(int i = 0; i < expectedExtendedSchemaItems.size(); i++) {
SchemaItem expectedExtendedSchemaItem = expectedExtendedSchemaItems.get(i); SchemaItem expectedExtendedSchemaItem = expectedExtendedSchemaItems.get(i);
...@@ -654,7 +654,7 @@ public class PropertyConfigurationsServiceImplTest { ...@@ -654,7 +654,7 @@ public class PropertyConfigurationsServiceImplTest {
when(this.searchService.query(any())).thenAnswer(invocation -> { when(this.searchService.query(any())).thenAnswer(invocation -> {
SearchRequest searchRequest = invocation.getArgument(0); SearchRequest searchRequest = invocation.getArgument(0);
SearchResponse searchResponse = new SearchResponse(); SearchResponse searchResponse = new SearchResponse();
if (searchRequest.getKind().toString().equals(propertyConfigurationKind)) { if (searchRequest.getKind().toString().equals(augmenterConfigurationKind)) {
if (searchRequest.getQuery().contains("ParentToChildren")) { if (searchRequest.getQuery().contains("ParentToChildren")) {
// Return of getParentChildRelatedObjectsSpecs(...) // Return of getParentChildRelatedObjectsSpecs(...)
Map<String, Object> dataMap = getDataMap("wellbore_configuration_record.json"); Map<String, Object> dataMap = getDataMap("wellbore_configuration_record.json");
...@@ -818,7 +818,7 @@ public class PropertyConfigurationsServiceImplTest { ...@@ -818,7 +818,7 @@ public class PropertyConfigurationsServiceImplTest {
when(this.searchService.query(any())).thenAnswer(invocation -> { when(this.searchService.query(any())).thenAnswer(invocation -> {
SearchRequest searchRequest = invocation.getArgument(0); SearchRequest searchRequest = invocation.getArgument(0);
SearchResponse searchResponse = new SearchResponse(); SearchResponse searchResponse = new SearchResponse();
if (searchRequest.getKind().toString().equals(propertyConfigurationKind)) { if (searchRequest.getKind().toString().equals(augmenterConfigurationKind)) {
if (searchRequest.getQuery().contains("ChildToParent") || searchRequest.getQuery().contains("data.Code:")) { if (searchRequest.getQuery().contains("ChildToParent") || searchRequest.getQuery().contains("data.Code:")) {
// Return of getParentChildRelatedObjectsSpecs(...) or // Return of getParentChildRelatedObjectsSpecs(...) or
// getPropertyConfigurations(...) // getPropertyConfigurations(...)
...@@ -868,11 +868,11 @@ public class PropertyConfigurationsServiceImplTest { ...@@ -868,11 +868,11 @@ public class PropertyConfigurationsServiceImplTest {
return gson.fromJson(jsonText, Schema.class); return gson.fromJson(jsonText, Schema.class);
} }
private PropertyConfigurations getConfigurations(String file) throws JsonProcessingException { private AugmenterConfiguration getConfiguration(String file) throws JsonProcessingException {
Map<String, Object> dataMap = getDataMap(file); Map<String, Object> dataMap = getDataMap(file);
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
String data = objectMapper.writeValueAsString(dataMap); String data = objectMapper.writeValueAsString(dataMap);
PropertyConfigurations configurations = objectMapper.readValue(data, PropertyConfigurations.class); AugmenterConfiguration configurations = objectMapper.readValue(data, AugmenterConfiguration.class);
return configurations; return configurations;
} }
......
...@@ -34,7 +34,7 @@ import org.opengroup.osdu.core.common.model.storage.SchemaItem; ...@@ -34,7 +34,7 @@ import org.opengroup.osdu.core.common.model.storage.SchemaItem;
import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver; import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver;
import org.opengroup.osdu.indexer.cache.partitionsafe.FlattenedSchemaCache; import org.opengroup.osdu.indexer.cache.partitionsafe.FlattenedSchemaCache;
import org.opengroup.osdu.indexer.cache.partitionsafe.SchemaCache; import org.opengroup.osdu.indexer.cache.partitionsafe.SchemaCache;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations; import org.opengroup.osdu.indexer.model.indexproperty.AugmenterConfiguration;
import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException; import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException;
import org.opengroup.osdu.indexer.schema.converter.interfaces.IVirtualPropertiesSchemaCache; import org.opengroup.osdu.indexer.schema.converter.interfaces.IVirtualPropertiesSchemaCache;
import org.opengroup.osdu.indexer.util.AugmenterSetting; import org.opengroup.osdu.indexer.util.AugmenterSetting;
...@@ -81,7 +81,7 @@ public class IndexerSchemaServiceTest { ...@@ -81,7 +81,7 @@ public class IndexerSchemaServiceTest {
@Mock @Mock
private IVirtualPropertiesSchemaCache virtualPropertiesSchemaCache; private IVirtualPropertiesSchemaCache virtualPropertiesSchemaCache;
@Mock @Mock
private PropertyConfigurationsService propertyConfigurationsService; private AugmenterConfigurationService propertyConfigurationsService;
@Mock @Mock
private AugmenterSetting augmenterSetting; private AugmenterSetting augmenterSetting;
@InjectMocks @InjectMocks
...@@ -252,7 +252,7 @@ public class IndexerSchemaServiceTest { ...@@ -252,7 +252,7 @@ public class IndexerSchemaServiceTest {
when(this.schemaCache.get(kind)).thenReturn(null); when(this.schemaCache.get(kind)).thenReturn(null);
when(this.schemaService.getSchema(kind)).thenReturn(storageSchema); when(this.schemaService.getSchema(kind)).thenReturn(storageSchema);
when(this.propertyConfigurationsService.getPropertyConfigurations(kind)).thenReturn(new PropertyConfigurations()); when(this.propertyConfigurationsService.getConfiguration(kind)).thenReturn(new AugmenterConfiguration());
when(this.propertyConfigurationsService.getExtendedSchemaItems(any(), any(), any())).thenReturn(extendedSchemaItems); when(this.propertyConfigurationsService.getExtendedSchemaItems(any(), any(), any())).thenReturn(extendedSchemaItems);
IndexSchema indexSchema = this.sut.getIndexerInputSchema(kind, false); IndexSchema indexSchema = this.sut.getIndexerInputSchema(kind, false);
...@@ -293,7 +293,7 @@ public class IndexerSchemaServiceTest { ...@@ -293,7 +293,7 @@ public class IndexerSchemaServiceTest {
when(this.schemaCache.get(kind)).thenReturn(null); when(this.schemaCache.get(kind)).thenReturn(null);
when(this.schemaService.getSchema(kind)).thenReturn(storageSchema); when(this.schemaService.getSchema(kind)).thenReturn(storageSchema);
when(this.propertyConfigurationsService.getPropertyConfigurations(kind)).thenReturn(new PropertyConfigurations()); when(this.propertyConfigurationsService.getConfiguration(kind)).thenReturn(new AugmenterConfiguration());
when(this.propertyConfigurationsService.getExtendedSchemaItems(any(), any(), any())).thenReturn(extendedSchemaItems); when(this.propertyConfigurationsService.getExtendedSchemaItems(any(), any(), any())).thenReturn(extendedSchemaItems);
IndexSchema indexSchema = this.sut.getIndexerInputSchema(kind, true); IndexSchema indexSchema = this.sut.getIndexerInputSchema(kind, true);
...@@ -348,13 +348,13 @@ public class IndexerSchemaServiceTest { ...@@ -348,13 +348,13 @@ public class IndexerSchemaServiceTest {
" ]\n" + " ]\n" +
"}"; "}";
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
PropertyConfigurations configurations = objectMapper.readValue(propertyConfigurations, PropertyConfigurations.class); AugmenterConfiguration augmenterConfiguration = objectMapper.readValue(propertyConfigurations, AugmenterConfiguration.class);
when(this.elasticIndexNameResolver.getIndexNameFromKind(kind)).thenReturn(kind.replace(":", "-")); when(this.elasticIndexNameResolver.getIndexNameFromKind(kind)).thenReturn(kind.replace(":", "-"));
when(this.schemaCache.get(kind)).thenReturn(null); when(this.schemaCache.get(kind)).thenReturn(null);
when(this.indicesService.isIndexExist(any(), any())).thenReturn(true); when(this.indicesService.isIndexExist(any(), any())).thenReturn(true);
when(this.schemaService.getSchema(kind)).thenReturn(storageSchema); when(this.schemaService.getSchema(kind)).thenReturn(storageSchema);
when(this.propertyConfigurationsService.getPropertyConfigurations(kind)).thenReturn(configurations); when(this.propertyConfigurationsService.getConfiguration(kind)).thenReturn(augmenterConfiguration);
when(this.propertyConfigurationsService.resolveConcreteKind(anyString())).thenAnswer(invocation -> { when(this.propertyConfigurationsService.resolveConcreteKind(anyString())).thenAnswer(invocation -> {
String relatedObjectKind = invocation.getArgument(0); String relatedObjectKind = invocation.getArgument(0);
return relatedObjectKind + "0.0"; return relatedObjectKind + "0.0";
......
...@@ -30,8 +30,6 @@ import org.mockito.ArgumentCaptor; ...@@ -30,8 +30,6 @@ import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockedStatic; import org.mockito.MockedStatic;
import org.mockito.Spy;
import org.opengroup.osdu.core.common.http.HeadersUtil;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.entitlements.Acl; import org.opengroup.osdu.core.common.model.entitlements.Acl;
import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.http.DpsHeaders;
...@@ -41,7 +39,7 @@ import org.opengroup.osdu.core.common.model.storage.ConversionStatus; ...@@ -41,7 +39,7 @@ import org.opengroup.osdu.core.common.model.storage.ConversionStatus;
import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo; import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo;
import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver; import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver;
import org.opengroup.osdu.indexer.logging.AuditLogger; import org.opengroup.osdu.indexer.logging.AuditLogger;
import org.opengroup.osdu.indexer.model.indexproperty.PropertyConfigurations; import org.opengroup.osdu.indexer.model.indexproperty.AugmenterConfiguration;
import org.opengroup.osdu.indexer.provider.interfaces.IPublisher; import org.opengroup.osdu.indexer.provider.interfaces.IPublisher;
import org.opengroup.osdu.indexer.util.AugmenterSetting; import org.opengroup.osdu.indexer.util.AugmenterSetting;
import org.opengroup.osdu.indexer.util.ElasticClientHandler; import org.opengroup.osdu.indexer.util.ElasticClientHandler;
...@@ -101,7 +99,7 @@ public class IndexerServiceImplTest { ...@@ -101,7 +99,7 @@ public class IndexerServiceImplTest {
@Mock @Mock
private IPublisher progressPublisher; private IPublisher progressPublisher;
@Mock @Mock
private PropertyConfigurationsService propertyConfigurationsService; private AugmenterConfigurationService propertyConfigurationsService;
@Mock @Mock
private IndexerQueueTaskBuilder indexerQueueTaskBuilder; private IndexerQueueTaskBuilder indexerQueueTaskBuilder;
@Mock @Mock
...@@ -182,7 +180,7 @@ public class IndexerServiceImplTest { ...@@ -182,7 +180,7 @@ public class IndexerServiceImplTest {
prepareTestDataAndEnv(this.pubsubMsg); prepareTestDataAndEnv(this.pubsubMsg);
// setup property configuration // setup property configuration
when(this.propertyConfigurationsService.isPropertyConfigurationsEnabled(any())).thenReturn(true); when(this.propertyConfigurationsService.isConfigurationEnabled(any())).thenReturn(true);
ArgumentCaptor<Map<String, List<String>>> upsertArgumentCaptor = ArgumentCaptor.forClass(Map.class); ArgumentCaptor<Map<String, List<String>>> upsertArgumentCaptor = ArgumentCaptor.forClass(Map.class);
ArgumentCaptor<Map<String, List<String>>> deleteArgumentCaptor = ArgumentCaptor.forClass(Map.class); ArgumentCaptor<Map<String, List<String>>> deleteArgumentCaptor = ArgumentCaptor.forClass(Map.class);
...@@ -208,7 +206,7 @@ public class IndexerServiceImplTest { ...@@ -208,7 +206,7 @@ public class IndexerServiceImplTest {
prepareTestDataAndEnv(this.pubsubMsgForDeletion); prepareTestDataAndEnv(this.pubsubMsgForDeletion);
// setup property configuration // setup property configuration
when(this.propertyConfigurationsService.isPropertyConfigurationsEnabled(any())).thenReturn(true); when(this.propertyConfigurationsService.isConfigurationEnabled(any())).thenReturn(true);
ArgumentCaptor<Map<String, List<String>>> upsertArgumentCaptor = ArgumentCaptor.forClass(Map.class); ArgumentCaptor<Map<String, List<String>>> upsertArgumentCaptor = ArgumentCaptor.forClass(Map.class);
ArgumentCaptor<Map<String, List<String>>> deleteArgumentCaptor = ArgumentCaptor.forClass(Map.class); ArgumentCaptor<Map<String, List<String>>> deleteArgumentCaptor = ArgumentCaptor.forClass(Map.class);
...@@ -234,14 +232,14 @@ public class IndexerServiceImplTest { ...@@ -234,14 +232,14 @@ public class IndexerServiceImplTest {
prepareTestDataAndEnv(this.pubsubMsg); prepareTestDataAndEnv(this.pubsubMsg);
// setup property configuration // setup property configuration
when(this.propertyConfigurationsService.isPropertyConfigurationsEnabled(any())).thenReturn(true); when(this.propertyConfigurationsService.isConfigurationEnabled(any())).thenReturn(true);
when(this.propertyConfigurationsService.getPropertyConfigurations(any())).thenReturn(new PropertyConfigurations()); when(this.propertyConfigurationsService.getConfiguration(any())).thenReturn(new AugmenterConfiguration());
// test // test
this.sut.processRecordChangedMessages(recordChangedMessages, recordInfos); this.sut.processRecordChangedMessages(recordChangedMessages, recordInfos);
// validate // validate
verify(this.propertyConfigurationsService, times(2)).getPropertyConfigurations(any()); verify(this.propertyConfigurationsService, times(2)).getConfiguration(any());
verify(this.propertyConfigurationsService, times(2)).getExtendedProperties(any(), any(), any()); verify(this.propertyConfigurationsService, times(2)).getExtendedProperties(any(), any(), any());
verify(this.propertyConfigurationsService, times(2)).cacheDataRecord(any(), any(), any()); verify(this.propertyConfigurationsService, times(2)).cacheDataRecord(any(), any(), any());
} catch (Exception e) { } catch (Exception e) {
......
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