Class: SfxDb::SfxDbBase

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/sfx_db/sfx_db_base.rb

Direct Known Subclasses

AzAdditionalTitle, AzLetterGroup, AzTitle, AzTitleV2, Isbn, Issn, Object, ObjectPortfolio, Publisher, Target, TargetService, Title

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) fetch_sfx_urls

Atttempts to extract all URLs that SFX knows about from the db. This process is not 100%, becuase of the way SFX calculates URLs on the fly. We are only grabbing them from the db--and even the way they are stored in the db is hard for us to grab reliably! So this is really just a kind of guess heuristic in a bunch of ways. But we do our best, and use this to load the SfxUrl model.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/sfx_db/sfx_db_base.rb', line 27

def self.fetch_sfx_urls
    # Fetch all target services that look like they might have a URL
    # in the parse param, and that are active. We know this misses ones
    # that are just active for certain institutes! Known defect.
    target_services = TargetService.find(:all, :conditions => "PARSE_PARAM like '%.%' and AVAILABILITY ='ACTIVE'")

    # Same with object portfolios, which can also have urls hidden in em
    object_portfolios = ObjectPortfolio.find(:all, :conditions => "PARSE_PARAM like '%.%' and AVAILABILITY = 'ACTIVE'")

    urls = []
    (target_services + object_portfolios).each do |db_row|
      parse_param = db_row.PARSE_PARAM

      # Try to get things that look sort of like URLs out. Brutal force,
      # sorry. 
      url_re = Regexp.new('(https?://\S+\.\S+)(\s|$)')
      urls.concat( parse_param.scan( url_re ).collect {|matches| matches[0]} )
      
    end
    urls.uniq!
    return urls        
end

Instance Method Details

- (Boolean) readonly?

All SfxDb things are read-only!

Returns:

  • (Boolean)


16
17
18
# File 'app/models/sfx_db/sfx_db_base.rb', line 16

def readonly?() 
  return true
end