Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Commit

Permalink
Adding instantiationDimensions element
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Trautmann committed Oct 13, 2011
1 parent a01ff34 commit 2989b13
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/instantiations_controller.rb
Expand Up @@ -118,7 +118,7 @@ def update
@instantiation = @asset.instantiations.find(params[:id])
@instantiation.transaction do
parsed_instantiation = Instantiation.from_xml(params[:xml])
[:format_ids, :instantiation_dates, :essence_tracks, :annotations, :format, ## WTF DATE_AVAILABLES :date_availables
[:format_ids, :instantiation_dates, :instantiation_dimensions, :essence_tracks, :annotations, :format, ## WTF DATE_AVAILABLES :date_availables
:instantiation_media_type, :instantiation_generation, :instantiation_color, :format_location,
:format_file_size, :format_time_start, :format_duration,
:format_data_rate, :format_tracks, :format_channel_configuration,
Expand Down
2 changes: 2 additions & 0 deletions app/models/instantiation.rb
Expand Up @@ -5,6 +5,7 @@ class Instantiation < ActiveRecord::Base
belongs_to :asset
has_many :format_ids, :dependent => :destroy, :attributes => true
has_many :instantiation_dates, :dependent => :destroy, :attributes => true
has_many :instantiation_dimensions, :dependent => :destroy, :attributes => true
belongs_to :format
belongs_to :instantiation_media_type
belongs_to :instantiation_generation
Expand All @@ -31,6 +32,7 @@ class Instantiation < ActiveRecord::Base
xml << fid
end
xml_subelements "instantiationDate", :instantiation_dates
xml_subelements "instantiationDimensions", :instantiation_dimensions
from_xml_elt do |record|
elt = record._working_xml.find_first("pbcore:instantiationPhysical|pbcore:instantiationDigital", PbcoreXmlElement::PBCORE_NAMESPACE)
if elt && elt.content
Expand Down
7 changes: 7 additions & 0 deletions app/models/instantiation_dimension.rb
@@ -0,0 +1,7 @@
class InstantiationDimension < ActiveRecord::Base
include PbcoreXmlElement
belongs_to :instantiation

xml_text_field :dimension
# xml_attributes { "unitsOfMeasure" => :units_of_measure }, { "annotation" => :annotation }
end
2 changes: 2 additions & 0 deletions app/views/instantiations/_form.html.haml
Expand Up @@ -16,6 +16,8 @@
#format_ids
%h3 Instantiation Dates
#instantiation_dates
%h3 Instantiation Dimensions
#instantiation_dimensions
%h3 Instantiation Information
#instantiation_info
%h3 Essence Tracks
Expand Down
16 changes: 16 additions & 0 deletions db/migrate/20111013040951_create_instantiation_dimensions.rb
@@ -0,0 +1,16 @@
class CreateInstantiationDimensions < ActiveRecord::Migration
def self.up
create_table :instantiation_dimensions do |t|
t.integer :instantiation_id
t.string :dimension
t.string :units_of_measure
t.text :annotation

t.timestamps
end
end

def self.down
drop_table :instantiation_dimensions
end
end
11 changes: 10 additions & 1 deletion db/schema.rb
Expand Up @@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20111012154123) do
ActiveRecord::Schema.define(:version => 20111013040951) do

create_table "annotations", :force => true do |t|
t.integer "instantiation_id"
Expand Down Expand Up @@ -353,6 +353,15 @@
t.datetime "updated_at"
end

create_table "instantiation_dimensions", :force => true do |t|
t.integer "instantiation_id"
t.string "dimension"
t.string "units_of_measure"
t.text "annotation"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "instantiation_generations", :force => true do |t|
t.string "name", :null => false
t.boolean "visible", :default => false, :null => false
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/common/edit.js
Expand Up @@ -715,6 +715,7 @@ var FormEditor = (function($, undefined) {
return $(elt).attr("source") === 'pbcore XML database UUID';
});
mkfields("instantiation_dates", "instantiationDate", pbcore_maker(undefined, "dateType", Style.VERBOSE, false, true));
mkfields("instantiation_dimensions", "instantiationDimensions", pbcore_maker(undefined, undefined, Style.ONLY_TEXTAREA));
basic_instantiation_fields();
mkfields("essence_tracks", "pbcoreEssenceTrack", essence_track_maker);
mkfields("annotations", "instantiationAnnotation", pbcore_maker(undefined, "annotationType", Style.TEXTAREA, false, true));
Expand Down Expand Up @@ -837,7 +838,6 @@ var FormEditor = (function($, undefined) {
var name = this.name, elt;
if (name === 'instantiation') {
name += $('input[name="format_type"]:checked').val();
alert(name);
}
elt = mkelt(name);
root.appendChild(elt);
Expand Down
2 changes: 1 addition & 1 deletion public/stylesheets/application/styles.css
Expand Up @@ -482,7 +482,7 @@ input.pbcorefield.ui-autocomplete-input { width: 211px; }
}


#identifiers, #titles, #subjects, #descriptions, #genres, #relations, #publishers, #essence_tracks, #instantiation_info, #format_ids, #instantiation_dates, #annotations, #creators, #contributors, #publishers, #rights_summaries, #extensions, #coverages, #audience_levels, #audience_ratings, #asset_dates {
#identifiers, #titles, #subjects, #descriptions, #genres, #relations, #publishers, #essence_tracks, #instantiation_info, #format_ids, #instantiation_dates, #instantiation_dimensions, #annotations, #creators, #contributors, #publishers, #rights_summaries, #extensions, #coverages, #audience_levels, #audience_ratings, #asset_dates {
padding:5px;
margin:0 10px 0 0;
display:block;
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/instantiation_dimensions.yml
@@ -0,0 +1,11 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html

one:
dimension: MyString
units_of_measure: MyString
annotation: MyText

two:
dimension: MyString
units_of_measure: MyString
annotation: MyText
8 changes: 8 additions & 0 deletions test/unit/instantiation_dimension_test.rb
@@ -0,0 +1,8 @@
require 'test_helper'

class InstantiationDimensionTest < ActiveSupport::TestCase
# Replace this with your real tests.
def test_truth
assert true
end
end

0 comments on commit 2989b13

Please sign in to comment.