61fcfaee205327a30f83f0a394a748fd0a8154cc
[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
56         @SafeHtml
57         private String name;
58
59         @SafeHtml
60         private String imageUrl;
61
62         @SafeHtml
63         private String appDescription;
64
65         @SafeHtml
66         private String appNotes;
67
68         @SafeHtml
69         private String landingPage;
70
71         @SafeHtml
72         private String alternateLandingPage;
73
74         @SafeHtml
75         private String appRestEndpoint;
76
77         @SafeHtml
78         private String mlAppName;
79
80         @SafeHtml
81         private String mlAppAdminId;
82         private Long motsId;
83
84         @SafeHtml
85         private String appBasicAuthUsername;
86
87         @SafeHtml
88         private String appBasicAuthPassword;
89
90         @Lob
91         private byte[] thumbnail;
92
93         private Boolean open;
94
95         private Boolean enabled;
96
97         @SafeHtml
98         private String uebTopicName;
99
100         @SafeHtml
101         private String uebKey;
102
103         @SafeHtml
104         private String uebSecret;
105
106         private Integer appType;
107
108         @Valid
109         private AppContactUs contactUs;
110
111         private Boolean rolesInAAF;
112         @SafeHtml
113         private String nameSpace;
114
115         @SafeHtml
116         private String modeOfIntegration;
117
118         private Boolean appAck;
119
120         private Boolean usesCadi;
121
122         public EPApp() {
123                 // Attention!!!
124                 // We set here all default values. We also place protection
125                 // into setters for fields with default values.
126                 // If we don't use such protection we are able to place null
127                 // to these fields and save such fields into DB even if DB has
128                 // default values for these fields.
129                 this.name = "";
130                 this.mlAppName = "";
131                 this.mlAppAdminId = "";
132                 this.appBasicAuthUsername = "";
133                 this.appBasicAuthPassword = "";
134                 this.open = new Boolean(false);
135                 this.enabled = new Boolean(true);
136                 this.uebTopicName = "";
137                 this.uebKey = "";
138                 this.uebSecret = "";
139                 this.appType = 1;
140         }
141
142         public String getName() {
143                 return name;
144         }
145
146         public void setName(String name) {
147                 if (StringUtils.isEmpty(name)) {
148                         name = "";
149                 }
150                 this.name = name;
151         }
152
153         public String getImageUrl() {
154                 return imageUrl;
155         }
156
157         public void setImageUrl(String imageUrl) {
158                 this.imageUrl = imageUrl;
159         }
160
161         public byte[] getThumbnail() {
162                 return this.thumbnail;
163         }
164
165         public void setThumbnail(byte[] thumbnail) {
166                 this.thumbnail = thumbnail;
167         }
168
169         public String getAppDescription() {
170                 return appDescription;
171         }
172
173         public void setAppDescription(String appDescription) {
174                 this.appDescription = appDescription;
175         }
176
177         public String getAppNotes() {
178                 return appNotes;
179         }
180
181         public void setAppNotes(String appNotes) {
182                 this.appNotes = appNotes;
183         }
184
185         public String getLandingPage() {
186                 return landingPage;
187         }
188
189         public void setLandingPage(String landingPage) {
190                 this.landingPage = landingPage;
191         }
192
193         public String getAlternateLandingPage() {
194                 return alternateLandingPage;
195         }
196
197         public void setAlternateLandingPage(String alternateLandingPage) {
198                 this.alternateLandingPage = alternateLandingPage;
199         }
200
201         public String getAppRestEndpoint() {
202                 return appRestEndpoint;
203         }
204
205         public void setAppRestEndpoint(String appRestEndpoint) {
206                 this.appRestEndpoint = appRestEndpoint;
207         }
208
209         public String getMlAppName() {
210                 return mlAppName;
211         }
212
213         public void setMlAppName(String mlAppName) {
214                 if (StringUtils.isEmpty(mlAppName)) {
215                         mlAppName = "";
216                 }
217                 this.mlAppName = mlAppName;
218         }
219
220         public String getMlAppAdminId() {
221                 return mlAppAdminId;
222         }
223
224         public void setMlAppAdminId(String mlAppAdminId) {
225                 if (StringUtils.isEmpty(mlAppAdminId)) {
226                         mlAppAdminId = "";
227                 }
228                 this.mlAppAdminId = mlAppAdminId;
229         }
230
231         public Long getMotsId() {
232                 return motsId;
233         }
234
235         public void setMotsId(Long motsId) {
236                 this.motsId = motsId;
237         }
238
239         public String getAppBasicAuthUsername() {
240                 return appBasicAuthUsername;
241         }
242
243         public void setAppBasicAuthUsername(String appBasicAuthUsername) {
244                 this.appBasicAuthUsername = appBasicAuthUsername;
245         }
246
247         public String getAppBasicAuthPassword() {
248                 return appBasicAuthPassword;
249         }
250
251         public void setAppBasicAuthPassword(String appBasicAuthPassword) {
252                 if (StringUtils.isEmpty(appBasicAuthPassword)) {
253                         appBasicAuthPassword = "";
254                 }
255                 this.appBasicAuthPassword = appBasicAuthPassword;
256         }
257         
258         public Boolean getOpen() {
259                 return open;
260         }
261
262         public void setOpen(Boolean open) {
263                 if (open == null) {
264                         open = new Boolean(false);
265                 }
266                 this.open = open;
267         }
268
269         public Boolean getEnabled() {
270                 return enabled;
271         }
272
273         public void setEnabled(Boolean enabled) {
274                 if (enabled == null) {
275                         enabled = new Boolean(true);
276                 }
277                 this.enabled = enabled;
278         }
279
280         public Boolean isRestrictedApp() {
281                 return (this.appType == 2 ? true : false);
282         }
283
284         public int compareTo(Object obj) {
285                 Long c1 = getId();
286                 Long c2 = ((EPApp) obj).getId();
287
288                 return c1.compareTo(c2);
289         }
290
291         public String getUebTopicName() {
292                 return this.uebTopicName;
293         }
294
295         public void setUebTopicName(String topicName) {
296                 if (StringUtils.isEmpty(topicName)) {
297                         this.uebTopicName = "";
298                 }
299                 this.uebTopicName = topicName;
300         }
301
302         public String getUebKey() {
303                 return this.uebKey;
304         }
305
306         public void setUebKey(String uebKey) {
307                 if (StringUtils.isEmpty(uebKey)) {
308                         this.uebKey = "";
309                 }
310                 this.uebKey = uebKey;
311         }
312
313         public String getUebSecret() {
314                 return this.uebSecret;
315         }
316
317         public Integer getAppType() {
318                 return appType;
319         }
320
321         public void setAppType(Integer appType) {
322                 this.appType = appType;
323         }
324
325         public void setUebSecret(String uebSecret) {
326                 if (StringUtils.isEmpty(uebSecret)) {
327                         this.uebSecret = "";
328                 }
329                 this.uebSecret = uebSecret;
330         }
331
332         public AppContactUs getContactUs() {
333                 return contactUs;
334         }
335
336         public void setContactUs(AppContactUs contactUs) {
337                 this.contactUs = contactUs;
338         }
339
340         public Boolean getRolesInAAF() {
341                 return rolesInAAF;
342         }
343
344         public void setRolesInAAF(Boolean rolesInAAF) {
345                 if (rolesInAAF == null) {
346                         rolesInAAF = new Boolean(false);
347                 }
348                 this.rolesInAAF = rolesInAAF;
349         }
350
351         public String getNameSpace() {
352                 return nameSpace;
353         }
354
355         public void setNameSpace(String nameSpace) {
356                 if (StringUtils.isEmpty(nameSpace)) {
357                         nameSpace = null;
358                 }
359                 this.nameSpace = nameSpace;
360         }
361
362         public String getModeOfIntegration() {
363                 return modeOfIntegration;
364         }
365
366         public void setModeOfIntegration(String modeOfIntegration) {
367                 this.modeOfIntegration = modeOfIntegration;
368         }
369
370         public Boolean getAppAck() {
371                 return appAck;
372         }
373
374         public void setAppAck(Boolean appAck) {
375                 this.appAck = appAck;
376         }
377
378         public Boolean getUsesCadi() {
379                 return usesCadi;
380         }
381
382         public void setUsesCadi(Boolean usesCadi) {
383                 this.usesCadi = usesCadi;
384         }
385         
386         @Override
387         public String toString() {
388                 return "EPApp [name=" + name + ", imageUrl=" + imageUrl + ", appDescription=" + appDescription + ", appNotes="
389                                 + appNotes + ", landingPage=" + landingPage + ", alternateLandingPage=" + alternateLandingPage
390                                 + ", appRestEndpoint=" + appRestEndpoint + ", mlAppName=" + mlAppName + ", mlAppAdminId=" + mlAppAdminId
391                                 + ", motsId=" + motsId + ", appBasicAuthUsername=" + appBasicAuthUsername + ", appBasicAuthPassword="
392                                 + appBasicAuthPassword + ", thumbnail=" + Arrays.toString(thumbnail) + ", open=" + open + ", enabled="
393                                 + enabled + ", uebTopicName=" + uebTopicName + ", uebKey=" + uebKey + ", uebSecret=" + uebSecret
394                                 + ", appType=" + appType + ", contactUs=" + contactUs + ", rolesInAAF=" + rolesInAAF + ", nameSpace="
395                                 + nameSpace + ", modeOfIntegration=" + modeOfIntegration + ", appAck=" + appAck + ", usesCadi="
396                                 + usesCadi + "]";
397         }
398
399         @Override
400         public int hashCode() {
401                 final int prime = 31;
402                 int result = 1;
403                 result = prime * result + ((alternateLandingPage == null) ? 0 : alternateLandingPage.hashCode());
404                 result = prime * result + ((appAck == null) ? 0 : appAck.hashCode());
405                 result = prime * result + ((appBasicAuthPassword == null) ? 0 : appBasicAuthPassword.hashCode());
406                 result = prime * result + ((appBasicAuthUsername == null) ? 0 : appBasicAuthUsername.hashCode());
407                 result = prime * result + ((appDescription == null) ? 0 : appDescription.hashCode());
408                 result = prime * result + ((appNotes == null) ? 0 : appNotes.hashCode());
409                 result = prime * result + ((appRestEndpoint == null) ? 0 : appRestEndpoint.hashCode());
410                 result = prime * result + ((appType == null) ? 0 : appType.hashCode());
411                 result = prime * result + ((enabled == null) ? 0 : enabled.hashCode());
412                 result = prime * result + ((imageUrl == null) ? 0 : imageUrl.hashCode());
413                 result = prime * result + ((landingPage == null) ? 0 : landingPage.hashCode());
414                 result = prime * result + ((mlAppAdminId == null) ? 0 : mlAppAdminId.hashCode());
415                 result = prime * result + ((mlAppName == null) ? 0 : mlAppName.hashCode());
416                 result = prime * result + ((modeOfIntegration == null) ? 0 : modeOfIntegration.hashCode());
417                 result = prime * result + ((motsId == null) ? 0 : motsId.hashCode());
418                 result = prime * result + ((name == null) ? 0 : name.hashCode());
419                 result = prime * result + ((nameSpace == null) ? 0 : nameSpace.hashCode());
420                 result = prime * result + ((open == null) ? 0 : open.hashCode());
421                 result = prime * result + ((rolesInAAF == null) ? 0 : rolesInAAF.hashCode());
422                 result = prime * result + Arrays.hashCode(thumbnail);
423                 result = prime * result + ((uebKey == null) ? 0 : uebKey.hashCode());
424                 result = prime * result + ((uebSecret == null) ? 0 : uebSecret.hashCode());
425                 result = prime * result + ((uebTopicName == null) ? 0 : uebTopicName.hashCode());
426                 result = prime * result + ((usesCadi == null) ? 0 : usesCadi.hashCode());
427                 return result;
428         }
429
430         @Override
431         public boolean equals(Object obj) {
432                 if (this == obj)
433                         return true;
434                 if (!super.equals(obj))
435                         return false;
436                 if (!(obj instanceof EPApp))
437                         return false;
438                 EPApp other = (EPApp) obj;
439                 if (alternateLandingPage == null) {
440                         if (other.alternateLandingPage != null)
441                                 return false;
442                 } else if (!alternateLandingPage.equals(other.alternateLandingPage))
443                         return false;
444                 if (appAck == null) {
445                         if (other.appAck != null)
446                                 return false;
447                 } else if (!appAck.equals(other.appAck))
448                         return false;
449                 if (appBasicAuthPassword == null) {
450                         if (other.appBasicAuthPassword != null)
451                                 return false;
452                 } else if (!appBasicAuthPassword.equals(other.appBasicAuthPassword))
453                         return false;
454                 if (appBasicAuthUsername == null) {
455                         if (other.appBasicAuthUsername != null)
456                                 return false;
457                 } else if (!appBasicAuthUsername.equals(other.appBasicAuthUsername))
458                         return false;
459                 if (appDescription == null) {
460                         if (other.appDescription != null)
461                                 return false;
462                 } else if (!appDescription.equals(other.appDescription))
463                         return false;
464                 if (appNotes == null) {
465                         if (other.appNotes != null)
466                                 return false;
467                 } else if (!appNotes.equals(other.appNotes))
468                         return false;
469                 if (appRestEndpoint == null) {
470                         if (other.appRestEndpoint != null)
471                                 return false;
472                 } else if (!appRestEndpoint.equals(other.appRestEndpoint))
473                         return false;
474                 if (appType == null) {
475                         if (other.appType != null)
476                                 return false;
477                 } else if (!appType.equals(other.appType))
478                         return false;
479                 if (enabled == null) {
480                         if (other.enabled != null)
481                                 return false;
482                 } else if (!enabled.equals(other.enabled))
483                         return false;
484                 if (imageUrl == null) {
485                         if (other.imageUrl != null)
486                                 return false;
487                 } else if (!imageUrl.equals(other.imageUrl))
488                         return false;
489                 if (landingPage == null) {
490                         if (other.landingPage != null)
491                                 return false;
492                 } else if (!landingPage.equals(other.landingPage))
493                         return false;
494                 if (mlAppAdminId == null) {
495                         if (other.mlAppAdminId != null)
496                                 return false;
497                 } else if (!mlAppAdminId.equals(other.mlAppAdminId))
498                         return false;
499                 if (mlAppName == null) {
500                         if (other.mlAppName != null)
501                                 return false;
502                 } else if (!mlAppName.equals(other.mlAppName))
503                         return false;
504                 if (modeOfIntegration == null) {
505                         if (other.modeOfIntegration != null)
506                                 return false;
507                 } else if (!modeOfIntegration.equals(other.modeOfIntegration))
508                         return false;
509                 if (motsId == null) {
510                         if (other.motsId != null)
511                                 return false;
512                 } else if (!motsId.equals(other.motsId))
513                         return false;
514                 if (name == null) {
515                         if (other.name != null)
516                                 return false;
517                 } else if (!name.equals(other.name))
518                         return false;
519                 if (nameSpace == null) {
520                         if (other.nameSpace != null)
521                                 return false;
522                 } else if (!nameSpace.equals(other.nameSpace))
523                         return false;
524                 if (open == null) {
525                         if (other.open != null)
526                                 return false;
527                 } else if (!open.equals(other.open))
528                         return false;
529                 if (rolesInAAF == null) {
530                         if (other.rolesInAAF != null)
531                                 return false;
532                 } else if (!rolesInAAF.equals(other.rolesInAAF))
533                         return false;
534                 if (!Arrays.equals(thumbnail, other.thumbnail))
535                         return false;
536                 if (uebKey == null) {
537                         if (other.uebKey != null)
538                                 return false;
539                 } else if (!uebKey.equals(other.uebKey))
540                         return false;
541                 if (uebSecret == null) {
542                         if (other.uebSecret != null)
543                                 return false;
544                 } else if (!uebSecret.equals(other.uebSecret))
545                         return false;
546                 if (uebTopicName == null) {
547                         if (other.uebTopicName != null)
548                                 return false;
549                 } else if (!uebTopicName.equals(other.uebTopicName))
550                         return false;
551                 if (usesCadi == null) {
552                         if (other.usesCadi != null)
553                                 return false;
554                 } else if (!usesCadi.equals(other.usesCadi))
555                         return false;
556                 return true;
557         }
558
559         
560 }