com.atlassian.greenhopper.model.timetracking
Class WorklogTimeline

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<java.lang.String,java.util.SortedMap<org.joda.time.DateMidnight,DayWorkHistory>>
          extended by com.atlassian.greenhopper.model.timetracking.WorklogTimeline
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.util.SortedMap<org.joda.time.DateMidnight,DayWorkHistory>>

public class WorklogTimeline
extends java.util.HashMap<java.lang.String,java.util.SortedMap<org.joda.time.DateMidnight,DayWorkHistory>>

Stores the history of work done and remaining estimate, per issue.

Logged work and remaining estimate are different in concept, since logged work is an event at a particular point in time, whereas remaining estimate is a value that spans time between events (before - after). Since the values stored are just points in time, remaining estimate totals have to be calculated (see computeTotalRemainingEstimate())

The generic type is intentionally set to TreeMap. First, this is necessary for the correct working of this class. Second, it allows us some optimisations in navigating the Map.

Author:
ahennecke
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
WorklogTimeline()
           
 
Method Summary
 long computeRemainingEstimate(java.lang.String issueKey, org.joda.time.DateMidnight day)
          Returns the remaining estimate valid for the given issue on the given day.
 long computeTimeSpentSince(org.joda.time.DateMidnight day)
          Compute the cumulative time spent since the given day (inclusive) up to now.
 long computeTotalRemainingEstimate(org.joda.time.DateMidnight day)
          Compute the remaining estimate at the end of the given day, for all issues..
 DayWorkHistory getEntryAtDay(java.lang.String issueKey, org.joda.time.DateMidnight day)
          Return the DayWorkHistory entry at the given day for the given issue, or null if there is no such entry.
 boolean hasEntryAtDay(java.lang.String issueKey, org.joda.time.DateMidnight day)
           
 void putEntry(java.lang.String issueKey, org.joda.time.DateMidnight day, DayWorkHistory history)
          Add an entry for the given Issue key on the given day.
 java.util.Map<org.joda.time.DateMidnight,java.util.List<DayWorkHistory>> transpose()
          Transpose the map so that the days become the keys and the values are Lists of DayWorkHistory objects.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

WorklogTimeline

public WorklogTimeline()
Method Detail

computeTotalRemainingEstimate

public long computeTotalRemainingEstimate(org.joda.time.DateMidnight day)
Compute the remaining estimate at the end of the given day, for all issues.. Work logged or issues created after that day will not be taken into account.

Parameters:
day - : the day to compute the estimate for, inclusive
Returns:
: total remaining estimate on the given day for all issues in the timeline

computeRemainingEstimate

public long computeRemainingEstimate(java.lang.String issueKey,
                                     org.joda.time.DateMidnight day)
Returns the remaining estimate valid for the given issue on the given day. If there is no estimate change that day, the value from the last previous change is used. If there is no remaining estimate registered at all, 0 is returned.

Parameters:
issueKey - : the key of the issue to look for
day - : the day to look at
Returns:
remaining estimate valid that day, in seconds

computeTimeSpentSince

public long computeTimeSpentSince(org.joda.time.DateMidnight day)
Compute the cumulative time spent since the given day (inclusive) up to now.

Parameters:
day - : The day to start computing
Returns:
: The cumulative time spent, over all issues, since the given day

transpose

public java.util.Map<org.joda.time.DateMidnight,java.util.List<DayWorkHistory>> transpose()
Transpose the map so that the days become the keys and the values are Lists of DayWorkHistory objects. This is useful if log times need to be calculated by day.

Returns:
a new Map with the transposed entries

hasEntryAtDay

public boolean hasEntryAtDay(java.lang.String issueKey,
                             org.joda.time.DateMidnight day)
Returns:
if the timeline contains an entry for the given issue and the given day

getEntryAtDay

public DayWorkHistory getEntryAtDay(java.lang.String issueKey,
                                    org.joda.time.DateMidnight day)
Return the DayWorkHistory entry at the given day for the given issue, or null if there is no such entry.

Parameters:
issueKey - : The key of the issue
day - : The day to get the entry for
Returns:
the entry for the day and issue, or null

putEntry

public void putEntry(java.lang.String issueKey,
                     org.joda.time.DateMidnight day,
                     DayWorkHistory history)
Add an entry for the given Issue key on the given day. If a previous entry existed, it will be overwritten (Map-Put-behaviour).



Copyright © 2007-2011 Atlassian. All Rights Reserved.