1 24 package org.objectweb.speedo.j2eedo.database; 25 26 import java.math.BigDecimal ; 27 import java.util.ArrayList ; 28 import java.util.Collection ; 29 import java.util.Iterator ; 30 31 36 public class Project implements DatabaseObjectInterface { 37 private long proid; 38 private String name; 39 private BigDecimal budget; 40 private Collection members; private Department department; 42 43 47 public Project(String name, Department department) { 48 super(); 49 this.name = name; 50 this.department = department; 51 this.members = new ArrayList (); 52 } 53 56 public Project() { 57 super(); 58 } 59 60 public String getAsString() { 61 StringBuffer sb = new StringBuffer (); 62 sb.append("\nProject (proid:").append(proid); 63 sb.append(" department:"); 64 if (this.department != null) { 65 sb.append(this.department.getName()); 66 } else { 67 sb.append("is null"); 68 } 69 sb.append(")\n\tName:").append(name); 70 sb.append("\n\tbudget:").append(budget); 71 if (null != this.members) { 72 Iterator i = this.members.iterator(); 73 if (i.hasNext()) 74 sb.append("\n\tMembers:"); 75 Employee e = null; 76 while (i.hasNext()) { 77 e = (Employee) i.next(); 78 sb.append(e.getFirstname()).append(" "); 79 sb.append(e.getLastname()).append(" "); 80 } 81 } 82 return sb.toString(); 83 } 84 85 88 public long getId() { 89 return this.proid; 90 } 91 92 95 public BigDecimal getBudget() { 96 return budget; 97 } 98 99 103 public void setBudget(BigDecimal budget) { 104 this.budget = budget; 105 } 106 107 110 public Collection getMembers() { 111 return members; 112 } 113 114 118 public void setMembers(Collection members) { 119 this.members.addAll(members); 120 } 121 122 125 public boolean addMember(Employee newEmployee) { 126 if (!members.contains(newEmployee)) { 127 this.members.add(newEmployee); 128 return true; 129 } else { 130 return false; 131 } 132 } 133 136 public void removeMember(Employee newEmployee) { 137 this.members.remove(newEmployee); 138 } 139 142 public String getName() { 143 return name; 144 } 145 146 150 public void setName(String name) { 151 this.name = name; 152 } 153 154 157 public long getProid() { 158 return proid; 159 } 160 161 164 public Department getDepartment() { 165 return department; 166 } 167 168 172 public void setDepartment(Department department) { 173 this.department = department; 174 } 175 176 } 177 | Popular Tags |