diff --git a/app/assets/javascripts/digital_objects_app/models/digital_object/asset.js b/app/assets/javascripts/digital_objects_app/models/digital_object/asset.js index 52734540e..286280491 100644 --- a/app/assets/javascripts/digital_objects_app/models/digital_object/asset.js +++ b/app/assets/javascripts/digital_objects_app/models/digital_object/asset.js @@ -87,7 +87,7 @@ Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.getOriginalFilePath = f }; Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.hasImage = function () { - return Hyacinth.imageServerUrl && this.getDcType() == 'StillImage'; + return Hyacinth.imageServerUrl && this.isStillImage(); }; Hyacinth.DigitalObjectsApp.DigitalObject.Asset.prototype.isRestrictedSizeImage = function () { diff --git a/app/assets/javascripts/digital_objects_app/models/digital_object/base.js b/app/assets/javascripts/digital_objects_app/models/digital_object/base.js index 5aea1a173..bda88ae6c 100644 --- a/app/assets/javascripts/digital_objects_app/models/digital_object/base.js +++ b/app/assets/javascripts/digital_objects_app/models/digital_object/base.js @@ -76,6 +76,14 @@ Hyacinth.DigitalObjectsApp.DigitalObject.Base.prototype.getStateAsDisplayLabel = return statesToDisplayLabels[this.getState()]; }; +Hyacinth.DigitalObjectsApp.DigitalObject.Base.prototype.isAudioMovingImage = function () { + return ['Audio','MovingImage', 'Sound', 'Video'].includes(this.dc_type); +}; + +Hyacinth.DigitalObjectsApp.DigitalObject.Base.prototype.isStillImage = function () { + return ['Image','StillImage'].includes(this.dc_type); +}; + Hyacinth.DigitalObjectsApp.DigitalObject.Base.prototype.isNewRecord = function () { return (this.getPid() == null); }; diff --git a/app/assets/javascripts/digital_objects_app/models/digital_object_search_result.js b/app/assets/javascripts/digital_objects_app/models/digital_object_search_result.js index 534029fa2..895ee4aa9 100644 --- a/app/assets/javascripts/digital_objects_app/models/digital_object_search_result.js +++ b/app/assets/javascripts/digital_objects_app/models/digital_object_search_result.js @@ -18,6 +18,14 @@ Hyacinth.DigitalObjectsApp.DigitalObjectSearchResult.prototype.getDcType = funct return this.dcType; }; +Hyacinth.DigitalObjectsApp.DigitalObjectSearchResult.prototype.isAudioMovingImage = function(){ + return ['Audio','MovingImage', 'Sound', 'Video'].includes(this.dcType); +}; + +Hyacinth.DigitalObjectsApp.DigitalObjectSearchResult.prototype.isStillImage = function(){ + return ['Image', 'StillImage'].includes(this.dcType); +}; + Hyacinth.DigitalObjectsApp.DigitalObjectSearchResult.prototype.getPid = function(){ return this.pid; }; diff --git a/app/assets/javascripts/digital_objects_app/widgets/digital_object_annotation_editor.js b/app/assets/javascripts/digital_objects_app/widgets/digital_object_annotation_editor.js index 07238c8f4..9dceddc06 100644 --- a/app/assets/javascripts/digital_objects_app/widgets/digital_object_annotation_editor.js +++ b/app/assets/javascripts/digital_objects_app/widgets/digital_object_annotation_editor.js @@ -36,7 +36,7 @@ Hyacinth.DigitalObjectsApp.DigitalObjectAnnotationEditor.prototype.init = functi this.$containerElement.addClass(Hyacinth.DigitalObjectsApp.DigitalObjectAnnotationEditor.ANNOTATION_EDITOR_ELEMENT_CLASS); //Add class to container element this.$containerElement.data(Hyacinth.DigitalObjectsApp.DigitalObjectAnnotationEditor.ANNOTATION_EDITOR_DATA_KEY, this); //Assign this editor object as data to the container element so that we can access it later - if(['MovingImage', 'Sound'].indexOf(this.digitalObject.getDcType()) > -1) { + if(this.digitalObject.isAudioMovingImage()) { this.$containerElement.html( Hyacinth.DigitalObjectsApp.renderTemplate('digital_objects_app/widgets/digital_object_annotation_editor/oh_synchronizer_index_mode.ejs', { digitalObject: this.digitalObject, diff --git a/app/assets/javascripts/digital_objects_app/widgets/digital_object_synchronized_transcript_editor.js b/app/assets/javascripts/digital_objects_app/widgets/digital_object_synchronized_transcript_editor.js index 523f4c249..8f6c6a9f5 100644 --- a/app/assets/javascripts/digital_objects_app/widgets/digital_object_synchronized_transcript_editor.js +++ b/app/assets/javascripts/digital_objects_app/widgets/digital_object_synchronized_transcript_editor.js @@ -36,7 +36,7 @@ Hyacinth.DigitalObjectsApp.DigitalObjectSynchronizedTranscriptEditor.prototype.i this.$containerElement.addClass(Hyacinth.DigitalObjectsApp.DigitalObjectSynchronizedTranscriptEditor.SYNCHRONIZED_TRANSCRIPT_EDITOR_ELEMENT_CLASS); //Add class to container element this.$containerElement.data(Hyacinth.DigitalObjectsApp.DigitalObjectSynchronizedTranscriptEditor.SYNCHRONIZED_TRANSCRIPT_EDITOR_DATA_KEY, this); //Assign this editor object as data to the container element so that we can access it later - if (['MovingImage', 'Sound'].indexOf(this.digitalObject.getDcType()) > -1) { + if(this.digitalObject.isAudioMovingImage()) { this.$containerElement.html( Hyacinth.DigitalObjectsApp.renderTemplate('digital_objects_app/widgets/digital_object_synchronized_transcript_editor/oh_synchronizer_transcript_mode.ejs', { digitalObject: this.digitalObject, diff --git a/app/assets/templates/digital_objects_app/digital_objects/show.ejs b/app/assets/templates/digital_objects_app/digital_objects/show.ejs index 9cff5f970..22da8c797 100644 --- a/app/assets/templates/digital_objects_app/digital_objects/show.ejs +++ b/app/assets/templates/digital_objects_app/digital_objects/show.ejs @@ -23,22 +23,21 @@ if (digitalObject.digital_object_type.string_key == 'asset') { Hyacinth.DigitalObjectsApp.paramsToHashValue({controller: 'digital_objects', action: 'manage_transcript', pid: Hyacinth.DigitalObjectsApp.params['pid']})}); -} - -if (digitalObject.digital_object_type.string_key == 'asset' && (digitalObject.getDcType() == 'MovingImage' || digitalObject.getDcType() == 'Sound')) { - navItems.push({label: ' Annotation', url: '#' + - Hyacinth.DigitalObjectsApp.paramsToHashValue({controller: 'digital_objects', - action: 'manage_annotation', - pid: Hyacinth.DigitalObjectsApp.params['pid']})}); + if (digitalObject.isAudioMovingImage()) { + navItems.push({label: ' Annotation', url: '#' + + Hyacinth.DigitalObjectsApp.paramsToHashValue({controller: 'digital_objects', + action: 'manage_annotation', + pid: Hyacinth.DigitalObjectsApp.params['pid']})}); - navItems.push({label: ' Synchronized Transcript', url: '#' + - Hyacinth.DigitalObjectsApp.paramsToHashValue({controller: 'digital_objects', - action: 'manage_synchronized_transcript', - pid: Hyacinth.DigitalObjectsApp.params['pid']})}); - navItems.push({label: ' Captions', url: '#' + - Hyacinth.DigitalObjectsApp.paramsToHashValue({controller: 'digital_objects', - action: 'manage_captions', - pid: Hyacinth.DigitalObjectsApp.params['pid']})}); + navItems.push({label: ' Synchronized Transcript', url: '#' + + Hyacinth.DigitalObjectsApp.paramsToHashValue({controller: 'digital_objects', + action: 'manage_synchronized_transcript', + pid: Hyacinth.DigitalObjectsApp.params['pid']})}); + navItems.push({label: ' Captions', url: '#' + + Hyacinth.DigitalObjectsApp.paramsToHashValue({controller: 'digital_objects', + action: 'manage_captions', + pid: Hyacinth.DigitalObjectsApp.params['pid']})}); + } } if (hasUpdatePermission) { diff --git a/app/assets/templates/digital_objects_app/widgets/digital_object_editor/_header.ejs b/app/assets/templates/digital_objects_app/widgets/digital_object_editor/_header.ejs index 0b548e9f7..09a7b48b6 100644 --- a/app/assets/templates/digital_objects_app/widgets/digital_object_editor/_header.ejs +++ b/app/assets/templates/digital_objects_app/widgets/digital_object_editor/_header.ejs @@ -299,7 +299,7 @@

