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