54ce4f330698305486919282e5156a71a53ef272
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / transport / CentralV2Role.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.transport;
39
40 import java.io.Serializable;
41 import java.util.Date;
42 import java.util.SortedSet;
43 import java.util.TreeSet;
44
45 import org.onap.portalapp.portal.domain.CentralV2RoleFunction;
46
47 @SuppressWarnings("rawtypes")
48 public class CentralV2Role implements Serializable, Comparable{
49                 /**
50          * 
51          */
52         private static final long serialVersionUID = -4332644961113063714L;
53                 private Long id;
54                 private Date created;
55                 private Date modified;
56                 private Long createdId;
57                 private Long modifiedId;
58                 private Long rowNum;
59                 
60             private String  name;
61             private boolean active;
62             private Integer priority;
63             
64         private SortedSet<CentralV2RoleFunction> roleFunctions = new TreeSet<>();
65             
66             private SortedSet<CentralV2Role> childRoles = new TreeSet<>();
67
68             private SortedSet<CentralV2Role> parentRoles = new TreeSet<>();
69
70                 public CentralV2Role(Long id, Date created, Date modified, Long createdId, Long modifiedId, Long rowNum,
71                                 String name, boolean active, Integer priority, SortedSet<CentralV2RoleFunction> roleFunctions,
72                                 SortedSet<CentralV2Role> childRoles, SortedSet<CentralV2Role> parentRoles) {
73                         super();
74                         this.id = id;
75                         this.created = created;
76                         this.modified = modified;
77                         this.createdId = createdId;
78                         this.modifiedId = modifiedId;
79                         this.rowNum = rowNum;
80                         this.name = name;
81                         this.active = active;
82                         this.priority = priority;
83                         this.roleFunctions = roleFunctions;
84                         this.childRoles = childRoles;
85                         this.parentRoles = parentRoles;
86                 }
87                 
88                 public CentralV2Role(){
89                         
90                 }
91                 
92                 public CentralV2Role(Long id, String name){
93                         this.id = id;
94                         this.name = name;
95                 }
96
97                 public Long getId() {
98                         return id;
99                 }
100
101                 public void setId(Long id) {
102                         this.id = id;
103                 }
104
105                 public Date getCreated() {
106                         return created;
107                 }
108
109                 public void setCreated(Date created) {
110                         this.created = created;
111                 }
112
113                 public Date getModified() {
114                         return modified;
115                 }
116
117                 public void setModified(Date modified) {
118                         this.modified = modified;
119                 }
120
121                 public Long getCreatedId() {
122                         return createdId;
123                 }
124
125                 public void setCreatedId(Long createdId) {
126                         this.createdId = createdId;
127                 }
128
129                 public Long getModifiedId() {
130                         return modifiedId;
131                 }
132
133                 public void setModifiedId(Long modifiedId) {
134                         this.modifiedId = modifiedId;
135                 }
136
137                 public Long getRowNum() {
138                         return rowNum;
139                 }
140
141                 public void setRowNum(Long rowNum) {
142                         this.rowNum = rowNum;
143                 }
144
145                 public String getName() {
146                         return name;
147                 }
148
149                 public void setName(String name) {
150                         this.name = name;
151                 }
152
153                 public boolean getActive() {
154                         return active;
155                 }
156
157                 public void setActive(boolean active) {
158                         this.active = active;
159                 }
160
161                 public Integer getPriority() {
162                         return priority;
163                 }
164
165                 public void setPriority(Integer priority) {
166                         this.priority = priority;
167                 }
168
169                 public SortedSet<CentralV2RoleFunction> getRoleFunctions() {
170                         return roleFunctions;
171                 }
172
173                 public void setRoleFunctions(SortedSet<CentralV2RoleFunction> roleFunctions) {
174                         this.roleFunctions = roleFunctions;
175                 }
176
177                 public SortedSet<CentralV2Role> getChildRoles() {
178                         return childRoles;
179                 }
180
181                 public void setChildRoles(SortedSet<CentralV2Role> childRoles) {
182                         this.childRoles = childRoles;
183                 }
184
185                 public SortedSet<CentralV2Role> getParentRoles() {
186                         return parentRoles;
187                 }
188
189                 public void setParentRoles(SortedSet<CentralV2Role> parentRoles) {
190                         this.parentRoles = parentRoles;
191                 }
192                 public void addRoleFunction(CentralV2RoleFunction roleFunction) {
193                         this.roleFunctions.add(roleFunction);
194                 }
195
196                 public void addChildRole(CentralV2Role role) {
197                         this.childRoles.add(role);
198                 }
199
200                 public void addParentRole(CentralV2Role role) {
201                         this.parentRoles.add(role);
202                 }
203                 
204                 public int compareTo(Object obj){
205                 CentralV2Role other = (CentralV2Role)obj;
206
207                 String c1 = getName();
208                 String c2 = other.getName();
209
210                 return (c1 == null || c2 == null) ? 1 : c1.compareTo(c2);
211             }
212
213                 @Override
214                 public int hashCode() {
215                         final int prime = 31;
216                         int result = 1;
217                         result = prime * result + ((id == null) ? 0 : id.hashCode());
218                         result = prime * result + ((name == null) ? 0 : name.hashCode());
219                         return result;
220                 }
221
222                 @Override
223                 public boolean equals(Object obj) {
224                         if (this == obj)
225                                 return true;
226                         if (obj == null)
227                                 return false;
228                         if (getClass() != obj.getClass())
229                                 return false;
230                         CentralV2Role other = (CentralV2Role) obj;
231                         if (id == null) {
232                                 if (other.id != null)
233                                         return false;
234                         } else if (!id.equals(other.id))
235                                 return false;
236                         if (name == null) {
237                                 if (other.name != null)
238                                         return false;
239                         } else if (!name.equals(other.name))
240                                 return false;
241                         return true;
242                 }
243                 
244                 
245                 
246 }