class Twb::ColumnField
Attributes
XML Attributes known to exist in TWB xml
aggregation aggregation-param alias auto-column caption datatype datatype-customized default-format default-role default-type hidden layered name param-domain-type pivot role semantic-role SplitFieldIndex SplitFieldOrigin type user-datatype value visual-totals
XML Attributes known to exist in TWB xml
aggregation aggregation-param alias auto-column caption datatype datatype-customized default-format default-role default-type hidden layered name param-domain-type pivot role semantic-role SplitFieldIndex SplitFieldOrigin type user-datatype value visual-totals
Public Class Methods
# File lib/twb/columnfield.rb, line 73 def initialize(fieldNode, datasource=nil) @datasource = datasource @node = fieldNode @name = load('name').sub(/^\[/,'').sub(/\]$/,'') @caption = load 'caption' @uiname = @caption.nil? ? @name : @caption #-- loadAttributes @node # @dataType = load 'datatype' # @userDataType = load 'user-datatype' # @defaultFormat = load 'default-format' # @paramDomainType = load 'param-domain-type' # @type = load 'type' # @value = load 'value' # @alias = load 'alias' # @semanticRole = load 'semantic-role' # @aggregation = load 'aggregation' # @autoColumn = load 'auto-column' # @datatypeCustomized = load 'datatype-customized' end
Public Instance Methods
# File lib/twb/columnfield.rb, line 268 def <=>(other) @name <=> other.name end
# File lib/twb/columnfield.rb, line 179 def comment @commentLines ||= loadComment end
# File lib/twb/columnfield.rb, line 272 def eql?(other) @name == other.name end
# File lib/twb/columnfield.rb, line 231 def hasComment? loadComment if @commentLines.nil? @commentLines.empty? end
# File lib/twb/columnfield.rb, line 276 def hash @name.hash end
# File lib/twb/columnfield.rb, line 94 def id @id ||= @id = @name.hash end
# File lib/twb/columnfield.rb, line 98 def load nodeName attr = @node.attribute(nodeName) val = attr.nil? ? nil : attr.text.strip return val end
# File lib/twb/columnfield.rb, line 191 def loadAliases @aliases = {} if hasaliases @node.at_xpath('./aliases//alias').each do |an| dbvalue = an['key'].to_s.gsub(/^["]+/,'').gsub(/["]+$/,'') @aliases[ dbvalue ] = an['value'] end end return @aliases end
# File lib/twb/columnfield.rb, line 104 def loadAttributes node # puts "augmenting with node:#{node}" @node = node if node.has_attribute?('aggregation') then @aggregation = node['aggregation'] end if node.has_attribute?('alias') then @alias = node['alias'] end if node.has_attribute?('auto-column') then @autoColumn = node['auto-column'] end if node.has_attribute?('datatype') then @dataType = node['datatype'] end if node.has_attribute?('datatype-customized') then @datatypeCustomized = node['datatype-customized'] end if node.has_attribute?('default-format') then @defaultFormat = node['default-format'] end if node.has_attribute?('param-domain-type') then @paramDomainType = node['param-domain-type'] end if node.has_attribute?('role') then @role = node['role'] end if node.has_attribute?('semantic-role') then @semanticRole = node['semantic-role'] end if node.has_attribute?('type') then @type = node['type'] end if node.has_attribute?('user-datatype') then @userDataType = node['user-datatype'] end if node.has_attribute?('value') then @value = node['value'] end # loadAttr @aggregation, 'aggregation' # loadAttr @alias, 'alias' # loadAttr @autoColumn, 'auto-column' # loadAttr @dataType, 'datatype' # loadAttr @datatypeCustomized, 'datatype-customized' # loadAttr @defaultFormat, 'default-format' # loadAttr @paramDomainType, 'param-domain-type' # loadAttr @role, 'role' # loadAttr @semanticRole, 'semantic-role' # loadAttr @type, 'type' # loadAttr @userDataType, 'user-datatype' # loadAttr @value, 'value' end
# File lib/twb/columnfield.rb, line 163 def loadCalcField if !@node.at_xpath('./calculation').nil? @calcField = Twb::CalculatedField.new @node, @datasource else @calcField = nil end end
COMMENTED FIELDS
<column caption='Calculation1' datatype='real' name=‘' role='measure' type='quantitative'>
<calculation class='tableau' formula='[Formula Length] * 1.1' /> <desc> <formatted-text> <run>THIS IS A COMMENT</run> </formatted-text> </desc>
</column> <column datatype='string' name='[Data Source Name (tech) (CalculatedFieldsReferencedFields.csv)]' role='dimension' type='nominal'>
<desc> <formatted-text> <run>THIS IS A COMMENT</run> </formatted-text> </desc>
</column>
# File lib/twb/columnfield.rb, line 219 def loadComment @commentLines = [] runs = @node.xpath('./desc/formatted-text/run') runs.each do |run| lines = run.text.split(/\n/) lines.each do |line| @commentLines << line end end return @commentLines end
# File lib/twb/columnfield.rb, line 255 def loadProperties @properties = {} if @properties.nil? @node.attributes.each do |name,attr| @properties[name] = attr.value end @properties[:uiname] = @name return @properties end
# File lib/twb/columnfield.rb, line 175 def pathbare @pathbare ||= path().gsub(/\[\]/,'') end
# File lib/twb/columnfield.rb, line 264 def to_s "n:#{@name}: uin:#{uiname}: " end