001: /*
002: * Speedo: an implementation of JDO compliant personality on top of JORM
003: * generic I/O sub-system. Copyright (C) 2001-2004 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU Lesser General Public License as published by the
007: * Free Software Foundation; either version 2 of the License, or (at your
008: * option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful, but WITHOUT
011: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
013: * for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public License
016: * along with this library; if not, write to the Free Software Foundation,
017: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * Release: 1.0
020: *
021: * Created on 27 feb. 2004 @author fmillevi@yahoo.com
022: *
023: */
024: package org.objectweb.speedo.j2eedo.database;
025:
026: import java.math.BigDecimal;
027: import java.util.ArrayList;
028: import java.util.Collection;
029: import java.util.Iterator;
030:
031: /**
032: * This class define the Java class to access to the project's data
033: * @author fmillevi@yahoo.com
034: *
035: */
036: public class Project implements DatabaseObjectInterface {
037: private long proid;
038: private String name;
039: private BigDecimal budget;
040: private Collection members; //element:Employee
041: private Department department;
042:
043: /**
044: * @param name
045: * @param department
046: */
047: public Project(String name, Department department) {
048: super ();
049: this .name = name;
050: this .department = department;
051: this .members = new ArrayList();
052: }
053:
054: /**
055: * Empty constructor
056: */
057: public Project() {
058: super ();
059: }
060:
061: public String getAsString() {
062: StringBuffer sb = new StringBuffer();
063: sb.append("\nProject (proid:").append(proid);
064: sb.append(" department:");
065: if (this .department != null) {
066: sb.append(this .department.getName());
067: } else {
068: sb.append("is null");
069: }
070: sb.append(")\n\tName:").append(name);
071: sb.append("\n\tbudget:").append(budget);
072: if (null != this .members) {
073: Iterator i = this .members.iterator();
074: if (i.hasNext())
075: sb.append("\n\tMembers:");
076: Employee e = null;
077: while (i.hasNext()) {
078: e = (Employee) i.next();
079: sb.append(e.getFirstname()).append(" ");
080: sb.append(e.getLastname()).append(" ");
081: }
082: }
083: return sb.toString();
084: }
085:
086: /**
087: * @see org.objectweb.speedo.j2eedo.database.DatabaseObjectInterface#getId()
088: */
089: public long getId() {
090: return this .proid;
091: }
092:
093: /**
094: * @return Returns the budget.
095: */
096: public BigDecimal getBudget() {
097: return budget;
098: }
099:
100: /**
101: * @param budget
102: * The budget to set.
103: */
104: public void setBudget(BigDecimal budget) {
105: this .budget = budget;
106: }
107:
108: /**
109: * @return Returns the members.
110: */
111: public Collection getMembers() {
112: return members;
113: }
114:
115: /**
116: * @param members
117: * The members to set.
118: */
119: public void setMembers(Collection members) {
120: this .members.addAll(members);
121: }
122:
123: /**
124: * @param newEmployee
125: */
126: public boolean addMember(Employee newEmployee) {
127: if (!members.contains(newEmployee)) {
128: this .members.add(newEmployee);
129: return true;
130: } else {
131: return false;
132: }
133: }
134:
135: /**
136: * @param newEmployee
137: */
138: public void removeMember(Employee newEmployee) {
139: this .members.remove(newEmployee);
140: }
141:
142: /**
143: * @return Returns the name.
144: */
145: public String getName() {
146: return name;
147: }
148:
149: /**
150: * @param name
151: * The name to set.
152: */
153: public void setName(String name) {
154: this .name = name;
155: }
156:
157: /**
158: * @return Returns the proid.
159: */
160: public long getProid() {
161: return proid;
162: }
163:
164: /**
165: * @return Returns the department.
166: */
167: public Department getDepartment() {
168: return department;
169: }
170:
171: /**
172: * @param department
173: * The department to set.
174: */
175: public void setDepartment(Department department) {
176: this.department = department;
177: }
178:
179: }
|