Sha256: c9b90c7e9ce241a2a8fb412a4245403b2366d5797ceebaf19e4804488da42b1c

Contents?: true

Size: 1.64 KB

Versions: 6

Compression:

Stored size: 1.64 KB

Contents

# Attributes and methods for raster works
module GeoWorks
  module RasterWorkBehavior
    extend ActiveSupport::Concern
    include ::GeoWorks::MetadataExtractionHelper

    included do
      type [Hydra::PCDM::Vocab::PCDMTerms.Object,
            Hydra::Works::Vocab::WorksTerms.GenericWork,
            ::GeoWorks::GeoTerms.RasterWork]
    end

    def raster_files
      members.select(&:raster_file?)
    end

    def metadata_files
      members.select(&:external_metadata_file?)
    end

    def vector_works
      members.select(&:vector_work?)
    end

    # Defines type by what it is and isn't
    # @return [Boolean]
    def image_work?
      false
    end

    def image_file?
      false
    end

    def raster_work?
      true
    end

    def raster_file?
      false
    end

    def vector_work?
      false
    end

    def vector_file?
      false
    end

    def external_metadata_file?
      false
    end

    # Retrieve all Image Works for which georeferencing generates this Raster Work
    # @return [Array]
    def image_works
      ordered_by.select do |parent|
        parent.class.included_modules.include?(::GeoWorks::ImageWorkBehavior)
      end
    end

    # Retrieve the only Image Works for which georeferencing generates this Raster Work
    # @return [GeoWorks::ImageWork]
    def image_work
      image_works.first
    end

    def to_solr(solr_doc = {})
      super.tap do |doc|
        doc[solr_name("ordered_by", :symbol)] ||= []
        doc[solr_name("ordered_by", :symbol)] += send(:ordered_by_ids)
      end
    end

    private

      def solr_name(*args)
        ActiveFedora.index_field_mapper.solr_name(*args)
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
geo_works-0.2.0 app/models/concerns/geo_works/raster_work_behavior.rb
geo_works-0.1.4 app/models/concerns/geo_works/raster_work_behavior.rb
geo_works-0.1.3 app/models/concerns/geo_works/raster_work_behavior.rb
geo_works-0.1.2 app/models/concerns/geo_works/raster_work_behavior.rb
geo_works-0.1.1 app/models/concerns/geo_works/raster_work_behavior.rb
geo_works-0.1.0 app/models/concerns/geo_works/raster_work_behavior.rb