1 16 package com.blandware.atleap.model.core; 17 18 import java.util.List ; 19 import java.util.ArrayList ; 20 import java.util.Iterator ; 21 import java.io.Serializable ; 22 23 40 public class Group extends BaseObject implements Serializable { 41 44 protected String name; 45 48 protected String title; 49 52 protected String description; 53 56 private Boolean fixed; 57 60 protected Long version; 61 62 65 protected List roles = new ArrayList (); 66 67 70 protected List users = new ArrayList (); 71 72 75 public Group() { 76 } 77 78 84 public Group(String name, String title) { 85 this.name = name; 86 this.title = title; 87 } 88 89 91 103 public String getName() { 104 return this.name; 105 } 106 107 117 public String getTitle() { 118 return this.title; 119 } 120 121 128 public String getDescription() { 129 return this.description; 130 } 131 132 138 public Boolean getFixed() { 139 return fixed; 140 } 141 142 147 public void setFixed(Boolean fixed) { 148 this.fixed = fixed; 149 } 150 151 156 public void setName(String name) { 157 this.name = name; 158 } 159 160 165 public void setTitle(String title) { 166 this.title = title; 167 } 168 169 174 public void setDescription(String description) { 175 this.description = description; 176 } 177 178 183 public String getRolesAsString() { 184 StringBuffer roles = new StringBuffer (); 185 if ( this.roles != null && this.roles.size() > 0 ) { 186 for ( Iterator i = this.roles.iterator(); i.hasNext(); ) { 187 Role role = (Role) i.next(); 188 roles.append(role.getTitle()); 189 if ( i.hasNext() ) { 190 roles.append(", "); 191 } 192 } 193 } 194 return roles.toString(); 195 } 196 197 204 public Long getVersion() { 205 return version; 206 } 207 208 213 public void setVersion(Long version) { 214 this.version = version; 215 } 216 217 218 228 public List getRoles() { 229 return roles; 230 } 231 232 237 public void setRoles(List roles) { 238 this.roles = roles; 239 } 240 241 251 public List getUsers() { 252 return users; 253 } 254 255 260 public void setUsers(List users) { 261 this.users = users; 262 } 263 264 269 public void addRole(Role role) { 270 if ( !role.getGroups().contains(this) ) { 271 role.getGroups().add(this); 272 } 273 if ( !getRoles().contains(role) ) { 274 getRoles().add(role); 275 } 276 } 277 278 283 public void removeRole(Role role) { 284 role.getGroups().remove(this); 285 getRoles().remove(role); 286 } 287 288 293 public void addUser(User user) { 294 if ( !user.getGroups().contains(this) ) { 295 user.getGroups().add(this); 296 } 297 if ( !getUsers().contains(user) ) { 298 getUsers().add(user); 299 } 300 } 301 302 307 public void removeUser(User user) { 308 user.getGroups().remove(this); 309 getUsers().remove(user); 310 } 311 312 public boolean equals(Object o) { 313 if ( this == o ) { 314 return true; 315 } 316 317 if ( !(o instanceof Group) ) { 318 return false; 319 } 320 final Group group = (Group) o; 321 322 if ( title != null ? !title.equals(group.title) : group.title != null ) { 323 return false; 324 } 325 326 return true; 327 } 328 329 public int hashCode() { 330 if ( title == null ) { 331 return 0; 332 } else { 333 return title.hashCode(); 334 } 335 } 336 337 } 338 | Popular Tags |