KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > projectmanagement > business > project > ProjectImpl


1 package projectmanagement.business.project;
2
3 import projectmanagement.business.customer.*;
4 import projectmanagement.business.ProjectManagementBusinessException;
5 import projectmanagement.data.project.*;
6 import com.lutris.appserver.server.sql.DatabaseManagerException;
7 import com.lutris.appserver.server.sql.ObjectIdException;
8 import com.lutris.dods.builder.generator.query.DataObjectException;
9
10 import projectmanagement.spec.project.*;
11 import projectmanagement.spec.customer.*;
12 /**
13  * Represents a project.
14  *
15  * @author Sasa Bojanic
16  * @version 1.0
17  */

18 public class ProjectImpl implements Project {
19    /**
20     * The DO of the Project.
21     */

22    protected ProjectDO myDO = null;
23
24    /**
25     * The public constructor.
26     */

27    public ProjectImpl() throws ProjectManagementBusinessException {
28       try {
29          this.myDO = ProjectDO.createVirgin();
30       } catch(DatabaseManagerException ex) {
31          throw new ProjectManagementBusinessException("Error creating empty project", ex);
32       } catch(ObjectIdException ex) {
33          throw new ProjectManagementBusinessException("Error creating object ID for project", ex);
34       }
35    }
36
37    /** The public constructor
38     *
39     * @param theProject. The data object of the project.
40     */

41    public ProjectImpl(ProjectDO theProject) {
42       this.myDO = theProject;
43    }
44
45    /**
46     * Gets the DO object for the project
47     *
48     * @return the DO object.
49     * @exception ProjectManagementBusinessException if an error occurs
50     * retrieving data.
51     */

52    public ProjectDO getDO()
53          throws ProjectManagementBusinessException {
54       if (this.myDO!=null) {
55          return this.myDO;
56       } else {
57          throw new ProjectManagementBusinessException("Error getting DO object for project");
58       }
59    }
60
61    /**
62     * Gets the object id for the project
63     *
64     * @return the object id.
65     * @exception ProjectManagementBusinessException if an error occurs
66     * retrieving data (usually due to an underlying data layer
67     * error).
68     */

69    public String JavaDoc getHandle()
70       throws ProjectManagementBusinessException {
71       try {
72          return this.myDO.getHandle();
73       } catch(DatabaseManagerException ex) {
74          throw new ProjectManagementBusinessException("Error getting handle for project", ex);
75       }
76    }
77
78    /**
79     * Sets the name for the project.
80     *
81     * @param the name.
82     * @exception ProjectManagementBusinessException if an error occurs
83     * setting the data (usually due to an underlying data layer
84     * error).
85     */

86    public void setName(String JavaDoc name)
87       throws ProjectManagementBusinessException {
88       try {
89          myDO.setName(name);
90       } catch(DataObjectException ex) {
91          throw new ProjectManagementBusinessException("Error setting project name", ex);
92       }
93    }
94
95    /**
96     * Gets the name for the project
97     *
98     * @return the name.
99     * @exception ProjectManagementBusinessException if an error occurs
100     * retrieving data (usually due to an underlying data layer
101     * error).
102     */

103    public String JavaDoc getName ()
104       throws ProjectManagementBusinessException {
105       try {
106          return myDO.getName();
107       } catch(DataObjectException ex) {
108          throw new ProjectManagementBusinessException("Error getting project name", ex);
109       }
110    }
111
112    /**
113     * Sets the money per hour for the project.
114     *
115     * @param the money per hour.
116     * @exception ProjectManagementBusinessException if an error occurs
117     * setting the data (usually due to an underlying data layer
118     * error).
119     */

120    public void setMoneyPerHour(double moneyPerHour)
121       throws ProjectManagementBusinessException {
122       try {
123          myDO.setMoneyPerHour(moneyPerHour);
124       } catch(DataObjectException ex) {
125          throw new ProjectManagementBusinessException("Error setting money per hour", ex);
126       }
127    }
128
129    /**
130     * Gets the money per hour for the project
131     *
132     * @return the money per hour.
133     * @exception ProjectManagementBusinessException if an error occurs
134     * retrieving data (usually due to an underlying data layer
135     * error).
136     */

137    public double getMoneyPerHour ()
138       throws ProjectManagementBusinessException {
139       try {
140          return myDO.getMoneyPerHour();
141       } catch(DataObjectException ex) {
142          throw new ProjectManagementBusinessException("Error getting money per hour", ex);
143       }
144    }
145
146    /**
147     * Sets the customer for the project.
148     *
149     * @param the customer.
150     * @exception ProjectManagementBusinessException if an error occurs
151     * setting the data (usually due to an underlying data layer
152     * error).
153     */

154    public void setCustomer(Customer customer)
155       throws ProjectManagementBusinessException {
156       try {
157          myDO.setCustomer(((CustomerImpl)customer).getDO());
158       } catch(DataObjectException ex) {
159          throw new ProjectManagementBusinessException("Error setting customer", ex);
160       }
161    }
162
163    /**
164     * Gets the customer.
165     *
166     * @return the customer.
167     * @exception ProjectManagementBusinessException if an error occurs
168     * retrieving data (usually due to an underlying data layer
169     * error).
170     */

171    public Customer getCustomer()
172       throws ProjectManagementBusinessException {
173       try {
174          return new CustomerImpl(myDO.getCustomer());
175       } catch(DataObjectException ex) {
176          throw new ProjectManagementBusinessException("Error getting customer", ex);
177       }
178    }
179
180    /**
181     * Commits all changes to the database.
182     *
183     * @exception ProjectManagementBusinessException if an error occurs
184     * retrieving data (usually due to an underlying data layer
185     * error).
186     */

187    public void save() throws ProjectManagementBusinessException {
188       try {
189          this.myDO.save();
190       } catch(Exception JavaDoc ex) {
191          throw new ProjectManagementBusinessException("Error saving project", ex);
192       }
193    }
194
195    /**
196     * Deletes the project from database.
197     *
198     * @exception ProjectManagementBusinessException if an error occurs
199     * deleting data (usually due to an underlying data layer
200     * error).
201     */

202    public void delete() throws ProjectManagementBusinessException {
203       try {
204          this.myDO.delete();
205       } catch(Exception JavaDoc ex) {
206          throw new ProjectManagementBusinessException("Error deleting project", ex);
207       }
208    }
209
210 }
211
Popular Tags