Coverity Scan issues fix
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / db / cr / CrReportFileHistory.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.Id;
51 import javax.persistence.Index;
52 import javax.persistence.JoinColumn;
53 import javax.persistence.JoinTable;
54 import javax.persistence.ManyToMany;
55 import javax.persistence.ManyToOne;
56 import javax.persistence.Table;
57 import javax.validation.Valid;
58 import javax.validation.constraints.Digits;
59 import javax.validation.constraints.FutureOrPresent;
60 import javax.validation.constraints.NotNull;
61 import javax.validation.constraints.Pattern;
62 import javax.validation.constraints.Positive;
63 import javax.validation.constraints.Size;
64 import lombok.AllArgsConstructor;
65 import lombok.Getter;
66 import lombok.NoArgsConstructor;
67 import lombok.Setter;
68 import org.hibernate.validator.constraints.SafeHtml;
69 import org.hibernate.validator.constraints.URL;
70 import org.onap.portal.domain.db.fn.FnUser;
71
72 /*
73 CREATE TABLE `cr_report_file_history` (
74         `hist_id` int(11) NOT NULL,
75         `sched_user_id` decimal(11,0) NOT NULL,
76         `schedule_id` decimal(11,0) NOT NULL,
77         `user_id` decimal(11,0) NOT NULL,
78         `rep_id` decimal(11,0) DEFAULT NULL,
79         `run_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
80         `recurrence` varchar(50) DEFAULT NULL,
81         `file_type_id` decimal(2,0) DEFAULT NULL,
82         `file_name` varchar(80) DEFAULT NULL,
83         `file_blob` blob DEFAULT NULL,
84         `file_size` decimal(11,0) DEFAULT NULL,
85         `raptor_url` varchar(4000) DEFAULT NULL,
86         `error_yn` char(1) DEFAULT 'n',
87         `error_code` decimal(11,0) DEFAULT NULL,
88         `deleted_yn` char(1) DEFAULT 'n',
89         `deleted_by` decimal(38,0) DEFAULT NULL,
90         PRIMARY KEY (`hist_id`),
91         KEY `sys_c0014614` (`file_type_id`),
92         KEY `sys_c0014615` (`rep_id`),
93         CONSTRAINT `sys_c0014614` FOREIGN KEY (`file_type_id`) REFERENCES `cr_lu_file_type` (`lookup_id`),
94         CONSTRAINT `sys_c0014615` FOREIGN KEY (`rep_id`) REFERENCES `cr_report` (`rep_id`)
95         )
96 */
97
98 @Table(name = "cr_report_file_history", indexes = {
99         @Index(name = "sys_c0014617", columnList = "user_id"),
100         @Index(name = "sys_c0014614", columnList = "file_type_id"),
101         @Index(name = "sys_c0014615", columnList = "rep_id")
102 })
103 @NoArgsConstructor
104 @AllArgsConstructor
105 @Getter
106 @Setter
107 @Entity
108 public class CrReportFileHistory implements Serializable {
109        @Id
110        @Column(name = "hist_id", nullable = false, length = 11)
111        @Digits(integer = 11, fraction = 0)
112        private Long histId;
113        @Column(name = "sched_user_id", nullable = false)
114        @Digits(integer = 11, fraction = 0)
115        @NotNull
116        private Long schedUserId;
117        @Column(name = "schedule_id", nullable = false)
118        @Digits(integer = 11, fraction = 0)
119        @NotNull
120        private Long scheduleId;
121        @Column(name = "user_id", nullable = false)
122        @Digits(integer = 11, fraction = 0)
123        @NotNull
124        private Long userId;
125        @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
126        @JoinColumn(name = "rep_id")
127        @Valid
128        private CrReport repId;
129        @Column(name = "run_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()")
130        @FutureOrPresent
131        private LocalDateTime runDate;
132        @Column(name = "recurrence", length = 50, columnDefinition = "varchar(50) DEFAULT NULL")
133        @Size(max = 50)
134        @SafeHtml
135        private String recurrence;
136        @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
137        @JoinColumn(name = "file_type_id")
138        @Valid
139        private CrLuFileType fileTypeId;
140        @Column(name = "file_name", length = 80, columnDefinition = "varchar(80) DEFAULT NULL")
141        @Size(max = 80)
142        @SafeHtml
143        private String fileName;
144        @Column(name = "file_blob", columnDefinition = "blob DEFAULT NULL")
145        private byte[] fileBlob;
146        @Column(name = "file_size", columnDefinition = "decimal(11,0) DEFAULT NULL")
147        @Digits(integer = 11, fraction = 0)
148        @Positive
149        private Long file_size;
150        //TODO URL @URL
151        @URL
152        @Column(name = "raptor_url", length = 4000)
153        @Size(max = 4000)
154        @SafeHtml
155        private String raptorUrl;
156        @Column(name = "error_yn", length = 1, columnDefinition = "character(1) default 'n'")
157        @Pattern(regexp = "[YNyn]")
158        @Size(max = 1)
159        @SafeHtml
160        private String errorYn;
161        @Column(name = "error_code", columnDefinition = "decimal(11,0) DEFAULT NULL")
162        @Digits(integer = 11, fraction = 0)
163        private Long errorCode;
164        @Column(name = "deleted_yn", length = 1, columnDefinition = "character(1) default 'n'")
165        @Pattern(regexp = "[YNyn]")
166        @Size(max = 1)
167        @SafeHtml
168        private String deletedYn;
169        @Column(name = "deleted_by", columnDefinition = "decimal(38,0) DEFAULT NULL")
170        @Digits(integer = 38, fraction = 0)
171        private Long deletedBy;
172
173        @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
174        @JoinTable(
175                name = "cr_hist_user_map",
176                joinColumns = {@JoinColumn(name = "hist_id", referencedColumnName = "hist_id")},
177                inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "user_id")}
178        )
179        private Set<FnUser> fnUserList;
180 }