lib/TaskJuggler.rb in taskjuggler-0.0.6 vs lib/TaskJuggler.rb in taskjuggler-0.0.7
- old
+ new
@@ -43,21 +43,33 @@
@parser = ProjectFileParser.new(@messageHandler)
files.each do |file|
begin
@parser.open(file, master)
- rescue TjException
+ rescue TjException => msg
+ if msg.message && !msg.message.empty?
+ @messageHandler.critical('parse', msg.message)
+ end
Log.exit('parser')
return false
end
if master
- @project = @parser.parse('project')
+ # The first file is considered the master file.
+ if (@project = @parser.parse('project')) == false
+ Log.exit('parser')
+ return false
+ end
master = false
else
+ # All other files.
@parser.setGlobalMacros
- @parser.parse('properties')
+ if @parser.parse('properties') == false
+ Log.exit('parser')
+ return false
+ end
end
+ @project.inputFiles << file
@parser.close
end
# For the report server mode we may need to keep the parser. Otherwise,
# destroy it.
@@ -68,24 +80,43 @@
end
# Parse a file and add the content to the existing project. _fileName_ is
# the name of the file. _rule_ is the TextParser::Rule to start with.
def parseFile(fileName, rule)
- @parser.open(fileName, false)
+ begin
+ @parser.open(fileName, false)
+ @project.inputFiles << fileName
+ rescue TjException => msg
+ if msg.message && !msg.message.empty?
+ @messageHandler.critical('parse_file', msg.message)
+ end
+ return nil
+ end
+
@parser.setGlobalMacros
- return nil if (res = @parser.parse(rule)).nil?
+ return nil if (res = @parser.parse(rule)) == false
+
@parser.close
res
end
# Schedule all scenarios in the project. Return true if no error was
# detected, false otherwise.
def schedule
Log.enter('scheduler', 'Scheduling project ...')
#puts @project.to_s
@project.warnTsDeltas = @warnTsDeltas
- res = @project.schedule
+
+ begin
+ res = @project.schedule
+ rescue TjException => msg
+ if msg.message && !msg.message.empty?
+ @messageHandler.critical('scheduling_error', msg.message)
+ end
+ return false
+ end
+
Log.exit('scheduler')
res
end
# Generate all specified reports. The project must have be scheduled before
@@ -93,13 +124,22 @@
# otherwise.
def generateReports(outputDir = './')
outputDir += '/' unless outputDir.empty? || outputDir[-1] == '/'
@project.outputDir = outputDir
Log.enter('reports', 'Generating reports ...')
- res = @project.generateReports(@maxCpuCores)
+
+ begin
+ @project.generateReports(@maxCpuCores)
+ rescue TjException => msg
+ if msg.message && !msg.message.empty?
+ @messageHandler.critical('generate_reports', msg.message)
+ end
+ return false
+ end
+
Log.exit('reports')
- res
+ true
end
# Generate the report with the ID _reportId_. If _regExpMode_ is true,
# _reportId_ is interpreted as a Regular Expression and all reports with
# matching IDs are generated. _dynamicAtributes_ is a String that may
@@ -107,26 +147,31 @@
# in TJP format and may be nil if no additional attributes are provided.
def generateReport(reportId, regExpMode, dynamicAttributes = nil)
begin
Log.enter('generateReport', 'Generating report #{reportId} ...')
@project.generateReport(reportId, regExpMode, dynamicAttributes)
- rescue TjException
+ rescue TjException => msg
+ if msg.message && !msg.message.empty?
+ @messageHandler.critical('generate_report', msg.message)
+ end
Log.exit('generateReport')
return false
end
Log.exit('generateReport')
true
end
- # Generate the report with the ID _reportId_. If _regExpMode_ is true,
- # _reportId_ is interpreted as a Regular Expression and all reports with
- # matching IDs are listed.
+ # List the details of the report with _reportId_ or if _regExpMode_ the
+ # reports that match the regular expression in _reportId_.
def listReports(reportId, regExpMode)
begin
Log.enter('listReports', 'Generating report list for #{reportId} ...')
@project.listReports(reportId, regExpMode)
- rescue TjException
+ rescue TjException => msg
+ if msg.message && !msg.message.empty?
+ @messageHandler.critical('list_reports', msg.message)
+ end
Log.exit('listReports')
return false
end
Log.exit('listReports')
true
@@ -147,21 +192,18 @@
'property' => ts.resource,
'scopeProperty' => nil,
'scenarioIdx' => @project['trackingScenarioIdx'],
'start' => ts.interval.start,
'end' => ts.interval.end,
- 'timeFormat' => '%Y-%m-%d' }
+ 'timeFormat' => '%Y-%m-%d',
+ 'selfContained' => true }
query = Query.new(queryAttrs)
- rti = ts.resource.query_journal(query)
- rti.lineWidth = 72
- rti.indent = 2
- rti.titleIndent = 0
- rti.listIndent = 2
- rti.parIndent = 2
- rti.preIndent = 4
- puts rti.to_s
- rescue TjException
+ puts ts.resource.query_journal(query).richText.inputText
+ rescue TjException => msg
+ if msg.message && !msg.message.empty?
+ @messageHandler.critical('check_time_sheet', msg.message)
+ end
Log.exit('checkTimeSheet')
return false
end
Log.exit('checkTimeSheet')
true
@@ -179,20 +221,17 @@
'scopeProperty' => nil,
'scenarioIdx' => @project['trackingScenarioIdx'],
'timeFormat' => '%Y-%m-%d',
'start' => ss[1],
'end' => ss[2],
- 'timeFormat' => '%Y-%m-%d' }
+ 'timeFormat' => '%Y-%m-%d',
+ 'selfContained' => true }
query = Query.new(queryAttrs)
- rti = ss[0].query_dashboard(query)
- rti.lineWidth = 72
- rti.indent = 2
- rti.titleIndent = 0
- rti.listIndent = 2
- rti.parIndent = 2
- rti.preIndent = 4
- puts rti.to_s
- rescue TjException
+ puts ss[0].query_dashboard(query).richText.inputText
+ rescue TjException => msg
+ if msg.message && !msg.message.empty?
+ @messageHandler.critical('check_status_sheet', msg.message)
+ end
Log.exit('checkStatusSheet')
return false
end
Log.exit('checkStatusSheet')
true