ddr-models 3.0.0.beta.11 → 3.0.0.beta.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b649796b2ae7a3e6d271ae693967c20ffcaf09c6
4
- data.tar.gz: a08a5a96113854923916d642994a458f0899edef
3
+ metadata.gz: 4f083a735027958d5b91d4c88489f3fb4aa89c5d
4
+ data.tar.gz: 0a23cbc2083fa5981c83b51bd1fbf886a4b98e40
5
5
  SHA512:
6
- metadata.gz: 92bf5752a52715353c0c6e8bc88a009e0840a1d23caff13383c10c5bb900600dfdce1e30691ff0f2c9dd02e8756806d407e4e785bc67ee9050a9d09dbb40f554
7
- data.tar.gz: 35f6bc9504c3500b54ec397dc0fc904de3c00a0a6226e52f1438d2698c7016a34e73bf3843a2b3c509a9cd0a9bcf86fed83a9e402f88f7974e8c12d27d0335f6
6
+ metadata.gz: a140e0f42c7ccfceee28286980a357be7673b942b04d61ac032d8c6dd0c2f4d267318ea81f79830dce77c404c72ed2f9972efc99ae0eafe6481d10df59075454
7
+ data.tar.gz: c93e6bb6856409f9ef4fdd728839fc84f41b62073df089792b8b566895aec1b4aa61b0ccd82158538ee3310891a6176a37c78919a623a78de7dbc5dabdf4e778
@@ -13,10 +13,14 @@ module Ddr
13
13
 
14
14
  def self.const_missing(name)
15
15
  case name
16
- when :CONTENT, :DESC_METADATA, :EXTRACTED_TEXT, :FITS, :STRUCT_METADATA, :THUMBNAIL
16
+ when :CONTENT, :EXTRACTED_TEXT, :FITS, :STRUCT_METADATA, :THUMBNAIL
17
17
  Deprecation.warn(self, "Ddr::Datastreams::#{name} is deprecated." \
18
18
  " Use Ddr::Models::File::#{name} instead.")
19
19
  Ddr::Models::File.const_get(name)
20
+ when :DESC_METADATA
21
+ Deprecation.warn(self, "Ddr::Datastreams::DESC_METADATA is deprecated." \
22
+ " Use Ddr::Models::Metadata::DESC_METADATA instead.")
23
+ Ddr::Models::Metadata::DESC_METADATA
20
24
  when :FitsDatastream
21
25
  Deprecation.warn(self, "Ddr::Datastreams::FitsDatastream is deprecated." \
22
26
  " Use Ddr::Models::FitsXmlFile instead.")
@@ -10,10 +10,11 @@ module Ddr
10
10
  #
11
11
  class PermanentIdManager
12
12
 
13
- PERMANENT_URL_BASE = "http://id.library.duke.edu/"
13
+ PERMANENT_URL_BASE = "http://id.library.duke.edu/"
14
14
  ASSIGN_EVENT_SUMMARY = "Permanent ID assignment"
15
- SOFTWARE = Ezid::Client.version
16
- FCREPO3_PID = "fcrepo3.pid"
15
+ SOFTWARE = Ezid::Client.version
16
+ FCREPO3_PID = "fcrepo3.pid"
17
+ FCREPO4_ID = "fcrepo4.id"
17
18
 
18
19
  attr_reader :object
19
20
 
@@ -56,7 +57,7 @@ EZID Metadata:
56
57
  def default_metadata
57
58
  { :profile => "dc",
58
59
  :export => "no",
59
- FCREPO3_PID => object.pid
60
+ FCREPO4_ID => object.id
60
61
  }
61
62
  end
62
63
 
@@ -74,6 +74,7 @@ module Ddr
74
74
  end
75
75
 
76
76
  autoload_under "metadata" do
77
+ autoload :AdministrativeMetadata
77
78
  autoload :DescriptiveMetadata
78
79
  autoload :Metadata
79
80
  autoload :MetadataMapping
@@ -35,6 +35,15 @@ module Ddr::Models
35
35
  model_and_id
36
36
  end
37
37
 
38
+ def adminMetadata
39
+ Deprecation.warn(Base, "`adminMetadata` is deprecated; use `admin_metadata` instead.")
40
+ admin_metadata
41
+ end
42
+
43
+ def admin_metadata
44
+ @admin_metadata ||= AdministrativeMetadata.new(self)
45
+ end
46
+
38
47
  def descMetadata
