[PORTAL-7] Rebase
[portal.git] / ecomp-portal-BE-common / src / main / java / org / openecomp / portalapp / portal / domain / FunctionalMenuItemWithAppID.java
1 /*-\r
2  * ================================================================================\r
3  * ECOMP Portal\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ================================================================================\r
19  */\r
20 package org.openecomp.portalapp.portal.domain;\r
21 \r
22 import java.util.List;\r
23 \r
24 import javax.persistence.Column;\r
25 import javax.persistence.Entity;\r
26 import javax.persistence.GeneratedValue;\r
27 import javax.persistence.GenerationType;\r
28 import javax.persistence.Id;\r
29 import javax.persistence.Transient;\r
30 /***\r
31  * \r
32  * This class is almost identical to org.openecomp.portalapp.portal.transport.FunctionalMenuItem\r
33  * The only difference is the appId field. In FunctionMenuItem, we used @Transient as an attribute, and we are using @Column in this class.\r
34  * In some sql queries, we need to have appId, but it's not a field in fn_menu_functional table.\r
35  * \r
36  * @author robertlo\r
37  *\r
38  */\r
39 @Entity\r
40 public class FunctionalMenuItemWithAppID{\r
41         private static final long serialVersionUID = 1L;\r
42 \r
43         @Id\r
44     @GeneratedValue(strategy=GenerationType.IDENTITY)\r
45         @Column(name = "MENU_ID")\r
46         public Long menuId;\r
47         \r
48         @Column(name = "COLUMN_NUM")\r
49         public Integer column;\r
50         \r
51         @Column(name = "TEXT")\r
52         public String text;\r
53         \r
54         @Column(name = "PARENT_MENU_ID")\r
55         public Integer parentMenuId;\r
56         \r
57         @Column(name = "URL")\r
58         public String url;\r
59         \r
60         @Column(name="ACTIVE_YN")\r
61         public String active_yn;\r
62 \r
63         @Column(name="APP_ID")\r
64         public Integer appid;\r
65         \r
66         @Transient\r
67         public List<Integer> roles;\r
68         \r
69         @Transient\r
70         public Boolean restrictedApp;\r
71         \r
72         public void normalize() {\r
73                 if (this.column == null)\r
74                         this.column = new Integer(1);\r
75                 this.text = (this.text == null) ? "" : this.text.trim();\r
76                 if (this.parentMenuId == null)\r
77                         this.parentMenuId = new Integer(-1);\r
78                 this.url = (this.url == null) ? "" : this.url.trim();\r
79         }\r
80 \r
81         @Override\r
82         public String toString() {\r
83                 return "FunctionalMenuItem [menuId=" + menuId + ", column=" + column + ", text=" + text + ", parentMenuId="\r
84                                 + parentMenuId + ", url=" + url + ", active_yn=" + active_yn + ", appid=" + appid + ", roles=" + roles\r
85                                 + ", restrictedApp=" + restrictedApp + "]";\r
86         }\r
87 \r
88         public void setUrl(String url) {\r
89                 this.url = url;\r
90         }\r
91 \r
92         public void setRestrictedApp(Boolean restrictedApp) {\r
93                 this.restrictedApp = restrictedApp;\r
94         }\r
95 }\r
96 \r