Fix sonar violations
[aai/gizmo.git] / src / main / java / org / onap / crud / event / GraphEvent.java
index b841389..b189373 100644 (file)
@@ -1,16 +1,15 @@
 /**
  * ============LICENSE_START=======================================================
- * Gizmo
+ * org.onap.aai
  * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property.
- * Copyright © 2017 Amdocs
- * All rights reserved.
+ * 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,
  * 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.crud.event;
 
+import java.util.Objects;
+import javax.ws.rs.core.Response.Status;
+import org.onap.crud.exception.CrudException;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.annotations.SerializedName;
 
-import org.onap.crud.exception.CrudException;
-
-import javax.ws.rs.core.Response.Status;
-
 public class GraphEvent {
 
   public enum GraphEventOperation {
@@ -45,6 +41,9 @@ public class GraphEvent {
 
   @SerializedName("transaction-id")
   private String transactionId;
+  
+  @SerializedName("database-transaction-id")
+  private String dbTransactionId;
 
   private long timestamp;
 
@@ -76,6 +75,14 @@ public class GraphEvent {
   public String getTransactionId() {
     return transactionId;
   }
+  
+  public String getDbTransactionId() {
+    return dbTransactionId;
+  }
+  
+  public void setDbTransactionId(String id) {
+    dbTransactionId = id;
+  }
 
   public long getTimestamp() {
     return timestamp;
@@ -163,19 +170,40 @@ public class GraphEvent {
 
   @Override
   public String toString() {
-
     return toJson();
   }
 
+  @Override
+  public boolean equals(Object o){
+    if(o == this){
+      return true;
+    }
+
+    if( !(o instanceof GraphEvent)){
+      return false;
+    }
+
+    GraphEvent graphEvent = (GraphEvent) o;
+    return this.dbTransactionId.equals(
+        graphEvent.getDbTransactionId())
+        && this.timestamp == graphEvent.getTimestamp()
+        && this.operation.equals(graphEvent.getOperation()
+    );
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(this.dbTransactionId, this.timestamp, this.operation);
+  }
+
   public String getObjectKey() {
     if (this.getVertex() != null) {
       return this.getVertex().getId();
     } else if (this.getEdge() != null) {
       return this.getEdge().getId();
     }
-
+    
     return null;
-
   }
 
   public String getObjectType() {
@@ -186,7 +214,6 @@ public class GraphEvent {
     }
 
     return null;
-
   }
 
   public static class Builder {