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