Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New: Allow not-yet declared resources for 'managers' and 'responsible'.

  • Loading branch information...
commit 035e8bf453539883516536124211a3db28136118 1 parent 022e4e3
@scrapper scrapper authored
View
49 lib/taskjuggler/ResourceScenario.rb
@@ -73,8 +73,6 @@ def initialize(resource, scenarioIdx, attributes)
def prepareScheduling
@effort = 0
initScoreboard if @property.leaf?
-
- setDirectReports
end
# The criticalness of a resource is a measure for the probabilty that all
@@ -97,17 +95,35 @@ def calcCriticalness
end
def setDirectReports
- # Only leaf resources have reporting lines.
- return unless @property.leaf?
-
- # The 'directreports' attribute is the reverse link for the 'managers'
- # attribute. In contrast to the 'managers' attribute, the
- # 'directreports' list has no duplicate entries.
- @managers.each do |manager|
- unless manager['directreports', @scenarioIdx].include?(@property)
- manager['directreports', @scenarioIdx] << @property
+ @managers.map! do |managerId|
+ # First we need to map 'managerId' to an existing Resource.
+ if (manager = @project.resource(managerId)).nil?
+ error('resource_id_expected', "#{managerId} is not a defined " +
+ 'resource.', @sourceFileInfo)
+ end
+ unless manager.leaf?
+ error('manager_is_group',
+ "Resource #{@property.fullId} has group #{manager.fullId} " +
+ "assigned as manager. Managers must be leaf resources.")
+ end
+ if manager == @property
+ error('manager_is_self',
+ "Resource #{@property.fullId} cannot manage itself.")
+ end
+
+ # Only leaf resources have reporting lines.
+ if @property.leaf?
+ # The 'directreports' attribute is the reverse link for the 'managers'
+ # attribute. In contrast to the 'managers' attribute, the
+ # 'directreports' list has no duplicate entries.
+ unless manager['directreports', @scenarioIdx].include?(@property)
+ manager['directreports', @scenarioIdx] << @property
+ end
end
+
+ manager
end
+ @managers.uniq!
end
def setReports
@@ -119,17 +135,6 @@ def setReports
end
def preScheduleCheck
- @managers.each do |manager|
- unless manager.leaf?
- error('manager_is_group',
- "Resource #{@property.fullId} has group #{manager.fullId} " +
- "assigned as manager. Managers must be leaf resources.")
- end
- if manager == @property
- error('manager_is_self',
- "Resource #{@property.fullId} cannot manage itself.")
- end
- end
end
# This method does some housekeeping work after the scheduling is
View
14 lib/taskjuggler/TaskScenario.rb
@@ -30,7 +30,8 @@ def initialize(task, scenarioIdx, attributes)
competitors criticalness depends duration
effort end forward gauge length
maxend maxstart minend minstart milestone pathcriticalness
- precedes priority scheduled shifts start status ).each do |attr|
+ precedes priority responsible
+ scheduled shifts start status ).each do |attr|
@property[attr, @scenarioIdx]
end
@@ -203,6 +204,17 @@ def preScheduleCheck
end
end
+ @responsible.map! do |resourceId|
+ # 'resource' is still just an ID and needs to be converted into a
+ # Resource.
+ if (resource = @project.resource(resourceId)).nil?
+ error('resource_id_expected', "#{resourceId} is not a defined " +
+ 'resource.', @sourceFileInfo)
+ end
+ resource
+ end
+ @responsible.uniq!
+
# Leaf tasks can be turned into containers after bookings have been added.
# We need to check for this.
unless @property.leaf? || @booking.empty?
View
9 lib/taskjuggler/TjpSyntaxRules.rb
@@ -4780,7 +4780,7 @@ def rule_resourceLeafList
end
def rule_resourceList
- listRule('moreResources', '!resourceId')
+ listRule('moreResources', '!undefResourceId')
end
def rule_resourceReport
@@ -7353,6 +7353,13 @@ def rule_tsTaskHeader
arg(1, 'task', 'ID of an already existing task')
end
+ def rule_undefResourceId
+ pattern(%w( $ID ), lambda {
+ (@resourceprefix.empty? ? '' : @resourceprefix + '.') + @val[0]
+ })
+ arg(0, 'resource', 'The ID of a defined resource')
+ end
+
def rule_vacationName
optional
pattern(%w( $STRING )) # We just throw the name away
Please sign in to comment.
Something went wrong with that request. Please try again.