Coverity Scan issues fix
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / db / cr / CrFolder.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.GeneratedValue;
51 import javax.persistence.GenerationType;
52 import javax.persistence.Id;
53 import javax.persistence.Index;
54 import javax.persistence.JoinColumn;
55 import javax.persistence.ManyToOne;
56 import javax.persistence.OneToMany;
57 import javax.persistence.Table;
58 import javax.validation.constraints.Digits;
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
69 /*
70
71 CREATE TABLE `cr_folder` (
72         `folder_id` int(11) NOT NULL,
73         `folder_name` varchar(50) NOT NULL,
74         `descr` varchar(500) DEFAULT NULL,
75         `create_id` int(11) NOT NULL,
76         `create_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
77         `parent_folder_id` int(11) DEFAULT NULL,
78         `public_yn` varchar(1) NOT NULL DEFAULT 'n',
79         PRIMARY KEY (`folder_id`),
80         KEY `fk_parent_key_cr_folder` (`parent_folder_id`),
81         CONSTRAINT `fk_parent_key_cr_folder` FOREIGN KEY (`parent_folder_id`) REFERENCES `cr_folder` (`folder_id`)
82         )
83 */
84
85
86 @Table(name = "cr_folder", indexes = {
87         @Index(name = "fk_parent_key_cr_folder", columnList = "parent_folder_id")
88 })
89 @NoArgsConstructor
90 @AllArgsConstructor
91 @Getter
92 @Setter
93 @Entity
94 public class CrFolder implements Serializable {
95        @Id
96        @GeneratedValue(strategy = GenerationType.AUTO)
97        @Column(name = "folder_id", length = 11, nullable = false)
98        @Digits(integer = 11, fraction = 0)
99        @Positive
100        private Long folderId;
101        @Column(name = "folder_name", length = 50, nullable = false)
102        @Size(max = 50)
103        @NotNull
104        @SafeHtml
105        private String folderName;
106        @Column(name = "descr", length = 500, columnDefinition = "varchar(500) DEFAULT NULL")
107        @Size(max = 500)
108        @SafeHtml
109        private String descr;
110        @Column(name = "create_id", length = 50, nullable = false)
111        @Digits(integer = 11, fraction = 0)
112        @Positive
113        private Long createId;
114        @Column(name = "create_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()")
115        @NotNull
116        private LocalDateTime createDate;
117        @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
118        @JoinColumn(name = "parent_Folder_Id")
119        private CrFolder parentFolderId;
120        @Column(name = "public_Yn", length = 1, nullable = false, columnDefinition = "varchar(1) DEFAULT 'n'")
121        @Pattern(regexp = "[YNyn]")
122        @SafeHtml
123        @NotNull
124        private String publicYn;
125        @OneToMany(
126                targetEntity = CrFolder.class,
127                mappedBy = "parentFolderId",
128                cascade = CascadeType.ALL,
129                fetch = FetchType.LAZY
130        )
131        private Set<CrFolder> crFolders;
132 }