NAME
App::Dochazka::REST::Model::Tempintvls - object class for "scratch schedules"
SYNOPSIS
use App::Dochazka::REST::Model::Tempintvls;
...
METHODS
tiid
If tiid attribute has been populated, return it. If it hasn't been, populate it and return it.
populate
Called automatically when new object is instantiated; assigns next TIID.
_vet_tsrange
Takes a DBIx::Connector
object and a tsrange. Checks the tsrange for sanity and populates the tsrange
, lower_canon
, lower_ymd
, upper_canon
, upper_ymd
attributes. Returns a status object.
The algorithm for generating fillup intervals takes lower and upper date bounds - it does not know about timestamps or tsranges
_vet_employee
Expects to be called *after* _vet_tsrange
.
Takes a DBIx::Connector
object and an employee object. First, retrieves from the database the employee object corresponding to the EID. Second, checks that the employee's privlevel did not change during the tsrange. Third, retrieves the prevailing schedule and checks that the schedule does not change at all during the tsrange. Returns a status object.
_vet_activity
Takes a DBIx::Connector
object and an AID. Verifies that the AID exists and populates the activity_obj
attribute.
vet
Calls the _vet_tsrange
, _vet_employee
, and _vet_activity
methods.
vetted
Returns boolean true if object has been completely vetted. Otherwise false.
fillup
Takes a DBIx::Connector
object. In addition, it optionally takes an include_holidays
boolean flag, which defaults to 0. This method expects to be called on a fully vetted object (see vetted
, above).
This method attempts to INSERT records into the tempintvls table according to the tsrange and the employee's schedule. Returns a status object.
Note that this method does not create any attendance intervals. If the fillup operation is successful, the payload will contain a list of attendance intervals that will be created if the commit
method is called.
new
Constructor using all of the above. Returns a status object. If successful, level will be 'OK' and tempintvls object will be in the payload.
dump
Takes a PARAMHASH containing a DBIx::Connector
object and a tiid
property. Returns all intervals matching that tiid
.
commit
Takes a PARAMHASH containing a DBIx::Connector
object and, optionally, a dry_run
boolean value that defaults to 0.
If dry_run
is true, merely SELECTs intervals from the tempintvls table corresponding to the tsrange (already vetted and stored in the object by calling _vet_tsrange
). This SELECT includes partial intervals (if any) at the beginning and end of the tsrange (using PostgreSQL intersection operator).
If dry_run
is false, all the intervals from the SELECT are INSERTed into the intervals table.
update
There is no update method for tempintvls. Instead, delete and re-create.
DESTROY
Instance destructor. Once we are done with the scratch intervals, they can be deleted. Returns a status object.
FUNCTIONS
_next_tiid
Get next value from the temp_intvl_seq sequence
Days_to_Date
Missing function in Date::Calc
_init_lower_sched_hash
Given schedule hash (JSON string from database), return schedule hash keyed on the "low_dow" property. In other words, convert the schedule to hash format keyed on numeric form of "low_dow" i.e. 1 for MON, 2 for TUE, etc. The values are references to arrays containing the entries beginning on the given DOW.
AUTHOR
Nathan Cutler, <presnypreklad@gmail.com>