class Twb::ColumnField

Attributes

aggregation[R]
alias[R]
aliases[R]
autoColumn[R]
calcField[R]
caption[R]
dataType[R]
datatypeCustomized[R]
defaultFormat[R]
hasaliases[R]
hidden[R]
name[R]
node[R]

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

paramDomainType[R]
path[R]
properties[R]

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

role[R]
semanticRole[R]
type[R]
uiname[R]
value[R]

Public Class Methods

new(fieldNode, datasource=nil) click to toggle source
# 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

<=>(other) click to toggle source
# File lib/twb/columnfield.rb, line 268
def <=>(other)
  @name <=> other.name
end
comment() click to toggle source
# File lib/twb/columnfield.rb, line 179
def comment
  @commentLines ||= loadComment
end
eql?(other) click to toggle source
# File lib/twb/columnfield.rb, line 272
def eql?(other)
  @name == other.name
end
hasComment?() click to toggle source
# File lib/twb/columnfield.rb, line 231
def hasComment?
  loadComment if @commentLines.nil?
  @commentLines.empty?
end
hash() click to toggle source
# File lib/twb/columnfield.rb, line 276
 def hash
  @name.hash
end
id() click to toggle source
# File lib/twb/columnfield.rb, line 94
def id
    @id ||= @id = @name.hash
end
load(nodeName) click to toggle source
# File lib/twb/columnfield.rb, line 98
def load nodeName
  attr = @node.attribute(nodeName)
  val  = attr.nil? ? nil : attr.text.strip
  return val
end
loadAliases() click to toggle source
# 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
loadAttributes(node) click to toggle source
# 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
loadCalcField() click to toggle source
# 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
loadComment() click to toggle source

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
loadProperties() click to toggle source
# 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
pathbare() click to toggle source
# File lib/twb/columnfield.rb, line 175
def pathbare
  @pathbare ||= path().gsub(/\[\]/,'')
end
to_s() click to toggle source
# File lib/twb/columnfield.rb, line 264
def to_s
  "n:#{@name}: uin:#{uiname}: "
end