c25f80620144ea59459a789b7dfa5ebd1e3cd887
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / db / cr / CrReport.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.ArrayList;
46 import java.util.List;
47 import javax.persistence.CascadeType;
48 import javax.persistence.Column;
49 import javax.persistence.Embeddable;
50 import javax.persistence.Entity;
51 import javax.persistence.FetchType;
52 import javax.persistence.Id;
53 import javax.persistence.Index;
54 import javax.persistence.OneToMany;
55 import javax.persistence.Table;
56 import javax.validation.constraints.Digits;
57 import javax.validation.constraints.FutureOrPresent;
58 import javax.validation.constraints.NotNull;
59 import javax.validation.constraints.PastOrPresent;
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.EqualsAndHashCode;
65 import lombok.Getter;
66 import lombok.NoArgsConstructor;
67 import lombok.Setter;
68 import org.hibernate.validator.constraints.SafeHtml;
69
70 /*
71
72 CREATE TABLE `cr_report` (
73         `rep_id` decimal(11,0) NOT NULL,
74         `title` varchar(100) NOT NULL,
75         `descr` varchar(255) DEFAULT NULL,
76         `public_yn` varchar(1) NOT NULL DEFAULT 'n',
77         `report_xml` text DEFAULT NULL,
78         `create_id` decimal(11,0) DEFAULT NULL,
79         `create_date` timestamp NOT NULL DEFAULT current_timestamp(),
80         `maint_id` decimal(11,0) DEFAULT NULL,
81         `maint_date` timestamp NOT NULL DEFAULT current_timestamp(),
82         `menu_id` varchar(500) DEFAULT NULL,
83         `menu_approved_yn` varchar(1) NOT NULL DEFAULT 'n',
84         `owner_id` decimal(11,0) DEFAULT NULL,
85         `folder_id` int(11) DEFAULT 0,
86         `dashboard_type_yn` varchar(1) DEFAULT 'n',
87         `dashboard_yn` varchar(1) DEFAULT 'n',
88         PRIMARY KEY (`rep_id`),
89         KEY `cr_report_create_idpublic_yntitle` (`create_id`,`public_yn`,`title`) USING BTREE
90         )
91 */
92
93
94 @Table(name = "cr_report", indexes = {
95         @Index(name = "cr_report_create_idpublic_yntitle", columnList = "create_id, public_yn, title")
96 })
97 @NoArgsConstructor
98 @AllArgsConstructor
99 @EqualsAndHashCode
100 @Getter
101 @Setter
102 @Entity
103 @Embeddable
104 public class CrReport implements Serializable {
105        @Id
106        @Column(name = "rep_id", length = 11, nullable = false)
107        @Digits(integer = 11, fraction = 0)
108        @Positive
109        private Long repId;
110        @Column(name = "title", length = 100, nullable = false)
111        @Size(max = 100)
112        @SafeHtml
113        @NotNull
114        private String title;
115        @Column(name = "descr", length = 255, columnDefinition = "varchar(255) DEFAULT NULL")
116        @Size(max = 255)
117        @SafeHtml
118        private String descr;
119        @Column(name = "public_yn", nullable = false, length = 1, columnDefinition = "character varying(1) default 'n'")
120        @Pattern(regexp = "[YNyn]")
121        @Size(max = 1)
122        @SafeHtml
123        @NotNull
124        private String publicYn;
125        @Column(name = "report_xml", columnDefinition = "text DEFAULT NULL")
126        private String reportXml;
127        @Column(name = "create_id", columnDefinition = "decimal(11,0) DEFAULT NULL")
128        @Digits(integer = 11, fraction = 0)
129        @Positive
130        private Long createId;
131        @Column(name = "create_date", nullable = false, columnDefinition = "timestamp DEFAULT current_timestamp()")
132        @PastOrPresent
133        @NotNull
134        protected LocalDateTime createDate;
135        @Column(name = "maint_id", columnDefinition = "decimal(11,0) DEFAULT NULL")
136        @Digits(integer = 11, fraction = 0)
137        private Long maintId;
138        @Column(name = "maint_date", nullable = false, columnDefinition = "timestamp DEFAULT current_timestamp()")
139        @PastOrPresent
140        @NotNull
141        protected LocalDateTime maintDate;
142        @Column(name = "menu_id", length = 500, columnDefinition = "varchar(500) DEFAULT NULL")
143        @Size(max = 500)
144        @SafeHtml
145        private String menuId;
146        @Column(name = "menu_approved_yn", nullable = false, length = 1, columnDefinition = "character varying(1) default 'n'")
147        @Pattern(regexp = "[YNyn]")
148        @Size(max = 1)
149        @SafeHtml
150        @NotNull
151        private String menuApprovedYn;
152        @Column(name = "owner_id", columnDefinition = "decimal(11,0) DEFAULT NULL")
153        @Digits(integer = 11, fraction = 0)
154        private Long ownerId;
155        @Column(name = "folder_id", length = 11, columnDefinition = "int(11) DEFAULT 0")
156        @Digits(integer = 11, fraction = 0)
157        @Positive
158        private Integer folderId;
159        @Column(name = "dashboard_type_yn", length = 1, columnDefinition = "character varying(1) default 'n'")
160        @Pattern(regexp = "[YNyn]")
161        @Size(max = 1)
162        @SafeHtml
163        private String dashboardTypeYn;
164        @Column(name = "dashboard_yn", length = 1, columnDefinition = "character varying(1) default 'n'")
165        @Pattern(regexp = "[YNyn]")
166        @Size(max = 1)
167        @SafeHtml
168        private String dashboardYn;
169
170        public CrReport(
171                @Digits(integer = 11, fraction = 0) @Positive Long repId,
172                @Size(max = 100) @SafeHtml @NotNull String title,
173                @Size(max = 255) @SafeHtml String descr,
174                @Pattern(regexp = "[YNyn]") @Size(max = 1) @SafeHtml @NotNull String publicYn,
175                @SafeHtml String reportXml,
176                @Digits(integer = 11, fraction = 0) @Positive Long createId,
177                @FutureOrPresent @NotNull LocalDateTime createDate,
178                @Digits(integer = 11, fraction = 0) Long maintId,
179                @FutureOrPresent @NotNull LocalDateTime maintDate,
180                @Size(max = 500) @SafeHtml String menuId,
181                @Pattern(regexp = "[YNyn]") @Size(max = 1) @SafeHtml @NotNull String menuApprovedYn,
182                @Digits(integer = 11, fraction = 0) Long ownerId,
183                @Digits(integer = 11, fraction = 0) @Positive Integer folderId,
184                @Pattern(regexp = "[YNyn]") @Size(max = 1) @SafeHtml String dashboardTypeYn,
185                @Pattern(regexp = "[YNyn]") @Size(max = 1) @SafeHtml String dashboardYn) {
186               this.repId = repId;
187               this.title = title;
188               this.descr = descr;
189               this.publicYn = publicYn;
190               this.reportXml = reportXml;
191               this.createId = createId;
192               this.createDate = createDate;
193               this.maintId = maintId;
194               this.maintDate = maintDate;
195               this.menuId = menuId;
196               this.menuApprovedYn = menuApprovedYn;
197               this.ownerId = ownerId;
198               this.folderId = folderId;
199               this.dashboardTypeYn = dashboardTypeYn;
200               this.dashboardYn = dashboardYn;
201        }
202
203        @OneToMany(
204                targetEntity = CrReportSchedule.class,
205                mappedBy = "repId",
206                cascade = CascadeType.ALL,
207                fetch = FetchType.LAZY
208        )
209        private List<CrReportSchedule> crReportSchedules = new ArrayList<>();
210        @OneToMany(
211                targetEntity = CrReportAccess.class,
212                mappedBy = "repId",
213                cascade = CascadeType.ALL,
214                fetch = FetchType.LAZY
215        )
216        private List<CrReportAccess> crReportAccesses = new ArrayList<>();
217        @OneToMany(
218                targetEntity = CrReportLog.class,
219                mappedBy = "repId",
220                cascade = CascadeType.ALL,
221                fetch = FetchType.LAZY
222        )
223        private List<CrReportLog> crReportLogs = new ArrayList<>();
224        @OneToMany(
225                targetEntity = CrReportEmailSentLog.class,
226                mappedBy = "repId",
227                cascade = CascadeType.ALL,
228                fetch = FetchType.LAZY
229        )
230        private List<CrReportEmailSentLog> crReportEmailSentLogs = new ArrayList<>();
231        @OneToMany(
232                targetEntity = CrReportFileHistory.class,
233                mappedBy = "repId",
234                cascade = CascadeType.ALL,
235                fetch = FetchType.LAZY
236        )
237        private List<CrReportFileHistory> crReportFileHistories = new ArrayList<>();
238
239 }