lib/stanford-mods/searchworks.rb in stanford-mods-1.0.1 vs lib/stanford-mods/searchworks.rb in stanford-mods-1.0.2
- old
+ new
@@ -525,12 +525,12 @@
@logger ||= Logger.new(STDOUT)
end
# select one or more format values from the controlled vocabulary here:
# http://searchworks-solr-lb.stanford.edu:8983/solr/select?facet.field=format&rows=0&facet.sort=index
- # based on the dor_content_type
- # @return [String] value in the SearchWorks controlled vocabulary
+ # @return <Array[String]> value in the SearchWorks controlled vocabulary
+ # @deprecated - kept for backwards compatibility but not part of SW UI redesign work Summer 2014
def format
val = []
types = self.term_values(:typeOfResource)
if types
genres = self.term_values(:genre)
@@ -571,9 +571,90 @@
val << 'Other' if genres and !(genres & stu_proj_rpt).empty?
thesis = ['thesis', 'Thesis']
val << 'Thesis' if genres and !(genres & thesis).empty?
when 'three dimensional object'
val << 'Other'
+ end
+ end
+ end
+ val.uniq
+ end
+
+ # select one or more format values from the controlled vocabulary per JVine Summer 2014
+ # http://searchworks-solr-lb.stanford.edu:8983/solr/select?facet.field=format_main_ssim&rows=0&facet.sort=index
+ # @return <Array[String]> value in the SearchWorks controlled vocabulary
+ def format_main
+ val = []
+ types = self.term_values(:typeOfResource)
+ if types
+ genres = self.term_values(:genre)
+ issuance = self.term_values([:origin_info,:issuance])
+ types.each do |type|
+ case type
+ when 'cartographic'
+ val << 'Map'
+ when 'mixed material'
+ val << 'Archive/Manuscript'
+ when 'moving image'
+ val << 'Video'
+ when 'notated music'
+ val << 'Music score'
+ when 'software, multimedia'
+ if genres and (genres.include?('dataset') || genres.include?('Dataset'))
+ val << 'Dataset'
+ else
+ val << 'Software/Multimedia'
+ end
+ when 'sound recording-musical'
+ val << 'Music recording'
+ when 'sound recording-nonmusical', 'sound recording'
+ val << 'Sound recording'
+ when 'still image'
+ val << 'Image'
+ when 'text'
+ article_genres = ['article', 'Article',
+ 'book chapter', 'Book chapter', 'Book Chapter',
+ 'issue brief', 'Issue brief', 'Issue Brief',
+ 'project report', 'Project report', 'Project Report',
+ 'student project report', 'Student project report', 'Student Project report', 'Student Project Report',
+ 'technical report', 'Technical report', 'Technical Report',
+ 'working paper', 'Working paper', 'Working Paper'
+ ]
+ val << 'Article' if genres and !(genres & article_genres).empty?
+ val << 'Book' if issuance and issuance.include? 'monographic'
+ book_genres = ['conference publication', 'Conference publication', 'Conference Publication',
+ 'instruction', 'Instruction',
+ 'librettos', 'Librettos',
+ 'thesis', 'Thesis'
+ ]
+ val << 'Book' if genres and !(genres & book_genres).empty?
+ val << 'Journal/Periodical' if issuance and issuance.include? 'continuing'
+ when 'three dimensional object'
+ val << 'Object'
+ end
+ end
+ end
+ val.uniq
+ end
+
+ # return values for the genre facet in SearchWorks
+ # @return <Array[String]>
+ def sw_genre
+ val = []
+ genres = self.term_values(:genre)
+ if genres
+ val << genres.map(&:capitalize)
+ val.flatten! if !val.empty?
+ if genres.include?('thesis') || genres.include?('Thesis')
+ val << 'Thesis/Dissertation'
+ val.delete 'Thesis'
+ end
+ conf_pub = ['conference publication', 'Conference publication', 'Conference Publication']
+ if !(genres & conf_pub).empty?
+ types = self.term_values(:typeOfResource)
+ if types && types.include?('text')
+ val << 'Conference proceedings'
+ val.delete 'Conference publication'
end
end
end
val.uniq
end