Class: TaskJuggler::MspXmlRE

Inherits:
ReportBase show all
Defined in:
lib/taskjuggler/reports/MspXmlRE.rb

Overview

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.

Instance Method Summary collapse

Methods inherited from ReportBase

#a, #filterAccountList, #filterResourceList, #filterTaskList

Constructor Details

#initialize(report) ⇒ MspXmlRE

Create a new object and set some default values.



26
27
28
29
30
31
32
33
34
35
36
# 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

Instance Method Details

#generateIntermediateFormatObject



38
39
40
# File 'lib/taskjuggler/reports/MspXmlRE.rb', line 38

def generateIntermediateFormat
  super
end

#to_mspxmlObject

Return the project data in Microsoft Project XML format.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 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