001: package com.technoetic.xplanner.domain;
002:
003: import com.technoetic.xplanner.XPlannerProperties;
004:
005: public class TimeEntry extends DomainObject {
006: private int taskId;
007: private java.util.Date startTime;
008: private java.util.Date endTime;
009: private double duration;
010: private int person1Id;
011: private int person2Id;
012: private java.util.Date reportDate;
013: private String description;
014:
015: public TimeEntry() {
016: }
017:
018: public TimeEntry(int id) {
019: setId(id);
020: }
021:
022: public int getTaskId() {
023: return taskId;
024: }
025:
026: public void setTaskId(int taskId) {
027: this .taskId = taskId;
028: }
029:
030: public void setStartTime(java.util.Date startTime) {
031: this .startTime = startTime;
032: }
033:
034: public java.util.Date getStartTime() {
035: return startTime;
036: }
037:
038: public void setEndTime(java.util.Date endTime) {
039: this .endTime = endTime;
040: }
041:
042: public java.util.Date getEndTime() {
043: return endTime;
044: }
045:
046: public void setPerson1Id(int person1Id) {
047: this .person1Id = person1Id;
048: }
049:
050: public int getPerson1Id() {
051: return person1Id;
052: }
053:
054: public void setPerson2Id(int person2Id) {
055: this .person2Id = person2Id;
056: }
057:
058: public int getPerson2Id() {
059: return person2Id;
060: }
061:
062: public double getDuration() {
063: if (startTime != null && endTime != null) {
064: duration = (endTime.getTime() - startTime.getTime()) / 3600000.0;
065: }
066: return duration;
067: }
068:
069: /**
070: * The classic way for XPlanner to calculate "effort" is in idea wall clock time or
071: * pair-programming hours. Some teams would like to do labor tracking using XPlanner
072: * and want to double the effort measured for a paired time entry.
073: *
074: * This behavior is configurable in xplanner.properties.
075: * @return measured effort
076: */
077: public double getEffort() {
078: boolean adjustHoursForPairing = "double"
079: .equalsIgnoreCase(new XPlannerProperties().getProperty(
080: "xplanner.pairprogramming", "single"));
081: boolean isPairedEntry = person1Id != 0 && person2Id != 0;
082: return (adjustHoursForPairing && isPairedEntry) ? getDuration() * 2
083: : getDuration();
084: }
085:
086: public void setDuration(double duration) {
087: this .duration = duration;
088: }
089:
090: public java.util.Date getReportDate() {
091: return reportDate;
092: }
093:
094: public void setReportDate(java.util.Date reportDate) {
095: this .reportDate = reportDate;
096: }
097:
098: public String getDescription() {
099: return description;
100: }
101:
102: public void setDescription(String description) {
103: this .description = description;
104: }
105:
106: public boolean isCurrentlyActive(int personId) {
107: return startTime != null && endTime == null && duration == 0
108: && (personId == person1Id || personId == person2Id);
109: }
110:
111: //DEBT: LSP violation. Should have a class of domain object that are not Nameable
112: public String getName() {
113: return "";
114: }
115:
116: public String toString() {
117: return "TimeEntry(id=" + this .getId() + ", person1Id="
118: + this .getPerson1Id() + ", person2Id="
119: + this .getPerson2Id() + ", taskId=" + this .getTaskId()
120: + ", startTime=" + this .getStartTime() + ", endTime="
121: + this .getEndTime() + ", description="
122: + this .getDescription() + ")";
123: }
124:
125: }
|