Hibernate db fix
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / db / fn / FnTab.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.fn;
42
43 import java.math.BigInteger;
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.ManyToOne;
53 import javax.persistence.OneToMany;
54 import javax.persistence.Table;
55 import javax.validation.Valid;
56 import javax.validation.constraints.Digits;
57 import javax.validation.constraints.NotNull;
58 import javax.validation.constraints.Pattern;
59 import javax.validation.constraints.Size;
60 import lombok.AllArgsConstructor;
61 import lombok.Getter;
62 import lombok.NoArgsConstructor;
63 import lombok.Setter;
64 import org.hibernate.validator.constraints.SafeHtml;
65
66 /*
67 CREATE TABLE `fn_tab` (
68         `tab_cd` varchar(30) NOT NULL,
69         `tab_name` varchar(50) NOT NULL,
70         `tab_descr` varchar(100) DEFAULT NULL,
71         `action` varchar(100) NOT NULL,
72         `function_cd` varchar(30) NOT NULL,
73         `active_yn` char(1) NOT NULL,
74         `sort_order` decimal(11,0) NOT NULL,
75         `parent_tab_cd` varchar(30) DEFAULT NULL,
76         `tab_set_cd` varchar(30) DEFAULT NULL,
77         PRIMARY KEY (`tab_cd`),
78         KEY `fk_fn_tab_function_cd` (`function_cd`),
79         KEY `fk_fn_tab_set_cd` (`tab_set_cd`),
80         CONSTRAINT `fk_fn_tab_function_cd` FOREIGN KEY (`function_cd`) REFERENCES `fn_function` (`function_cd`),
81         CONSTRAINT `fk_fn_tab_set_cd` FOREIGN KEY (`tab_set_cd`) REFERENCES `fn_lu_tab_set` (`tab_set_cd`)
82         )
83 */
84
85 @Table(name = "fn_tab", indexes = {
86         @Index(name = "fk_fn_tab_function_cd", columnList = "function_cd"),
87         @Index(name = "fk_fn_tab_set_cd", columnList = "tab_set_cd")
88 })
89 @NoArgsConstructor
90 @AllArgsConstructor
91 @Getter
92 @Setter
93 @Entity
94 public class FnTab {
95        @Id
96        @Column(name = "tab_cd", length = 30, nullable = false)
97        @Size(max = 30)
98        @SafeHtml
99        private String tabCd;
100        @Column(name = "tab_name", length = 50, nullable = false)
101        @Size(max = 50)
102        @SafeHtml
103        @NotNull
104        private String tabName;
105        @Column(name = "tab_descr", length = 100, columnDefinition = "varchar(100) DEFAULT NULL")
106        @Size(max = 100)
107        @SafeHtml
108        private String tabDescr;
109        @Column(name = "action", length = 100, nullable = false)
110        @Size(max = 100)
111        @SafeHtml
112        @NotNull
113        private String action;
114        @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
115        @JoinColumn(name = "function_cd", nullable = false)
116        @NotNull
117        @Valid
118        private FnFunction functionCd;
119        @Column(name = "active_yn", length = 1, nullable = false)
120        @Pattern(regexp = "[YNyn]")
121        @Size(max = 1)
122        @NotNull
123        @SafeHtml
124        private String activeYn;
125        @Column(name = "sort_order", length = 11, nullable = false)
126        @Digits(integer = 11, fraction = 0)
127        @NotNull
128        private BigInteger sortDrder;
129        @Column(name = "parent_tab_cd", length = 30, columnDefinition = "varchar(30) DEFAULT NULL")
130        @Size(max = 30)
131        @SafeHtml
132        private String parentTabCd;
133        @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
134        @JoinColumn(name = "tab_set_cd", nullable = false)
135        @NotNull
136        @Valid
137        private FnLuTabSet fnLuTabSet;
138        @OneToMany(
139                targetEntity = FnTabSelected.class,
140                mappedBy = "selectedTabCd",
141                cascade = CascadeType.ALL,
142                fetch = FetchType.LAZY
143        )
144        private Set<FnTabSelected> selectedTabCd;
145
146 }