[PORTAL-16 PORTAL-18] Widget ms; staging
[portal.git] / ecomp-portal-BE-common / src / main / java / org / openecomp / portalapp / portal / domain / EPApp.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 javax.persistence.Lob;
23
24 import org.apache.commons.lang.StringUtils;
25 import org.openecomp.portalsdk.core.domain.support.DomainVo;
26
27 /**
28  * Model for all columns in the fn_app table.
29  */
30 public class EPApp extends DomainVo {
31
32         private static final long serialVersionUID = 1L;
33
34         private String name;
35         private String imageUrl;
36         private String description;
37         private String notes;
38         private String url;
39         private String alternateUrl;
40         private String appRestEndpoint;
41         private String mlAppName;
42         private String mlAppAdminId;
43         private Long motsId;
44         private String username;
45         private String appPassword;
46         @Lob
47         private byte[] thumbnail;
48         private Boolean open;
49         private Boolean enabled;
50         private String uebTopicName;
51         private String uebKey;
52         private String uebSecret;
53         private Integer appType;
54
55         private AppContactUs contactUs;
56
57         public EPApp() {
58                 // Attention!!!
59                 // We set here all default values. We also place protection
60                 // into setters for fields with default values.
61                 // If we don't use such protection we are able to place null
62                 // to these fields and save such fields into DB even if DB has
63                 // default values for these fields.
64                 this.name = "";
65                 this.mlAppName = "";
66                 this.mlAppAdminId = "";
67                 this.username = "";
68                 this.appPassword = "";
69                 this.open = new Boolean(false);
70                 this.enabled = new Boolean(true);
71                 this.uebTopicName = "";
72                 this.uebKey = "";
73                 this.uebSecret = "";
74                 this.appType = 1;
75         }
76
77         public String getName() {
78                 return name;
79         }
80
81         public void setName(String name) {
82                 if (StringUtils.isEmpty(name)) {
83                         name = "";
84                 }
85                 this.name = name;
86         }
87
88         public String getImageUrl() {
89                 return imageUrl;
90         }
91
92         public void setImageUrl(String imageUrl) {
93                 this.imageUrl = imageUrl;
94         }
95
96         public byte[] getThumbnail() {
97                 return this.thumbnail;
98         }
99
100         public void setThumbnail(byte[] thumbnail) {
101                 this.thumbnail = thumbnail;
102         }
103
104         public String getDescription() {
105                 return description;
106         }
107
108         public void setDescription(String description) {
109                 this.description = description;
110         }
111
112         public String getNotes() {
113                 return notes;
114         }
115
116         public void setNotes(String notes) {
117                 this.notes = notes;
118         }
119
120         public String getUrl() {
121                 return url;
122         }
123
124         public void setUrl(String url) {
125                 this.url = url;
126         }
127
128         public String getAlternateUrl() {
129                 return alternateUrl;
130         }
131
132         public void setAlternateUrl(String alternateUrl) {
133                 this.alternateUrl = alternateUrl;
134         }
135
136         public String getAppRestEndpoint() {
137                 return appRestEndpoint;
138         }
139
140         public void setAppRestEndpoint(String appRestEndpoint) {
141                 this.appRestEndpoint = appRestEndpoint;
142         }
143
144         public String getMlAppName() {
145                 return mlAppName;
146         }
147
148         public void setMlAppName(String mlAppName) {
149                 if (StringUtils.isEmpty(mlAppName)) {
150                         mlAppName = "";
151                 }
152                 this.mlAppName = mlAppName;
153         }
154
155         public String getMlAppAdminId() {
156                 return mlAppAdminId;
157         }
158
159         public void setMlAppAdminId(String mlAppAdminId) {
160                 if (StringUtils.isEmpty(mlAppAdminId)) {
161                         mlAppAdminId = "";
162                 }
163                 this.mlAppAdminId = mlAppAdminId;
164         }
165
166         public Long getMotsId() {
167                 return motsId;
168         }
169
170         public void setMotsId(Long motsId) {
171                 this.motsId = motsId;
172         }
173
174         public String getUsername() {
175                 return username;
176         }
177
178         public void setUsername(String username) {
179                 this.username = username;
180         }
181
182         public String getAppPassword() {
183                 return appPassword;
184         }
185
186         public void setAppPassword(String appPassword) {
187                 if (StringUtils.isEmpty(appPassword)) {
188                         appPassword = "";
189                 }
190                 this.appPassword = appPassword;
191         }
192
193         public Boolean getOpen() {
194                 return open;
195         }
196
197         public void setOpen(Boolean open) {
198                 if (open == null) {
199                         open = new Boolean(false);
200                 }
201                 this.open = open;
202         }
203
204         public Boolean getEnabled() {
205                 return enabled;
206         }
207
208         public void setEnabled(Boolean enabled) {
209                 if (enabled == null) {
210                         enabled = new Boolean(true);
211                 }
212                 this.enabled = enabled;
213         }
214
215         public Integer getAppType() {
216                 return appType;
217         }
218
219         public void setAppType(Integer appType) {
220                 if (appType == null) {
221                         appType = new Integer(1);
222                 }
223                 this.appType = appType;
224         }
225
226         public void setRestrictedApp(Boolean restrictedApp) {
227                 Integer result = 1;
228                 if (restrictedApp) {
229                         result = 2;
230                 }
231                 this.appType = result;
232         }
233
234         public Boolean isRestrictedApp() {
235                 return (this.appType == 2 ? true : false);
236         }
237
238         public int compareTo(Object obj) {
239                 Long c1 = getId();
240                 Long c2 = ((EPApp) obj).getId();
241
242                 return c1.compareTo(c2);
243         }
244
245         public String getUebTopicName() {
246                 return this.uebTopicName;
247         }
248
249         public void setUebTopicName(String topicName) {
250                 if (StringUtils.isEmpty(topicName)) {
251                         this.uebTopicName = "";
252                 }
253                 this.uebTopicName = topicName;
254         }
255
256         public String getUebKey() {
257                 return this.uebKey;
258         }
259
260         public void setUebKey(String uebKey) {
261                 if (StringUtils.isEmpty(uebKey)) {
262                         this.uebKey = "";
263                 }
264                 this.uebKey = uebKey;
265         }
266
267         public String getUebSecret() {
268                 return this.uebSecret;
269         }
270
271         public void setUebSecret(String uebSecret) {
272                 if (StringUtils.isEmpty(uebSecret)) {
273                         this.uebSecret = "";
274                 }
275                 this.uebSecret = uebSecret;
276         }
277
278         public AppContactUs getContactUs() {
279                 return contactUs;
280         }
281
282         public void setContactUs(AppContactUs contactUs) {
283                 this.contactUs = contactUs;
284         }
285
286         @Override
287         public String toString() {
288                 String str = "[" + getId() + ":" + getName() + "]";
289                 return str;
290         }
291
292 }