/**
* ============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 {
@SerializedName("transaction-id")
private String transactionId;
+
+ @SerializedName("database-transaction-id")
+ private String dbTransactionId;
private long timestamp;
public String getTransactionId() {
return transactionId;
}
+
+ public String getDbTransactionId() {
+ return dbTransactionId;
+ }
+
+ public void setDbTransactionId(String id) {
+ dbTransactionId = id;
+ }
public long getTimestamp() {
return timestamp;
return gson.fromJson(json, GraphEvent.class);
} catch (Exception ex) {
- throw new CrudException("Unable to parse JSON string: ", Status.BAD_REQUEST);
+ throw new CrudException("Unable to parse JSON string: "+json, Status.BAD_REQUEST);
}
}
@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() {
}
return null;
-
}
public static class Builder {