001: /*
002: The contents of this file are subject to the Common Public Attribution License
003: Version 1.0 (the "License"); you may not use this file except in compliance with
004: the License. You may obtain a copy of the License at
005: http://www.projity.com/license . The License is based on the Mozilla Public
006: License Version 1.1 but Sections 14 and 15 have been added to cover use of
007: software over a computer network and provide for limited attribution for the
008: Original Developer. In addition, Exhibit A has been modified to be consistent
009: with Exhibit B.
010:
011: Software distributed under the License is distributed on an "AS IS" basis,
012: WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
013: specific language governing rights and limitations under the License. The
014: Original Code is OpenProj. The Original Developer is the Initial Developer and
015: is Projity, Inc. All portions of the code written by Projity are Copyright (c)
016: 2006, 2007. All Rights Reserved. Contributors Projity, Inc.
017:
018: Alternatively, the contents of this file may be used under the terms of the
019: Projity End-User License Agreeement (the Projity License), in which case the
020: provisions of the Projity License are applicable instead of those above. If you
021: wish to allow use of your version of this file only under the terms of the
022: Projity License and not to allow others to use your version of this file under
023: the CPAL, indicate your decision by deleting the provisions above and replace
024: them with the notice and other provisions required by the Projity License. If
025: you do not delete the provisions above, a recipient may use your version of this
026: file under either the CPAL or the Projity License.
027:
028: [NOTE: The text of this license may differ slightly from the text of the notices
029: in Exhibits A and B of the license at http://www.projity.com/license. You should
030: use the latest text at http://www.projity.com/license for your modifications.
031: You may not remove this license text from the source files.]
032:
033: Attribution Information: Attribution Copyright Notice: Copyright © 2006, 2007
034: Projity, Inc. Attribution Phrase (not exceeding 10 words): Powered by OpenProj,
035: an open source solution from Projity. Attribution URL: http://www.projity.com
036: Graphic Image as provided in the Covered Code as file: openproj_logo.png with
037: alternatives listed on http://www.projity.com/logo
038:
039: Display of Attribution Information is required in Larger Works which are defined
040: in the CPAL as a work which combines Covered Code or portions thereof with code
041: not governed by the terms of the CPAL. However, in addition to the other notice
042: obligations, all copies of the Covered Code in Executable and Source Code form
043: distributed must, as a form of attribution of the original author, include on
044: each user interface screen the "OpenProj" logo visible to all users. The
045: OpenProj logo should be located horizontally aligned with the menu bar and left
046: justified on the top left of the screen adjacent to the File menu. The logo
047: must be at least 100 x 25 pixels. When users click on the "OpenProj" logo it
048: must direct them back to http://www.projity.com.
049: */
050: package com.projity.pm.assignment.timesheet;
051:
052: import java.util.Collection;
053: import java.util.Date;
054:
055: import org.apache.commons.lang.builder.ToStringBuilder;
056:
057: import com.projity.datatype.Rate;
058: import com.projity.field.CanBeDirty;
059: import com.projity.field.FieldContext;
060: import com.projity.functor.IntervalConsumer;
061: import com.projity.graphic.configuration.HasCssStyle;
062: import com.projity.pm.assignment.Assignment;
063: import com.projity.pm.assignment.AssignmentSpecificFields;
064: import com.projity.pm.assignment.TimeDistributedFields;
065: import com.projity.pm.calendar.WorkCalendar;
066: import com.projity.pm.scheduling.Schedule;
067: import com.projity.pm.scheduling.ScheduleInterval;
068: import com.projity.pm.task.HasNotes;
069: import com.projity.pm.task.Project;
070: import com.projity.util.DateTime;
071:
072: public class TimesheetAssignment implements Schedule,
073: AssignmentSpecificFields, TimeDistributedFields,
074: UpdatesFromTimesheet, HasCssStyle, CanBeDirty, Comparable,
075: HasNotes {
076: Assignment assignment;
077: String taskName;
078: String projectName;
079: long projectUniqueId;
080: long taskUniqueId;
081: long resourceUniqueId;
082: boolean alreadyTimesheet = false;
083: Collection parentsNames = null;
084: transient boolean dirty = false;
085:
086: transient String description; //used when sending data to partner
087: private String notes;
088:
089: public final boolean isAlreadyTimesheet() {
090: return alreadyTimesheet;
091: }
092:
093: public final void setAlreadyTimesheet(boolean alreadyTimesheet) {
094: this .alreadyTimesheet = alreadyTimesheet;
095: }
096:
097: public final long getResourceUniqueId() {
098: return resourceUniqueId;
099: }
100:
101: public final long getTaskUniqueId() {
102: return taskUniqueId;
103: }
104:
105: public final Assignment getAssignment() {
106: return assignment;
107: }
108:
109: public final void setAssignment(Assignment assignment) {
110: this .assignment = assignment;
111: }
112:
113: public TimesheetAssignment(String projectName, String taskName,
114: long projectUniqueId, long taskUniqueId,
115: long resourceUniqueId, Assignment assignment, String notes) {
116: this .projectName = projectName;
117: this .taskName = taskName;
118: this .projectUniqueId = projectUniqueId;
119: this .taskUniqueId = taskUniqueId;
120: this .resourceUniqueId = resourceUniqueId;
121: this .assignment = assignment;
122: this .notes = notes;
123: }
124:
125: public long getDuration() {
126: return assignment.getDuration();
127: }
128:
129: public long getEnd() {
130: return assignment.getEnd();
131: }
132:
133: public long getStart() {
134: return assignment.getStart();
135: }
136:
137: public long getActualDuration() {
138: return assignment.getActualDuration();
139: }
140:
141: public long getActualFinish() {
142: return assignment.getActualFinish();
143: }
144:
145: public long getActualStart() {
146: return assignment.getActualStart();
147: }
148:
149: public double getPercentComplete() {
150: return assignment.getPercentComplete();
151: }
152:
153: public long getRemainingDuration() {
154: return assignment.getRemainingDuration();
155: }
156:
157: public long getResume() {
158: return assignment.getResume();
159: }
160:
161: public long getStop() {
162: return assignment.getStop();
163: }
164:
165: public final String getProjectName() {
166: return projectName;
167: }
168:
169: public final void setProjectName(String projectName) {
170: this .projectName = projectName;
171: }
172:
173: public final String getTaskName() {
174: return taskName;
175: }
176:
177: public final void setTaskName(String taskName) {
178: this .taskName = taskName;
179: }
180:
181: public TimesheetAssignment(Assignment assignment) {
182: this .assignment = assignment;
183: }
184:
185: public int getWorkContourType() {
186: return assignment.getWorkContourType();
187: }
188:
189: public void setWorkContourType(int workContourType) {
190: }
191:
192: public long getResourceAvailability() {
193: return assignment.getResourceAvailability();
194: }
195:
196: public String getTaskId() {
197: return taskUniqueId + "";
198: }
199:
200: public String getResourceName() {
201: return null;
202: }
203:
204: public String getResourceId() {
205: return resourceUniqueId + "";
206: }
207:
208: public Rate getRate() {
209: return assignment.getRate();
210: }
211:
212: public void setRate(Rate rate) {
213: assignment.setRate(rate);
214: }
215:
216: public double getCost(FieldContext fieldContext) {
217: return assignment.getCost();
218: }
219:
220: public long getWork(FieldContext fieldContext) {
221: return assignment.getWork(fieldContext);
222: }
223:
224: public void setWork(long work, FieldContext fieldContext) {
225: assignment.setWork(work, fieldContext);
226: }
227:
228: public boolean isReadOnlyWork(FieldContext fieldContext) {
229: return false;
230: }
231:
232: public double getActualCost(FieldContext fieldContext) {
233: return assignment.getActualCost(fieldContext);
234: }
235:
236: public long getActualWork(FieldContext fieldContext) {
237: return assignment.getActualWork(fieldContext);
238: }
239:
240: public void setActualWork(long actualWork, FieldContext fieldContext) {
241: assignment.setActualWork(actualWork, fieldContext);
242:
243: }
244:
245: public boolean isReadOnlyActualWork(FieldContext fieldContext) {
246: return false;
247: }
248:
249: public long getRemainingWork(FieldContext fieldContext) {
250: return assignment.getRemainingWork(fieldContext);
251: }
252:
253: public void setRemainingWork(long remainingWork,
254: FieldContext fieldContext) {
255: assignment.setRemainingWork(remainingWork, fieldContext);
256: }
257:
258: public boolean isReadOnlyRemainingWork(FieldContext fieldContext) {
259: return false;
260: }
261:
262: public double getBaselineCost(int numBaseline,
263: FieldContext fieldContext) {
264: return assignment.getBaselineCost(numBaseline, fieldContext);
265: }
266:
267: public long getBaselineWork(int numBaseline,
268: FieldContext fieldContext) {
269: return assignment.getBaselineWork(numBaseline, fieldContext);
270: }
271:
272: public boolean fieldHideCost(FieldContext fieldContext) {
273: return false;
274: }
275:
276: public boolean fieldHideWork(FieldContext fieldContext) {
277: return false;
278: }
279:
280: public boolean fieldHideBaselineCost(int numBaseline,
281: FieldContext fieldContext) {
282: return false;
283: }
284:
285: public boolean fieldHideBaselineWork(int numBaseline,
286: FieldContext fieldContext) {
287: return false;
288: }
289:
290: public boolean fieldHideActualCost(FieldContext fieldContext) {
291: return false;
292: }
293:
294: public boolean fieldHideActualWork(FieldContext fieldContext) {
295: return false;
296: }
297:
298: public double getFixedCost(FieldContext fieldContext) {
299: return assignment.getFixedCost(fieldContext);
300: }
301:
302: public void setFixedCost(double fixedCost, FieldContext fieldContext) {
303: assignment.setFixedCost(fixedCost, fieldContext);
304: }
305:
306: public boolean isReadOnlyFixedCost(FieldContext fieldContext) {
307: return false;
308: }
309:
310: public double getActualFixedCost(FieldContext fieldContext) {
311: return assignment.getActualFixedCost(fieldContext);
312: }
313:
314: public boolean fieldHideActualFixedCost(FieldContext fieldContext) {
315: return false;
316: }
317:
318: public double getRemainingCost(FieldContext fieldContext) {
319: return assignment.getRemainingCost(fieldContext);
320: }
321:
322: public void setActualStart(long actualStart) {
323: assignment.setActualStart(actualStart);
324:
325: }
326:
327: public void setActualFinish(long actualFinish) {
328: assignment.setActualFinish(actualFinish);
329: }
330:
331: public void setActualDuration(long actualDuration) {
332: assignment.setActualDuration(actualDuration);
333: }
334:
335: public void setRemainingDuration(long remainingDuration) {
336: assignment.setRemainingDuration(remainingDuration);
337: }
338:
339: public void setPercentComplete(double percentComplete) {
340: assignment.setPercentComplete(percentComplete);
341: }
342:
343: public void setDuration(long duration) {
344: assignment.setDuration(duration);
345: }
346:
347: public long getElapsedDuration() {
348: return assignment.getElapsedDuration();
349: }
350:
351: public long getDependencyStart() {
352: return assignment.getDependencyStart();
353: }
354:
355: public void setDependencyStart(long dependencyStart) {
356: assignment.setDependencyStart(dependencyStart);
357: }
358:
359: public void setResume(long resume) {
360: assignment.setResume(resume);
361: }
362:
363: public void setStop(long stop) {
364: assignment.setStop(stop);
365: }
366:
367: public void clearDuration() {
368: assignment.clearDuration();
369: }
370:
371: public void moveRemainingToDate(long date) {
372: assignment.moveRemainingToDate(date);
373: }
374:
375: public void moveInterval(Object eventSource, long start, long end,
376: ScheduleInterval oldInterval, boolean isChild) {
377: assignment.moveInterval(eventSource, start, end, oldInterval,
378: isChild);
379: }
380:
381: public void consumeIntervals(IntervalConsumer consumer) {
382: assignment.consumeIntervals(consumer);
383: }
384:
385: public WorkCalendar getEffectiveWorkCalendar() {
386: return assignment.getEffectiveWorkCalendar();
387: }
388:
389: public void split(Object eventSource, long from, long to) {
390: assignment.split(eventSource, from, to);
391: }
392:
393: public boolean isJustModified() {
394: return assignment.isJustModified();
395: }
396:
397: public void setStart(long start) {
398: assignment.setStart(start);
399: }
400:
401: public void setEnd(long end) {
402: assignment.setEnd(end);
403: }
404:
405: public boolean isComplete() {
406: return assignment.isComplete();
407: }
408:
409: public void setComplete(boolean complete) {
410: assignment.setComplete(complete);
411: }
412:
413: public Project getProject() {
414: return assignment.getOwningProject();
415: }
416:
417: public long getTimesheetFinish() {
418: return assignment.getTimesheetFinish();
419: }
420:
421: public long getTimesheetStart() {
422: return assignment.getTimesheetStart();
423: }
424:
425: public long getLastTimesheetUpdate() {
426: return assignment.getLastTimesheetUpdate();
427: }
428:
429: public boolean applyTimesheet(Collection fieldArray,
430: long timesheetUpdateDate) {
431: return false;
432: }
433:
434: public boolean isPendingTimesheetUpdate() {
435: return assignment.isPendingTimesheetUpdate();
436: }
437:
438: public int getTimesheetStatus() {
439: return assignment.getTimesheetStatus();
440: }
441:
442: public String getTimesheetStatusName() {
443: return assignment.getTimesheetStatusName();
444: }
445:
446: public String getCssStyleClass() {
447: return getTimesheetStatusName();
448: }
449:
450: public void setHierarchy(Collection parentsNames) {
451: this .parentsNames = parentsNames;
452: }
453:
454: public Collection getHierarchy() {
455: return parentsNames;
456: }
457:
458: public boolean isIntegratedOrComplete() {
459: if (getTimesheetStatus() == TimesheetStatus.INTEGRATED)
460: return true;
461: if (getTimesheetStatus() == TimesheetStatus.VALIDATED) // validated timesheets must always be shown in dialog till integrated
462: return false;
463: return isComplete();
464: }
465:
466: public final boolean isDirty() {
467: return dirty;
468: }
469:
470: public final void setDirty(boolean dirty) {
471: this .dirty = dirty;
472: }
473:
474: public long getCachedStart() {
475: Date d = assignment.getCachedStart();
476: if (d == null)
477: return 0;
478: d = DateTime.fromGmt(d);
479: return d.getTime();
480: }
481:
482: public long getCachedEnd() {
483: Date d = assignment.getCachedEnd();
484: if (d == null)
485: return 0;
486: return DateTime.gmt(d);
487: // return d.getTime();
488: }
489:
490: public int compareTo(Object arg0) {
491: return com.projity.util.MathUtils.signum(getCachedStart()
492: - ((TimesheetAssignment) arg0).getCachedStart());
493: }
494:
495: public long getReadOnlyDuration() {
496: return getDuration();
497: }
498:
499: public final long getEarliestStop() {
500: return assignment.getEarliestStop();
501: }
502:
503: public final long getCompletedThrough() {
504: return assignment.getCompletedThrough();
505: }
506:
507: public void setCompletedThrough(long completedThrough) {
508: assignment.setCompletedThrough(completedThrough);
509: }
510:
511: public final String getDescription() {
512: return description;
513: }
514:
515: public final void setDescription(String description) {
516: this .description = description;
517: }
518:
519: public String toExternalId() {
520: return taskUniqueId + "/" + resourceUniqueId;
521: }
522:
523: public Object backupDetail() {
524: // TODO Auto-generated method stub
525: return null;
526: }
527:
528: public void restoreDetail(Object source, Object detail,
529: boolean isChild) {
530: // TODO Auto-generated method stub
531:
532: }
533:
534: public long getProjectUniqueId() {
535: return projectUniqueId;
536: }
537:
538: public void setProjectUniqueId(long projectUniqueId) {
539: this .projectUniqueId = projectUniqueId;
540: }
541:
542: public String toString() {
543: return ToStringBuilder.reflectionToString(this );
544: }
545:
546: public String getNotes() {
547: return notes;
548: }
549:
550: public void setNotes(String notes) {
551: this.notes = notes;
552: }
553:
554: }
|