Module: Sfx4::Abstract::Base

Included in:
Local::Base
Defined in:
app/models/sfx4/abstract/base.rb

Instance Method Summary collapse

Instance Method Details

#fetch_urlsObject

Class method for the module that gets called by the umlaut:load_sfx_urls task. Kind of hacky way of trying to extract target URLs from SFX4. Will probably be deprecated in the near future.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
# File 'app/models/sfx4/abstract/base.rb', line 18

def fetch_urls
  # Crazy crazy URLs to try to find PARSE_PARAMS in Sfx4 db that have a period in
  # them, so they look like they might be URLs. Parse params could be at target service
  # level, or at portfolio level; and could be in local overrides or in global kb. 
  # This is crazy crazy SQL to get this, sorry. Talking directly to SFX db isn't
  # a great idea, but best way we've found to get this for now. Might make more
  # sense to try to use the (very very slow) SFX export in the future instead. 
  sql = %{
    SELECT 
      COALESCE(LCL_SERVICE_LINKING_INFO.PARSE_PARAM,KB_TARGET_SERVICES.PARSE_PARAM) PARSE_PARAM
    FROM
      LCL_TARGET_INVENTORY
    JOIN sfxglb41.KB_TARGET_SERVICES
      ON KB_TARGET_SERVICES.TARGET_ID = LCL_TARGET_INVENTORY.TARGET_ID
    JOIN LCL_SERVICE_INVENTORY 
      ON LCL_TARGET_INVENTORY.TARGET_ID = LCL_SERVICE_INVENTORY.TARGET_ID
    LEFT OUTER JOIN LCL_SERVICE_LINKING_INFO
      ON LCL_SERVICE_INVENTORY.TARGET_SERVICE_ID = LCL_SERVICE_LINKING_INFO.TARGET_SERVICE_ID
    WHERE
      ( LCL_SERVICE_LINKING_INFO.PARSE_PARAM like '%.%' OR
        KB_TARGET_SERVICES.PARSE_PARAM like '%.%' )
    AND
      LCL_SERVICE_INVENTORY.ACTIVATION_STATUS='ACTIVE'
    AND
      LCL_TARGET_INVENTORY.ACTIVATION_STATUS = 'ACTIVE'

    UNION
      -- object portfolio parse param version
      SELECT
        COALESCE(LCL_OBJECT_PORTFOLIO_LINKING_INFO.PARSE_PARAM, KB_OBJECT_PORTFOLIOS.PARSE_PARAM) PARSE_PARAM
      FROM
        sfxglb41.KB_OBJECT_PORTFOLIOS
      JOIN LCL_SERVICE_INVENTORY
        ON KB_OBJECT_PORTFOLIOS.TARGET_SERVICE_ID = LCL_SERVICE_INVENTORY.TARGET_SERVICE_ID
      JOIN LCL_OBJECT_PORTFOLIO_INVENTORY
        ON KB_OBJECT_PORTFOLIOS.OP_ID = LCL_OBJECT_PORTFOLIO_INVENTORY.OP_ID
      left outer join  LCL_OBJECT_PORTFOLIO_LINKING_INFO
        ON KB_OBJECT_PORTFOLIOS.OP_ID = LCL_OBJECT_PORTFOLIO_LINKING_INFO.OP_ID        
      WHERE
        ( KB_OBJECT_PORTFOLIOS.PARSE_PARAM like '%.%' OR 
          LCL_OBJECT_PORTFOLIO_LINKING_INFO.PARSE_PARAM like '%.%' )
      AND LCL_OBJECT_PORTFOLIO_INVENTORY.ACTIVATION_STATUS = 'ACTIVE'        
      AND LCL_SERVICE_INVENTORY.ACTIVATION_STATUS='ACTIVE'
    }

  results =  connection.select_all(sql)
  urls = []
  results.each do |line|
    param_string = line["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( param_string.scan( url_re ).collect {|matches| matches[0]} )                
  end      
  urls.uniq!
  return urls
end

#sunspot?Boolean

Is Umlaut configured to use Sunspot?

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
# File 'app/models/sfx4/abstract/base.rb', line 5

def sunspot?
  begin
    Sunspot and Sunspot.const_defined?(:Rails) and self.ancestors.include?(Sunspot::Rails::Searchable)
  rescue NameError
    # no need to log, jsut annoying people who choose not to use it. 
    #warn "Sunspot::Rails has not been implemented in this Umlaut instance."
    false
  end
end