001: package projectmanagement.business.timewage;
002:
003: import projectmanagement.business.project.*;
004: import projectmanagement.business.employee.*;
005: import projectmanagement.business.ProjectManagementBusinessException;
006: import projectmanagement.data.timewage.*;
007: import com.lutris.appserver.server.sql.DatabaseManagerException;
008: import com.lutris.appserver.server.sql.ObjectIdException;
009: import com.lutris.dods.builder.generator.query.DataObjectException;
010:
011: import projectmanagement.spec.timewage.*;
012: import projectmanagement.spec.employee.*;
013: import projectmanagement.spec.project.*;
014:
015: import java.sql.Date;
016:
017: /**
018: * Represents a pay rate.
019: *
020: * @author Sasa Bojanic
021: * @version 1.0
022: */
023: public class PayRateImpl implements PayRate {
024: /**
025: * The DO of the PayRate.
026: */
027: protected PayRateDO myDO = null;
028:
029: /**
030: * The public constructor.
031: */
032: public PayRateImpl() throws ProjectManagementBusinessException {
033: try {
034: this .myDO = PayRateDO.createVirgin();
035: } catch (DatabaseManagerException ex) {
036: throw new ProjectManagementBusinessException(
037: "Error creating empty pay rate", ex);
038: } catch (ObjectIdException ex) {
039: throw new ProjectManagementBusinessException(
040: "Error creating object ID for pay rate", ex);
041: }
042: }
043:
044: /** The public constructor
045: *
046: * @param thePayRate. The data object of the pay rate.
047: */
048: public PayRateImpl(PayRateDO thePayRate) {
049: this .myDO = thePayRate;
050: }
051:
052: /**
053: * Gets the DO object for the pay rate
054: *
055: * @return the DO object.
056: * @exception ProjectManagementBusinessException if an error occurs
057: * retrieving data.
058: */
059: public PayRateDO getDO() throws ProjectManagementBusinessException {
060: if (this .myDO != null) {
061: return this .myDO;
062: } else {
063: throw new ProjectManagementBusinessException(
064: "Error getting DO object for pay rate");
065: }
066: }
067:
068: /**
069: * Gets the object id for the pay rate
070: *
071: * @return the object id.
072: * @exception ProjectManagementBusinessException if an error occurs
073: * retrieving data (usually due to an underlying data layer
074: * error).
075: */
076: public String getHandle() throws ProjectManagementBusinessException {
077: try {
078: return this .myDO.getHandle();
079: } catch (DatabaseManagerException ex) {
080: throw new ProjectManagementBusinessException(
081: "Error getting handle for pay rate", ex);
082: }
083: }
084:
085: /**
086: * Sets the rate for the pay rate.
087: *
088: * @param the rate.
089: * @exception ProjectManagementBusinessException if an error occurs
090: * setting the data (usually due to an underlying data layer
091: * error).
092: */
093: public void setRate(double rate)
094: throws ProjectManagementBusinessException {
095: try {
096: myDO.setRate(rate);
097: } catch (DataObjectException ex) {
098: throw new ProjectManagementBusinessException(
099: "Error setting pay rate rate", ex);
100: }
101: }
102:
103: /**
104: * Gets the rate for the pay rate
105: *
106: * @return the rate.
107: * @exception ProjectManagementBusinessException if an error occurs
108: * retrieving data (usually due to an underlying data layer
109: * error).
110: */
111: public double getRate() throws ProjectManagementBusinessException {
112: try {
113: return myDO.getRate();
114: } catch (DataObjectException ex) {
115: throw new ProjectManagementBusinessException(
116: "Error getting pay rate rate", ex);
117: }
118: }
119:
120: /**
121: * Sets the date the payrate is valid from.
122: *
123: * @param the date the payrate is valid from.
124: * @exception ProjectManagementBusinessException if an error occurs
125: * setting the data (usually due to an underlying data layer
126: * error).
127: */
128: public void setValidFrom(Date validFrom)
129: throws ProjectManagementBusinessException {
130: try {
131: myDO.setValidFrom(validFrom);
132: } catch (DataObjectException ex) {
133: throw new ProjectManagementBusinessException(
134: "Error setting valid from", ex);
135: }
136: }
137:
138: /**
139: * Gets the date the payrate is valid from.
140: *
141: * @return the date the payrate is valid from.
142: * @exception ProjectManagementBusinessException if an error occurs
143: * retrieving data (usually due to an underlying data layer
144: * error).
145: */
146: public Date getValidFrom()
147: throws ProjectManagementBusinessException {
148: try {
149: return myDO.getValidFrom();
150: } catch (DataObjectException ex) {
151: throw new ProjectManagementBusinessException(
152: "Error getting valid from", ex);
153: }
154: }
155:
156: /**
157: * Sets the employee for the pay rate.
158: *
159: * @param the employee.
160: * @exception ProjectManagementBusinessException if an error occurs
161: * setting the data (usually due to an underlying data layer
162: * error).
163: */
164: public void setEmployee(Employee employee)
165: throws ProjectManagementBusinessException {
166: try {
167: myDO.setEmployee(((EmployeeImpl) employee).getDO());
168: } catch (DataObjectException ex) {
169: throw new ProjectManagementBusinessException(
170: "Error setting employee", ex);
171: }
172: }
173:
174: /**
175: * Gets the employee.
176: *
177: * @return the employee.
178: * @exception ProjectManagementBusinessException if an error occurs
179: * retrieving data (usually due to an underlying data layer
180: * error).
181: */
182: public Employee getEmployee()
183: throws ProjectManagementBusinessException {
184: try {
185: return new EmployeeImpl(myDO.getEmployee());
186: } catch (DataObjectException ex) {
187: throw new ProjectManagementBusinessException(
188: "Error getting employee", ex);
189: }
190: }
191:
192: /**
193: * Sets the project for the pay rate.
194: *
195: * @param the project.
196: * @exception ProjectManagementBusinessException if an error occurs
197: * setting the data (usually due to an underlying data layer
198: * error).
199: */
200: public void setProject(Project project)
201: throws ProjectManagementBusinessException {
202: try {
203: myDO.setProject(((ProjectImpl) project).getDO());
204: } catch (DataObjectException ex) {
205: throw new ProjectManagementBusinessException(
206: "Error setting project", ex);
207: }
208: }
209:
210: /**
211: * Gets the project.
212: *
213: * @return the project.
214: * @exception ProjectManagementBusinessException if an error occurs
215: * retrieving data (usually due to an underlying data layer
216: * error).
217: */
218: public Project getProject()
219: throws ProjectManagementBusinessException {
220: try {
221: return new ProjectImpl(myDO.getProject());
222: } catch (DataObjectException ex) {
223: throw new ProjectManagementBusinessException(
224: "Error getting project", ex);
225: }
226: }
227:
228: /**
229: * Commits all changes to the database.
230: *
231: * @exception ProjectManagementBusinessException if an error occurs
232: * retrieving data (usually due to an underlying data layer
233: * error).
234: */
235: public void save() throws ProjectManagementBusinessException {
236: try {
237: this .myDO.save();
238: } catch (Exception ex) {
239: throw new ProjectManagementBusinessException(
240: "Error saving pay rate", ex);
241: }
242: }
243:
244: /**
245: * Deletes the pay rate from database.
246: *
247: * @exception ProjectManagementBusinessException if an error occurs
248: * deleting data (usually due to an underlying data layer
249: * error).
250: */
251: public void delete() throws ProjectManagementBusinessException {
252: try {
253: this .myDO.delete();
254: } catch (Exception ex) {
255: throw new ProjectManagementBusinessException(
256: "Error deleting pay rate", ex);
257: }
258: }
259:
260: }
|