KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > projectmanagement > business > timewage > PayRateImpl


1 package projectmanagement.business.timewage;
2
3 import projectmanagement.business.project.*;
4 import projectmanagement.business.employee.*;
5 import projectmanagement.business.ProjectManagementBusinessException;
6 import projectmanagement.data.timewage.*;
7 import com.lutris.appserver.server.sql.DatabaseManagerException;
8 import com.lutris.appserver.server.sql.ObjectIdException;
9 import com.lutris.dods.builder.generator.query.DataObjectException;
10
11 import projectmanagement.spec.timewage.*;
12 import projectmanagement.spec.employee.*;
13 import projectmanagement.spec.project.*;
14
15 import java.sql.Date JavaDoc;
16
17 /**
18  * Represents a pay rate.
19  *
20  * @author Sasa Bojanic
21  * @version 1.0
22  */

23 public class PayRateImpl implements PayRate {
24    /**
25     * The DO of the PayRate.
26     */

27    protected PayRateDO myDO = null;
28
29    /**
30     * The public constructor.
31     */

32    public PayRateImpl() throws ProjectManagementBusinessException {
33       try {
34          this.myDO = PayRateDO.createVirgin();
35       } catch(DatabaseManagerException ex) {
36          throw new ProjectManagementBusinessException("Error creating empty pay rate", ex);
37       } catch(ObjectIdException ex) {
38          throw new ProjectManagementBusinessException("Error creating object ID for pay rate", ex);
39       }
40    }
41
42    /** The public constructor
43     *
44     * @param thePayRate. The data object of the pay rate.
45     */

46    public PayRateImpl(PayRateDO thePayRate) {
47       this.myDO = thePayRate;
48    }
49
50    /**
51     * Gets the DO object for the pay rate
52     *
53     * @return the DO object.
54     * @exception ProjectManagementBusinessException if an error occurs
55     * retrieving data.
56     */

57    public PayRateDO getDO()
58          throws ProjectManagementBusinessException {
59       if (this.myDO!=null) {
60          return this.myDO;
61       } else {
62          throw new ProjectManagementBusinessException("Error getting DO object for pay rate");
63       }
64    }
65
66    /**
67     * Gets the object id for the pay rate
68     *
69     * @return the object id.
70     * @exception ProjectManagementBusinessException if an error occurs
71     * retrieving data (usually due to an underlying data layer
72     * error).
73     */

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

91    public void setRate(double rate)
92       throws ProjectManagementBusinessException {
93       try {
94          myDO.setRate(rate);
95       } catch(DataObjectException ex) {
96          throw new ProjectManagementBusinessException("Error setting pay rate rate", ex);
97       }
98    }
99
100    /**
101     * Gets the rate for the pay rate
102     *
103     * @return the rate.
104     * @exception ProjectManagementBusinessException if an error occurs
105     * retrieving data (usually due to an underlying data layer
106     * error).
107     */

108    public double getRate ()
109       throws ProjectManagementBusinessException {
110       try {
111          return myDO.getRate();
112       } catch(DataObjectException ex) {
113          throw new ProjectManagementBusinessException("Error getting pay rate rate", ex);
114       }
115    }
116
117    /**
118     * Sets the date the payrate is valid from.
119     *
120     * @param the date the payrate is valid from.
121     * @exception ProjectManagementBusinessException if an error occurs
122     * setting the data (usually due to an underlying data layer
123     * error).
124     */

125    public void setValidFrom(Date JavaDoc validFrom)
126       throws ProjectManagementBusinessException {
127       try {
128          myDO.setValidFrom(validFrom);
129       } catch(DataObjectException ex) {
130          throw new ProjectManagementBusinessException("Error setting valid from", ex);
131       }
132    }
133
134    /**
135     * Gets the date the payrate is valid from.
136     *
137     * @return the date the payrate is valid from.
138     * @exception ProjectManagementBusinessException if an error occurs
139     * retrieving data (usually due to an underlying data layer
140     * error).
141     */

142    public Date JavaDoc getValidFrom ()
143       throws ProjectManagementBusinessException {
144       try {
145          return myDO.getValidFrom();
146       } catch(DataObjectException ex) {
147          throw new ProjectManagementBusinessException("Error getting valid from", ex);
148       }
149    }
150
151    /**
152     * Sets the employee for the pay rate.
153     *
154     * @param the employee.
155     * @exception ProjectManagementBusinessException if an error occurs
156     * setting the data (usually due to an underlying data layer
157     * error).
158     */

159    public void setEmployee(Employee employee)
160       throws ProjectManagementBusinessException {
161       try {
162          myDO.setEmployee(((EmployeeImpl)employee).getDO());
163       } catch(DataObjectException ex) {
164          throw new ProjectManagementBusinessException("Error setting employee", ex);
165       }
166    }
167
168    /**
169     * Gets the employee.
170     *
171     * @return the employee.
172     * @exception ProjectManagementBusinessException if an error occurs
173     * retrieving data (usually due to an underlying data layer
174     * error).
175     */

176    public Employee getEmployee()
177       throws ProjectManagementBusinessException {
178       try {
179          return new EmployeeImpl(myDO.getEmployee());
180       } catch(DataObjectException ex) {
181          throw new ProjectManagementBusinessException("Error getting employee", ex);
182       }
183    }
184
185    /**
186     * Sets the project for the pay rate.
187     *
188     * @param the project.
189     * @exception ProjectManagementBusinessException if an error occurs
190     * setting the data (usually due to an underlying data layer
191     * error).
192     */

193    public void setProject(Project project)
194       throws ProjectManagementBusinessException {
195       try {
196          myDO.setProject(((ProjectImpl)project).getDO());
197       } catch(DataObjectException ex) {
198          throw new ProjectManagementBusinessException("Error setting project", ex);
199       }
200    }
201
202    /**
203     * Gets the project.
204     *
205     * @return the project.
206     * @exception ProjectManagementBusinessException if an error occurs
207     * retrieving data (usually due to an underlying data layer
208     * error).
209     */

210    public Project getProject()
211       throws ProjectManagementBusinessException {
212       try {
213          return new ProjectImpl(myDO.getProject());
214       } catch(DataObjectException ex) {
215          throw new ProjectManagementBusinessException("Error getting project", ex);
216       }
217    }
218
219    /**
220     * Commits all changes to the database.
221     *
222     * @exception ProjectManagementBusinessException if an error occurs
223     * retrieving data (usually due to an underlying data layer
224     * error).
225     */

226    public void save() throws ProjectManagementBusinessException {
227       try {
228          this.myDO.save();
229       } catch(Exception JavaDoc ex) {
230          throw new ProjectManagementBusinessException("Error saving pay rate", ex);
231       }
232    }
233
234    /**
235     * Deletes the pay rate from database.
236     *
237     * @exception ProjectManagementBusinessException if an error occurs
238     * deleting data (usually due to an underlying data layer
239     * error).
240     */

241    public void delete() throws ProjectManagementBusinessException {
242       try {
243          this.myDO.delete();
244       } catch(Exception JavaDoc ex) {
245          throw new ProjectManagementBusinessException("Error deleting pay rate", ex);
246       }
247    }
248
249 }
250
Popular Tags