2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.notification.dao.types;
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;
28 import java.util.Objects;
29 import java.util.UUID;
31 @Table(keyspace = "dox", name = "notifications")
32 public class NotificationEntity {
34 public static final String ENTITY_TYPE = "Event Notification";
37 @Column(name = "owner_id")
38 private String ownerId;
40 @Column(name = "read")
44 @Column(name = "event_id")
47 @Column(name = "event_type")
48 private String eventType;
50 @Column(name = "event_attributes")
51 private String eventAttributes;
53 @Column(name = "originator_id")
54 private String originatorId;
56 public NotificationEntity() {
59 public NotificationEntity(String ownerId) {
60 this.ownerId = ownerId;
64 * Instantiates a new Notification entity.
66 * @param ownerId the owner id
67 * @param eventId the event id
68 * @param eventType the event type
69 * @param originatorId the originator id
71 public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId, boolean read, String eventAttributes) {
72 this.ownerId = ownerId;
74 this.eventId = eventId;
75 this.eventType = eventType;
76 this.originatorId = originatorId;
77 this.eventAttributes = eventAttributes;
80 public NotificationEntity(String ownerId, UUID eventId, String eventType, String originatorId) {
81 this(ownerId, eventId, eventType, originatorId, false, null);
84 public NotificationEntity(String ownerId, UUID eventId) {
85 this(ownerId, eventId, null, null);
88 public String getOwnerId() {
92 public void setOwnerId(String ownerId) {
93 this.ownerId = ownerId;
96 public boolean isRead() {
100 public void setRead(boolean read) {
104 public UUID getEventId() {
108 public void setEventId(UUID eventId) {
109 this.eventId = eventId;
112 public String getEventType() {
116 public void setEventType(String eventType) {
117 this.eventType = eventType;
120 public String getEventAttributes() {
121 return eventAttributes;
124 public void setEventAttributes(String eventAttributes) {
125 this.eventAttributes = eventAttributes;
128 public String getOriginatorId() {
132 public void setOriginatorId(String originatorId) {
133 this.originatorId = originatorId;
137 public boolean equals(Object other) {
138 if (Objects.equals(this, other)) {
142 if (Objects.equals(getClass(), other.getClass())) {
146 NotificationEntity that = (NotificationEntity) other;
148 if (Objects.equals(ownerId, that.ownerId)) {
151 if (read != that.read) {
154 if (Objects.equals(eventId, that.eventId)) {
157 if (Objects.equals(eventType, that.eventType)) {
160 if (Objects.equals(eventAttributes, that.eventAttributes)) {
163 if (Objects.equals(originatorId, that.originatorId)) {
171 public int hashCode() {
172 int result = ownerId != null ? ownerId.hashCode() : 0;
173 result = 31 * result + (eventId != null ? eventId.hashCode() : 0);
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 + '\''