Class: ODDB::MiniFiPlugin

Inherits:
Plugin show all
Defined in:
src/plugin/minifi.rb

Constant Summary

Constants inherited from Plugin

ARCHIVE_PATH, RECIPIENTS

Instance Method Summary (collapse)

Methods inherited from Plugin

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

Methods included from HttpFile

#http_body, #http_file

Constructor Details

- (MiniFiPlugin) initialize(app)

A new instance of MiniFiPlugin



10
11
12
13
14
# File 'src/plugin/minifi.rb', line 10

def initialize(app)
  super
  @imported = []
  @attached = []
end

Instance Method Details

- (Object) postprocess



41
42
43
# File 'src/plugin/minifi.rb', line 41

def postprocess
  update_rss_feeds('minifi.rss', @app.sorted_minifis, View::Rss::MiniFi)
end

- (Object) report



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'src/plugin/minifi.rb', line 44

def report
  lines = [
    "Imported #{@imported.size} Mini-Fachinfos:",
  ]
  lines.concat @imported.collect { |minifi|
    " - %s" % minifi.name
  }
  lines.concat [ nil, 
    "Attached #{@attached.size} Mini-Fachinfos to Registrations:" ]
  lines.concat @attached.collect { |minifi|
    " - %s" % minifi.name
  }
  lines.join("\n")
end

- (Object) update(month)



15
16
17
18
19
20
21
22
23
24
25
# File 'src/plugin/minifi.rb', line 15

def update(month)
  path = File.join(ARCHIVE_PATH, 'pdf', 
                   month.strftime('%m_%Y.pdf'))
  minifis = DRbObject.new(nil, FIPARSE_URI).extract_minifi(path)
  minifis.each { |data|
    data.store(:publication_date, month)
    minifi = update_minifi(data)
    update_registration(minifi)
  }
  postprocess
end

- (Object) update_minifi(data)



26
27
28
29
30
31
# File 'src/plugin/minifi.rb', line 26

def update_minifi(data)
  pointer = Persistence::Pointer.new(:minifi)
  minifi = @app.update(pointer.creator, data, :minifi)
  @imported.push(minifi)
  minifi
end

- (Object) update_registration(minifi)



32
33
34
35
36
37
38
39
40
# File 'src/plugin/minifi.rb', line 32

def update_registration(minifi)
  sequences = @app.search_sequences(minifi.name)
  registrations = sequences.collect { |seq| 
    seq.registration }.compact.uniq
  registrations.each { |reg|
    @attached.push(minifi)
    @app.update(reg.pointer, {:minifi => minifi}, :minifi)
  }
end