Class: Dor::TechnicalMetadataService
- Inherits:
-
Object
- Object
- Dor::TechnicalMetadataService
- Defined in:
- lib/dor/services/technical_metadata_service.rb
Overview
Extracts technical metadata from files using JHOVE If this is a new version it gets the old technicalMetadata datastream by making an API call to sdr-services-app (via dor-services-app) and only overwrites/adds parts for the files that were changed or added. This allows us to avoid re-staging files that have not changed. Switching to a more granular data model that has file metadata separate from the Work metadata will allow us to simplify this greatly.
Class Method Summary collapse
-
.add_update_technical_metadata(dor_item) ⇒ Boolean
True if technical metadata is correctly added or updated.
Class Method Details
.add_update_technical_metadata(dor_item) ⇒ Boolean
Returns True if technical metadata is correctly added or updated.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dor/services/technical_metadata_service.rb', line 19 def self.(dor_item) test_jhove_service druid = dor_item.pid content_group_diff = get_content_group_diff(dor_item) deltas = get_file_deltas(content_group_diff) new_files = get_new_files(deltas) old_techmd = (dor_item) new_techmd = (druid, new_files) if old_techmd.nil? # this is version 1 or previous technical metadata was not saved final_techmd = new_techmd elsif content_group_diff.difference_count == 0 # there have been no changes to content files from previous version return true else merged_nodes = merge_file_nodes(old_techmd, new_techmd, deltas) final_techmd = (druid, merged_nodes) end ds = dor_item.datastreams['technicalMetadata'] ds.dsLabel = 'Technical Metadata' ds.content = final_techmd ds.save true end |