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