Domain model change
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / db / fn / FnMenu.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.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.ForeignKey;
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.Valid;
60 import javax.validation.constraints.Digits;
61 import javax.validation.constraints.NotNull;
62 import javax.validation.constraints.Pattern;
63 import javax.validation.constraints.Size;
64 import lombok.AllArgsConstructor;
65 import lombok.Builder;
66 import lombok.Getter;
67 import lombok.NoArgsConstructor;
68 import lombok.Setter;
69 import org.hibernate.validator.constraints.SafeHtml;
70 import org.hibernate.validator.constraints.URL;
71
72 /*
73 CREATE TABLE `fn_menu` (
74         `menu_id` int(11) NOT NULL AUTO_INCREMENT,
75         `label` varchar(100) DEFAULT NULL,
76         `parent_id` int(11) DEFAULT NULL,
77         `sort_order` decimal(4,0) DEFAULT NULL,
78         `action` varchar(200) DEFAULT NULL,
79         `function_cd` varchar(30) DEFAULT NULL,
80         `active_yn` varchar(1) NOT NULL DEFAULT 'y',
81         `servlet` varchar(50) DEFAULT NULL,
82         `query_string` varchar(200) DEFAULT NULL,
83         `external_url` varchar(200) DEFAULT NULL,
84         `target` varchar(25) DEFAULT NULL,
85         `menu_set_cd` varchar(10) DEFAULT 'app',
86         `separator_yn` char(1) DEFAULT 'n',
87         `image_src` varchar(100) DEFAULT NULL,
88         PRIMARY KEY (`menu_id`),
89         KEY `fk_fn_menu_ref_196_fn_menu` (`parent_id`),
90         KEY `fk_fn_menu_menu_set_cd` (`menu_set_cd`),
91         KEY `idx_fn_menu_label` (`label`),
92         CONSTRAINT `fk_fn_menu_menu_set_cd` FOREIGN KEY (`menu_set_cd`) REFERENCES `fn_lu_menu_set` (`menu_set_cd`),
93         CONSTRAINT `fk_fn_menu_ref_196_fn_menu` FOREIGN KEY (`parent_id`) REFERENCES `fn_menu` (`menu_id`)
94         )
95 */
96
97 @Table(name = "fn_menu", indexes = {
98         @Index(name = "idx_fn_menu_label", columnList = "label"),
99         @Index(name = "fk_fn_menu_ref_196_fn_menu", columnList = "parent_id"),
100         @Index(name = "fk_fn_menu_menu_set_cd", columnList = "menu_set_cd")
101 })
102 @NoArgsConstructor
103 @AllArgsConstructor
104 @Builder
105 @Getter
106 @Setter
107 @Entity
108 public class FnMenu implements Serializable {
109        @Id
110        @GeneratedValue(strategy = GenerationType.AUTO)
111        @Column(name = "menu_id", nullable = false, length = 11, columnDefinition = "int(11) auto_increment")
112        @Digits(integer = 11, fraction = 0)
113        private Integer menu_id;
114        @Column(name = "label", length = 100, columnDefinition = "varchar(100) DEFAULT NULL")
115        @Size(max = 100)
116        @SafeHtml
117        private String label;
118        @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
119        @JoinColumn(name = "parent_Id", columnDefinition = "int(11) DEFAULT NULL")
120        @Valid
121        private FnMenu parentId;
122        @Column(name = "sort_order", length = 4, columnDefinition = "decimal(4,0) DEFAULT NULL")
123        @Digits(integer = 4, fraction = 0)
124        private Integer sortOrder;
125        @Column(name = "action", length = 200, columnDefinition = "varchar(200) DEFAULT NULL")
126        @Size(max = 200)
127        @SafeHtml
128        private String action;
129        @Column(name = "function_cd", length = 30, columnDefinition = "varchar(30) DEFAULT NULL")
130        @Size(max = 30)
131        @SafeHtml
132        private String functionCd;
133        @Column(name = "active_yn", length = 1, columnDefinition = "boolean default true", nullable = false)
134        @NotNull
135        private Boolean activeYn = true;
136        @Column(name = "servlet", length = 50, columnDefinition = "varchar(50) DEFAULT NULL")
137        @Size(max = 50)
138        @SafeHtml
139        private String servlet;
140        @Column(name = "query_string", length = 200, columnDefinition = "varchar(200) DEFAULT NULL")
141        @Size(max = 200)
142        @SafeHtml
143        private String queryString;
144        @Column(name = "external_url", length = 200, columnDefinition = "varchar(200) DEFAULT NULL")
145        @Size(max = 200)
146        @SafeHtml
147        @URL
148        //TODO url
149        private String externalUrl;
150        @Column(name = "target", length = 25, columnDefinition = "varchar(25) DEFAULT NULL")
151        @Size(max = 25)
152        @SafeHtml
153        private String target;
154        @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
155        @JoinColumn(name = "menu_set_cd", columnDefinition = "character varying(10) default 'app'", foreignKey = @ForeignKey(name = "fk_fn_menu_menu_set_cd"))
156        @Valid
157        private FnLuMenuSet menuSetCd;
158        @Column(name = "separator_yn", length = 1, columnDefinition = "boolean default false")
159        @NotNull
160        private Boolean separatorYn = false;
161        @Column(name = "image_src", length = 100, columnDefinition = "varchar(100) DEFAULT NULL")
162        @Size(max = 100)
163        @SafeHtml
164        private String imageSrc;
165        @OneToMany(
166                targetEntity = FnMenu.class,
167                mappedBy = "parentId",
168                cascade = CascadeType.MERGE,
169                fetch = FetchType.LAZY
170        )
171        private Set<FnMenu> fnMenus;
172 }