Asset

- <% if (digitalObject.getDcType() == 'StillImage') { %> + <% if (digitalObject.isStillImage()) { %> View Zoomable Image <% if (mode == 'show') { %>
@@ -314,7 +314,7 @@
<% } %> - <% } else if (['Sound','MovingImage'].includes(digitalObject.getDcType())) { %> + <% } else if (digitalObject.isAudioMovingImage()) { %> View Media <% } %> diff --git a/app/controllers/assignments/changesets_controller.rb b/app/controllers/assignments/changesets_controller.rb index d983ccd6c..ab4a87040 100644 --- a/app/controllers/assignments/changesets_controller.rb +++ b/app/controllers/assignments/changesets_controller.rb @@ -36,7 +36,7 @@ def update end when 'annotate_object' if index_document_params[:index_document_text] - if ['MovingImage', 'Sound'].include?(digital_object.dc_type) + if digital_object.audio_moving_image? create_or_update_annotate_changeset(@assignment, digital_object, index_document_params[:index_document_text]) @assignment.save else @@ -45,7 +45,7 @@ def update end when 'synchronize' if synchronized_transcript_params[:synchronized_transcript_text] - if ['MovingImage', 'Sound'].include?(digital_object.dc_type) + if digital_object.audio_moving_image? create_or_update_synchronize_changeset(@assignment, digital_object, synchronized_transcript_params[:synchronized_transcript_text]) @assignment.save else @@ -86,7 +86,7 @@ def create_or_update_transcribe_changeset(assignment, digital_object, new_conten end def create_or_update_annotate_changeset(assignment, digital_object, new_content) - if ['MovingImage', 'Sound'].include?(digital_object.dc_type) + if digital_object.audio_moving_image? assignment.original = digital_object.index_document if assignment.original.nil? else raise 'Not implemented yet' @@ -95,7 +95,7 @@ def create_or_update_annotate_changeset(assignment, digital_object, new_content) end def create_or_update_synchronize_changeset(assignment, digital_object, new_content) - if ['MovingImage', 'Sound'].include?(digital_object.dc_type) + if digital_object.audio_moving_image? assignment.original = digital_object.synchronized_transcript if assignment.original.nil? else raise 'Not implemented yet' diff --git a/app/controllers/assignments_controller.rb b/app/controllers/assignments_controller.rb index 4b7edcebc..9bf49b51c 100644 --- a/app/controllers/assignments_controller.rb +++ b/app/controllers/assignments_controller.rb @@ -34,7 +34,7 @@ def create @assignment.proposed = @assignment.original when 'annotate_object' # store current state of transcript in *original* field - if ['MovingImage', 'Sound'].include?(@digital_object.dc_type) + if @digital_object.audio_moving_image? @assignment.original = @digital_object.index_document else raise 'Not implemented yet' @@ -43,7 +43,7 @@ def create @assignment.proposed = @assignment.original when 'synchronize' # store current state of transcript in *original* field - if ['MovingImage', 'Sound'].include?(@digital_object.dc_type) + if @digital_object.audio_moving_image? @assignment.original = @digital_object.synchronized_transcript else raise 'Not implemented yet' @@ -124,13 +124,13 @@ def commit digital_object.transcript = @assignment.proposed when 'annotate_object' # TODO: Probably change index_document to annotation - if ['MovingImage', 'Sound'].include?(digital_object.dc_type) + if digital_object.audio_moving_image? digital_object.index_document = @assignment.proposed else raise 'Not implemented yet' end when 'synchronize' - if ['MovingImage', 'Sound'].include?(digital_object.dc_type) + if digital_object.audio_moving_image? digital_object.synchronized_transcript = @assignment.proposed else raise "Cannot commit synchronized transcript for non-audiovisual resource (pid: #{digital_object.pid}, dc_type: #{digital_object.dc_type})" diff --git a/app/controllers/digital_objects_controller.rb b/app/controllers/digital_objects_controller.rb index 6bca56d87..1ab2deb18 100644 --- a/app/controllers/digital_objects_controller.rb +++ b/app/controllers/digital_objects_controller.rb @@ -262,7 +262,7 @@ def saveable?(errors = nil) end def rotate_image - unless @digital_object.is_a?(DigitalObject::Asset) && @digital_object.dc_type == 'StillImage' + unless @digital_object.is_a?(DigitalObject::Asset) && @digital_object.still_image? render json: { errors: ["Only Assets of type StillImage can be rotated. This is a #{@digital_object.digital_object_type.display_label} of type #{@digital_object.dc_type}"] } return end diff --git a/app/models/digital_object/asset.rb b/app/models/digital_object/asset.rb index 3a5779728..aed639acb 100644 --- a/app/models/digital_object/asset.rb +++ b/app/models/digital_object/asset.rb @@ -9,8 +9,12 @@ class DigitalObject::Asset < DigitalObject::Base include DigitalObject::Assets::Captions include Hyacinth::Utils::StringUtils - UNKNOWN_DC_TYPE = 'Unknown' - VALID_DC_TYPES = [UNKNOWN_DC_TYPE, 'Dataset', 'MovingImage', 'Software', 'Sound', 'StillImage', 'Text'] + UNKNOWN_DC_TYPE = BestType::PcdmTypeLookup::UNKNOWN + ASSET_DC_TYPES = ['Dataset', 'MovingImage', 'Software', 'Sound', 'StillImage', 'Text'] + VALID_DC_TYPES = (BestType::PcdmTypeLookup::VALID_TYPES + ASSET_DC_TYPES).uniq + AMI_DC_TYPES = ['Audio', 'MovingImage', 'Sound', 'Video'] + IMAGE_DC_TYPES = ['Image', 'StillImage'] + DIGITAL_OBJECT_TYPE_STRING_KEY = 'asset' DEFAULT_ASSET_NAME = 'Asset' # For when a title is not supplied and we're not doing with a filesystem upload @@ -405,6 +409,14 @@ def write_update_synchronized_transcript_file_if_changed! end end + def audio_moving_image? + AMI_DC_TYPES.include?(self.dc_type || BestType.dc_type.for_file_name(self.original_filename)) + end + + def still_image? + IMAGE_DC_TYPES.include?(self.dc_type || BestType.dc_type.for_file_name(self.original_filename)) + end + def player_mime_type if HYACINTH.fetch(:media_streaming, {})['wowza'].present? 'application/x-mpegURL' diff --git a/app/models/digital_object/base.rb b/app/models/digital_object/base.rb index abe5114b3..82ce112ca 100644 --- a/app/models/digital_object/base.rb +++ b/app/models/digital_object/base.rb @@ -259,6 +259,14 @@ def self.valid_dc_types self::VALID_DC_TYPES end + def audio_moving_image? + false + end + + def still_image? + false + end + def allowed_publish_targets DigitalObject::PublishTarget.basic_publish_target_data_from_solr(project.enabled_publish_target_pids) end diff --git a/app/views/digital_objects/media_view.html.erb b/app/views/digital_objects/media_view.html.erb index 012c09af9..06992b951 100644 --- a/app/views/digital_objects/media_view.html.erb +++ b/app/views/digital_objects/media_view.html.erb @@ -1,4 +1,4 @@ -<% if @digital_object.dc_type == 'StillImage' %> +<% if @digital_object.still_image? %>