Class: Replication::SdrObjectVersion
- Inherits:
-
Moab::StorageObjectVersion
- Object
- Moab::StorageObjectVersion
- Replication::SdrObjectVersion
- Defined in:
- lib/replication/sdr_object_version.rb
Overview
Copyright © 2014 by The Board of Trustees of the Leland Stanford Junior University. All rights reserved. See LICENSE for details.
Instance Method Summary collapse
-
#catalog_object_data ⇒ Boolean
Update digital_objects and sdr_objects tables in Archive Catalog.
-
#catalog_version_data ⇒ Boolean
Update sdr_object_versions and sdr_version_stats tables in Archive Catalog.
-
#create_replica ⇒ Replica
Copy the object version into a BagIt Bag in tarfile format.
-
#digital_object_id ⇒ String
The digital object’s identifier (druid).
-
#parse_identity_metadata ⇒ Hash
The contents of the identityMetadata file.
-
#parse_relationship_metadata ⇒ Hash
The contents of the relationshipMetadata file.
-
#parse_version_metadata ⇒ Hash
The contents of the versionMetadata file.
-
#replica ⇒ Replica
The Replica of the object version that is archived to tape, etc.
-
#version_additions ⇒ Moab::FileInventory
The moab version manifest for the version.
-
#version_inventory ⇒ Moab::FileInventory
The moab version manifest for the version.
Instance Method Details
#catalog_object_data ⇒ Boolean
Returns Update digital_objects and sdr_objects tables in Archive Catalog.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/replication/sdr_object_version.rb', line 70 def catalog_object_data = = digital_object_data = { :digital_object_id => digital_object_id, :home_repository => 'sdr' } sdr_object_data = { :sdr_object_id => digital_object_id, :object_type => [:object_type].to_s[0..19], :object_label => [:object_label].to_s[0..99], :governing_object => [:governed_by].to_s, :latest_version => storage_object.current_version_id } if version_id == 1 ArchiveCatalog.add_or_update_item(:digital_objects,digital_object_data) ArchiveCatalog.add_or_update_item(:sdr_objects,sdr_object_data) else ArchiveCatalog.update_item(:sdr_objects, digital_object_id, sdr_object_data) end true end |
#catalog_version_data ⇒ Boolean
Returns Update sdr_object_versions and sdr_version_stats tables in Archive Catalog.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/replication/sdr_object_version.rb', line 99 def catalog_version_data version_inventory = self.version_inventory sdr_object_version_data = { :sdr_object_id => digital_object_id, :sdr_version_id => version_id, :replica_id => composite_key, :ingest_date => version_inventory.inventory_datetime } ArchiveCatalog.add_or_update_item(:sdr_object_versions, sdr_object_version_data) content = version_inventory.group('content') = version_inventory.group('metadata') raise "No metadata group found in version inventory" unless sdr_version_full = { :sdr_object_id => digital_object_id, :sdr_version_id => version_id, :inventory_type => 'full', :content_files => (content ? content.file_count : 0), :content_bytes => (content ? content.byte_count : 0), :content_blocks => (content ? content.block_count : 0), :metadata_files => .file_count, :metadata_bytes => .byte_count, :metadata_blocks => .block_count } ArchiveCatalog.add_or_update_item(:sdr_version_stats, sdr_version_full) version_additions = self.version_additions content = version_additions.group('content') = version_additions.group('metadata') raise "No metadata group found in version additions" unless sdr_version_delta = { :sdr_object_id => digital_object_id, :sdr_version_id => version_id, :inventory_type => 'delta', :content_files => (content ? content.file_count : 0), :content_bytes => (content ? content.byte_count : 0), :content_blocks => (content ? content.block_count : 0), :metadata_files => .file_count, :metadata_bytes => .byte_count, :metadata_blocks => .block_count } ArchiveCatalog.add_or_update_item(:sdr_version_stats, sdr_version_delta) true end |
#create_replica ⇒ Replica
Returns Copy the object version into a BagIt Bag in tarfile format.
153 154 155 156 157 158 159 160 161 162 |
# File 'lib/replication/sdr_object_version.rb', line 153 def create_replica replica = self.replica bag = BagitBag.create_bag(replica.bag_pathname) bag.bag_checksum_types = [:sha256] bag.add_payload_tarfile("#{replica.replica_id}.tar",version_pathname, storage_object.object_pathname.parent) bag.write_bag_info_txt bag.write_manifest_checksums('tagmanifest', bag.generate_tagfile_checksums) replica.bagit_bag = bag replica end |
#digital_object_id ⇒ String
Returns The digital object’s identifier (druid).
12 13 14 |
# File 'lib/replication/sdr_object_version.rb', line 12 def digital_object_id storage_object.digital_object_id end |
#parse_identity_metadata ⇒ Hash
Returns The contents of the identityMetadata file.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/replication/sdr_object_version.rb', line 39 def = Hash.new pathname = find_filepath('metadata', 'identityMetadata.xml') if pathname.exist? doc = Nokogiri::XML(pathname.read) nodeset = doc.xpath("/identityMetadata/objectType") [:object_type] = nodeset.first.text unless nodeset.empty? nodeset = doc.xpath("/identityMetadata/objectLabel") [:object_label] = nodeset.first.text unless nodeset.empty? end end |
#parse_relationship_metadata ⇒ Hash
Returns The contents of the relationshipMetadata file.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/replication/sdr_object_version.rb', line 53 def = Hash.new pathname = find_filepath('metadata', 'relationshipMetadata.xml') if pathname.exist? doc = Nokogiri::XML(pathname.read) nodeset = doc.xpath("//hydra:isGovernedBy", 'hydra' => 'http://projecthydra.org/ns/relations#') unless nodeset.empty? apo_id = nodeset.first.attribute_with_ns('resource', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#') if apo_id [:governed_by] = apo_id.text.split('/')[-1] end end end end |
#parse_version_metadata ⇒ Hash
Returns The contents of the versionMetadata file.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/replication/sdr_object_version.rb', line 27 def = Hash.new pathname = find_filepath('metadata', 'versionMetadata.xml') if pathname.exist? doc = Nokogiri::XML(pathname.read) nodeset = doc.xpath("/versionMetadata/version") [:version_id] = nodeset.last['versionId'].to_i unless nodeset.empty? end end |
#replica ⇒ Replica
Returns The Replica of the object version that is archived to tape, etc.
148 149 150 |
# File 'lib/replication/sdr_object_version.rb', line 148 def replica Replica.new(composite_key.sub(/^druid:/,''), 'sdr') end |
#version_additions ⇒ Moab::FileInventory
Returns The moab version manifest for the version.
22 23 24 |
# File 'lib/replication/sdr_object_version.rb', line 22 def version_additions file_inventory('additions') end |
#version_inventory ⇒ Moab::FileInventory
Returns The moab version manifest for the version.
17 18 19 |
# File 'lib/replication/sdr_object_version.rb', line 17 def version_inventory file_inventory('version') end |