2 * Copyright © 2016-2017 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.notification.dao.types;
19 import com.datastax.driver.mapping.annotations.ClusteringColumn;
20 import com.datastax.driver.mapping.annotations.Column;
21 import com.datastax.driver.mapping.annotations.PartitionKey;
22 import com.datastax.driver.mapping.annotations.Table;
24 import java.util.Objects;
25 import java.util.UUID;
27 @Table(keyspace = "dox", name = "notifications")
28 public class NotificationEntity {
30 public static final String ENTITY_TYPE = "Event Notification";
33 @Column(name = "owner_id")
34 private String ownerId;
36 @Column(name = "read")
40 @Column(name = "event_id")
43 @Column(name = "event_type")
44 private String eventType;
46 @Column(name = "event_attributes")
47 private String eventAttributes;
49 @Column(name = "originator_id")
50 private String originatorId;
53 * Every entity class must have a default constructor according to
54 * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
55 * Definition of mapped classes</a>.
57 public NotificationEntity() {
58 // Don't delete! Default constructor is required by DataStax driver
61 public NotificationEntity(String ownerId) {
62 this.ownerId = ownerId;
66 * Instantiates a new Notification entity.
68 * @param ownerId the owner id
69 * @param eventId the event id
70 * @param eventType the event type
71 * @param originatorId the originator id
73 public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId, boolean read,
74 String eventAttributes) {
75 this.ownerId = ownerId;
77 this.eventId = eventId;
78 this.eventType = eventType;
79 this.originatorId = originatorId;
80 this.eventAttributes = eventAttributes;
83 public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId) {
84 this(ownerId, eventId, eventType, originatorId, false, null);
87 public NotificationEntity(String ownerId, UUID eventId) {
88 this(ownerId, eventId, null, null);
91 public String getOwnerId() {
95 public void setOwnerId(String ownerId) {
96 this.ownerId = ownerId;
99 public boolean isRead() {
103 public void setRead(boolean read) {
107 public UUID getEventId() {
111 public void setEventId(UUID eventId) {
112 this.eventId = eventId;
115 public String getEventType() {
119 public void setEventType(String eventType) {
120 this.eventType = eventType;
123 public String getEventAttributes() {
124 return eventAttributes;
127 public void setEventAttributes(String eventAttributes) {
128 this.eventAttributes = eventAttributes;
131 public String getOriginatorId() {
135 public void setOriginatorId(String originatorId) {
136 this.originatorId = originatorId;
141 public boolean equals(Object o) {
142 if (this == o) return true;
143 if (o == null || getClass() != o.getClass()) return false;
144 NotificationEntity that = (NotificationEntity) o;
145 return read == that.read &&
146 Objects.equals(ownerId, that.ownerId) &&
147 Objects.equals(eventId, that.eventId) &&
148 Objects.equals(eventType, that.eventType) &&
149 Objects.equals(eventAttributes, that.eventAttributes) &&
150 Objects.equals(originatorId, that.originatorId);
154 public int hashCode() {
155 return Objects.hash(ownerId, read, eventId, eventType, eventAttributes, originatorId);
159 public String toString() {
160 return "NotificationEntity {"
161 + "ownerId='" + ownerId + '\''
162 + ", state='" + (read ? "Read" : "Noread") + '\''
163 + ", originatorId='" + originatorId + '\''
164 + ", eventId='" + eventId + '\''
165 + ", eventType='" + eventType + '\''
166 + ", eventAttributes='" + eventAttributes + '\''