ad9dec56009de61ee60085246b8ed48bed793daf
[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 java.util.Arrays;
23
24 import javax.persistence.Lob;
25
26 import org.apache.commons.lang.StringUtils;
27 import org.openecomp.portalsdk.core.domain.support.DomainVo;
28
29 /**
30  * Model for all columns in the fn_app table.
31  */
32 public class EPApp extends DomainVo {
33
34         private static final long serialVersionUID = 1L;
35
36         private String name;
37         private String imageUrl;
38         private String description;
39         private String notes;
40         private String url;
41         private String alternateUrl;
42         private String appRestEndpoint;
43         private String mlAppName;
44         private String mlAppAdminId;
45         private Long motsId;
46         private String username;
47         private String appPassword;
48         @Lob
49         private byte[] thumbnail;
50         private Boolean open;
51         private Boolean enabled;
52         private String uebTopicName;
53         private String uebKey;
54         private String uebSecret;
55         private Integer appType;
56         private AppContactUs contactUs;
57         private Boolean centralAuth;
58         private String  nameSpace;
59
60         public EPApp() {
61                 // Attention!!!
62                 // We set here all default values. We also place protection
63                 // into setters for fields with default values.
64                 // If we don't use such protection we are able to place null
65                 // to these fields and save such fields into DB even if DB has
66                 // default values for these fields.
67                 this.name = "";
68                 this.mlAppName = "";
69                 this.mlAppAdminId = "";
70                 this.username = "";
71                 this.appPassword = "";
72                 this.open = new Boolean(false);
73                 this.enabled = new Boolean(true);
74                 this.uebTopicName = "";
75                 this.uebKey = "";
76                 this.uebSecret = "";
77                 this.appType = 1;
78         }
79
80         public String getName() {
81                 return name;
82         }
83
84         public void setName(String name) {
85                 if (StringUtils.isEmpty(name)) {
86                         name = "";
87                 }
88                 this.name = name;
89         }
90
91         public String getImageUrl() {
92                 return imageUrl;
93         }
94
95         public void setImageUrl(String imageUrl) {
96                 this.imageUrl = imageUrl;
97         }
98
99
100
101         public byte[] getThumbnail() {
102                 return this.thumbnail;
103         }
104
105         public void setThumbnail(byte[] thumbnail) {
106                 this.thumbnail = thumbnail;
107         }
108
109         public String getDescription() {
110                 return description;
111         }
112
113         public void setDescription(String description) {
114                 this.description = description;
115         }
116
117         public String getNotes() {
118                 return notes;
119         }
120
121         public void setNotes(String notes) {
122                 this.notes = notes;
123         }
124
125         public String getUrl() {
126                 return url;
127         }
128
129         public void setUrl(String url) {
130                 this.url = url;
131         }
132
133         public String getAlternateUrl() {
134                 return alternateUrl;
135         }
136
137         public void setAlternateUrl(String alternateUrl) {
138                 this.alternateUrl = alternateUrl;
139         }
140
141         public String getAppRestEndpoint() {
142                 return appRestEndpoint;
143         }
144
145         public void setAppRestEndpoint(String appRestEndpoint) {
146                 this.appRestEndpoint = appRestEndpoint;
147         }
148
149         public String getMlAppName() {
150                 return mlAppName;
151         }
152
153         public void setMlAppName(String mlAppName) {
154                 if (StringUtils.isEmpty(mlAppName)) {
155                         mlAppName = "";
156                 }
157                 this.mlAppName = mlAppName;
158         }
159
160         public String getMlAppAdminId() {
161                 return mlAppAdminId;
162         }
163
164         public void setMlAppAdminId(String mlAppAdminId) {
165                 if (StringUtils.isEmpty(mlAppAdminId)) {
166                         mlAppAdminId = "";
167                 }
168                 this.mlAppAdminId = mlAppAdminId;
169         }
170
171         public Long getMotsId() {
172                 return motsId;
173         }
174
175         public void setMotsId(Long motsId) {
176                 this.motsId = motsId;
177         }
178
179         public String getUsername() {
180                 return username;
181         }
182
183         public void setUsername(String username) {
184                 this.username = username;
185         }
186
187         public String getAppPassword() {
188                 return appPassword;
189         }
190
191         public void setAppPassword(String appPassword) {
192                 if (StringUtils.isEmpty(appPassword)) {
193                         appPassword = "";
194                 }
195                 this.appPassword = appPassword;
196         }
197
198         public Boolean getOpen() {
199                 return open;
200         }
201
202         public void setOpen(Boolean open) {
203                 if (open == null) {
204                         open = new Boolean(false);
205                 }
206                 this.open = open;
207         }
208
209         public Boolean getEnabled() {
210                 return enabled;
211         }
212
213         public void setEnabled(Boolean enabled) {
214                 if (enabled == null) {
215                         enabled = new Boolean(true);
216                 }
217                 this.enabled = enabled;
218         }
219
220         public Integer getAppType() {
221                 return appType;
222         }
223
224         public void setAppType(Integer appType) {
225                 if (appType == null) {
226                         appType = new Integer(1);
227                 }
228                 this.appType = appType;
229         }
230
231         public void setRestrictedApp(Boolean restrictedApp) {
232                 Integer result = 1;
233                 if (restrictedApp) {
234                         result = 2;
235                 }
236                 this.appType = result;
237         }
238
239         public Boolean isRestrictedApp() {
240                 return (this.appType == 2 ? true : false);
241         }
242
243         public int compareTo(Object obj) {
244                 Long c1 = getId();
245                 Long c2 = ((EPApp) obj).getId();
246
247                 return c1.compareTo(c2);
248         }
249
250         public String getUebTopicName() {
251                 return this.uebTopicName;
252         }
253
254         public void setUebTopicName(String topicName) {
255                 if (StringUtils.isEmpty(topicName)) {
256                         this.uebTopicName = "";
257                 }
258                 this.uebTopicName = topicName;
259         }
260
261         public String getUebKey() {
262                 return this.uebKey;
263         }
264
265         public void setUebKey(String uebKey) {
266                 if (StringUtils.isEmpty(uebKey)) {
267                         this.uebKey = "";
268                 }
269                 this.uebKey = uebKey;
270         }
271
272         public String getUebSecret() {
273                 return this.uebSecret;
274         }
275
276         public void setUebSecret(String uebSecret) {
277                 if (StringUtils.isEmpty(uebSecret)) {
278                         this.uebSecret = "";
279                 }
280                 this.uebSecret = uebSecret;
281         }
282
283         public AppContactUs getContactUs() {
284                 return contactUs;
285         }
286
287         public void setContactUs(AppContactUs contactUs) {
288                 this.contactUs = contactUs;
289         }
290         
291         public Boolean getCentralAuth() {
292                 return centralAuth;
293         }
294
295         public void setCentralAuth(Boolean centralAuth) {
296                 if (centralAuth == null) {
297                         centralAuth = new Boolean(false);
298                 }
299                 this.centralAuth = centralAuth;
300         }
301         
302         public String getNameSpace() {
303                 return nameSpace;
304         }
305
306         public void setNameSpace(String nameSpace) {
307                 if (StringUtils.isEmpty(nameSpace)) {
308                         nameSpace = null;
309                 }
310                 this.nameSpace = nameSpace;
311         }
312
313         @Override
314         public String toString() {
315                 String str = "[" + getId() + ":" + getName() + "]";
316                 return str;
317         }
318
319         @Override
320         public int hashCode() {
321                 final int prime = 31;
322                 int result = 1;
323                 result = prime * result + ((alternateUrl == null) ? 0 : alternateUrl.hashCode());
324                 result = prime * result + ((appPassword == null) ? 0 : appPassword.hashCode());
325                 result = prime * result + ((appRestEndpoint == null) ? 0 : appRestEndpoint.hashCode());
326                 result = prime * result + ((appType == null) ? 0 : appType.hashCode());
327                 result = prime * result + ((centralAuth == null) ? 0 : centralAuth.hashCode());
328                 result = prime * result + ((contactUs == null) ? 0 : contactUs.hashCode());
329                 result = prime * result + ((description == null) ? 0 : description.hashCode());
330                 result = prime * result + ((enabled == null) ? 0 : enabled.hashCode());
331                 result = prime * result + ((imageUrl == null) ? 0 : imageUrl.hashCode());
332                 result = prime * result + ((mlAppAdminId == null) ? 0 : mlAppAdminId.hashCode());
333                 result = prime * result + ((mlAppName == null) ? 0 : mlAppName.hashCode());
334                 result = prime * result + ((motsId == null) ? 0 : motsId.hashCode());
335                 result = prime * result + ((name == null) ? 0 : name.hashCode());
336                 result = prime * result + ((nameSpace == null) ? 0 : nameSpace.hashCode());
337                 result = prime * result + ((notes == null) ? 0 : notes.hashCode());
338                 result = prime * result + ((open == null) ? 0 : open.hashCode());
339                 result = prime * result + Arrays.hashCode(thumbnail);
340                 result = prime * result + ((uebKey == null) ? 0 : uebKey.hashCode());
341                 result = prime * result + ((uebSecret == null) ? 0 : uebSecret.hashCode());
342                 result = prime * result + ((uebTopicName == null) ? 0 : uebTopicName.hashCode());
343                 result = prime * result + ((url == null) ? 0 : url.hashCode());
344                 result = prime * result + ((username == null) ? 0 : username.hashCode());
345                 return result;
346         }
347
348         @Override
349         public boolean equals(Object obj) {
350                 if (this == obj)
351                         return true;
352                 if (obj == null)
353                         return false;
354                 if (getClass() != obj.getClass())
355                         return false;
356                 EPApp other = (EPApp) obj;
357                 if (alternateUrl == null) {
358                         if (other.alternateUrl != null)
359                                 return false;
360                 } else if (!alternateUrl.equals(other.alternateUrl))
361                         return false;
362                 if (appPassword == null) {
363                         if (other.appPassword != null)
364                                 return false;
365                 } else if (!appPassword.equals(other.appPassword))
366                         return false;
367                 if (appRestEndpoint == null) {
368                         if (other.appRestEndpoint != null)
369                                 return false;
370                 } else if (!appRestEndpoint.equals(other.appRestEndpoint))
371                         return false;
372                 if (appType == null) {
373                         if (other.appType != null)
374                                 return false;
375                 } else if (!appType.equals(other.appType))
376                         return false;
377                 if (centralAuth == null) {
378                         if (other.centralAuth != null)
379                                 return false;
380                 } else if (!centralAuth.equals(other.centralAuth))
381                         return false;
382                 if (contactUs == null) {
383                         if (other.contactUs != null)
384                                 return false;
385                 } else if (!contactUs.equals(other.contactUs))
386                         return false;
387                 if (description == null) {
388                         if (other.description != null)
389                                 return false;
390                 } else if (!description.equals(other.description))
391                         return false;
392                 if (enabled == null) {
393                         if (other.enabled != null)
394                                 return false;
395                 } else if (!enabled.equals(other.enabled))
396                         return false;
397                 if (imageUrl == null) {
398                         if (other.imageUrl != null)
399                                 return false;
400                 } else if (!imageUrl.equals(other.imageUrl))
401                         return false;
402                 if (mlAppAdminId == null) {
403                         if (other.mlAppAdminId != null)
404                                 return false;
405                 } else if (!mlAppAdminId.equals(other.mlAppAdminId))
406                         return false;
407                 if (mlAppName == null) {
408                         if (other.mlAppName != null)
409                                 return false;
410                 } else if (!mlAppName.equals(other.mlAppName))
411                         return false;
412                 if (motsId == null) {
413                         if (other.motsId != null)
414                                 return false;
415                 } else if (!motsId.equals(other.motsId))
416                         return false;
417                 if (name == null) {
418                         if (other.name != null)
419                                 return false;
420                 } else if (!name.equals(other.name))
421                         return false;
422                 if (nameSpace == null) {
423                         if (other.nameSpace != null)
424                                 return false;
425                 } else if (!nameSpace.equals(other.nameSpace))
426                         return false;
427                 if (notes == null) {
428                         if (other.notes != null)
429                                 return false;
430                 } else if (!notes.equals(other.notes))
431                         return false;
432                 if (open == null) {
433                         if (other.open != null)
434                                 return false;
435                 } else if (!open.equals(other.open))
436                         return false;
437                 if (!Arrays.equals(thumbnail, other.thumbnail))
438                         return false;
439                 if (uebKey == null) {
440                         if (other.uebKey != null)
441                                 return false;
442                 } else if (!uebKey.equals(other.uebKey))
443                         return false;
444                 if (uebSecret == null) {
445                         if (other.uebSecret != null)
446                                 return false;
447                 } else if (!uebSecret.equals(other.uebSecret))
448                         return false;
449                 if (uebTopicName == null) {
450                         if (other.uebTopicName != null)
451                                 return false;
452                 } else if (!uebTopicName.equals(other.uebTopicName))
453                         return false;
454                 if (url == null) {
455                         if (other.url != null)
456                                 return false;
457                 } else if (!url.equals(other.url))
458                         return false;
459                 if (username == null) {
460                         if (other.username != null)
461                                 return false;
462                 } else if (!username.equals(other.username))
463                         return false;
464                 return true;
465         }
466 }