Class BTTimesheetShiftCalculation
java.lang.Object
overit.geocall.bl.BusinessTask<TimesheetShiftCalculationEvent>
overit.geocallapp.wfm.core.bl.timesheet.task.BTTimesheet<TimesheetShiftCalculationEvent>
overit.geocallapp.wfm.core.bl.timesheet.task.BTTimesheetShiftCalculation
- All Implemented Interfaces:
Serializable,Tool
@Event(TimesheetShiftCalculationEvent.class)
public class BTTimesheetShiftCalculation
extends BTTimesheet<TimesheetShiftCalculationEvent>
Business task in order to calculate all the shifts linked to a timesheet task,
which can be both
When the
BOWorkShift or BOOnCallShift. When the
TimesheetShiftCalculationEvent is launched
the BT notices the call and calculates all the shifts basing on the event's input. - Since:
- 9.2
- See Also:
- GCApi:
- task
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected TimesheetShiftCalculationOutputbuildInterval(List<BOWorkShift> workShifts, List<BOOnCallShift> onCallShifts, Date startDate, Date endDate) Builds an interval linked to a shift or to an on call shift.protected TimesheetShiftCalculationOutputbuildInterval(overit.geocallapp.wfm.util.timeline.TimeLineRange range) Builds an interval linked to a shift or to an on call shift.protected voidcompleteShiftIds(List<TimesheetShiftCalculationOutput> intervals, Long user, Date timesheetStartDate, Date timesheetEndDate, TimesheetTaskEventCache cache, PoolKit poolKit) Calculates the shift id for intervals that don't have it.protected voidexecute(TimesheetShiftCalculationEvent event, PoolKit poolKit) Writes the results, i.e a list ofTimesheetShiftCalculationOutputinto the event journal.protected List<overit.geocallapp.wfm.util.timeline.TimeLineRange> getRanges(List<BOWorkShift> workShifts, List<BOOnCallShift> onCallShifts, Long user, Date startDate, Date endDate) Builds a new timeline with shifts and on call shifts and extracts the ranges.protected booleanisTimesheetShift(Long shiftId, Date timesheetStartDate, Date timesheetEndDate, TimesheetTaskEventCache cache, PoolKit poolKit) protected List<BOOnCallShift> loadOnCallShifts(Long user, Date startDate, Date endDate, PoolKit poolKit) Loads the on call shifts that overlap the task.protected List<BOWorkShift> loadWorkShifts(Long user, Date startDate, Date endDate, PoolKit poolKit) Loads the work shifts that overlap the task.protected List<TimesheetShiftCalculationOutput> Merges adjacent intervals.Methods inherited from class overit.geocallapp.wfm.core.bl.timesheet.task.BTTimesheet
body, checkTimesheetActivation, throwInactiveTimesheetExceptionMethods inherited from class overit.geocall.bl.BusinessTask
start, start, startAlone, startInBackground
-
Constructor Details
-
BTTimesheetShiftCalculation
public BTTimesheetShiftCalculation()
-
-
Method Details
-
execute
protected void execute(TimesheetShiftCalculationEvent event, PoolKit poolKit) throws DAException, DAValidateException Writes the results, i.e a list ofTimesheetShiftCalculationOutputinto the event journal.- Specified by:
executein classBTTimesheet<TimesheetShiftCalculationEvent>- Parameters:
event- the timesheet calculation eventpoolKit- the pool kit- Throws:
DAException- the DA exceptionDAValidateException- the DA validate exception
-
loadWorkShifts
protected List<BOWorkShift> loadWorkShifts(Long user, Date startDate, Date endDate, PoolKit poolKit) throws DAValidateException, DAException Loads the work shifts that overlap the task.- Parameters:
user- the user idstartDate- the task start dateendDate- the task end datepoolKit- the poolKit- Returns:
- the list of work shift that overlap the task
- Throws:
DAValidateExceptionDAException
-
loadOnCallShifts
protected List<BOOnCallShift> loadOnCallShifts(Long user, Date startDate, Date endDate, PoolKit poolKit) throws DAValidateException, DAException Loads the on call shifts that overlap the task.- Parameters:
user- the user idstartDate- the task start dateendDate- the task end datepoolKit- the poolKit- Returns:
- the list of on call shift that overlap the task
- Throws:
DAValidateExceptionDAException
-
getRanges
protected List<overit.geocallapp.wfm.util.timeline.TimeLineRange> getRanges(List<BOWorkShift> workShifts, List<BOOnCallShift> onCallShifts, Long user, Date startDate, Date endDate) Builds a new timeline with shifts and on call shifts and extracts the ranges.- Parameters:
workShifts- the work shifts related to the taskonCallShifts- the on call shifts related to the taskuser- the user idstartDate- the task start dateendDate- the task end date- Returns:
-
buildInterval
protected TimesheetShiftCalculationOutput buildInterval(overit.geocallapp.wfm.util.timeline.TimeLineRange range) Builds an interval linked to a shift or to an on call shift.- Parameters:
range- the timeline range- Returns:
- a new interval linked to a shift or to an on call shift
-
buildInterval
protected TimesheetShiftCalculationOutput buildInterval(List<BOWorkShift> workShifts, List<BOOnCallShift> onCallShifts, Date startDate, Date endDate) Builds an interval linked to a shift or to an on call shift.- Parameters:
workShifts- the work shifts related to the taskonCallShifts- the on call shifts related to the taskstartDate- the task start dateendDate- the task end date- Returns:
- a new interval linked to a shift or to an on call shift
-
completeShiftIds
protected void completeShiftIds(List<TimesheetShiftCalculationOutput> intervals, Long user, Date timesheetStartDate, Date timesheetEndDate, TimesheetTaskEventCache cache, PoolKit poolKit) throws DAValidateException, DAException Calculates the shift id for intervals that don't have it.- Parameters:
intervals- the list of intervalsuser- the user idtimesheetStartDate- the timesheet start datetimesheetEndDate- the timesheet end datepoolKit- the poolKittimesheetTaskEventCache- the timesheet task event cache- Throws:
DAValidateExceptionDAException
-
isTimesheetShift
protected boolean isTimesheetShift(Long shiftId, Date timesheetStartDate, Date timesheetEndDate, TimesheetTaskEventCache cache, PoolKit poolKit) -
mergeAdjacentIntervals
protected List<TimesheetShiftCalculationOutput> mergeAdjacentIntervals(List<TimesheetShiftCalculationOutput> intervals) Merges adjacent intervals.- Parameters:
intervals- the original list of intervals- Returns:
- a new list of merged adjacent intervals
-