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