1 24 package org.objectweb.speedo.j2eedo.database; 25 26 import java.util.ArrayList ; 27 import java.util.Collection ; 28 import java.util.Iterator ; 29 30 35 public class Department implements DatabaseObjectInterface { 36 private long deptid; 37 private String name; 38 private Collection employees; private Collection projects; 41 44 public Department() { 45 super(); 46 } 47 48 public String getAsString() { 49 StringBuffer sb = new StringBuffer (); 50 sb.append("\nDepartment (deptid:").append(this.deptid); 51 sb.append(")\n\tName:").append(this.name); 52 if (null != this.employees) { 53 sb.append("\n\tEmployees:"); 54 Iterator employeeIterator = employees.iterator(); 55 Employee e = null; 56 while (employeeIterator.hasNext()) { 57 e = (Employee) employeeIterator.next(); 58 sb.append("\n\t\t").append(e.getFirstname()).append(" "); 59 sb.append(e.getLastname()); 60 } 61 } 62 if (projects != null) { 63 Iterator projectIterator = projects.iterator(); 64 if (projectIterator.hasNext()) { 65 sb.append("\n\tProjects:"); 66 } 67 while (projectIterator.hasNext()) { 68 sb.append("\n\t\t"); 69 sb.append(((Project) projectIterator.next()).getName()); 70 } 71 } 72 return sb.toString(); 73 } 74 77 public long getId() { 78 return this.deptid; 79 } 80 81 public Department(String itsName) { 82 this.name = itsName; 83 employees = new ArrayList (); 84 projects = new ArrayList (); 85 } 86 89 public long getDeptid() { 90 return deptid; 91 } 92 93 96 public Collection getEmployees() { 97 return employees; 98 } 99 100 104 public void setEmployees(Collection employees) { 105 this.employees = employees; 106 } 107 108 111 public void addEmployee(Employee newEmployee) { 112 employees.add(newEmployee); 113 } 114 115 118 public void removeEmployee(Employee newEmployee) { 119 employees.remove(newEmployee); 120 } 121 122 125 public String getName() { 126 return name; 127 } 128 129 133 public void setName(String name) { 134 this.name = name; 135 } 136 137 140 public Collection getProjects() { 141 return projects; 142 } 143 144 148 public void setProjects(Collection projects) { 149 this.projects.addAll(projects); 150 } 151 152 155 public void addProject(Project newProject) { 156 projects.add(newProject); 157 } 158 161 public void removeProject(Project newProject) { 162 projects.remove(newProject); 163 } 164 } | Popular Tags |