Hibernate db fix
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / db / ep / EpNotification.java
1 /*
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  * Modifications Copyright (c) 2019 Samsung
8  * ===================================================================
9  *
10  * Unless otherwise specified, all software contained herein is licensed
11  * under the Apache License, Version 2.0 (the "License");
12  * you may not use this software except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  *             http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  * Unless otherwise specified, all documentation contained herein is licensed
24  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
25  * you may not use this documentation except in compliance with the License.
26  * You may obtain a copy of the License at
27  *
28  *             https://creativecommons.org/licenses/by/4.0/
29  *
30  * Unless required by applicable law or agreed to in writing, documentation
31  * distributed under the License is distributed on an "AS IS" BASIS,
32  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33  * See the License for the specific language governing permissions and
34  * limitations under the License.
35  *
36  * ============LICENSE_END============================================
37  *
38  *
39  */
40
41 package org.onap.portal.domain.db.ep;
42
43 import java.time.LocalDateTime;
44 import java.util.Set;
45 import javax.persistence.CascadeType;
46 import javax.persistence.Column;
47 import javax.persistence.Entity;
48 import javax.persistence.FetchType;
49 import javax.persistence.GeneratedValue;
50 import javax.persistence.GenerationType;
51 import javax.persistence.Id;
52 import javax.persistence.OneToMany;
53 import javax.persistence.Table;
54 import javax.validation.constraints.Digits;
55 import javax.validation.constraints.FutureOrPresent;
56 import javax.validation.constraints.NotNull;
57 import javax.validation.constraints.PastOrPresent;
58 import javax.validation.constraints.Pattern;
59 import javax.validation.constraints.Size;
60 import lombok.AllArgsConstructor;
61 import lombok.Getter;
62 import lombok.NoArgsConstructor;
63 import lombok.Setter;
64 import org.hibernate.validator.constraints.SafeHtml;
65
66 /*
67 CREATE TABLE `ep_notification` (
68         `notification_ID` int(11) NOT NULL AUTO_INCREMENT,
69         `is_for_online_users` char(1) DEFAULT 'N',
70         `is_for_all_roles` char(1) DEFAULT 'N',
71         `active_YN` char(1) DEFAULT 'Y',
72         `msg_header` varchar(100) DEFAULT NULL,
73         `msg_description` varchar(2000) DEFAULT NULL,
74         `msg_source` varchar(50) DEFAULT 'EP',
75         `start_time` timestamp NOT NULL DEFAULT current_timestamp(),
76         `end_time` timestamp NULL DEFAULT NULL,
77         `priority` int(11) DEFAULT NULL,
78         `creator_ID` int(11) DEFAULT NULL,
79         `created_date` timestamp NULL DEFAULT NULL,
80         `notification_hyperlink` varchar(512) DEFAULT NULL,
81         PRIMARY KEY (`notification_ID`)
82         )
83 */
84
85 @Table(name = "ep_notification")
86 @NoArgsConstructor
87 @AllArgsConstructor
88 @Getter
89 @Setter
90 @Entity
91 public class EpNotification {
92        @Id
93        @GeneratedValue(strategy = GenerationType.AUTO)
94        @Column(name = "notification_ID", length = 11, nullable = false)
95        @Digits(integer = 11, fraction = 0)
96        private Long notificationID;
97        @Column(name = "is_for_online_users", length = 1, columnDefinition = "char(1) default 'N'")
98        @Pattern(regexp = "[YNyn]")
99        @Size(max = 1)
100        @SafeHtml
101        private String isForOnlineUsers;
102        @Column(name = "is_for_all_roles", length = 1, columnDefinition = "char(1) default 'N'")
103        @Pattern(regexp = "[YNyn]")
104        @Size(max = 1)
105        @SafeHtml
106        private String isForAllRoles;
107        @Column(name = "active_yn", length = 1, columnDefinition = "char(1) default 'Y'")
108        @Pattern(regexp = "[YNyn]")
109        @Size(max = 1)
110        @SafeHtml
111        private String activeYn;
112        @Column(name = "msg_header", length = 100)
113        @Size(max = 100)
114        @SafeHtml
115        private String msgHeader;
116        @Column(name = "msg_description", length = 2000)
117        @Size(max = 2000)
118        @SafeHtml
119        private String msgDescription;
120        @Column(name = "msg_source", length = 50, columnDefinition = "varchar(50) default 'EP'")
121        @Size(max = 50)
122        @SafeHtml
123        private String msgSource;
124        @Column(name = "start_time", nullable = false, columnDefinition = "datetime default now()")
125        @PastOrPresent
126        @NotNull
127        private LocalDateTime startTime;
128        @Column(name = "end_time")
129        @FutureOrPresent
130        private LocalDateTime end_time;
131        @Column(name = "priority", length = 11)
132        @Digits(integer = 11, fraction = 0)
133        private Long priority;
134        @Column(name = "creator_ID", length = 11)
135        @Digits(integer = 11, fraction = 0)
136        private Long creatorID;
137        @Column(name = "created_date")
138        @FutureOrPresent
139        private LocalDateTime createdDate;
140        @Column(name = "notification_hyperlink", length = 512)
141        @Size(max = 512)
142        @SafeHtml
143        private String notificationHyperlink;
144        @OneToMany(
145                targetEntity = EpRoleNotification.class,
146                mappedBy = "notificationID",
147                cascade = CascadeType.ALL,
148                fetch = FetchType.LAZY
149        )
150        private Set<EpRoleNotification> epRoleNotifications;
151        @OneToMany(
152                targetEntity = EpUserNotification.class,
153                mappedBy = "notificationId",
154                cascade = CascadeType.ALL,
155                fetch = FetchType.LAZY
156        )
157        private Set<EpUserNotification> epUserNotifications;
158 }