Module: Sufia::GenericFile
- Extended by:
- ActiveSupport::Concern
- Includes:
- Hydra::Collections::Collectible, Audit, Characterization, Derivatives, Export, Featured, FullTextIndexing, Metadata, MimeTypes, Permissions, ProxyDeposit, ReloadOnSave, Trophies, Versions, VirusCheck, WebForm, ModelMethods, Noid
- Included in:
- GenericFile
- Defined in:
- app/actors/sufia/generic_file/actor.rb,
app/models/concerns/sufia/generic_file.rb,
app/models/concerns/sufia/generic_file/audit.rb,
app/models/concerns/sufia/generic_file/export.rb,
app/models/concerns/sufia/generic_file/featured.rb,
app/models/concerns/sufia/generic_file/metadata.rb,
app/models/concerns/sufia/generic_file/trophies.rb,
app/models/concerns/sufia/generic_file/versions.rb,
app/models/concerns/sufia/generic_file/web_form.rb,
app/models/concerns/sufia/generic_file/mime_types.rb,
app/models/concerns/sufia/generic_file/derivatives.rb,
app/models/concerns/sufia/generic_file/permissions.rb,
app/models/concerns/sufia/generic_file/virus_check.rb,
app/models/concerns/sufia/generic_file/proxy_deposit.rb,
app/models/concerns/sufia/generic_file/reload_on_save.rb,
app/models/concerns/sufia/generic_file/characterization.rb,
app/models/concerns/sufia/generic_file/full_text_indexing.rb,
app/models/concerns/sufia/generic_file/accessible_attributes.rb
Defined Under Namespace
Modules: AccessibleAttributes, Audit, Characterization, Derivatives, Export, Featured, FullTextIndexing, Metadata, MimeTypes, Permissions, ProxyDeposit, ReloadOnSave, Trophies, Versions, VirusCheck, WebForm Classes: Actor
Constant Summary
Constants included from Audit
Instance Attribute Summary
Attributes included from ReloadOnSave
Class Method Summary collapse
-
.noid_indexer ⇒ Object
Unstemmed, searchable, stored.
Instance Method Summary collapse
- #label=(new_label) ⇒ Object
- #persistent_url ⇒ Object
-
#processing? ⇒ Boolean
Is this file in the middle of being processed by a batch?.
-
#related_files ⇒ Object
Get the files with a sibling relationship (belongs_to :batch) The batch id is minted when visiting the upload screen and attached to each file when it is done uploading.
- #retry_warming ⇒ Object
- #to_solr(solr_doc = {}, opts = {}) ⇒ Object
Methods included from ProxyDeposit
#create_transfer_request, #request_transfer_to
Methods included from FullTextIndexing
Methods included from ReloadOnSave
Methods included from VirusCheck
Methods included from Versions
Methods included from Metadata
Methods included from Featured
Methods included from Trophies
Methods included from WebForm
#initialize_fields, #remove_blank_assertions, #terms_for_display, #terms_for_editing, #to_jq_upload
Methods included from AccessibleAttributes
#accessible_attributes, #sanitize_attributes
Methods included from Permissions::Readable
#private?, #public?, #registered?
Methods included from Permissions::Writable
#paranoid_permissions, #permissions, #permissions=
Methods included from Audit
#audit, #audit!, #audit_each, #audit_stat, #audit_stat!, #logs, #per_version
Methods included from Characterization
#append_metadata, #characterization_terms, #characterize, #duration, #height, #sample_rate, #width
Methods included from Export
#export_as_apa_citation, #export_as_chicago_citation, #export_as_endnote, #export_as_mla_citation, #export_as_openurl_ctx_kev
Methods included from MimeTypes
#audio?, #collection?, #file_format, #image?, #office_document?, #pdf?, #video?
Methods included from Noid
namespaceize, #noid, noidify, #to_param
Methods included from ModelMethods
#apply_depositor_metadata, #to_s
Class Method Details
.noid_indexer ⇒ Object
Unstemmed, searchable, stored
80 81 82 |
# File 'app/models/concerns/sufia/generic_file.rb', line 80 def self.noid_indexer @noid_indexer ||= Solrizer::Descriptor.new(:text, :indexed, :stored) end |
Instance Method Details
#label=(new_label) ⇒ Object
95 96 97 98 99 100 |
# File 'app/models/concerns/sufia/generic_file.rb', line 95 def label=(new_label) @inner_object.label = new_label if self.title.empty? self.title = [new_label].compact end end |
#persistent_url ⇒ Object
33 34 35 |
# File 'app/models/concerns/sufia/generic_file.rb', line 33 def persistent_url "#{Sufia.config.persistent_hostpath}#{noid}" end |
#processing? ⇒ Boolean
Is this file in the middle of being processed by a batch?
103 104 105 106 107 |
# File 'app/models/concerns/sufia/generic_file.rb', line 103 def processing? return false if self.batch.blank? return false if !self.batch.methods.include? :status return (!self.batch.status.empty?) && (self.batch.status.count == 1) && (self.batch.status[0] == "processing") end |
#related_files ⇒ Object
Get the files with a sibling relationship (belongs_to :batch) The batch id is minted when visiting the upload screen and attached to each file when it is done uploading. The Batch object is not created until all objects are done uploading and the user is redirected to BatchController#edit. Therefore, we must handle the case where self.batch_id is set but self.batch returns nil.
74 75 76 77 |
# File 'app/models/concerns/sufia/generic_file.rb', line 74 def return [] if batch.nil? batch.generic_files.reject { |sibling| sibling.id == id } end |
#retry_warming ⇒ Object
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 |
# File 'app/models/concerns/sufia/generic_file.rb', line 37 def retry_warming save_tries = 0 conflict_tries = 0 begin yield rescue RSolr::Error::Http => error save_tries += 1 logger.warn "Retry Solr caught RSOLR error on #{self.pid}: #{error.inspect}" # fail for good if the tries is greater than 3 raise if save_tries >=3 sleep 0.01 retry rescue ActiveResource::ResourceConflict => error conflict_tries += 1 logger.warn "Retry caught Active Resource Conflict #{self.pid}: #{error.inspect}" raise if conflict_tries >=10 sleep 0.01 retry rescue => error if error.to_s.downcase.include? "conflict" conflict_tries += 1 logger.warn "Retry caught Active Resource Conflict #{self.pid}: #{error.inspect}" raise if conflict_tries >=10 sleep 0.01 retry else raise end end end |
#to_solr(solr_doc = {}, opts = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'app/models/concerns/sufia/generic_file.rb', line 84 def to_solr(solr_doc={}, opts={}) super(solr_doc, opts).tap do |solr_doc| solr_doc[Solrizer.solr_name('label')] = self.label solr_doc[Solrizer.solr_name('noid', Sufia::GenericFile.noid_indexer)] = noid solr_doc[Solrizer.solr_name('file_format')] = file_format solr_doc[Solrizer.solr_name('file_format', :facetable)] = file_format solr_doc['all_text_timv'] = full_text.content solr_doc = index_collection_pids(solr_doc) end end |