Class: ODDB::OdbaExporter::OddbDatExport

Inherits:
Plugin show all
Defined in:
src/plugin/oddbdat_export.rb,
test/test_plugin/oddbdat_export.rb

Constant Summary

EXPORT_SERVER =
StubDRbObject.new
EXPORT_DIR =
File.expand_path('../../data/downloads', 
File.dirname(__FILE__))
@@today =
Date.new(2011,2,3)

Constants inherited from Plugin

ARCHIVE_PATH, RECIPIENTS

Instance Method Summary (collapse)

Methods inherited from Plugin

#l10n_sessions, #log_info, #recipients, #report, #resolve_link, #update_rss_feeds

Methods included from HttpFile

#http_body, #http_file

Constructor Details

- (OddbDatExport) initialize(app)

A new instance of OddbDatExport



36
37
38
39
# File 'src/plugin/oddbdat_export.rb', line 36

def initialize(app)
  @date = @@today 
  super
end

Instance Method Details

- (Object) export



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'src/plugin/oddbdat_export.rb', line 40

def export
  files = []

  # package tables
  package_tables = [
    AcTable, AccompTable, AcLimTable, AcmedTable, AcnamTable,
    AcOddbTable, AcpricealgTable, AcscTable, LimitationTable,
    LimTxtTable, EanTable
  ]
  ids = []
      dose_missing_list = []
  @app.each_package { |pac| 
        ids.push(pac.odba_id) 
        if pac.parts.empty?
          dose_missing_list.push([pac.basename, pac.iksnr, pac.sequence.seqnr, pac.ikscd])
        end
      }

  files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, package_tables)

  # codes table
  ids = @app.atc_classes.values.collect { |atc| atc.odba_id }
  @app.each_galenic_form { |galform| ids.push(galform.odba_id) }
  files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, [CodesTable])

  # substances table
  ids = @app.substances.collect { |subs| subs.odba_id }
  files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, [ScTable])

  # companies table
  ids = @app.companies.collect { |oid, comp| comp.odba_id }
  files += EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, [CompTable])

  # readme
  files += EXPORT_SERVER.export_oddbdat(nil, EXPORT_DIR, [Readme])

  # compress
  EXPORT_SERVER.compress_many(EXPORT_DIR, 'oddbdat', files)

      # warning
      return dose_missing_list
end

- (Object) export_fachinfos



82
83
84
85
86
87
# File 'src/plugin/oddbdat_export.rb', line 82

def export_fachinfos
  # fachinfo table
  ids = @app.fachinfos.collect { |oid, fachinfo| fachinfo.odba_id }
  files = EXPORT_SERVER.export_oddbdat(ids, EXPORT_DIR, [MCMTable])
  EXPORT_SERVER.compress(EXPORT_DIR, files.first)
end