Fix aggregate-vnf search index population
[aai/data-router.git] / src / main / java / org / onap / aai / datarouter / policy / AbstractSpikeEntityEventProcessor.java
index 7a4884a..50d344b 100644 (file)
@@ -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;
@@ -33,7 +34,6 @@ import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.apache.http.conn.routing.RouteInfo.LayerType;
 import org.eclipse.persistence.dynamic.DynamicType;
 import org.eclipse.persistence.internal.helper.DatabaseField;
 import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
@@ -43,19 +43,19 @@ import org.json.JSONObject;
 import org.onap.aai.cl.api.Logger;
 import org.onap.aai.cl.eelf.LoggerFactory;
 import org.onap.aai.cl.mdc.MdcContext;
-import org.onap.aai.datarouter.schema.OxmModelLoader;
+import org.onap.aai.schema.OxmModelLoader;
 import org.onap.aai.datarouter.entity.DocumentStoreDataEntity;
-import org.onap.aai.datarouter.entity.OxmEntityDescriptor;
 import org.onap.aai.datarouter.entity.SpikeEventEntity;
 import org.onap.aai.datarouter.entity.SpikeEventMeta;
 import org.onap.aai.datarouter.entity.SpikeEventVertex;
 import org.onap.aai.datarouter.logging.EntityEventPolicyMsgs;
-import org.onap.aai.datarouter.util.EntityOxmReferenceHelper;
-import org.onap.aai.datarouter.util.ExternalOxmModelProcessor;
 import org.onap.aai.datarouter.util.RouterServiceUtil;
 import org.onap.aai.datarouter.util.SearchServiceAgent;
-import org.onap.aai.datarouter.util.Version;
-import org.onap.aai.datarouter.util.VersionedOxmEntities;
+import org.onap.aai.entity.OxmEntityDescriptor;
+import org.onap.aai.util.EntityOxmReferenceHelper;
+import org.onap.aai.util.ExternalOxmModelProcessor;
+import org.onap.aai.util.Version;
+import org.onap.aai.util.VersionedOxmEntities;
 import org.onap.aai.restclient.client.Headers;
 import org.onap.aai.restclient.client.OperationResult;
 import org.onap.aai.restclient.rest.HttpUtil;
@@ -407,13 +407,7 @@ public abstract class AbstractSpikeEntityEventProcessor implements Processor {
 
 
  protected String getOxmEntityType(String entityType) {
-
-   String[] entityTypeArr = entityType.split("-");
-   String oxmEntityType = "";
-   for (String entityWord : entityTypeArr) {
-     oxmEntityType += entityWord.substring(0, 1).toUpperCase() + entityWord.substring(1);
-   }
-   return oxmEntityType;
+   return new OxmEntityTypeConverter().convert(entityType);
  }
  
  protected List<String> getSearchableAttibutes(DynamicJAXBContext oxmJaxbContext, String oxmEntityType,
@@ -912,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();
+  }
+  
 }