Sha256: 133e141d7e8a78ca193df6b0e23657b47d10e2e3c24ab49e0175ae544b47b3d2
Contents?: true
Size: 1.77 KB
Versions: 5
Compression:
Stored size: 1.77 KB
Contents
module Ddr module Models module HasStructMetadata extend ActiveSupport::Concern included do contains Ddr::Datastreams::STRUCT_METADATA, class_name: 'Ddr::Datastreams::StructuralMetadataDatastream' end def structure unless @structure if datastreams[Ddr::Datastreams::STRUCT_METADATA].content @structure = Ddr::Models::Structure.new(Nokogiri::XML(datastreams[Ddr::Datastreams::STRUCT_METADATA].content)) end end @structure end def build_default_structure structure = Ddr::Models::Structure.new(Ddr::Models::Structure.template) children = find_children children.each do |child| add_to_struct_map(structure, child) end structure end def multires_image_file_paths(type='default') ::SolrDocument.find(pid).multires_image_file_paths(type) end private def find_children query = association_query(:children) sort = "#{Ddr::Index::Fields::LOCAL_ID} ASC, #{Ddr::Index::Fields::OBJECT_CREATE_DATE} ASC" ActiveFedora::SolrService.query(query, sort: sort, rows: 999999) end def add_to_struct_map(stru, child) div = create_div(stru) create_fptr(stru, div, child['id']) end def create_div(stru) div_count = stru.structMap_node('default').xpath('xmlns:div').size div = Nokogiri::XML::Node.new('div', stru.as_xml_document) div['ORDER'] = div_count + 1 stru.structMap_node('default').add_child(div) div end def create_fptr(stru, div, pid) fptr = Nokogiri::XML::Node.new('fptr', stru.as_xml_document) fptr['CONTENTIDS'] = "info:fedora/#{pid}" div.add_child(fptr) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems