KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > j2eedo > database > Project


1 /*
2  * Speedo: an implementation of JDO compliant personality on top of JORM
3  * generic I/O sub-system. Copyright (C) 2001-2004 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Release: 1.0
20  *
21  * Created on 27 f�vr. 2004 @author fmillevi@yahoo.com
22  *
23  */

24 package org.objectweb.speedo.j2eedo.database;
25
26 import java.math.BigDecimal JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.Collection JavaDoc;
29 import java.util.Iterator JavaDoc;
30
31 /**
32  * This class define the Java class to access to the project's data
33  * @author fmillevi@yahoo.com
34  *
35  */

36 public class Project implements DatabaseObjectInterface {
37     private long proid;
38     private String JavaDoc name;
39     private BigDecimal JavaDoc budget;
40     private Collection JavaDoc members; //element:Employee
41
private Department department;
42
43     /**
44      * @param name
45      * @param department
46      */

47     public Project(String JavaDoc name, Department department) {
48         super();
49         this.name = name;
50         this.department = department;
51         this.members = new ArrayList JavaDoc();
52     }
53     /**
54      * Empty constructor
55      */

56     public Project() {
57         super();
58     }
59
60     public String JavaDoc getAsString() {
61         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
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 JavaDoc 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     /**
86      * @see org.objectweb.speedo.j2eedo.database.DatabaseObjectInterface#getId()
87      */

88     public long getId() {
89         return this.proid;
90     }
91
92     /**
93      * @return Returns the budget.
94      */

95     public BigDecimal JavaDoc getBudget() {
96         return budget;
97     }
98
99     /**
100      * @param budget
101      * The budget to set.
102      */

103     public void setBudget(BigDecimal JavaDoc budget) {
104         this.budget = budget;
105     }
106
107     /**
108      * @return Returns the members.
109      */

110     public Collection JavaDoc getMembers() {
111         return members;
112     }
113
114     /**
115      * @param members
116      * The members to set.
117      */

118     public void setMembers(Collection JavaDoc members) {
119         this.members.addAll(members);
120     }
121
122     /**
123      * @param newEmployee
124      */

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     /**
134      * @param newEmployee
135      */

136     public void removeMember(Employee newEmployee) {
137         this.members.remove(newEmployee);
138     }
139     /**
140      * @return Returns the name.
141      */

142     public String JavaDoc getName() {
143         return name;
144     }
145
146     /**
147      * @param name
148      * The name to set.
149      */

150     public void setName(String JavaDoc name) {
151         this.name = name;
152     }
153
154     /**
155      * @return Returns the proid.
156      */

157     public long getProid() {
158         return proid;
159     }
160
161     /**
162      * @return Returns the department.
163      */

164     public Department getDepartment() {
165         return department;
166     }
167
168     /**
169      * @param department
170      * The department to set.
171      */

172     public void setDepartment(Department department) {
173         this.department = department;
174     }
175
176 }
177
Popular Tags