update sparky with configurable features
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / viewandinspect / entity / ActiveInventoryNode.java
index 3981626..1a91a1b 100644 (file)
@@ -1,26 +1,22 @@
 /**
- * ============LICENSE_START===================================================
- * SPARKY (AAI UI service)
- * ============================================================================
- * Copyright © 2017 AT&T Intellectual Property.
- * Copyright © 2017 Amdocs
- * All rights reserved.
- * ============================================================================
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *       http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- * ============LICENSE_END=====================================================
- *
- * ECOMP and OpenECOMP are trademarks
- * and service marks of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
  */
 package org.onap.aai.sparky.viewandinspect.entity;
 
@@ -35,8 +31,6 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedDeque;
 import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import org.onap.aai.cl.api.Logger;
 import org.onap.aai.cl.eelf.LoggerFactory;
@@ -58,7 +52,6 @@ public class ActiveInventoryNode {
 
   private static final Logger LOG = LoggerFactory.getInstance().getLogger(
       ActiveInventoryNode.class);
-  private static final String URIRegexPattern = "aai/v[\\d]/";
 
   public static final int DEFAULT_INIT_NODE_DEPTH = 1000;
 
@@ -573,22 +566,6 @@ public class ActiveInventoryNode {
     return selfLink;
   }
 
-  /**
-   * Calculate edit attribute uri.
-   *
-   * @param link the link
-   * @return the string
-   */
-  public String calculateEditAttributeUri(String link) {
-    String uri = null;
-    Pattern pattern = Pattern.compile(URIRegexPattern);
-    Matcher matcher = pattern.matcher(link);
-    if (matcher.find()) {
-      uri = link.substring(matcher.end());
-    }
-    return uri;
-  }
-
   /**
    * Analyze self link relationship list.
    *
@@ -671,28 +648,19 @@ public class ActiveInventoryNode {
         } else {
           JsonNode nodeValue = field.getValue();
 
-          if (nodeValue != null && nodeValue.isValueNode()) {
-
-            /*
-             * before we blindly add the fieldName and value to our property set, let's do one more
-             * check to see if the field name is an entity type. If it is, then our complex
-             * attribute processing code will pick it up and process it instead, but this is
-             * probably more likely just for array node types, but we'll see.
-             */
+          if (nodeValue != null) {
+            if (nodeValue.isValueNode()) {
 
-            if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
               /*
-               * this is no an entity type as far as we can tell, so we can add it to our property
-               * set.
+               * before we blindly add the fieldName and value to our property set, let's do one more
+               * check to see if the field name is an entity type. If it is, then our complex
+               * attribute processing code will pick it up and process it instead, but this is
+               * probably more likely just for array node types, but we'll see.
                */
 
-              addProperty(fieldName, nodeValue.asText());
-
-            }
-
-          } else {
+              handleNodeValue(fieldName, nodeValue.asText());
 
-            if (nodeValue.isArray()) {
+            } else if (nodeValue.isArray()) {
 
               /*
                * make sure array entity-type collection is not an entityType before adding it to the
@@ -700,26 +668,13 @@ public class ActiveInventoryNode {
                * complex group or relationship.
                */
 
-              if (oxmEntityLookup.getEntityDescriptors().get(field.getKey()) == null) {
-                /*
-                 * this is no an entity type as far as we can tell, so we can add it to our property
-                 * set.
-                 */
-
-                addProperty(field.getKey(), nodeValue.toString());
-
-              }
-
+              handleNodeValue(field.getKey(), nodeValue.toString());
             } else {
-
               complexGroups.add(nodeValue);
-
             }
 
           }
-
         }
-
       }
 
     } catch (IOException exc) {
@@ -731,6 +686,18 @@ public class ActiveInventoryNode {
 
   }
 
+  private void handleNodeValue(String fieldName, String fieldValue) {
+    if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
+      /*
+       * this is no an entity type as far as we can tell, so we can add it to our property
+       * set.
+       */
+
+      addProperty(fieldName, fieldValue);
+
+    }
+  }
+
   public void setSelfLink(String selfLink) {
     this.selfLink = selfLink;
   }