module Ddr module HasContent extend ActiveSupport::Concern included do attribute :content, Ddr::File.optional attribute :fits_file, Ddr::File.optional ### DDRevo ################################################ # Extracted text factored out to separate concern -- Ddr::HasExtractedText ### DDRevo ################################################ # has_file_datastream \ # name: Ddr::Datastreams::EXTRACTED_TEXT, # type: Ddr::Datastreams::PlainTextDatastream, # versionable: true, # label: "Text extracted from the content file", # control_group: "M" # delegate :original_filename, to: :content, allow_nil: true #######DDRevo######### # expect that the FileManagement module will go to staff app #######DDRevo######### # include FileManagement # #######DDRevo######### # to staff app #######DDRevo######### # delegate :validate_checksum!, to: :content end #######DDRevo######### # to staff app #######DDRevo######### # # Convenience method wrapping FileManagement#add_file # def upload file, opts={} # add_file(file, Ddr::Datastreams::CONTENT, opts) # end # #######DDRevo######### # to staff app #######DDRevo######### # # Set content to file and save # def upload! file, opts={} # upload(file, opts) # save # end # #######DDRevo######### # DerivativesManager will go to staff app. Need to determine if there is a need for a '#derivatives' method on # content-bearing objects and, if so, what it should return #######DDRevo######### # def derivatives # @derivatives ||= Ddr::Managers::DerivativesManager.new(self) # end # def techmd @techmd ||= Ddr::Managers::TechnicalMetadataManager.new(self) end def content_size content&.file&.size end def content_human_size ActiveSupport::NumberHelper.number_to_human_size(content_size) if content_size end def content_type content&.media_type end def content_major_type content_type&.split("/")&.first end def content_sub_type content_type&.split("/")&.last end # def content_type= mime_type # self.content.mimeType = mime_type # end # def image? content_major_type == "image" end def pdf? content_type == "application/pdf" end # def virus_checks # Ddr::Events::VirusCheckEvent.for_object(self) # end # # def last_virus_check # virus_checks.last # end # # def last_virus_check_on # last_virus_check && last_virus_check.event_date_time # end # # def last_virus_check_outcome # last_virus_check && last_virus_check.outcome # end # # def content_changed? # content.external? ? content.dsLocation_changed? : content.content_changed? # end # ### DDRevo ########################################### # Moved to Ddr::Resource where other 'has_?' methods reside ### DDRevo ########################################### # def has_extracted_text? # extractedText.has_content? # end # # def with_content_file(&block) # WithContentFile.new(self, &block) # end # # protected # # def default_content_type # "application/octet-stream" # end end end