Sha256: 7f4a95aec9c4ea4812e517454047ffb11edbc859a6bed8bd8f5256cfbb3d2fcf

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

require "active-fedora"
class JP2ImageAggregator < ::ActiveFedora::Base
  extend ActiveModel::Callbacks
  include ::ActiveFedora::Finders
  include ::ActiveFedora::DatastreamCollections
  include ::ActiveFedora::Relationships
  include ::Hydra::ModelMethods
  include Cul::Scv::Hydra::ActiveFedora::Model::Common
  include Cul::Scv::Hydra::ActiveFedora::Model::Aggregator

  has_datastream :name => "SOURCE", :type=>::ActiveFedora::Datastream, :mimeType=>"image/jp2", :controlGroup=>'E'

  alias :file_objects :resources

  def route_as
    "zoomingimage"
  end

  def index_type_label
    "PART"
  end

  def to_solr(solr_doc = Hash.new, opts={})
    solr_doc = super
    source = self.datastreams["SOURCE"]
    source.profile
    if source.controlGroup == 'E'
      solr_doc["rft_id"] = source.dsLocation
    else
      rc = ActiveFedora::RubydoraConnection.instance.connection
      url = rc.config["url"]
      uri = URI::parse(url)
      url = "#{uri.scheme}://#{uri.host}:#{uri.port}/fedora/objects/#{pid}/datastreams/SOURCE/content"
      solr_doc["rft_id"] = url
    end
    solr_doc
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cul_scv_hydra-0.6.4 app/models/jp2_image_aggregator.rb
cul_scv_hydra-0.6.3 app/models/jp2_image_aggregator.rb
cul_scv_hydra-0.6.2 app/models/jp2_image_aggregator.rb
cul_scv_hydra-0.6.1 app/models/jp2_image_aggregator.rb
cul_scv_hydra-0.6.0 app/models/jp2_image_aggregator.rb