39
48
  Deprecation.warn(Base, "`descMetadata` is deprecated; use `desc_metadata` instead.")
40
49
  desc_metadata
@@ -44,10 +53,6 @@ module Ddr::Models
44
53
  @desc_metadata ||= DescriptiveMetadata.new(self)
45
54
  end
46
55
 
47
- def has_desc_metadata?
48
- desc_metadata.has_content?
49
- end
50
-
51
56
  def desc_metadata_terms(*args)
52
57
  return DescriptiveMetadata.unqualified_names.sort if args.empty?
53
58
  arg = args.pop
@@ -5,7 +5,6 @@ module Ddr::Models
5
5
  extend Deprecation
6
6
 
7
7
  CONTENT = "content".freeze
8
- DESC_METADATA = "descMetadata".freeze
9
8
  EXTRACTED_TEXT = "extractedText".freeze
10
9
  FITS = "fits".freeze
11
10
  STRUCT_METADATA = "structMetadata".freeze
@@ -14,6 +13,15 @@ module Ddr::Models
14
13
  DEFAULT_FILE_EXTENSION = "bin"
15
14
  STRFTIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%LZ"
16
15
 
16
+ def self.const_missing(name)
17
+ case name
18
+ when :DESC_METADATA
19
+ Deprecation.warn(self, "Ddr::File::DESC_METADATA is deprecated." \
20
+ " Use Ddr::Models::Metadata::DESC_METADATA instead.")
21
+ Ddr::Models::Metadata::DESC_METADATA
22
+ end
23
+ end
24
+
17
25
  def dsid
18
26
  Deprecation.warn(File, "`dsid` is no longer a file method. Use `::File.basename(id)`.")
19
27
  if id
@@ -0,0 +1,53 @@
1
+ require "forwardable"
2
+
3
+ module Ddr::Models
4
+ class AdministrativeMetadata
5
+ extend Forwardable
6
+ include Metadata
7
+
8
+
9
+ class << self
10
+ def field_names
11
+ [ :access_roles,
12
+ :admin_set,
13
+ :aspace_id,
14
+ :depositor,
15
+ :display_format,
16
+ :doi,
17
+ :ead_id,
18
+ :fcrepo3_pid,
19
+ :license,
20
+ :local_id,
21
+ :permanent_id,
22
+ :permanent_url,
23
+ :research_help_contact,
24
+ :workflow_state
25
+ ]
26
+ end
27
+
28
+ alias_method :unqualified_names, :field_names
29
+ alias_method :field_readers, :field_names
30
+
31
+ def field_writers
32
+ field_names.map { |name| "#{name}=".to_sym }
33
+ end
34
+
35
+ def property_terms
36
+ field_names.each_with_object({}) do |term, memo|
37
+ memo[term] = term
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ attr_reader :object
44
+
45
+ def_delegators :object, *field_readers
46
+ def_delegators :object, *field_writers
47
+
48
+ def initialize(object)
49
+ @object = object
50
+ end
51
+
52
+ end
53
+ end
@@ -24,6 +24,13 @@ module Ddr::Models
24
24
  def field_writers
25
25
  field_names.map { |name| "#{name}=".to_sym }
26
26
  end
27
+
28
+ def property_terms
29
+ mapping.terms.each_with_object({}) do |term, memo|
30
+ memo[term.unqualified_name] = term.qualified_name
31
+ end
32
+ end
33
+
27
34
  end
28
35
 
29
36
  self.mappings = [ MetadataMapping.dcterms, MetadataMapping.duketerms ].freeze
@@ -1,10 +1,29 @@
1
1
  module Ddr::Models
2
2
  module Metadata
3
+ extend ActiveSupport::Concern
4
+
5
+ ADMIN_METADATA = 'admin_metadata'.freeze
6
+ DESC_METADATA = 'desc_metadata'.freeze
7
+
8
+ included do
9
+ def self.property_term(term)
10
+ property_terms[term]
11
+ end
12
+ end
3
13
 
4
14
  def values(term)
5
15
  self.send(term)
6
16
  end
7
17
 
18
+ # Update singular term with value
19
+ def set_value(term, value)
20
+ begin
21
+ self.send("#{term}=", value)
22
+ rescue NoMethodError
23
+ raise ArgumentError, "No such term: #{term}"
24
+ end
25
+ end
26
+
8
27
  # Update term with values
