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