001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: EmployeeDO.java,v $
031: * Revision 1.9 2005/10/11 18:53:07 colinmacleod
032: * Fixed some checkstyle and javadoc issues.
033: *
034: * Revision 1.8 2005/10/03 10:21:13 colinmacleod
035: * Fixed some style and javadoc issues.
036: *
037: * Revision 1.7 2005/10/02 14:08:55 colinmacleod
038: * Added/improved log4j logging.
039: *
040: * Revision 1.6 2005/09/29 13:22:44 colinmacleod
041: * Added read-only functionality to data object classes (with a check on each
042: * setter).
043: *
044: * Revision 1.5 2005/09/15 10:23:23 colinmacleod
045: * Upgraded Maven to 1.1 (beta-2).
046: * Upgraded Hibernate to 3.0.5.
047: *
048: * Revision 1.4 2005/09/14 14:52:01 colinmacleod
049: * Added serialVersionUID.
050: *
051: * Revision 1.3 2005/04/10 20:09:35 colinmacleod
052: * Added new themes.
053: * Changed id type to String.
054: * Changed i tag to em and b tag to strong.
055: * Improved PicoContainerFactory with NanoContainer scripts.
056: *
057: * Revision 1.2 2005/04/09 17:19:07 colinmacleod
058: * Changed copyright text to GPL v2 explicitly.
059: *
060: * Revision 1.1.1.1 2005/03/10 17:50:31 colinmacleod
061: * Restructured ivata op around Hibernate/PicoContainer.
062: * Renamed ivata groupware.
063: *
064: * Revision 1.3 2004/07/13 19:41:13 colinmacleod
065: * Moved project to POJOs from EJBs.
066: * Applied PicoContainer to services layer (replacing session EJBs).
067: * Applied Hibernate to persistence layer (replacing entity EJBs).
068: *
069: * Revision 1.2 2004/03/21 21:16:06 colinmacleod
070: * Shortened name to ivata op.
071: *
072: * Revision 1.1.1.1 2004/01/27 20:57:50 colinmacleod
073: * Moved ivata openportal to SourceForge..
074: *
075: * Revision 1.3 2003/10/17 12:36:12 jano
076: * fixing problems with building
077: * converting intranet -> portal
078: * Eclipse building
079: *
080: * Revision 1.2 2003/10/15 13:18:02 colin
081: * fixing for XDoclet
082: *
083: * Revision 1.1 2003/02/24 19:09:21 colin
084: * moved to business
085: *
086: * Revision 1.2 2003/02/04 17:43:45 colin
087: * copyright notice
088: *
089: * Revision 1.1 2002/08/30 09:52:02 colin
090: * added new employee EJB
091: * -----------------------------------------------------------------------------
092: */
093: package com.ivata.groupware.business.addressbook.person.employee;
094:
095: import org.apache.log4j.Logger;
096:
097: import com.ivata.groupware.business.addressbook.address.country.CountryDO;
098: import com.ivata.groupware.container.persistence.BaseDO;
099:
100: /**
101: * <p>Tracks which people are employees and the number of vacation days they
102: * have remaining for the current calendar year.</p>
103: *
104: * @since ivata groupware 0.9 (2002-08-30)
105: * @author Colin MacLeod
106: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
107: * @version $Revision: 1.9 $
108: *
109: * @hibernate.class
110: * table="person_employee"
111: * @hibernate.cache
112: * usage="read-write"
113: */
114: public class EmployeeDO extends BaseDO {
115: /**
116: * Logger for this class.
117: */
118: private static final Logger logger = Logger
119: .getLogger(EmployeeDO.class);
120:
121: /**
122: * Static definitiaion of the display value prefix.
123: */
124: public static final String DISPLAY_VALUE_PREFIX = "[employee] ";
125: /**
126: * Serialization version (for <code>Serializable</code> interface).
127: */
128: private static final long serialVersionUID = 1L;
129: /**
130: * <p>Store the country for this employee.</p>
131: */
132: private CountryDO country;
133:
134: /**
135: * <p>Store the internal company employee number. This number is used
136: * by the client company for reference/internal use and is not required by
137: * the ivata groupware system.</p>
138: */
139: private String number;
140:
141: /**
142: * <p>Store the region for this employee. The region code together with the
143: * country code is used to filter the employee's public holidays in the
144: * calendar.</p>
145: */
146: private String regionCode;
147:
148: /**
149: * <p>Store the total number of days vacation this employee has for the
150: * current calendar year. <strong>Note:</strong> this is the total number of
151: * days for the employee, not the number of days remaining. The system
152: * calculates the days remaining by adding all previous vacation days within
153: * the current calendar year.</p>
154: */
155: private Integer vacationDays;
156:
157: /**
158: * <p>Get the country for this employee.</p>
159: *
160: * @return the country for the employee.
161: * @hibernate.many-to-one
162: * column="address_country"
163: */
164: public final CountryDO getCountry() {
165: if (logger.isDebugEnabled()) {
166: logger.debug("getCountry() - start");
167: }
168:
169: if (logger.isDebugEnabled()) {
170: logger.debug("getCountry() - end - return value = "
171: + country);
172: }
173: return country;
174: }
175:
176: /**
177: * Just returns the text "[employee] " followed by the employee number.
178: * <copyDoc>Refer to {@link #getName}.</copyDoc>
179: * @return <copyDoc>Refer to {@link #getName}.</copyDoc>
180: */
181: public String getDisplayValue() {
182: if (logger.isDebugEnabled()) {
183: logger.debug("getDisplayValue() - start");
184: }
185:
186: String returnString = DISPLAY_VALUE_PREFIX + getNumber();
187: if (logger.isDebugEnabled()) {
188: logger.debug("getDisplayValue() - end - return value = "
189: + returnString);
190: }
191: return returnString;
192: }
193:
194: /**
195: * <p>
196: * Unique identifier of this data object.
197: * </p>
198: *
199: * NOTE: this is a hibernate one-to-one relationship with person, so we
200: * need no generator here...
201: * @return {@inheritDoc}
202: * @hibernate.id
203: * generator-class = "assigned"
204: */
205: public final Integer getId() {
206: if (logger.isDebugEnabled()) {
207: logger.debug("getId() - start");
208: }
209:
210: Integer returnInteger = super .getId();
211: if (logger.isDebugEnabled()) {
212: logger.debug("getId() - end - return value = "
213: + returnInteger);
214: }
215: return returnInteger;
216: }
217:
218: /**
219: * <p>Get the internal company employee number. This number is used
220: * by the client company for reference/internal use and is not required by
221: * the ivata groupware system.</p>
222: *
223: * @return employee number, for company records. Need not be numeric only.
224: * @hibernate.property
225: * column="number"
226: */
227: public final String getNumber() {
228: if (logger.isDebugEnabled()) {
229: logger.debug("getNumber() - start");
230: }
231:
232: if (logger.isDebugEnabled()) {
233: logger
234: .debug("getNumber() - end - return value = "
235: + number);
236: }
237: return number;
238: }
239:
240: /**
241: * <p>Get the region for this employee. The region code together with the
242: * country code is used to filter the employee's public holidays in the
243: * calendar.</p>
244: *
245: * @return text value for the region code.
246: * @hibernate.property
247: * column="region_code"
248: */
249: public final String getRegionCode() {
250: if (logger.isDebugEnabled()) {
251: logger.debug("getRegionCode() - start");
252: }
253:
254: if (logger.isDebugEnabled()) {
255: logger.debug("getRegionCode() - end - return value = "
256: + regionCode);
257: }
258: return regionCode;
259: }
260:
261: /**
262: * <p>Get the total number of days vacation this employee has for the
263: * current calendar year. <strong>Note:</strong> this is the total number of
264: * days for the employee, not the number of days remaining. The system
265: * calculates the days remaining by adding all previous vacation days within
266: * the current calendar year.</p>
267: *
268: * @return total number of days vacation for this employee for the current
269: * calendar year.
270: * @hibernate.property
271: * column="vacation_days"
272: */
273: public final Integer getVacationDays() {
274: if (logger.isDebugEnabled()) {
275: logger.debug("getVacationDays() - start");
276: }
277:
278: if (logger.isDebugEnabled()) {
279: logger.debug("getVacationDays() - end - return value = "
280: + vacationDays);
281: }
282: return vacationDays;
283: }
284:
285: /**
286: * <p>Set the country for this employee.</p>
287: *
288: * @param countryParam new value of the country for the employee.
289: */
290: public final void setCountry(final CountryDO countryParam) {
291: if (logger.isDebugEnabled()) {
292: logger.debug("setCountry(CountryDO country = "
293: + countryParam + ") - start");
294: }
295:
296: checkSetter();
297: this .country = countryParam;
298:
299: if (logger.isDebugEnabled()) {
300: logger.debug("setCountry(CountryDO) - end");
301: }
302: }
303:
304: /**
305: * <p>Set the internal company employee number. This number is used
306: * by the client company for reference/internal use and is not required by
307: * the ivata groupware system.</p>
308: *
309: * @param numberParam employee number, for company records. Need not be
310: * numeric only.
311: */
312: public final void setNumber(final String numberParam) {
313: if (logger.isDebugEnabled()) {
314: logger.debug("setNumber(String number = " + numberParam
315: + ") - start");
316: }
317:
318: checkSetter();
319: this .number = numberParam;
320:
321: if (logger.isDebugEnabled()) {
322: logger.debug("setNumber(String) - end");
323: }
324: }
325:
326: /**
327: * <p>Set the region for this employee. The region code together with the
328: * country code is used to filter the employee's public holidays in the
329: * calendar.</p>
330: *
331: * @param regionCodeParam new text value for the region code. Can be a
332: * maximum of ten characters.
333: */
334: public final void setRegionCode(final String regionCodeParam) {
335: if (logger.isDebugEnabled()) {
336: logger.debug("setRegionCode(String regionCode = "
337: + regionCodeParam + ") - start");
338: }
339:
340: checkSetter();
341: this .regionCode = regionCodeParam;
342:
343: if (logger.isDebugEnabled()) {
344: logger.debug("setRegionCode(String) - end");
345: }
346: }
347:
348: /**
349: * <p>Set the total number of days vacation this employee has for the
350: * current calendar year. <strong>Note:</strong> this is the total number of
351: * days for the employee, not the number of days remaining. The system
352: * calculates the days remaining by adding all previous vacation days within
353: * the current calendar year.</p>
354: *
355: * @param vacationDaysParam total number of days vacation for this employee
356: * for the current calendar year.
357: */
358: public final void setVacationDays(final Integer vacationDaysParam) {
359: if (logger.isDebugEnabled()) {
360: logger.debug("setVacationDays(Integer vacationDays = "
361: + vacationDaysParam + ") - start");
362: }
363:
364: checkSetter();
365: this .vacationDays = vacationDaysParam;
366:
367: if (logger.isDebugEnabled()) {
368: logger.debug("setVacationDays(Integer) - end");
369: }
370: }
371: }
|