Class: Twb::Analysis::DataSources::DataSourceFieldsAnalyzer
- Inherits:
-
Object
- Object
- Twb::Analysis::DataSources::DataSourceFieldsAnalyzer
- Includes:
- TabTool
- Defined in:
- lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb
Constant Summary collapse
- @@fullFileType =
'DataSourceFieldsDetails'- @@fullFileName =
@@fullFileType + '.csv'
- @@fullHeader =
[ 'Record #', 'Workbook', 'Workbook Directory', 'Data Source', 'Field', 'Field - tech', 'Field - source', 'Field - class', 'Field - path', 'Property - Name', 'Property - Value' ]
- @@colsFileType =
'DataSourceFields'- @@colsFileName =
@@colsFileType + '.csv'
- @@colsHeader =
[ 'Record #', 'Workbook', 'Workbook Directory', 'Data Source', 'Field - tech', 'Caption', 'Field', 'Alias', 'Datatype', 'Datatype-customized', 'Default Format', 'Param-domain-type', 'Role', 'Type', 'Calculated?', 'Value', 'Hidden', 'Path' ]
Instance Attribute Summary collapse
-
#csvFileName ⇒ Object
readonly
Returns the value of attribute csvFileName.
-
#csvRecords ⇒ Object
readonly
Returns the value of attribute csvRecords.
-
#dsCount ⇒ Object
readonly
Returns the value of attribute dsCount.
-
#fieldsCount ⇒ Object
readonly
Returns the value of attribute fieldsCount.
Attributes included from TabTool
#alerts, #docDir, #docfiles, #funcdoc, #id, #licensed, #logfilename, #logger, #loglevel, #properties, #ttdocdir, #type, #uuid
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**args) ⇒ DataSourceFieldsAnalyzer
constructor
A new instance of DataSourceFieldsAnalyzer.
-
#metrics ⇒ Object
‘Workbook’, ‘Data Source’, ‘Field - tech’, ‘caption’, ‘uiname’, ‘alias’, ‘datatype’, ‘datatype-customized’, ‘default-format’, ‘param-domain-type’, ‘role’, ‘type’, ‘value’ ].
-
#processColumnFields(ds) ⇒ Object
def processTwb twb.
- #processTWB(twb) ⇒ Object
Methods included from TabTool
#addDocFile, #alert, #closeDocFiles, #config, #docFile, #docFileMaxNameLen, #docfilesdoc, #docfilesdocto_s, #emit, #emitCSV, #finis, #hasConfig, #init, #initCSV, #initDocDir, #initLogger, #license=, #licensed?, #loadConfig
Constructor Details
#initialize(**args) ⇒ DataSourceFieldsAnalyzer
Returns a new instance of DataSourceFieldsAnalyzer.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb', line 67 def initialize(**args) emit "DataSourceFieldsAnalyzer initialize(**args) args: #{args}" @args = args @recordDir = !@args.nil? && @args[:recordDir] == true @ttdocdir = @args[:ttdocdir] @csvAdd = args[:csvMode] == :add @csvMode = @csvAdd ? 'a' : 'w' init @funcdoc = {:class=>self.class, :blurb=>'Analyze Data Source Fields', :description=>'Documents Data Source fields, with (some) technical information.',} #-- detailsFileName = docFile(@@fullFileName) @csvFile = CSV.open( detailsFileName,@csvMode ) #-- colsFileName = docFile(@@colsFileName) @colsFile = CSV.open( colsFileName, @csvMode ) #-- unless @csvAdd @csvFile << @@fullHeader @colsFile << @@colsHeader end addDocFile @csvFile, detailsFileName, "Workbooks, Data Sources, and Fields' details (technical use)." addDocFile @colsFile, colsFileName, "Workbooks, Data Sources, and Column Fields." #-- @dsCount = 0 @recNum = 0 @colFldNum = 0 end |
Instance Attribute Details
#csvFileName ⇒ Object (readonly)
Returns the value of attribute csvFileName.
27 28 29 |
# File 'lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb', line 27 def csvFileName @csvFileName end |
#csvRecords ⇒ Object (readonly)
Returns the value of attribute csvRecords.
27 28 29 |
# File 'lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb', line 27 def csvRecords @csvRecords end |
#dsCount ⇒ Object (readonly)
Returns the value of attribute dsCount.
28 29 30 |
# File 'lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb', line 28 def dsCount @dsCount end |
#fieldsCount ⇒ Object (readonly)
Returns the value of attribute fieldsCount.
28 29 30 |
# File 'lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb', line 28 def fieldsCount @fieldsCount end |
Class Method Details
.csvFileNaame ⇒ Object
104 105 106 |
# File 'lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb', line 104 def self.csvFileNaame @@csvFileName end |
.csvFileType ⇒ Object
100 101 102 |
# File 'lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb', line 100 def self.csvFileType @@csvFileType end |
.csvHeader ⇒ Object
96 97 98 |
# File 'lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb', line 96 def self.csvHeader @@csvHeader end |
Instance Method Details
#metrics ⇒ Object
‘Workbook’,
'Data Source',
'Field - tech',
'caption',
'uiname',
'alias',
'datatype',
'datatype-customized',
'default-format',
'param-domain-type',
'role',
'type',
'value'
]
205 206 207 208 209 210 |
# File 'lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb', line 205 def metrics { '# of Data Sources' => @dsCount, '# of Records' => @recNum } end |
#processColumnFields(ds) ⇒ Object
def processTwb twb
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb', line 167 def processColumnFields ds deepFields = {} recordedFields = {} ds.columnFields.each do |field| if field..eql? '/workbook/datasources/datasource/column' recordColField field recordedFields[field.name] = field # print '.' else deepFields[field.name] = field # print '-' end end deepFields.each do |name,field| unless recordedFields.has_key? name recordColField(field) recordedFields[field.name] = field # print ':' end end end |
#processTWB(twb) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/twb/analysis/DataSources/datasourcefieldsanalyzer.rb', line 108 def processTWB twb @twb = nil @twb = twb if twb.instance_of? Twb::Workbook @twb = Twb::Workbook.new(twb) if twb.instance_of? String @twbName = @twb.name @twbDir = @twb.dir raise ArgumentError.new("ERROR in Workbok processing: '#{twb}' must be a Workbook (class) or the name of a Workbook (String), is a #{twb.class} \n ") unless @twb.is_a? Twb::Workbook # -- dss = @twb.datasources @fieldCnt = 0 dss.each do |ds| @dsname = ds.uiname processColumnFields ds # puts "\n -- #{ds.uiname} " # tables = Set.new # fields = {} @dsCount += 1 fclasses = Set.new ds.localFields.each do |field| recordFieldFull field, :local # recordField( fields, field, {:type=>:local,:columnField=>true,:hidden=>field.hidden} ) # emitTech( ds, field.uiname, 'Local', field.properties) # recordTech( field, 'LocalA') end ds.columnFields.each do |field| recordFieldFull field, :column # recordField( fields, field, {:type=>'column',:columnField=>true,:hidden=>field.hidden} ) # emitTech( ds, field.uiname, 'Column', field.properties) # recordTech( field, 'ColumnA') end ds.calculatedFields.each do |field| recordFieldFull field, :calc # puts "WWW #{field.class} :: #{field} ::prop:: #{field.properties.class} :: #{field.properties}" # recordField( fields, field, {:type=>'calc',:calculatedField=>true,:hidden=>field.hidden} ) # emitTech( ds, field.uiname, 'Calculated', field.properties) # recordTech( field, 'CalcA') end ds..each do |field| recordFieldFull field, :metadata # recordField( fields, field, {:type=>'metadata',:metadataField=>true} ) # emitTech( ds, field.uiname, 'MetaData', field.properties) # recordTech( field, 'MetadataA') end ds.dbFields.each do |field| recordFieldFull field, :db # recordField( fields, field, {:type=>'database',:dbField=>true} ) # emitTech( ds, field.uiname, 'Db', field.properties) # recordTech( field, 'DbA') end ds.mappedFields.each do |field| recordFieldFull field, :mapped # recordField( fields, field, {:type=>'mapped',:mappedField=>true} ) # emitTech( ds, field.uiname, 'Mapped', field.properties) # recordTech( field, 'MappedA') end # emitFields(fields) end end |