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