diff options
Diffstat (limited to 'src')
3 files changed, 39 insertions, 23 deletions
diff --git a/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java b/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java index c642102..50d344b 100644 --- a/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java +++ b/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java @@ -26,6 +26,7 @@ import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -905,4 +906,21 @@ public abstract class AbstractSpikeEntityEventProcessor implements Processor { } + protected List<String> extractSuggestableAttr(VersionedOxmEntities oxmEntities, String entityType) { + // Extract suggestable attributeshandleTopographicalData + Map<String, OxmEntityDescriptor> rootDescriptor = oxmEntities.getSuggestableEntityDescriptors(); + + if (rootDescriptor == null) { + return Collections.emptyList(); + } + + OxmEntityDescriptor desc = rootDescriptor.get(entityType); + + if (desc == null) { + return Collections.emptyList(); + } + + return desc.getSuggestableAttributes(); + } + } diff --git a/src/main/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessor.java b/src/main/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessor.java index b1a5a87..c723d2b 100644 --- a/src/main/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessor.java +++ b/src/main/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessor.java @@ -21,12 +21,16 @@ package org.onap.aai.datarouter.policy; import java.io.FileNotFoundException; +import java.util.ArrayList; import java.util.List; import org.apache.camel.Exchange; import org.onap.aai.datarouter.entity.SpikeAggregationEntity; import org.onap.aai.datarouter.entity.SpikeEventMeta; import org.onap.aai.datarouter.logging.EntityEventPolicyMsgs; +import org.onap.aai.util.EntityOxmReferenceHelper; +import org.onap.aai.util.Version; +import org.onap.aai.util.VersionedOxmEntities; import com.fasterxml.jackson.databind.JsonNode; @@ -45,25 +49,36 @@ public class SpikeAggregateGenericVnfProcessor extends AbstractSpikeEntityEventP // Create the indexes in the search service if they do not already exist. searchAgent.createSearchIndex(searchIndexName, searchIndexSchema, createIndexUrl); logger.info(EntityEventPolicyMsgs.ENTITY_EVENT_POLICY_REGISTERED); + } - + @Override public void process(Exchange exchange) throws Exception { long startTime = System.currentTimeMillis(); SpikeEventMeta meta = processSpikeEvent(exchange); - + if (meta == null) { return; } String oxmEntityType = getOxmEntityType(meta.getSpikeEventVertex().getType()); + + VersionedOxmEntities oxmEntities = + EntityOxmReferenceHelper.getInstance().getVersionedOxmEntities(Version.valueOf(oxmVersion.toLowerCase())); + + List<String> suggestibleAttrInPayload = new ArrayList<>(); + List<String> suggestibleAttrInOxm = extractSuggestableAttr(oxmEntities, meta.getSpikeEventVertex().getType()); + if (suggestibleAttrInOxm != null) { + for (String attr: suggestibleAttrInOxm){ + if (meta.getVertexProperties().has(attr)) { + suggestibleAttrInPayload.add(attr); + } + } + } - List<String> searchableAttr = getSearchableAttibutes(meta.getOxmJaxbContext(), oxmEntityType, - meta.getSpikeEventVertex().getType(), meta.getEventEntity().toString(), exchange); - - if (searchableAttr == null) { + if (suggestibleAttrInPayload.isEmpty()) { return; } diff --git a/src/main/java/org/onap/aai/datarouter/policy/SpikeAutosuggestIndexProcessor.java b/src/main/java/org/onap/aai/datarouter/policy/SpikeAutosuggestIndexProcessor.java index b2f9202..c101425 100644 --- a/src/main/java/org/onap/aai/datarouter/policy/SpikeAutosuggestIndexProcessor.java +++ b/src/main/java/org/onap/aai/datarouter/policy/SpikeAutosuggestIndexProcessor.java @@ -141,23 +141,6 @@ public class SpikeAutosuggestIndexProcessor extends AbstractSpikeEntityEventProc return; } - public List<String> extractSuggestableAttr(VersionedOxmEntities oxmEntities, String entityType) { - // Extract suggestable attributeshandleTopographicalData - Map<String, OxmEntityDescriptor> rootDescriptor = oxmEntities.getSuggestableEntityDescriptors(); - - if (rootDescriptor == null) { - return Collections.emptyList(); - } - - OxmEntityDescriptor desc = rootDescriptor.get(entityType); - - if (desc == null) { - return Collections.emptyList(); - } - - return desc.getSuggestableAttributes(); - } - public List<String> extractAliasForSuggestableEntity(VersionedOxmEntities oxmEntities, String entityType) { |