Holger's
Java API

com.antelmann.timeregister
Class WorkUnitAnalyzer

java.lang.Object
  extended by com.antelmann.timeregister.WorkUnitAnalyzer

public class WorkUnitAnalyzer
extends Object

maintains and analyzes set of WorkUnit objects.

Author:
Holger Antelmann

Constructor Summary
WorkUnitAnalyzer()
           
WorkUnitAnalyzer(Collection<WorkUnit> col)
           
 
Method Summary
 boolean add(WorkUnit unit)
           
 void filter(Filter<WorkUnit> filter)
           
 Set<String> getActivities()
          returns a set of activity Strings that are contained in this analyzer (null not included)
 DefaultTableModel getActivityTableModel()
          the returned table model contains two columns, the first (a String) denotes the activity and the second (a Long) denotes the time
 HashMap<String,Long> getActivityTimes()
          all units mapped to no activity are mapped through the key null in the map.
 long getBreakTime()
           
 Set<WorkUnit> getCorrespondingToPunchData(PunchDB db, boolean returnThoseThatCorrespond)
          returns those WorkUnits that do or do not directly correspond to a punch pair in the given database.
 Date getFirstDate()
           
 Date getLastDate()
           
 long getNetTime()
           
 long getNetTime(WorkUnit.Type type)
           
<T> HashMap<T,Long>
getNetTimes(PatternExtractor<WorkUnit,T> pattern)
           
 Set<WorkUnit> getOverlappingUnits()
          returns a set of WorkUnit objects that cause conflicts in this analyzer
 long getSickTime()
          time including pauses
 long getSpecialAssignmentTime()
          time including pauses
 long getTime()
          time including pauses
 long getTime(WorkUnit.Type type)
          time including pauses
<T> HashMap<T,Long>
getTimes(PatternExtractor<WorkUnit,T> pattern)
           
 Set<User> getUsers()
          returns a set of all users currently in this analyzer
 long getVacationTime()
          time including pauses
 long getWorkingTime()
          time including pauses
 List<WorkUnit> getWorkUnits(TimeUser user, Date beginFrom, Date beginUntil, String location)
          selects both dates inclusive
 List<WorkUnit> getWorkUnitsFor(User user, Date date)
          returns those WorkUnits that enclose the given date; user constrain may be null
static Filter<WorkUnit> makeFilter(User user, Date beginFrom, Date beginUntil, String activity, String comment)
          selects both dates inclusive
 WorkUnit overlappingUnit(WorkUnit unit)
          checks whether a unit exists that overlaps with the given one and returns it.
 void refresh(Collection<WorkUnit> col, Filter<WorkUnit> filter)
          updates this analyzer with the given data; the filter may be null; duplicates are left out
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkUnitAnalyzer

public WorkUnitAnalyzer()

WorkUnitAnalyzer

public WorkUnitAnalyzer(Collection<WorkUnit> col)
Method Detail

refresh

public void refresh(Collection<WorkUnit> col,
                    Filter<WorkUnit> filter)
updates this analyzer with the given data; the filter may be null; duplicates are left out


size

public int size()

add

public boolean add(WorkUnit unit)

getWorkUnitsFor

public List<WorkUnit> getWorkUnitsFor(User user,
                                      Date date)
returns those WorkUnits that enclose the given date; user constrain may be null


getUsers

public Set<User> getUsers()
returns a set of all users currently in this analyzer


getOverlappingUnits

public Set<WorkUnit> getOverlappingUnits()
returns a set of WorkUnit objects that cause conflicts in this analyzer


overlappingUnit

public WorkUnit overlappingUnit(WorkUnit unit)
checks whether a unit exists that overlaps with the given one and returns it. if no overlap exists, null is returned; if multiple units overlap, the first one found is returned.


filter

public void filter(Filter<WorkUnit> filter)

getBreakTime

public long getBreakTime()

getNetTime

public long getNetTime(WorkUnit.Type type)

getNetTime

public long getNetTime()

getWorkingTime

public long getWorkingTime()
time including pauses


getSickTime

public long getSickTime()
time including pauses


getSpecialAssignmentTime

public long getSpecialAssignmentTime()
time including pauses


getVacationTime

public long getVacationTime()
time including pauses


getTime

public long getTime(WorkUnit.Type type)
time including pauses


getTime

public long getTime()
time including pauses


getActivities

public Set<String> getActivities()
returns a set of activity Strings that are contained in this analyzer (null not included)


getActivityTimes

public HashMap<String,Long> getActivityTimes()
all units mapped to no activity are mapped through the key null in the map. Note that the activity time is the net time, i.e. w/o breaks.


getFirstDate

public Date getFirstDate()

getLastDate

public Date getLastDate()

getActivityTableModel

public DefaultTableModel getActivityTableModel()
the returned table model contains two columns, the first (a String) denotes the activity and the second (a Long) denotes the time


getCorrespondingToPunchData

public Set<WorkUnit> getCorrespondingToPunchData(PunchDB db,
                                                 boolean returnThoseThatCorrespond)
                                          throws DatabaseException
returns those WorkUnits that do or do not directly correspond to a punch pair in the given database.

Throws:
DatabaseException

getTimes

public <T> HashMap<T,Long> getTimes(PatternExtractor<WorkUnit,T> pattern)

getNetTimes

public <T> HashMap<T,Long> getNetTimes(PatternExtractor<WorkUnit,T> pattern)

getWorkUnits

public List<WorkUnit> getWorkUnits(TimeUser user,
                                   Date beginFrom,
                                   Date beginUntil,
                                   String location)
selects both dates inclusive


makeFilter

public static Filter<WorkUnit> makeFilter(User user,
                                          Date beginFrom,
                                          Date beginUntil,
                                          String activity,
                                          String comment)
selects both dates inclusive



(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads