twb 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/twb/dashboard.rb +1 -1
- data/lib/twb/datasource.rb +12 -4
- data/lib/twb/util/twbDashSheetDataDotBuilder.rb +13 -12
- data/lib/twb/workbook.rb +10 -11
- data/lib/twb/worksheet.rb +6 -2
- data/lib/twb.rb +1 -2
- metadata +1 -1
data/lib/twb/dashboard.rb
CHANGED
data/lib/twb/datasource.rb
CHANGED
@@ -73,13 +73,21 @@ module Twb
|
|
73
73
|
def processFields
|
74
74
|
# --
|
75
75
|
@localfields = {}
|
76
|
-
|
76
|
+
@metadatafields = {}
|
77
|
+
return if @connection.nil?
|
78
|
+
## load local fields
|
79
|
+
connClass = @node.at_xpath('./connection').attribute('class').text
|
80
|
+
fxpath = case connClass
|
81
|
+
when 'dataengine' then './column'
|
82
|
+
else './connection/relation/columns/column'
|
83
|
+
end
|
84
|
+
nodes = @node.xpath(fxpath)
|
85
|
+
# puts "DATASOURCE ::=>> @node: connClass: '#{connClass.class}' ::: #{connClass.eql?('dataengine')} fxpath: #{fxpath} :: #{nodes.length}"
|
77
86
|
nodes.each do |node|
|
78
87
|
field = Twb::LocalField.new(node)
|
79
88
|
@localfields[field.name] = field
|
80
89
|
end
|
81
|
-
|
82
|
-
@metadatafields = {}
|
90
|
+
## load metadata fields
|
83
91
|
nodes = @node.xpath("./connection/metadata-records/metadata-record[@class='column']")
|
84
92
|
# note: there are other nodes "<metadata-record class='capability'>" whose nature is unclear
|
85
93
|
# these nodes have no value for their <name node, so we're not loading them
|
@@ -91,4 +99,4 @@ module Twb
|
|
91
99
|
|
92
100
|
end
|
93
101
|
|
94
|
-
end
|
102
|
+
end
|
@@ -59,7 +59,7 @@ module Util
|
|
59
59
|
initDot
|
60
60
|
buildBody(pairs)
|
61
61
|
sameRank([@workbook.name] )
|
62
|
-
sameRank( @workbook.
|
62
|
+
sameRank( @workbook.dashboardNames )
|
63
63
|
sameRank( @workbook.worksheetNames )
|
64
64
|
sameRank( @workbook.datasourceNames )
|
65
65
|
buildHeader
|
@@ -99,11 +99,11 @@ module Util
|
|
99
99
|
@dotFile.puts ' "Workbook" -> "Dashboard" -> "Worksheet" -> "Data Source"'
|
100
100
|
@dotFile.puts ' }'
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
def labelDataSources
|
104
104
|
@dotFile.puts " "
|
105
|
-
|
106
|
-
|
105
|
+
@workbook.datasources.each do |ds|
|
106
|
+
name = ds.name
|
107
107
|
@dotFile.puts " \"#{name}\" [label=\"#{ds.uiname}\"];"
|
108
108
|
end
|
109
109
|
end
|
@@ -117,10 +117,11 @@ module Util
|
|
117
117
|
|
118
118
|
def processDashboards
|
119
119
|
pairs = []
|
120
|
-
@workbook.dashboards.each do |
|
120
|
+
@workbook.dashboards.each do |dash|
|
121
|
+
dashName = dash.name
|
121
122
|
pairs << [@workbook.name,dashName]
|
122
|
-
|
123
|
-
|
123
|
+
dash.worksheets.each do |sheet|
|
124
|
+
sheetName = sheet.name
|
124
125
|
pairs << [dashName,sheetName]
|
125
126
|
@worksheets.delete sheetName
|
126
127
|
end
|
@@ -130,11 +131,11 @@ module Util
|
|
130
131
|
|
131
132
|
def processWorksheets
|
132
133
|
pairs = []
|
133
|
-
|
134
|
-
|
135
|
-
datasources
|
136
|
-
|
137
|
-
pairs
|
134
|
+
@workbook.worksheets.each do |sheet|
|
135
|
+
sheetName = sheet.name
|
136
|
+
sheet.datasources.each do |ds|
|
137
|
+
dsName = ds.name
|
138
|
+
pairs << [sheetName,ds.name]
|
138
139
|
@datasources.delete ds.uiname
|
139
140
|
end
|
140
141
|
end
|
data/lib/twb/workbook.rb
CHANGED
@@ -48,13 +48,12 @@ module Twb
|
|
48
48
|
|
49
49
|
def loaddatasources
|
50
50
|
@dataSourcesNode = @ndoc.at_xpath('//workbook/datasources')
|
51
|
-
@datasources
|
51
|
+
@datasources = {}
|
52
52
|
@datasourceNodes = @ndoc.xpath('//workbook/datasources/datasource').to_a
|
53
53
|
@datasourceNodes.each do |node|
|
54
54
|
datasource = Twb::DataSource.new(node)
|
55
55
|
@datasources[datasource.name] = datasource
|
56
56
|
end
|
57
|
-
return true
|
58
57
|
end
|
59
58
|
|
60
59
|
def loadWorksheets
|
@@ -99,19 +98,19 @@ module Twb
|
|
99
98
|
|
100
99
|
|
101
100
|
def datasources
|
102
|
-
@datasources
|
101
|
+
@datasources.values
|
103
102
|
end
|
104
103
|
|
105
104
|
def dashboards
|
106
|
-
@dashboards
|
105
|
+
@dashboards.values
|
107
106
|
end
|
108
107
|
|
109
108
|
def storyboards
|
110
|
-
@storyboards
|
109
|
+
@storyboards.values
|
111
110
|
end
|
112
111
|
|
113
112
|
def worksheets
|
114
|
-
@worksheets
|
113
|
+
@worksheets.values
|
115
114
|
end
|
116
115
|
|
117
116
|
def datasourceNames
|
@@ -151,7 +150,7 @@ module Twb
|
|
151
150
|
def worksheet name
|
152
151
|
@worksheets[name]
|
153
152
|
end
|
154
|
-
|
153
|
+
|
155
154
|
# Make sure that the TWB has a <dashboards> node.
|
156
155
|
# It's possible for a TWB to have no dashboards, and therefore no <dashboards> node.
|
157
156
|
def ensureDashboardsNodeExists
|
@@ -178,9 +177,9 @@ module Twb
|
|
178
177
|
title = getNewDashboardTitle(docDashboard.title)
|
179
178
|
docDashboard.title=(title) unless title == docDashboard.title
|
180
179
|
@dashesNode.add_child(docDashboard.dashnode)
|
181
|
-
@windowsnode.add_child(docDashboard.winnode)
|
180
|
+
@windowsnode.add_child(docDashboard.winnode)
|
182
181
|
end
|
183
|
-
|
182
|
+
|
184
183
|
def getNewDashboardTitle(t)
|
185
184
|
title = t
|
186
185
|
if @datasources.include?(title)
|
@@ -206,7 +205,7 @@ module Twb
|
|
206
205
|
end
|
207
206
|
return name
|
208
207
|
end
|
209
|
-
|
208
|
+
|
210
209
|
# Write the TWB to a file, appending the base name with the provided string.
|
211
210
|
# Intended for use when making adjustments to the TWB without overwriting the original.
|
212
211
|
def writeAppend(str)
|
@@ -216,4 +215,4 @@ module Twb
|
|
216
215
|
|
217
216
|
end
|
218
217
|
|
219
|
-
end
|
218
|
+
end
|
data/lib/twb/worksheet.rb
CHANGED
data/lib/twb.rb
CHANGED