Hibernate db fix
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / db / cr / CrReportSchedule.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.cr;
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.JoinColumn;
53 import javax.persistence.ManyToOne;
54 import javax.persistence.OneToMany;
55 import javax.persistence.Table;
56 import javax.validation.Valid;
57 import javax.validation.constraints.Digits;
58 import javax.validation.constraints.FutureOrPresent;
59 import javax.validation.constraints.NotNull;
60 import javax.validation.constraints.Pattern;
61 import javax.validation.constraints.Positive;
62 import javax.validation.constraints.Size;
63 import lombok.AllArgsConstructor;
64 import lombok.Getter;
65 import lombok.NoArgsConstructor;
66 import lombok.Setter;
67 import org.hibernate.validator.constraints.SafeHtml;
68
69 /*
70 CREATE TABLE `cr_report_schedule` (
71         `schedule_id` decimal(11,0) NOT NULL,
72         `sched_user_id` decimal(11,0) NOT NULL,
73         `rep_id` decimal(11,0) NOT NULL,
74         `enabled_yn` varchar(1) NOT NULL,
75         `start_date` timestamp NOT NULL DEFAULT current_timestamp(),
76         `end_date` timestamp NOT NULL DEFAULT current_timestamp(),
77         `run_date` timestamp NOT NULL DEFAULT current_timestamp(),
78         `recurrence` varchar(50) DEFAULT NULL,
79         `conditional_yn` varchar(1) NOT NULL,
80         `condition_sql` varchar(4000) DEFAULT NULL,
81         `notify_type` int(11) DEFAULT 0,
82         `max_row` int(11) DEFAULT 1000,
83         `initial_formfields` varchar(3500) DEFAULT NULL,
84         `processed_formfields` varchar(3500) DEFAULT NULL,
85         `formfields` varchar(3500) DEFAULT NULL,
86         `condition_large_sql` text DEFAULT NULL,
87         `encrypt_yn` char(1) DEFAULT 'n',
88         `attachment_yn` char(1) DEFAULT 'y',
89         PRIMARY KEY (`schedule_id`),
90         KEY `fk_cr_repor_ref_14707_cr_repor` (`rep_id`),
91         CONSTRAINT `fk_cr_repor_ref_14707_cr_repor` FOREIGN KEY (`rep_id`) REFERENCES `cr_report` (`rep_id`)
92         )
93 */
94
95
96 @Table(name = "cr_report_schedule")
97 @NoArgsConstructor
98 @AllArgsConstructor
99 @Getter
100 @Setter
101 @Entity
102 public class CrReportSchedule {
103        @Id
104        @GeneratedValue(strategy = GenerationType.AUTO)
105        @Column(name = "schedule_id", length = 11, nullable = false)
106        @Digits(integer = 11, fraction = 0)
107        @Positive
108        private Long scheduleId;
109        @Column(name = "sched_user_id", length = 11, nullable = false)
110        @Digits(integer = 11, fraction = 0)
111        @Positive
112        @NotNull
113        private Long schedUserId;
114        @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
115        @JoinColumn(name = "rep_id", nullable = false)
116        @Valid
117        @NotNull
118        private CrReport repId;
119        @Column(name = "enabled_yn", length = 1, nullable = false)
120        @Pattern(regexp = "[YNyn]")
121        @Size(max = 1)
122        @SafeHtml
123        @NotNull
124        private String enabledYn;
125        @Column(name = "start_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp()")
126        @FutureOrPresent
127        @NotNull
128        private LocalDateTime startDate;
129        @Column(name = "end_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp()")
130        @FutureOrPresent
131        @NotNull
132        private LocalDateTime endDate;
133        @Column(name = "run_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp()")
134        @FutureOrPresent
135        @NotNull
136        private LocalDateTime runDate;
137        @Column(name = "recurrence_", length = 50, columnDefinition = "varchar(50) DEFAULT NULL")
138        @Size(max = 50)
139        @SafeHtml
140        private String recurrence;
141        @Column(name = "conditional_yn", length = 1, nullable = false)
142        @Pattern(regexp = "[YNyn]")
143        @Size(max = 1)
144        @SafeHtml
145        @NotNull
146        private String conditionalYn;
147        @Column(name = "condition_sql", length = 4000, columnDefinition = "varchar(4000) DEFAULT NULL")
148        @Size(max = 4000)
149        @SafeHtml
150        private String conditionSql;
151        @Column(name = "notify_type", columnDefinition = "int(11) DEFAULT 0")
152        private Integer notifyType;
153        @Column(name = "max_row", columnDefinition = "integer default 1000")
154        private Integer max_row;
155        @Column(name = "initial_formfields", length = 3500, columnDefinition = "varchar(3500) DEFAULT NULL")
156        @Size(max = 3500)
157        @SafeHtml
158        private String initialFormfields;
159        @Column(name = "processed_formfields", length = 3500, columnDefinition = "varchar(3500) DEFAULT NULL")
160        @Size(max = 3500)
161        @SafeHtml
162        private String processedFormfields;
163        @Column(name = "formfields", length = 3500, columnDefinition = "varchar(3500) DEFAULT NULL")
164        @Size(max = 3500)
165        @SafeHtml
166        private String formfields;
167        @Column(name = "condition_large_sql", length = 65535, columnDefinition = "text DEFAULT NULL")
168        private String conditionLargeSql;
169        @Column(name = "encrypt_yn", length = 1, columnDefinition = "character(1) default 'n'")
170        @Pattern(regexp = "[YNyn]")
171        @Size(max = 1)
172        @SafeHtml
173        private String encryptYn;
174        @Column(name = "attachment_yn", length = 1, columnDefinition = "character(1) default 'y'")
175        @Pattern(regexp = "[YNyn]")
176        @Size(max = 1)
177        @SafeHtml
178        private String attachmentYn;
179        @OneToMany(
180                targetEntity = CrReportScheduleUsers.class,
181                mappedBy = "scheduleId",
182                cascade = CascadeType.ALL,
183                fetch = FetchType.LAZY
184        )
185        private Set<CrReportScheduleUsers> crReportScheduleUsers;
186 }