Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/taskjuggler/TaskScenario.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1840,14 +1840,17 @@ def bookResources

# We first have to make sure that if there are mandatory resources
# that these are all available for the time slot.
# Note: These log entries can make the report file very long
takenMandatories = []
#Log.msg { "BookResources:Mandatory Check: Start..." }
@mandatories.each do |allocation|
return unless allocation.onShift?(@currentSlotIdx)

# For mandatory allocations with alternatives at least one of the
# alternatives must be available.
found = false
allocation.candidates(@scenarioIdx).each do |candidate|
#Log.msg { "BookResources:Mandatory Check: Checking #{candidate.name}" }
# When a resource group is marked mandatory, all members of the
# group must be available.
allAvailable = true
Expand All @@ -1870,7 +1873,23 @@ def bookResources
end

# At least one mandatory resource is not available. We cannot continue.
Log.msg { "BookResources:Mandatory Check: At least one mandatory resource is not available. T #{@property.fullId}" } unless found
return unless found
#Log.msg { "BookResources:Mandatory Check: All mandatories available. Task #{@property.fullId}" }
end

# Check if any persistent resources are mandatory, and don't make a
# booking if any of them are unavaliable
@allocate.each do |allocation|
next unless allocation.lockedResource && allocation.mandatory
# Make the same check book() does to see if a booking would be succesful,
# and if not return.
allocation.lockedResource.allLeaves.each do |resource|
next if resource.available?(@scenarioIdx, @currentSlotIdx) &&
limitsOk?(@currentSlotIdx, resource) && allocation.onShift?(@currentSlotIdx)
Log.msg { "BookResources:Persistent Mandatory Check: Task #{@property.fullId} Bookings for slot #{@currentSlotIdx} aborted. #{allocation.lockedResource.name}, is persistent and mandatory but not avaliable." }
return
end
end

@allocate.each do |allocation|
Expand All @@ -1884,6 +1903,7 @@ def bookResources

if allocation.atomic &&
locked_candidate.bookedTask(@scenarioIdx, @currentSlotIdx)
Log.msg { "Rolling back #{@property.fullId}."}
rollbackBookings
return
end
Expand Down