9
28
  # Note that empty values (nil or "") are rejected from values array
10
29
  def set_values(term, values)
@@ -25,8 +44,13 @@ module Ddr::Models
25
44
  def add_value(term, value)
26
45
  begin
27
46
  unless value.blank?
28
- values = values(term).to_a << value
29
- set_values term, values
47
+ prop_term = self.class.property_term(term)
48
+ if object.class.properties[prop_term.to_s].multiple?
49
+ values = values(term).to_a << value
50
+ set_values term, values
51
+ else
52
+ set_value term, value
53
+ end
30
54
  end
31
55
  rescue NoMethodError
32
56
  raise ArgumentError, "No such term: #{term}"
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "3.0.0.beta.11"
3
+ VERSION = "3.0.0.beta.12"
4
4
  end
5
5
  end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ module Ddr::Models
4
+ RSpec.describe AdministrativeMetadata do
5
+
6
+ let(:obj) { FactoryGirl.build(:item) }
7
+
8
+ describe ".property_term" do
9
+ it "should return the correct property term" do
10
+ expect(described_class.property_term(:local_id)).to eq(:local_id)
11
+ end
12
+ end
13
+
14
+ describe "using the set_values and add_value methods" do
15
+ let(:ds) { described_class.new(obj) }
16
+ before { ds.local_id = 'foo001' }
17
+ describe "#set_values" do
18
+ it "should set the value of the term to the one supplied" do
19
+ ds.set_value :local_id, 'bar002'
20
+ expect(ds.local_id).to eq('bar002')
21
+ end
22
+ end
23
+ describe "#add_value" do
24
+ it "should set the term value to the supplied value" do
25
+ ds.add_value :local_id, 'bar002'
26
+ expect(ds.local_id).to eq('bar002')
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -15,6 +15,11 @@ module Ddr::Models
15
15
  expect(subject).to include(*Ddr::Vocab::Vocabulary.term_names(Ddr::Vocab::DukeTerms))
16
16
  end
17
17
  end
18
+ describe ".property_term" do
19
+ it "should return the correct property term" do
20
+ expect(described_class.property_term(:subject)).to eq(:dc_subject)
21
+ end
22
+ end
18
23
  describe "using the set_values and add_value methods" do
19
24
  let(:ds) { described_class.new(obj) }
20
25
  before { ds.type = ["Photograph"] }
@@ -63,7 +63,7 @@ module Ddr::Models
63
63
  it "sets default metadata" do
64
64
  expect(identifier.profile).to eq("dc")
65
65
  expect(identifier.export).to eq("no")
66
- expect(identifier["fcrepo3.pid"]).to eq(subject.pid)
66
+ expect(identifier["fcrepo4.id"]).to eq(subject.id)
67
67
  end
68
68
  end
69
69
  describe "object destruction" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta.11
4
+ version: 3.0.0.beta.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-23 00:00:00.000000000 Z
12
+ date: 2016-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -551,6 +551,7 @@ files:
551
551
  - lib/ddr/models/licenses/inherited_license.rb
552
552
  - lib/ddr/models/licenses/license.rb
553
553
  - lib/ddr/models/licenses/parent_license.rb
554
+ - lib/ddr/models/metadata/administrative_metadata.rb
554
555
  - lib/ddr/models/metadata/descriptive_metadata.rb
555
556
  - lib/ddr/models/metadata/metadata.rb
556
557
  - lib/ddr/models/metadata/metadata_mapping.rb
@@ -687,6 +688,7 @@ files:
687
688
  - spec/managers/technical_metadata_manager_spec.rb
688
689
  - spec/models/active_fedora_base_spec.rb
689
690
  - spec/models/admin_set_spec.rb
691
+ - spec/models/administrative_metadata_spec.rb
690
692
  - spec/models/attachment_spec.rb
691
693
  - spec/models/collection_spec.rb
692
694
  - spec/models/component_spec.rb
@@ -861,6 +863,7 @@ test_files:
861
863
  - spec/managers/technical_metadata_manager_spec.rb
862
864
  - spec/models/active_fedora_base_spec.rb
863
865
  - spec/models/admin_set_spec.rb
866
+ - spec/models/administrative_metadata_spec.rb
864
867
  - spec/models/attachment_spec.rb
865
868
  - spec/models/collection_spec.rb
866
869
  - spec/models/component_spec.rb