Add collaboration feature
[sdc.git] / openecomp-be / lib / openecomp-sdc-notification-lib / openecomp-sdc-notification-api / src / main / java / org / openecomp / sdc / notification / dao / types / NotificationEntity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.notification.dao.types;
22
23 import com.datastax.driver.mapping.annotations.ClusteringColumn;
24 import com.datastax.driver.mapping.annotations.Column;
25 import com.datastax.driver.mapping.annotations.PartitionKey;
26 import com.datastax.driver.mapping.annotations.Table;
27
28 import java.util.Objects;
29 import java.util.UUID;
30
31 @Table(keyspace = "dox", name = "notifications")
32 public class NotificationEntity {
33
34   public static final String ENTITY_TYPE = "Event Notification";
35
36   @PartitionKey
37   @Column(name = "owner_id")
38   private String ownerId;
39
40   @Column(name = "read")
41   private boolean read;
42
43   @ClusteringColumn
44   @Column(name = "event_id")
45   private UUID eventId;
46
47   @Column(name = "event_type")
48   private String eventType;
49
50   @Column(name = "event_attributes")
51   private String eventAttributes;
52
53   @Column(name = "originator_id")
54   private String originatorId;
55
56   public NotificationEntity() {
57   }
58
59   public NotificationEntity(String ownerId) {
60     this.ownerId = ownerId;
61   }
62
63   /**
64    * Instantiates a new Notification entity.
65    *
66    * @param ownerId      the owner id
67    * @param eventId      the event id
68    * @param eventType    the event type
69    * @param originatorId the originator id
70    */
71   public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId, boolean read, String eventAttributes) {
72     this.ownerId = ownerId;
73     this.read = read;
74     this.eventId = eventId;
75     this.eventType = eventType;
76     this.originatorId = originatorId;
77     this.eventAttributes = eventAttributes;
78   }
79
80   public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId) {
81                 this(ownerId, eventId, eventType, originatorId, false, null);
82   }
83
84   public NotificationEntity(String ownerId, UUID eventId) {
85                 this(ownerId, eventId, null, null);
86   }
87
88   public String getOwnerId() {
89     return ownerId;
90   }
91
92   public void setOwnerId(String ownerId) {
93     this.ownerId = ownerId;
94   }
95
96   public boolean isRead() {
97     return read;
98   }
99
100   public void setRead(boolean read) {
101     this.read = read;
102   }
103
104   public UUID getEventId() {
105     return eventId;
106   }
107
108   public void setEventId(UUID eventId) {
109     this.eventId = eventId;
110   }
111
112   public String getEventType() {
113     return eventType;
114   }
115
116   public void setEventType(String eventType) {
117     this.eventType = eventType;
118   }
119
120   public String getEventAttributes() {
121     return eventAttributes;
122   }
123
124   public void setEventAttributes(String eventAttributes) {
125     this.eventAttributes = eventAttributes;
126   }
127
128   public String getOriginatorId() {
129     return originatorId;
130   }
131
132   public void setOriginatorId(String originatorId) {
133     this.originatorId = originatorId;
134   }
135
136   @Override
137   public boolean equals(Object other) {
138     if (Objects.equals(this, other)) {
139       return true;
140     }
141
142     if (Objects.equals(getClass(), other.getClass())) {
143       return false;
144     }
145
146     NotificationEntity that = (NotificationEntity) other;
147
148     if (Objects.equals(ownerId, that.ownerId)) {
149       return false;
150     }
151     if (read != that.read) {
152       return false;
153     }
154     if (Objects.equals(eventId, that.eventId)) {
155       return false;
156     }
157     if (Objects.equals(eventType, that.eventType)) {
158       return false;
159     }
160     if (Objects.equals(eventAttributes, that.eventAttributes)) {
161       return false;
162     }
163     if (Objects.equals(originatorId, that.originatorId)) {
164       return false;
165     }
166
167     return true;
168   }
169
170   @Override
171   public int hashCode() {
172     int result = ownerId != null ? ownerId.hashCode() : 0;
173     result = 31 * result + (eventId != null ? eventId.hashCode() : 0);
174     return result;
175   }
176
177   @Override
178   public String toString() {
179     return "NotificationEntity {"
180         + "ownerId='" + ownerId + '\''
181         + ", state='" + (read ? "Read" : "Noread") + '\''
182         + ", originatorId='" + originatorId + '\''
183         + ", eventId='" + eventId + '\''
184         + ", eventType='" + eventType + '\''
185         + ", eventAttributes='" + eventAttributes + '\''
186         + '}';
187   }
188 }