Fuego.Fdi : Absence

An instance of the Absence component defines an absence period for a human participant, and includes a list of human participants who can replace the absentee's work items.

To read or assign absence periods to a human participant, use the DirHumanParticipant.absencePeriods attribute, which is an array of Absence objects. Use method DirHumanParticipant.getAbsenceFor(Time) to obtain the absence period of a participant for a given point in time.

Example 1

The following example retrieves all absence periods for the current participant:

// Load current participant
session = DirectorySession.currentEngineSession
currentPart = DirHumanParticipant.fetch(session : session,
                                        id : Participant.id)

// iterate over the absence periods defined for
// this participant
for each absence in currentPart.absencePeriods
do
    logMessage "Absence Period: " + absence
end

Example 2

The following example adds an absence period for the current participant. The absent participant will be replaced by participants joe and sarah for the next 15 days:

// Create new absence period
newAbsence = Absence.create(from : 'now',
                       @to : 'now'+'15d',
		       replacements : ["joe", "sarah"])

// Load current participant
session = DirectorySession.currentEngineSession
currentPart = DirHumanParticipant.fetch(session : session,
                                        id : Participant.id)

// Add new absence to participant and save
currentPart.absencePeriods[]  = newAbsence
update currentPart