class TaskJuggler::MspXmlRE

This specialization of ReportBase implements an export of the project data into Microsoft Project XML format. Due to limitations of MS Project and this implementation, only a subset of core data is being exported. The exported data is already a scheduled project with full resource/task assignment data.

Public Class Methods

new(report) click to toggle source

Create a new object and set some default values.

Calls superclass method
# File lib/taskjuggler/reports/MspXmlRE.rb, line 26
def initialize(report)
  super(report)

  # This report type currently only supports a single scenario. Use the
  # first specified one.
  @scenarioIdx = a('scenarios').first

  # Hash to map calendar names to UIDs (numbers).
  @calendarUIDs = {}
  @timeformat = "%Y-%m-%dT%H:%M:%S"
end

Public Instance Methods

generateIntermediateFormat() click to toggle source
Calls superclass method
# File lib/taskjuggler/reports/MspXmlRE.rb, line 38
def generateIntermediateFormat
  super
end
to_mspxml() click to toggle source

Return the project data in Microsoft Project XML format.

# File lib/taskjuggler/reports/MspXmlRE.rb, line 43
    def to_mspxml
      @query = @project.reportContexts.last.query.dup

      # Prepare the resource list.
      @resourceList = PropertyList.new(@project.resources)
      @resourceList.setSorting(a('sortResources'))
      @resourceList = filterResourceList(@resourceList, nil, a('hideResource'),
                                         a('rollupResource'), a('openNodes'))
      @resourceList.sort!

      # Prepare the task list.
      @taskList = PropertyList.new(@project.tasks)
      @taskList.includeAdopted
      # The MSP XML format requires that the tasks are listed in 'tree' order.
      # We purposely ignore the user provided sorting criteria.
      @taskList.setSorting([ [ 'tree', true, -1 ],
                             [ 'seqno', true, -1 ] ])
      @taskList = filterTaskList(@taskList, nil, a('hideTask'), a('rollupTask'),
                                 a('openNodes'))
      @taskList.sort!
      @taskList.checkForDuplicates(@report.sourceFileInfo)

      @file = XMLDocument.new
      @file << XMLBlob.new('<?xml version="1.0" encoding="UTF-8" ' +
                           'standalone="yes"?>')
      @file << XMLComment.new(<<"EOT"
Generated by #{AppConfig.softwareName} v#{AppConfig.version} on #{TjTime.new}
For more information about #{AppConfig.softwareName} see #{AppConfig.contact}.
Project: #{@project['name']}
Date:    #{@project['now']}
EOT
                             )
      @file << (project =
                XMLElement.new('Project',
                               'xmlns' =>
                               'http://schemas.microsoft.com/project'))

      calendars = generateProjectAttributes(project)
      generateTasks(project)
      generateResources(project, calendars)
      generateAssignments(project)

      @file.to_s
    end