Merge "MicroserviceParameter class DB constraints"
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / domain / EPApp.java
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
8  * Unless otherwise specified, all software contained herein is licensed
9  * under the Apache License, Version 2.0 (the "License");
10  * you may not use this software except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * Unless otherwise specified, all documentation contained herein is licensed
22  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23  * you may not use this documentation except in compliance with the License.
24  * You may obtain a copy of the License at
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
28  * Unless required by applicable law or agreed to in writing, documentation
29  * distributed under the License is distributed on an "AS IS" BASIS,
30  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  * See the License for the specific language governing permissions and
32  * limitations under the License.
33  *
34  * ============LICENSE_END============================================
35  *
36  * 
37  */
38 package org.onap.portalapp.portal.domain;
39
40 import java.util.Arrays;
41
42 import javax.persistence.Lob;
43
44 import javax.validation.Valid;
45 import org.apache.commons.lang.StringUtils;
46 import org.hibernate.validator.constraints.SafeHtml;
47 import org.onap.portalsdk.core.domain.support.DomainVo;
48
49 /**
50  * Model for all columns in the fn_app table.
51  */
52 public class EPApp extends DomainVo {
53
54         private static final long serialVersionUID = 1L;
55         @SafeHtml
56         private String name;
57         @SafeHtml
58         private String imageUrl;
59         @SafeHtml
60         private String description;
61         @SafeHtml
62         private String notes;
63         @SafeHtml
64         private String url;
65         @SafeHtml
66         private String alternateUrl;
67         @SafeHtml
68         private String appRestEndpoint;
69         @SafeHtml
70         private String mlAppName;
71         @SafeHtml
72         private String mlAppAdminId;
73         private Long motsId;
74         @SafeHtml
75         private String username;
76         @SafeHtml
77         private String appPassword;
78         @Lob
79         private byte[] thumbnail;
80         private Boolean open;
81         private Boolean enabled;
82         @SafeHtml
83         private String uebTopicName;
84         @SafeHtml
85         private String uebKey;
86         @SafeHtml
87         private String uebSecret;
88         private Integer appType;
89         @Valid
90         private AppContactUs contactUs;
91         private Boolean centralAuth;
92         @SafeHtml
93         private String  nameSpace;
94
95         public EPApp() {
96                 // Attention!!!
97                 // We set here all default values. We also place protection
98                 // into setters for fields with default values.
99                 // If we don't use such protection we are able to place null
100                 // to these fields and save such fields into DB even if DB has
101                 // default values for these fields.
102                 this.name = "";
103                 this.mlAppName = "";
104                 this.mlAppAdminId = "";
105                 this.username = "";
106                 this.appPassword = "";
107                 this.open = new Boolean(false);
108                 this.enabled = new Boolean(true);
109                 this.uebTopicName = "";
110                 this.uebKey = "";
111                 this.uebSecret = "";
112                 this.appType = 1;
113         }
114
115         public String getName() {
116                 return name;
117         }
118
119         public void setName(String name) {
120                 if (StringUtils.isEmpty(name)) {
121                         name = "";
122                 }
123                 this.name = name;
124         }
125
126         public String getImageUrl() {
127                 return imageUrl;
128         }
129
130         public void setImageUrl(String imageUrl) {
131                 this.imageUrl = imageUrl;
132         }
133
134
135
136         public byte[] getThumbnail() {
137                 return this.thumbnail;
138         }
139
140         public void setThumbnail(byte[] thumbnail) {
141                 this.thumbnail = thumbnail;
142         }
143
144         public String getDescription() {
145                 return description;
146         }
147
148         public void setDescription(String description) {
149                 this.description = description;
150         }
151
152         public String getNotes() {
153                 return notes;
154         }
155
156         public void setNotes(String notes) {
157                 this.notes = notes;
158         }
159
160         public String getUrl() {
161                 return url;
162         }
163
164         public void setUrl(String url) {
165                 this.url = url;
166         }
167
168         public String getAlternateUrl() {
169                 return alternateUrl;
170         }
171
172         public void setAlternateUrl(String alternateUrl) {
173                 this.alternateUrl = alternateUrl;
174         }
175
176         public String getAppRestEndpoint() {
177                 return appRestEndpoint;
178         }
179
180         public void setAppRestEndpoint(String appRestEndpoint) {
181                 this.appRestEndpoint = appRestEndpoint;
182         }
183
184         public String getMlAppName() {
185                 return mlAppName;
186         }
187
188         public void setMlAppName(String mlAppName) {
189                 if (StringUtils.isEmpty(mlAppName)) {
190                         mlAppName = "";
191                 }
192                 this.mlAppName = mlAppName;
193         }
194
195         public String getMlAppAdminId() {
196                 return mlAppAdminId;
197         }
198
199         public void setMlAppAdminId(String mlAppAdminId) {
200                 if (StringUtils.isEmpty(mlAppAdminId)) {
201                         mlAppAdminId = "";
202                 }
203                 this.mlAppAdminId = mlAppAdminId;
204         }
205
206         public Long getMotsId() {
207                 return motsId;
208         }
209
210         public void setMotsId(Long motsId) {
211                 this.motsId = motsId;
212         }
213
214         public String getUsername() {
215                 return username;
216         }
217
218         public void setUsername(String username) {
219                 this.username = username;
220         }
221
222         public String getAppPassword() {
223                 return appPassword;
224         }
225
226         public void setAppPassword(String appPassword) {
227                 if (StringUtils.isEmpty(appPassword)) {
228                         appPassword = "";
229                 }
230                 this.appPassword = appPassword;
231         }
232
233         public Boolean getOpen() {
234                 return open;
235         }
236
237         public void setOpen(Boolean open) {
238                 if (open == null) {
239                         open = new Boolean(false);
240                 }
241                 this.open = open;
242         }
243
244         public Boolean getEnabled() {
245                 return enabled;
246         }
247
248         public void setEnabled(Boolean enabled) {
249                 if (enabled == null) {
250                         enabled = new Boolean(true);
251                 }
252                 this.enabled = enabled;
253         }
254
255         public Integer getAppType() {
256                 return appType;
257         }
258
259         public void setAppType(Integer appType) {
260                 if (appType == null) {
261                         appType = new Integer(1);
262                 }
263                 this.appType = appType;
264         }
265
266         public void setRestrictedApp(Boolean restrictedApp) {
267                 Integer result = 1;
268                 if (restrictedApp) {
269                         result = 2;
270                 }
271                 this.appType = result;
272         }
273
274         public Boolean isRestrictedApp() {
275                 return (this.appType == 2 ? true : false);
276         }
277
278         public int compareTo(Object obj) {
279                 Long c1 = getId();
280                 Long c2 = ((EPApp) obj).getId();
281
282                 return c1.compareTo(c2);
283         }
284
285         public String getUebTopicName() {
286                 return this.uebTopicName;
287         }
288
289         public void setUebTopicName(String topicName) {
290                 if (StringUtils.isEmpty(topicName)) {
291                         this.uebTopicName = "";
292                 }
293                 this.uebTopicName = topicName;
294         }
295
296         public String getUebKey() {
297                 return this.uebKey;
298         }
299
300         public void setUebKey(String uebKey) {
301                 if (StringUtils.isEmpty(uebKey)) {
302                         this.uebKey = "";
303                 }
304                 this.uebKey = uebKey;
305         }
306
307         public String getUebSecret() {
308                 return this.uebSecret;
309         }
310
311         public void setUebSecret(String uebSecret) {
312                 if (StringUtils.isEmpty(uebSecret)) {
313                         this.uebSecret = "";
314                 }
315                 this.uebSecret = uebSecret;
316         }
317
318         public AppContactUs getContactUs() {
319                 return contactUs;
320         }
321
322         public void setContactUs(AppContactUs contactUs) {
323                 this.contactUs = contactUs;
324         }
325         
326         public Boolean getCentralAuth() {
327                 return centralAuth;
328         }
329
330         public void setCentralAuth(Boolean centralAuth) {
331                 if (centralAuth == null) {
332                         centralAuth = new Boolean(false);
333                 }
334                 this.centralAuth = centralAuth;
335         }
336         
337         public String getNameSpace() {
338                 return nameSpace;
339         }
340
341         public void setNameSpace(String nameSpace) {
342                 if (StringUtils.isEmpty(nameSpace)) {
343                         nameSpace = null;
344                 }
345                 this.nameSpace = nameSpace;
346         }
347
348         @Override
349         public String toString() {
350                 String str = "[" + getId() + ":" + getName() + "]";
351                 return str;
352         }
353
354         @Override
355         public int hashCode() {
356                 final int prime = 31;
357                 int result = 1;
358                 result = prime * result + ((alternateUrl == null) ? 0 : alternateUrl.hashCode());
359                 result = prime * result + ((appPassword == null) ? 0 : appPassword.hashCode());
360                 result = prime * result + ((appRestEndpoint == null) ? 0 : appRestEndpoint.hashCode());
361                 result = prime * result + ((appType == null) ? 0 : appType.hashCode());
362                 result = prime * result + ((centralAuth == null) ? 0 : centralAuth.hashCode());
363                 result = prime * result + ((contactUs == null) ? 0 : contactUs.hashCode());
364                 result = prime * result + ((description == null) ? 0 : description.hashCode());
365                 result = prime * result + ((enabled == null) ? 0 : enabled.hashCode());
366                 result = prime * result + ((imageUrl == null) ? 0 : imageUrl.hashCode());
367                 result = prime * result + ((mlAppAdminId == null) ? 0 : mlAppAdminId.hashCode());
368                 result = prime * result + ((mlAppName == null) ? 0 : mlAppName.hashCode());
369                 result = prime * result + ((motsId == null) ? 0 : motsId.hashCode());
370                 result = prime * result + ((name == null) ? 0 : name.hashCode());
371                 result = prime * result + ((nameSpace == null) ? 0 : nameSpace.hashCode());
372                 result = prime * result + ((notes == null) ? 0 : notes.hashCode());
373                 result = prime * result + ((open == null) ? 0 : open.hashCode());
374                 result = prime * result + Arrays.hashCode(thumbnail);
375                 result = prime * result + ((uebKey == null) ? 0 : uebKey.hashCode());
376                 result = prime * result + ((uebSecret == null) ? 0 : uebSecret.hashCode());
377                 result = prime * result + ((uebTopicName == null) ? 0 : uebTopicName.hashCode());
378                 result = prime * result + ((url == null) ? 0 : url.hashCode());
379                 result = prime * result + ((username == null) ? 0 : username.hashCode());
380                 return result;
381         }
382
383         @Override
384         public boolean equals(Object obj) {
385                 if (this == obj)
386                         return true;
387                 if (obj == null)
388                         return false;
389                 if (getClass() != obj.getClass())
390                         return false;
391                 EPApp other = (EPApp) obj;
392                 if (alternateUrl == null) {
393                         if (other.alternateUrl != null)
394                                 return false;
395                 } else if (!alternateUrl.equals(other.alternateUrl))
396                         return false;
397                 if (appPassword == null) {
398                         if (other.appPassword != null)
399                                 return false;
400                 } else if (!appPassword.equals(other.appPassword))
401                         return false;
402                 if (appRestEndpoint == null) {
403                         if (other.appRestEndpoint != null)
404                                 return false;
405                 } else if (!appRestEndpoint.equals(other.appRestEndpoint))
406                         return false;
407                 if (appType == null) {
408                         if (other.appType != null)
409                                 return false;
410                 } else if (!appType.equals(other.appType))
411                         return false;
412                 if (centralAuth == null) {
413                         if (other.centralAuth != null)
414                                 return false;
415                 } else if (!centralAuth.equals(other.centralAuth))
416                         return false;
417                 if (contactUs == null) {
418                         if (other.contactUs != null)
419                                 return false;
420                 } else if (!contactUs.equals(other.contactUs))
421                         return false;
422                 if (description == null) {
423                         if (other.description != null)
424                                 return false;
425                 } else if (!description.equals(other.description))
426                         return false;
427                 if (enabled == null) {
428                         if (other.enabled != null)
429                                 return false;
430                 } else if (!enabled.equals(other.enabled))
431                         return false;
432                 if (imageUrl == null) {
433                         if (other.imageUrl != null)
434                                 return false;
435                 } else if (!imageUrl.equals(other.imageUrl))
436                         return false;
437                 if (mlAppAdminId == null) {
438                         if (other.mlAppAdminId != null)
439                                 return false;
440                 } else if (!mlAppAdminId.equals(other.mlAppAdminId))
441                         return false;
442                 if (mlAppName == null) {
443                         if (other.mlAppName != null)
444                                 return false;
445                 } else if (!mlAppName.equals(other.mlAppName))
446                         return false;
447                 if (motsId == null) {
448                         if (other.motsId != null)
449                                 return false;
450                 } else if (!motsId.equals(other.motsId))
451                         return false;
452                 if (name == null) {
453                         if (other.name != null)
454                                 return false;
455                 } else if (!name.equals(other.name))
456                         return false;
457                 if (nameSpace == null) {
458                         if (other.nameSpace != null)
459                                 return false;
460                 } else if (!nameSpace.equals(other.nameSpace))
461                         return false;
462                 if (notes == null) {
463                         if (other.notes != null)
464                                 return false;
465                 } else if (!notes.equals(other.notes))
466                         return false;
467                 if (open == null) {
468                         if (other.open != null)
469                                 return false;
470                 } else if (!open.equals(other.open))
471                         return false;
472                 if (!Arrays.equals(thumbnail, other.thumbnail))
473                         return false;
474                 if (uebKey == null) {
475                         if (other.uebKey != null)
476                                 return false;
477                 } else if (!uebKey.equals(other.uebKey))
478                         return false;
479                 if (uebSecret == null) {
480                         if (other.uebSecret != null)
481                                 return false;
482                 } else if (!uebSecret.equals(other.uebSecret))
483                         return false;
484                 if (uebTopicName == null) {
485                         if (other.uebTopicName != null)
486                                 return false;
487                 } else if (!uebTopicName.equals(other.uebTopicName))
488                         return false;
489                 if (url == null) {
490                         if (other.url != null)
491                                 return false;
492                 } else if (!url.equals(other.url))
493                         return false;
494                 if (username == null) {
495                         if (other.username != null)
496                                 return false;
497                 } else if (!username.equals(other.username))
498                         return false;
499                 return true;
500         }
501 }