nexus site path corrected
[portal.git] / ecomp-portal-BE / src / main / java / org / openecomp / portalapp / portal / domain / EPUserApp.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
23 @SuppressWarnings("rawtypes")
24 public class EPUserApp implements java.io.Serializable, Comparable {
25
26         private static final long serialVersionUID = 1L;
27         
28         private Long userId;
29         private EPApp app;
30         private EPRole role;
31         private Short priority;
32         
33         public EPUserApp() {
34         }
35         
36         public Long getAppId() {
37                 return this.getApp().getId();
38         }
39         
40         public Long getRoleId() {
41                 return (role == null) ? null : role.getId();
42         }
43         
44         public Long getAppRoleId() {
45                 return (role.getAppRoleId() == null) ? null : role.getAppRoleId();
46         }
47                 
48         @Override 
49         public String toString() {
50                 String str = "[u: "+getUserId()+"; a: "+getAppId()+", r: "+getRoleId()+"; appRoleId: "+getAppRoleId()+"]";
51                 return str;
52         }
53         
54         public Long getUserId() {
55                 return userId;
56         }
57
58         public void setUserId(Long id) {
59                 this.userId = id;
60         }
61
62         public EPApp getApp() {
63                 return app;
64         }
65
66         public void setApp(EPApp app) {
67                 this.app = app;
68         }
69
70         public EPRole getRole() {
71                 return role;
72         }
73
74         public void setRole(EPRole role) {
75                 this.role = role;
76         }
77                 
78         public Short getPriority() {
79                 return this.priority;
80         }
81
82         public void setPriority(Short priority) {
83                 this.priority = priority;
84         }
85
86         public boolean equals(Object other) {
87                 if ((this == other))
88                         return true;
89                 if ((other == null))
90                         return false;
91                 if (!(other instanceof EPUserApp))
92                         return false;
93                 EPUserApp castOther = (EPUserApp) other;
94
95                 return (this.getUserId().equals(castOther.getUserId()))
96                                 && (this.getApp().getId().equals(castOther.getApp().getId()))
97                                 && (this.getRole().getId().equals(castOther.getRole().getId()))
98                                 && ((this.priority==null && castOther.getPriority()==null) || this.getPriority().equals(castOther.getPriority()));
99         }
100
101         public int hashCode() {
102                 int result = 17;
103
104                 result = 37 * result + (int) (this.getUserId()==null ? 0 : this.getUserId().intValue());
105                 result = 37 * result + (int) (this.getApp().getId()==null ? 0 : this.getApp().getId().intValue());
106                 result = 37 * result + (int) (this.getRole().getId()==null ? 0 : this.getRole().getId().intValue());
107                 result = 37 * result + (int) (this.priority==null ? 0 : this.priority);
108                 return result;
109         }
110
111         public int compareTo(Object other){
112             EPUserApp castOther = (EPUserApp) other;
113
114             Long c1 = (this.getUserId()==null ? 0 : this.getUserId()) + (this.getApp()==null||this.getApp().getId()==null ? 0 : this.getApp().getId()) + (this.getRole()==null||this.getRole().getId()==null ? 0 : this.getRole().getId()) + (this.priority==null ? 0 : this.priority);
115             Long c2 = (castOther.getUserId()==null ? 0 : castOther.getUserId()) + (castOther.getApp()==null||castOther.getApp().getId()==null ? 0 : castOther.getApp().getId()) + (castOther.getRole()==null||castOther.getRole().getId()==null ? 0 : castOther.getRole().getId()) + (castOther.priority==null ? 0 : castOther.priority);
116
117             return c1.compareTo(c2);
118         }
119 }