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