1 package org.jbpm.identity; 2 3 import java.util.*; 4 5 23 public class Group extends Entity { 24 25 private static final long serialVersionUID = 1L; 26 27 protected String type = null; 28 protected Group parent = null; 29 protected Set children = null; 30 protected Set memberships = null; 31 32 public Group() { 33 } 34 35 public Group(String name) { 36 super(name); 37 } 38 39 public Group(String name, String type) { 40 super(name); 41 this.type = type; 42 } 43 44 public void addMembership(Membership membership) { 45 if (memberships==null) memberships = new HashSet(); 46 memberships.add(membership); 47 membership.setGroup(this); 48 } 49 50 public void addChild(Group child) { 51 if (children==null) children = new HashSet(); 52 children.add(child); 53 child.setParent(this); 54 } 55 56 public Set getUsers() { 57 Set users = new HashSet(); 58 if(memberships!=null) { 59 Iterator iter = memberships.iterator(); 60 while (iter.hasNext()) { 61 Membership membership = (Membership) iter.next(); 62 users.add(membership.getUser()); 63 } 64 } 65 return users; 66 } 67 68 public Set getUsersForMembershipName(String membershipName) { 69 Set users = new HashSet(); 70 if(memberships!=null) { 71 Iterator iter = memberships.iterator(); 72 while (iter.hasNext()) { 73 Membership membership = (Membership) iter.next(); 74 if (membershipName.equals(membership.getName())) { 75 users.add(membership.getUser()); 76 } 77 } 78 } 79 return users; 80 } 81 82 public long getId() { 83 return id; 84 } 85 public Set getMemberships() { 86 return memberships; 87 } 88 public Set getChildren() { 89 return children; 90 } 91 public Group getParent() { 92 return parent; 93 } 94 public String getType() { 95 return type; 96 } 97 public void setType(String type) { 98 this.type = type; 99 } 100 public void setChildren(Set children) { 101 this.children = children; 102 } 103 public void setMemberships(Set memberships) { 104 this.memberships = memberships; 105 } 106 public void setParent(Group parent) { 107 this.parent = parent; 108 } 109 } 110 | Popular Tags |