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