Module: Sufia::SolrDocumentBehavior

Extended by:
ActiveSupport::Concern
Includes:
CurationConcerns::Permissions::Readable, Hydra::Works::MimeTypes, Sufia::SolrDocument::Characterization, Sufia::SolrDocument::Export
Defined in:
app/models/concerns/sufia/solr_document_behavior.rb

Instance Method Summary collapse

Methods included from Sufia::SolrDocument::Characterization

#byte_order, #capture_device, #color_map, #color_space, #compression, #gps_timestamp, #height, #image_producer, #latitude, #longitude, #orientation, #profile_name, #profile_version, #scanning_software, #width

Methods included from Sufia::SolrDocument::Export

#end_note_format, #endnote_filename, #export_as_endnote, #persistent_url

Instance Method Details

#admin_setObject



60
61
62
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 60

def admin_set
  fetch(Solrizer.solr_name('admin_set'), [])
end

#based_nearObject

TODO: Move to curation_concerns?



31
32
33
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 31

def based_near
  self[Solrizer.solr_name('based_near')]
end

#collection_idsObject



56
57
58
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 56

def collection_ids
  Array.wrap(self['collection_ids_tesim'])
end

#collectionsObject

Find the solr documents for the collections this object belongs to



65
66
67
68
69
70
71
72
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 65

def collections
  return @collections if @collections
  query = 'id:' + collection_ids.map { |id| '"' + id + '"' }.join(' OR ')
  result = Blacklight.default_index.connection.select(params: { q: query })
  @collections = result['response']['docs'].map do |hash|
    ::SolrDocument.new(hash)
  end
end

#create_dateObject



21
22
23
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 21

def create_date
  date_field('system_create')
end

#date_createdObject

Date created indexed as a string. This allows users to enter values like: ‘Circa 1840-1844’ This overrides the default behavior of CurationConcerns which indexes a date



17
18
19
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 17

def date_created
  fetch(Solrizer.solr_name("date_created"), [])
end

#edit_groupsObject



48
49
50
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 48

def edit_groups
  Array.wrap(self[::Ability.edit_group_field])
end

#edit_peopleObject



52
53
54
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 52

def edit_people
  Array.wrap(self[::Ability.edit_user_field])
end

#identifierObject

TODO: Move to curation_concerns?



26
27
28
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 26

def identifier
  self[Solrizer.solr_name('identifier')]
end

#itemtypeObject

Add a schema.org itemtype



11
12
13
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 11

def itemtype
  ResourceTypesService.microdata_type(resource_type.first)
end

#read_groupsObject



44
45
46
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 44

def read_groups
  Array.wrap(self[::Ability.read_group_field])
end

TODO: Move to curation_concerns?



36
37
38
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 36

def related_url
  self[Solrizer.solr_name('related_url')]
end

#resource_typeObject



40
41
42
# File 'app/models/concerns/sufia/solr_document_behavior.rb', line 40

def resource_type
  Array.wrap(self[Solrizer.solr_name("resource_type")])
end