diff options
Diffstat (limited to 'proxy/code/src/org/fedoraproject/candlepin/model/Owner.java')
-rw-r--r-- | proxy/code/src/org/fedoraproject/candlepin/model/Owner.java | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/proxy/code/src/org/fedoraproject/candlepin/model/Owner.java b/proxy/code/src/org/fedoraproject/candlepin/model/Owner.java index 4765410..61f0787 100644 --- a/proxy/code/src/org/fedoraproject/candlepin/model/Owner.java +++ b/proxy/code/src/org/fedoraproject/candlepin/model/Owner.java @@ -14,8 +14,8 @@ */ package org.fedoraproject.candlepin.model; -import java.util.LinkedList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; @@ -53,21 +53,24 @@ public class Owner { // TODO: Remove these transients once the appropriate objects are mapped: - @Transient - private List<Consumer> consumers; + @OneToMany(mappedBy="owner", targetEntity=Consumer.class) + private Set<Consumer> consumers; // EntitlementPool is the owning side of this relationship. @OneToMany(mappedBy="owner", targetEntity=EntitlementPool.class) @ForeignKey(name="fk_user_owner_id") - private List<EntitlementPool> entitlementPools; + private Set<EntitlementPool> entitlementPools; @Transient - private List<User> users; + private Set<User> users; /** * Default constructor. */ public Owner() { + consumers = new HashSet<Consumer>(); + entitlementPools = new HashSet<EntitlementPool>(); + users = new HashSet<User>(); } /** @@ -77,6 +80,10 @@ public class Owner { */ public Owner(String nameIn) { this.name = nameIn; + + consumers = new HashSet<Consumer>(); + entitlementPools = new HashSet<EntitlementPool>(); + users = new HashSet<User>(); } /** @@ -110,37 +117,37 @@ public class Owner { /** * @return the consumers */ - public List<Consumer> getConsumers() { + public Set<Consumer> getConsumers() { return consumers; } /** * @param consumers the consumers to set */ - public void setConsumers(List<Consumer> consumers) { + public void setConsumers(Set<Consumer> consumers) { this.consumers = consumers; } /** * @return the entitlementPools */ - public List<EntitlementPool> getEntitlementPools() { + public Set<EntitlementPool> getEntitlementPools() { return entitlementPools; } /** * @param entitlementPools the entitlementPools to set */ - public void setEntitlementPools(List<EntitlementPool> entitlementPools) { + public void setEntitlementPools(Set<EntitlementPool> entitlementPools) { this.entitlementPools = entitlementPools; } /** * @return the users */ - public List<User> getUsers() { + public Set<User> getUsers() { return users; } /** * @param users the users to set */ - public void setUsers(List<User> users) { + public void setUsers(Set<User> users) { this.users = users; } @@ -151,7 +158,7 @@ public class Owner { public void addUser(User u) { u.setOwner(this); if (this.users == null) { - this.users = new LinkedList<User>(); + this.users = new HashSet<User>(); } this.users.add(u); } @@ -162,9 +169,6 @@ public class Owner { */ public void addConsumer(Consumer c) { c.setOwner(this); - if (this.consumers == null) { - this.consumers = new LinkedList<Consumer>(); - } this.consumers.add(c); } @@ -176,7 +180,7 @@ public class Owner { public void addEntitlementPool(EntitlementPool pool) { pool.setOwner(this); if (this.entitlementPools == null) { - this.entitlementPools = new LinkedList<EntitlementPool>(); + this.entitlementPools = new HashSet<EntitlementPool>(); } this.entitlementPools.add(pool); } |