Update the license for 2017-2018 license
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / serialization / db / EdgeRules.java
index 349f9e6..8d94b84 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 package org.onap.aai.serialization.db;
 
@@ -25,14 +23,8 @@ import static com.jayway.jsonpath.Criteria.where;
 import static com.jayway.jsonpath.Filter.filter;
 
 import java.io.InputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.Scanner;
-import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
@@ -243,6 +235,8 @@ public class EdgeRules {
                for (Entry<EdgeProperty, String> entry : propMap.entrySet()) {
                        edge.property(entry.getKey().toString(), entry.getValue());
                }
+
+               edge.property(AAIProperties.AAI_UUID, UUID.randomUUID().toString());
        }
 
        /**
@@ -652,11 +646,17 @@ public class EdgeRules {
                rule.setDeleteOtherV(edge.get(EdgeProperty.DELETE_OTHER_V.toString()));
                rule.setServiceInfrastructure(edge.get(EdgeProperty.SVC_INFRA.toString()));
                rule.setPreventDelete(edge.get(EdgeProperty.PREVENT_DELETE.toString()));
+               rule.setTo(edge.get("to"));
+               rule.setFrom(edge.get("from"));
                if (edge.containsKey("default")) {
                        rule.setIsDefault(edge.get("default"));
                }
 
-               return rule;
+        if(rule.getFrom().equals(rule.getTo())){
+            return this.flipDirection(rule);
+        } else {
+            return rule;
+        }
        }
        
        /**
@@ -777,6 +777,11 @@ public class EdgeRules {
         */
        private void verifyRule(Map<String, String> rule) {
                for (EdgeProperty prop : EdgeProperty.values()) {
+
+                   // Description is not required as it is only set for v12 versions
+                   if("description".equals(prop.toString())){
+                       continue;
+                   }
                        if (!rule.containsKey(prop.toString())) {
                                /* Throws RuntimeException as rule definition errors
                                 * cannot be recovered from, and should never happen anyway