Class: Libis::Tools::MetsFile::File
- Includes:
- MetsObject
- Defined in:
- lib/libis/tools/mets_objects.rb
Overview
Container class for creating a file in the METS.
Instance Attribute Summary collapse
-
#applications ⇒ Object
The currently allowed attributes on this class.
-
#checksum_MD5 ⇒ Object
The currently allowed attributes on this class.
-
#checksum_SHA1 ⇒ Object
The currently allowed attributes on this class.
-
#checksum_SHA256 ⇒ Object
The currently allowed attributes on this class.
-
#checksum_SHA384 ⇒ Object
The currently allowed attributes on this class.
-
#checksum_SHA512 ⇒ Object
The currently allowed attributes on this class.
-
#composition_level ⇒ Object
The currently allowed attributes on this class.
-
#creation_date ⇒ Object
The currently allowed attributes on this class.
-
#dc_record ⇒ Object
The currently allowed attributes on this class.
-
#entity_type ⇒ Object
The currently allowed attributes on this class.
-
#env_dependencies ⇒ Object
The currently allowed attributes on this class.
-
#environments ⇒ Object
The currently allowed attributes on this class.
-
#fixity_type ⇒ Object
The currently allowed attributes on this class.
-
#fixity_value ⇒ Object
The currently allowed attributes on this class.
-
#group_id ⇒ Object
The currently allowed attributes on this class.
-
#hardware_ids ⇒ Object
The currently allowed attributes on this class.
-
#hardware_infos ⇒ Object
The currently allowed attributes on this class.
-
#inhibitors ⇒ Object
The currently allowed attributes on this class.
-
#label ⇒ Object
The currently allowed attributes on this class.
-
#location ⇒ Object
The currently allowed attributes on this class.
-
#mimetype ⇒ Object
The currently allowed attributes on this class.
-
#modification_date ⇒ Object
The currently allowed attributes on this class.
-
#note ⇒ Object
The currently allowed attributes on this class.
-
#original ⇒ Object
The currently allowed attributes on this class.
-
#preservation_levels ⇒ Object
The currently allowed attributes on this class.
-
#puid ⇒ Object
The currently allowed attributes on this class.
-
#relationship_infos ⇒ Object
The currently allowed attributes on this class.
-
#representation ⇒ Object
The currently allowed attributes on this class.
-
#signatures ⇒ Object
The currently allowed attributes on this class.
-
#size ⇒ Object
The currently allowed attributes on this class.
-
#software_ids ⇒ Object
The currently allowed attributes on this class.
-
#software_infos ⇒ Object
The currently allowed attributes on this class.
-
#source_metadata ⇒ Object
The currently allowed attributes on this class.
-
#target_location ⇒ Object
The currently allowed attributes on this class.
Instance Method Summary collapse
-
#amd ⇒ Object
This method creates the appropriate DnxSections based on what attributes are filled in.
-
#make_group_id ⇒ Object
The id that will be used for the group in the XML file.
-
#orig_name ⇒ Object
The file’s name as it was originally.
-
#orig_path ⇒ Object
The file’s original directory.
-
#target ⇒ Object
The full path where the file is copied.
- #target_name ⇒ Object
- #target_path ⇒ Object
-
#xml_id ⇒ Object
The id that will be used in the XML file to reference this file.
Methods included from MetsObject
#id, #initialize, #set_from_hash, #set_id, #to_s
Instance Attribute Details
#applications ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def applications @applications end |
#checksum_MD5 ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def checksum_MD5 @checksum_MD5 end |
#checksum_SHA1 ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def checksum_SHA1 @checksum_SHA1 end |
#checksum_SHA256 ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def checksum_SHA256 @checksum_SHA256 end |
#checksum_SHA384 ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def checksum_SHA384 @checksum_SHA384 end |
#checksum_SHA512 ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def checksum_SHA512 @checksum_SHA512 end |
#composition_level ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def composition_level @composition_level end |
#creation_date ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def creation_date @creation_date end |
#dc_record ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def dc_record @dc_record end |
#entity_type ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def entity_type @entity_type end |
#env_dependencies ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def env_dependencies @env_dependencies end |
#environments ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def environments @environments end |
#fixity_type ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def fixity_type @fixity_type end |
#fixity_value ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def fixity_value @fixity_value end |
#group_id ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def group_id @group_id end |
#hardware_ids ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def hardware_ids @hardware_ids end |
#hardware_infos ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def hardware_infos @hardware_infos end |
#inhibitors ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def inhibitors @inhibitors end |
#label ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def label @label end |
#location ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def location @location end |
#mimetype ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def mimetype @mimetype end |
#modification_date ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def modification_date @modification_date end |
#note ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def note @note end |
#original ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def original @original end |
#preservation_levels ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def preservation_levels @preservation_levels end |
#puid ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def puid @puid end |
#relationship_infos ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def relationship_infos @relationship_infos end |
#representation ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def representation @representation end |
#signatures ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def signatures @signatures end |
#size ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def size @size end |
#software_ids ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def software_ids @software_ids end |
#software_infos ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def software_infos @software_infos end |
#source_metadata ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def @source_metadata end |
#target_location ⇒ Object
The currently allowed attributes on this class. The attributes will typically be used in DnxSections.
52 53 54 |
# File 'lib/libis/tools/mets_objects.rb', line 52 def target_location @target_location end |
Instance Method Details
#amd ⇒ Object
This method creates the appropriate DnxSections based on what attributes are filled in.
97 98 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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/libis/tools/mets_objects.rb', line 97 def amd dnx = {} tech_data = [] # General File charateristics data = { label: label, note: note, fileCreationDate: creation_date, fileModificationDate: modification_date, FileEntityType: entity_type, compositionLevel: composition_level, # fileLocationType: 'FILE', fileLocation: location, fileOriginalName: original || target_name, fileOriginalPath: target_path, # fileOriginalID: CGI.escape(location), # fileExtension: ::File.extname(orig_name), fileMIMEType: mimetype, fileSizeBytes: size, # formatLibraryId: puid }.cleanup tech_data << GeneralFileCharacteristics.new(data) unless data.empty? # Fixity %w'MD5 SHA1 SHA256 SHA384 SHA512'.each do |checksum_type| if (checksum = self.send("checksum_#{checksum_type}")) data = { fixityType: checksum_type, fixityValue: checksum, }.cleanup tech_data << FileFixity.new(data) unless data.empty? end end # Object characteristics data = { groupID: make_group_id }.cleanup tech_data << ObjectCharacteristics.new(data) unless data.empty? # Preservation level if preservation_levels data_list = [] preservation_levels.each do |preservation_level| data = { preservationLevelValue: preservation_level[:value], preservationLevelRole: preservation_level[:role], preservationLevelRationale: preservation_level[:rationale], preservationLevelDateAssigned: preservation_level[:date], }.cleanup data_list << OpenStruct.new(data) unless data.empty? end tech_data << PreservationLevel.new(array: data_list) unless data_list.empty? end # Inhibitor if inhibitors data_list = [] inhibitors.each do |inhibitor| data = { inhibitorType: inhibitor[:type], inhibitorTarget: inhibitor[:target], inhibitorKey: inhibitor[:key], }.cleanup data_list << OpenStruct.new(data) unless data.empty? end tech_data << Inhibitors.new(array: data_list) unless data_list.empty? end # Dependencies if env_dependencies data_list = [] env_dependencies.each do |dependency| data = { dependencyName: dependency[:name], dependencyIdentifierType1: dependency[:type1], dependencyIdentifierValue1: dependency[:value1], dependencyIdentifierType2: dependency[:type2], dependencyIdentifierValue2: dependency[:value2], dependencyIdentifierType3: dependency[:type3], dependencyIdentifierValue3: dependency[:value3], }.cleanup data_list << OpenStruct.new(data) unless data.empty? end tech_data << EnvironmentDependencies.new(array: data_list) unless data_list.empty? end # Hardware registry id if hardware_ids data_list = [] hardware_ids.each do |id| data = { registryId: id }.cleanup data_list << OpenStruct.new(data) unless data.empty? end tech_data << EnvHardwareRegistry.new(array: data_list) unless data_list.empty? end # Software registry id if software_ids data_list = [] software_ids.each do |id| data = { registryId: id }.cleanup data_list << OpenStruct.new(data) unless data.empty? end tech_data << EnvSoftwareRegistry.new(array: data_list) unless data_list.empty? end # Singatures if signatures data_list = [] signatures.each do |signature| data = { signatureInformationEncoding: signature[:encoding], signer: signature[:signer], signatureMethod: signature[:method], signatureValue: signature[:value], signatureValidationRules: signature[:rules], signatureProperties: signature[:properties], }.cleanup data_list << OpenStruct.new(data) unless data.empty? end tech_data << SignatureInformation.new(array: data_list) unless data_list.empty? end # Hardware if hardware_infos data_list = [] hardware_infos.each do |hardware| data = { hardwareName: hardware[:name], hardwareType: hardware[:type], hardwareOtherInformation: hardware[:info], }.cleanup data_list << OpenStruct.new(data) unless data.empty? end tech_data << EnvironmentHardware.new(array: data_list) unless data_list.empty? end # Software if software_infos data_list = [] software_infos.each do |software| data = { softwareName: software[:name], softwareVersion: software[:version], softwareType: software[:type], softwareOtherInformation: software[:info], softwareDependancy: software[:dependency], }.cleanup data_list << OpenStruct.new(data) unless data.empty? end tech_data << EnvironmentSoftware.new(array: data_list) unless data_list.empty? end # Relationship if relationship_infos data_list = [] relationship_infos.each do |relationship| data = { relationshipType: relationship[:type], relationshipSubType: relationship[:subtype], relatedObjectIdentifierType1: relationship[:type1], relatedObjectIdentifierValue1: relationship[:id1], relatedObjectSequence1: relationship[:seq1], relatedObjectIdentifierType2: relationship[:type2], relatedObjectIdentifierValue2: relationship[:id2], relatedObjectSequence2: relationship[:seq2], relatedObjectIdentifierType3: relationship[:type3], relatedObjectIdentifierValue3: relationship[:id3], relatedObjectSequence3: relationship[:seq3], }.cleanup data_list << OpenStruct.new(data) unless data.empty? end tech_data << RelationShip.new(array: data_list) unless data_list.empty? end # Environment if environments data_list = [] environments.each do |environment| data = { environmentCharacteristic: environment[:characteristic], environmentPurpose: environment[:purpose], environmentNote: environment[:note], }.cleanup data_list << OpenStruct.new(data) unless data.empty? end tech_data << Environment.new(array: data_list) unless data_list.empty? end # Application if applications data_list = [] applications.each do |application| data = { creatingApplicationName: application[:name], creatingApplicationVersion: application[:version], dateCreatedByApplication: application[:date], }.cleanup data_list << OpenStruct.new(data) unless data.empty? end tech_data << CreatingApplication.new(array: data_list) unless data_list.empty? end # Finally assemble technical section dnx[:tech] = tech_data unless tech_data.empty? dnx end |
#make_group_id ⇒ Object
The id that will be used for the group in the XML file.
66 67 68 |
# File 'lib/libis/tools/mets_objects.rb', line 66 def make_group_id "grp#{group_id rescue @id}" end |
#orig_name ⇒ Object
The file’s name as it was originally.
71 72 73 |
# File 'lib/libis/tools/mets_objects.rb', line 71 def orig_name ::File.basename(location) end |
#orig_path ⇒ Object
The file’s original directory.
76 77 78 |
# File 'lib/libis/tools/mets_objects.rb', line 76 def orig_path ::File.dirname(location) end |
#target ⇒ Object
The full path where the file is copied
81 82 83 84 85 86 |
# File 'lib/libis/tools/mets_objects.rb', line 81 def target if target_location.nil? return "#{xml_id}#{::File.extname(location)}" end target_location end |
#target_name ⇒ Object
88 89 90 |
# File 'lib/libis/tools/mets_objects.rb', line 88 def target_name ::File.basename(target) end |
#target_path ⇒ Object
92 93 94 |
# File 'lib/libis/tools/mets_objects.rb', line 92 def target_path ::File.dirname(target) end |
#xml_id ⇒ Object
The id that will be used in the XML file to reference this file.
61 62 63 |
# File 'lib/libis/tools/mets_objects.rb', line 61 def xml_id "fid#{@id}" end |