001: /*
002: * Copyright (c) 2004-2006, Jean-François Brazeau. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * 1. Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * 2. Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in the
012: * documentation and/or other materials provided with the distribution.
013: *
014: * 3. The name of the author may not be used to endorse or promote products
015: * derived from this software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
018: * IMPLIEDWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
019: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
020: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
021: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
022: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
023: * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
024: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
025: * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
026: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: */
028: package jfb.tools.activitymgr.core.beans;
029:
030: import java.util.Calendar;
031: import java.util.GregorianCalendar;
032:
033: /**
034: * Contribution d'un collaborateur à une tache.
035: */
036: public class Contribution {
037:
038: /** Année */
039: private int year;
040:
041: /** Mois */
042: private int month;
043:
044: /** Jour */
045: private int day;
046:
047: /** Identifiant du collaborateur */
048: private long contributorId;
049:
050: /** Identifiant de la tache */
051: private long taskId;
052:
053: /** Durée */
054: private long durationId;
055:
056: /**
057: * @return l'identifiant du collaborateur.
058: */
059: public long getContributorId() {
060: return contributorId;
061: }
062:
063: /**
064: * Définit l'identifiant du collaborateur.
065: * @param contributorId le nouvel identifiant.
066: */
067: public void setContributorId(long contributorId) {
068: this .contributorId = contributorId;
069: }
070:
071: /**
072: * @return la durée.
073: */
074: public long getDurationId() {
075: return durationId;
076: }
077:
078: /**
079: * Définit la durée.
080: * @param duration la nouvelle durée.
081: */
082: public void setDurationId(long duration) {
083: this .durationId = duration;
084: }
085:
086: /**
087: * @return l'identifiant de la tache.
088: */
089: public long getTaskId() {
090: return taskId;
091: }
092:
093: /**
094: * Définit l'identifiant de la tache.
095: * @param taskId le nouvel identifiant.
096: */
097: public void setTaskId(long taskId) {
098: this .taskId = taskId;
099: }
100:
101: /**
102: * @return le jour de la contribution.
103: */
104: public int getDay() {
105: return day;
106: }
107:
108: /**
109: * Définit le jour de la contribution.
110: * @param day le nouveau jour.
111: */
112: public void setDay(int day) {
113: this .day = day;
114: }
115:
116: /**
117: * @return le mois de la contribution.
118: */
119: public int getMonth() {
120: return month;
121: }
122:
123: /**
124: * Définit le mois de la contribution.
125: * @param month le nouveau mois.
126: */
127: public void setMonth(int month) {
128: this .month = month;
129: }
130:
131: /**
132: * @return l'année de la contribution.
133: */
134: public int getYear() {
135: return year;
136: }
137:
138: /**
139: * Définit l'année de la contribution.
140: * @param year la nouvelle année.
141: */
142: public void setYear(int year) {
143: this .year = year;
144: }
145:
146: /**
147: * Définit la date associée à la contribution.
148: * @param date la nouvelle date.
149: */
150: public void setDate(Calendar date) {
151: setYear(date.get(Calendar.YEAR));
152: setMonth(date.get(Calendar.MONTH) + 1);
153: setDay(date.get(Calendar.DAY_OF_MONTH));
154: }
155:
156: /**
157: * @return la date associée à la contribution.
158: */
159: public Calendar getDate() {
160: GregorianCalendar cal = new GregorianCalendar(year, month - 1,
161: day);
162: return cal;
163: }
164:
165: /* (non-Javadoc)
166: * @see java.lang.Object#equals(java.lang.Object)
167: */
168: public boolean equals(Object obj) {
169: boolean equals = false;
170: if (obj != null && obj instanceof Contribution) {
171: Contribution other = (Contribution) obj;
172: equals = (other.year == year);
173: equals &= (other.month == month);
174: equals &= (other.day == day);
175: equals &= (other.contributorId == contributorId);
176: equals &= (other.taskId == taskId);
177: }
178: return equals;
179: }
180:
181: }
|