2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ===================================================================
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
15 * http://www.apache.org/licenses/LICENSE-2.0
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.
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
28 * https://creativecommons.org/licenses/by/4.0/
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.
36 * ============LICENSE_END============================================
41 package org.onap.portal.domain.db.cr;
43 import java.time.LocalDateTime;
44 import java.util.ArrayList;
45 import java.util.List;
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;
65 import lombok.NoArgsConstructor;
67 import org.hibernate.validator.constraints.SafeHtml;
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`)
86 @Table(name = "cr_folder", indexes = {
87 @Index(name = "fk_parent_key_cr_folder", columnList = "parent_folder_id")
94 public class CrFolder {
96 @GeneratedValue(strategy = GenerationType.AUTO)
97 @Column(name = "folder_id", length = 11, nullable = false)
98 @Digits(integer = 11, fraction = 0)
100 private Long folderId;
101 @Column(name = "folder_name", length = 50, nullable = false)
105 private String folderName;
106 @Column(name = "descr", length = 500, columnDefinition = "varchar(500) DEFAULT NULL")
109 private String descr;
110 @Column(name = "create_id", length = 50, nullable = false)
111 @Digits(integer = 11, fraction = 0)
113 private Long createId;
114 @Column(name = "create_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()")
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]")
124 private String publicYn;
126 targetEntity = CrFolder.class,
127 mappedBy = "parentFolderId",
128 cascade = CascadeType.ALL,
129 fetch = FetchType.LAZY
131 private List<CrFolder> crFolders = new ArrayList<>();