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.io.Serializable;
44 import java.time.LocalDateTime;
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;
66 import lombok.NoArgsConstructor;
68 import org.hibernate.validator.constraints.SafeHtml;
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`)
87 @Table(name = "cr_folder", indexes = {
88 @Index(name = "fk_parent_key_cr_folder", columnList = "parent_folder_id")
95 public class CrFolder implements Serializable {
98 @GeneratedValue(strategy = GenerationType.AUTO)
99 @Column(name = "folder_id", length = 11, nullable = false)
100 @Digits(integer = 11, fraction = 0)
102 private Long folderId;
103 @Column(name = "folder_name", length = 50, nullable = false)
107 private String folderName;
108 @Column(name = "descr", length = 500, columnDefinition = "varchar(500) DEFAULT NULL")
111 private String descr;
112 @Column(name = "create_id", length = 50, nullable = false)
113 @Digits(integer = 11, fraction = 0)
115 private Long createId;
116 @Column(name = "create_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()")
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]")
126 private String publicYn;
128 targetEntity = CrFolder.class,
129 mappedBy = "parentFolderId",
130 cascade = CascadeType.MERGE,
131 fetch = FetchType.LAZY
133 private Set<CrFolder> crFolders;