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