Skip to content

Commit

Permalink
Move Alma and Standard Numbers to their own modules
Browse files Browse the repository at this point in the history
Remove commented out code
  • Loading branch information
sandbergja committed Apr 14, 2023
1 parent 919ed9d commit a66d9df
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
18 changes: 0 additions & 18 deletions app/models/concerns/blacklight/solr/document/marc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,6 @@ def to_ctx(format)
@_ctx || build_ctx(format)
end

# returns true if doc originated from alma
def alma_record?
if /^[0-9]+/.match?(self['id'])
true
else
false
end
end

# does we have any standard numbers that can be used by other services
def standard_numbers?
std_numbers.any? { |v| key? v }
end

def std_numbers
%w[lccn_s isbn_s issn_s oclc_s]
end

def format_to_openurl_genre(format)
return 'book' if format == 'book'
return 'bookitem' if format == 'book'
Expand Down
9 changes: 0 additions & 9 deletions app/models/requests/solr_open_url_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ def openurl_ctx_kev
ctx.kev
end

## double check what are valid openURL formsts in the catatlog
## look at our choices and map
# def format_to_openurl_genre(format)
# return 'book' if format == 'book'
# return 'journal' if format == 'serial'
# return 'journal' if format == 'journal'
# 'unknown'
# end

private

def build_ctx
Expand Down
2 changes: 2 additions & 0 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class SolrDocument
include Blacklight::Solr::Document
include Orangelight::Document::Export
include SolrDocument::Alma
include SolrDocument::StandardNumbers

# Explicitly required for sneakers
include Blacklight::Document::Extensions
Expand Down
10 changes: 10 additions & 0 deletions app/models/solr_document/alma.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class SolrDocument
# Special alma functionality for SolrDocument
module Alma
def alma_record?
/^[0-9]+/.match?(self['id'])
end
end
end
15 changes: 15 additions & 0 deletions app/models/solr_document/standard_numbers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true
class SolrDocument
# Standard Numbers functionality for SolrDocument
module StandardNumbers
def standard_numbers?
standard_number_fields.any? { |field| key? field }
end

private

def standard_number_fields
%w[lccn_s isbn_s issn_s oclc_s]
end
end
end

0 comments on commit a66d9df

Please sign in to comment.