183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
|
# File 'lib/fmpvc/FMPReport.rb', line 183
def define_content_procs
@script_content = Proc.new do |a_script|
content = ''
a_script.xpath("./StepList/Step/StepText").each {|t| content += t.text.gsub(%r{\n},'') + "\n" } content
end
@layouts_content = Proc.new do |a_layout|
content = ''
layout_name = a_layout['name']
layout_id = a_layout['id']
layout_table = a_layout.xpath('./Table').first['name']
layout_theme = a_layout.xpath('./Theme').first['name']
layout_format = "%18s %-25s\n"
object_format = " %-16s %-35s\n"
content += format(layout_format, "Layout name: ", layout_name)
content += format(layout_format, "id: ", layout_id)
content += format(layout_format, "Table: ", layout_table)
content += format(layout_format, "Theme: ", layout_theme)
content += NEWLINE
content += format(layout_format, "Objects: ", '')
layout_objects = a_layout.xpath("./*[name()='Object']") layout_objects_types = layout_objects.map { |o| o['type']} if !layout_objects_types.empty? layout_objects_types.uniq!
content += format(object_format, "Type", "'Name'" )
content += format(object_format, "----", "------" )
end
layout_objects_types.each do |a_type|
selected_objects = layout_objects.select { |o| o['type'] == a_type } selected_objects.each do |type_obj| content += format(object_format, type_obj['type'], type_obj.xpath('./*/Name').text) unless type_obj['type'] == "Text"
end
end
content
end
@value_list_content = Proc.new do |a_value_list|
content = ''
source_type = a_value_list.xpath("./Source").first['value']
if source_type == "Custom"
a_value_list.xpath("./CustomValues/Text").each {|t| content += t.text}
end
content
end
@table_content = Proc.new do |a_table|
content = ''
table_format = "%6d %-25s %-15s %-15s %-50s\n"
= table_format.gsub(%r{d}, 's')
content += format(, "id", "Field Name", "Data Type", "Field Type", "Comment")
content += format(, "--", "----------", "---------", "----------", "-------")
a_table.xpath("//BaseTable[@name='#{a_table['name']}']/FieldCatalog/*[name()='Field']").each do |t|
= t.xpath("./Comment").text
content += format(table_format, t['id'], t['name'], t['dataType'], t['fieldType'], )
end
content
end
@custom_function_content = Proc.new do |a_custom_function|
content = ''
content += a_custom_function.xpath("./Calculation").map {|t| t.text}.join(NEWLINE)
content
end
@menu_sets_content = Proc.new do ||
content = ''
= "%6d %-35s\n"
= .gsub(%r{d}, 's')
content += format(, "id", "Menu")
content += format(, "--", "----")
.xpath("./CustomMenuList/*[name()='CustomMenu']").each do ||
content += format(, ['id'], ['name'])
end
content
end
@custom_menus_content = Proc.new do ||
content = ''
= ['name']
= ['id']
= .xpath('./BaseMenu').first['name']
= .xpath('./Comment').text
= "%17s %-35s\n"
content += format(, "Menu name:", )
content += format(, "id:", )
content += format(, "Base menu:", )
content += format(, "Comment:", )
content += NEWLINE
= .xpath("./MenuItemList/*[name()='MenuItem']")
.each do |an_item|
an_item.xpath('./Command').each { |c| content += " #{c['name']}\n"}
end
content
end
@accounts_content = Proc.new do |accounts|
content = ''
accounts_format = "%6d %-25s %-10s %-12s %-20s %-12s %-12s %-50s"
= accounts_format.gsub(%r{d}, 's')
content += format(, "id", "Name", "Status", "Management", "Privilege Set", "Empty Pass?", "Change Pass?", "Description") + NEWLINE
content += format(, "--", "----", "------", "----------", "-------------", "-----------", "------------", "-----------") + NEWLINE
content += accounts.map do |an_account|
account_name = an_account['name']
account_id = an_account['id']
account_privilegeSet = an_account['privilegeSet']
account_emptyPassword = an_account['emptyPassword']
account_changePasswordOnNextLogin = an_account['changePasswordOnNextLogin']
account_managedBy = an_account['managedBy']
account_status = an_account['status']
account_Description = an_account.xpath('./Description').text
format(
accounts_format \
, account_id \
, account_name \
, account_status \
, account_managedBy \
, account_privilegeSet \
, account_emptyPassword \
, account_changePasswordOnNextLogin \
, account_Description
)
end.join(NEWLINE)
content
end
@privileges_content = Proc.new do |privileges|
content = ''
privileges_format = "%6d %-25s %-8s %-10s %-15s %-12s %-12s %-12s %-8s %-18s %-11s %-10s %-12s %-10s %-16s %-10s %-70s"
= privileges_format.gsub(%r{d}, 's')
content += format(, "id", "Name", "Print?", "Export?", "Manage Ext'd?", "Override?", "Disconnect?", "Password?", "Menus", "Records", "Layouts", "(Creation)", "ValueLists", "(Creation)", "Scripts", "(Creation)", "Description") + NEWLINE
content += format(, "--", "----", "------", "-------", "-------------", "---------", "-----------", "---------", "-----", "-------", "-------", "----------", "----------", "----------", "-------", "----------", "-----------") + NEWLINE
privileges.each do |a_privilege_set|
privilege_set_id = a_privilege_set['id']
privilege_set_name = a_privilege_set['name']
= a_privilege_set['comment']
privilege_set_printing = a_privilege_set['printing']
privilege_set_exporting = a_privilege_set['exporting']
privilege_set_managedExtended = a_privilege_set['managedExtended']
privilege_set_overrideValidationWarning = a_privilege_set['overrideValidationWarning']
privilege_set_idleDisconnect = a_privilege_set['idleDisconnect']
privilege_set_allowModifyPassword = a_privilege_set['allowModifyPassword']
= a_privilege_set['menu']
privilege_set_records_value = a_privilege_set.xpath('./Records').first['value']
privilege_set_layouts_value = a_privilege_set.xpath('./Layouts').first['value']
privilege_set_layouts_creation = a_privilege_set.xpath('./Layouts').first['allowCreation']
privilege_set_valuelists_value = a_privilege_set.xpath('./ValueLists').first['value']
privilege_set_valuelists_creation = a_privilege_set.xpath('./ValueLists').first['allowCreation']
privilege_set_scripts_value = a_privilege_set.xpath('./Scripts').first['value']
privilege_set_scripts_creation = a_privilege_set.xpath('./Scripts').first['allowCreation']
content += format(
privileges_format \
, privilege_set_id \
, privilege_set_name \
, privilege_set_printing \
, privilege_set_exporting \
, privilege_set_managedExtended \
, privilege_set_overrideValidationWarning \
, privilege_set_idleDisconnect \
, privilege_set_allowModifyPassword \
, \
, privilege_set_records_value \
, privilege_set_layouts_value \
, privilege_set_layouts_creation \
, privilege_set_valuelists_value \
, privilege_set_valuelists_creation \
, privilege_set_scripts_value \
, privilege_set_scripts_creation \
, \
) + NEWLINE
end
content
end
@extended_priviledge_content = Proc.new do |ext_privileges|
content = ''
ext_privilege_format = "%6d %-20s %-85s %-150s\n"
= ext_privilege_format.gsub(%r{d}, 's')
content += format(, "id", "Name", "Description", "Privilege Sets")
content += format(, "--", "----", "-----------", "--------------")
ext_privileges.each do |an_ext_privilege|
ext_privilege_id = an_ext_privilege['id']
ext_privilege_name = an_ext_privilege['name']
= an_ext_privilege['comment']
ext_privilege_sets = an_ext_privilege.xpath('./PrivilegeSetList/*[name()="PrivilegeSet"]').map {|s| s['name']}.join(", ")
content += format(
ext_privilege_format \
, ext_privilege_id \
, ext_privilege_name \
, \
, ext_privilege_sets \
)
end
content
end
@relationships_content = Proc.new do |relationships|
content = ''
tables = @report.xpath("/FMPReport/File/RelationshipGraph/TableList/*[name()='Table']")
table_format = " %-25s %-25s"
content +="Tables\n"
content += NEWLINE
content +=format(table_format, "Base Table (id)", "Table occurrence (id)") + NEWLINE
content +=format(table_format, "---------------", "---------------------") + NEWLINE
content += NEWLINE
tables.each do |a_table|
table_id = a_table['id']
table_name = a_table['name']
basetable_id = a_table['baseTableId']
basetable_name = a_table['baseTable']
content +=format(table_format, "#{basetable_name} (#{basetable_id})", "#{table_name} (#{table_id})") + NEWLINE
end
content += NEWLINE
relationship_format = " %-35s %-15s %-35s"
content +="Relationships" + NEWLINE
relationships.each do |a_relationship|
content += NEWLINE
content += format(" Relationship: %-4d", a_relationship['id']) + NEWLINE
predicates = a_relationship.xpath('./JoinPredicateList/*[name()="JoinPredicate"]')
predicates.each do |a_predicate|
predicate_type = a_predicate['type']
left_field = a_predicate.xpath('./LeftField/*[name()="Field"]').first
left_table = left_field['table']
left_field_name = left_field['name']
right_field = a_predicate.xpath('./RightField/*[name()="Field"]').first
right_table = right_field['table']
right_field_name = right_field['name']
content += format(relationship_format, "#{left_table}::#{left_field_name}", "#{predicate_type}", "#{right_table}::#{right_field_name}") + NEWLINE
end
end
content
end
@file_access_content = Proc.new do |file_access|
content = ''
inbound_access = file_access.xpath("./Inbound/*[name()='InboundAuthorization']")
outbound_access = file_access.xpath("./Outbound/*[name()='OutboundAuthorization']")
access_format = " %6d %-25s %-25s %-25s"
= access_format.gsub(%r{d}, 's')
auth_requirement = file_access.first['requireAuthorization']
content += "Authorization required: #{auth_requirement}" + NEWLINE
if auth_requirement == "True"
content += NEWLINE
content += format(, "id", "Timestamp", "Account", "Filenames") + NEWLINE
content += format(, "--", "---------", "-------", "---------") + NEWLINE
content += format("%12s", "Inbound:") + NEWLINE
inbound_access.each do |i|
content += format(access_format, i['id'], i['date'], i['user'], i['filenames']) + NEWLINE
end
content += format("%12s", "Outbound:") + NEWLINE
outbound_access.each do |o|
content += format(access_format, o['id'], o['date'], o['user'], o['filenames']) + NEWLINE
end
end
content += NEWLINE
content
end
@external_sources_content = Proc.new do |data_sources|
content = ''
file_references = data_sources.xpath("./*[name()='FileReference']")
odbc_sources = data_sources.xpath("./*[name()='OdbcDataSource']")
file_references_format = " %6d %-25s %-25s\n"
= file_references_format.gsub(%r{d},'s')
odbc_source_format = " %6d %-25s %-25s %-25s\n"
= odbc_source_format.gsub(%r{d},'s')
content += format(, "id", "File Reference", "Path List")
content += format(, "--", "--------------", "---------")
file_references.each do |r|
content += format(file_references_format, r['id'], r['name'], r['pathList'])
end
content += NEWLINE
content += format(, "id", "ODBC Source", "DSN", "Link")
content += format(, "--", "-----------", "---", "----")
odbc_sources.each do |s|
content += format(odbc_source_format, s['id'], s['name'], s['DSN'], s['link'])
end
content
end
@file_options_content = Proc.new do |file_options|
content = ''
file_options_format = " %-27s %-30s\n"
trigger_format = " %-23s %-30s\n"
open_account_search = file_options.xpath('./OnOpen/Account')
open_account = (open_account_search.size > 0 ? open_account_search.first['name']: "")
open_layout_search = file_options.xpath('./OnOpen/Layout')
open_layout = ( open_layout_search.size > 0 ? open_layout_search.first['name'] : "" )
encryption_type = file_options.xpath('./Encryption').first['type']
encryption_note = case encryption_type
when "0"
"no encryption"
when "1"
"AES256 encrypted"
end
content += "File Options\n"
content += "------------\n"
content += NEWLINE
content += format(file_options_format, "Encryption:", "#{encryption_type} (#{encryption_note})")
content += NEWLINE
content += format(file_options_format, "Minimum Allowed Version:", file_options.xpath('./OnOpen/MinimumAllowedVersion').first['name'])
content += format(file_options_format, "Account:", open_account)
content += format(file_options_format, "Layout:", open_layout)
content += NEWLINE
content += format(file_options_format, "Default Custom Menu Set:", file_options.xpath('./DefaultCustomMenuSet/CustomMenuSet').first['name'])
content += NEWLINE
content += " Triggers\n"
file_options.xpath('./WindowTriggers/*').each do |t|
content += format(trigger_format, t.name, t.xpath('./Script').first['name'])
end
content
end
@themes_content = Proc.new do |themes|
content = ''
theme_format = " %6s %-20s %-20s %-10s %-10s %-20s\n"
content += format(theme_format, "id", "Name", "Group", "Version", "Locale", "Internal Name")
content += format(theme_format, "--", "----", "-----", "-------", "------", "-------------")
themes.each do |a_theme|
content += format(theme_format, a_theme['id'], a_theme['name'], a_theme['group'], a_theme['version'], a_theme['locale'], a_theme['internalName'])
end
content
end
end
|