diff --git a/lib/active_fedora/simple_datastream.rb b/lib/active_fedora/simple_datastream.rb
index 06177b590..5890b6cef 100644
--- a/lib/active_fedora/simple_datastream.rb
+++ b/lib/active_fedora/simple_datastream.rb
@@ -1,6 +1,7 @@
module ActiveFedora
# This class represents a simple xml datastream.
class SimpleDatastream < OmDatastream
+ extend Deprecation
class_attribute :class_fields
attr_accessor :fields
self.class_fields = []
@@ -18,6 +19,7 @@ class SimpleDatastream < OmDatastream
# Constructor. this class will call self.field for each DCTERM. In short, all DCTERMS fields will already exist
# when this method returns. Each term is marked as a multivalue string.
def initialize(digital_object = nil, dsid = nil, options = {}, &block)
+ Deprecation.warn(SimpleDatastream, "ActiveFedora::SimpleDatastream is deprecated and will be removed in ActiveFedora 10.0")
self.fields = {}
super
end
diff --git a/spec/integration/attached_files_spec.rb b/spec/integration/attached_files_spec.rb
index c30d2122e..bbd8a96ef 100644
--- a/spec/integration/attached_files_spec.rb
+++ b/spec/integration/attached_files_spec.rb
@@ -186,7 +186,7 @@ def load_attached_files
end
describe ".metadata_streams" do
- let(:mds1) { ActiveFedora::SimpleDatastream.new }
+ let(:mds1) { ActiveFedora::QualifiedDublinCoreDatastream.new }
let(:mds2) { ActiveFedora::QualifiedDublinCoreDatastream.new }
let(:fds) { ActiveFedora::File.new }
before do
diff --git a/spec/integration/attributes_spec.rb b/spec/integration/attributes_spec.rb
index 48d9cfbff..0b768afca 100644
--- a/spec/integration/attributes_spec.rb
+++ b/spec/integration/attributes_spec.rb
@@ -10,13 +10,7 @@ class PropertiesDatastream < ActiveFedora::OmDatastream
end
end
class TitledObject < ActiveFedora::Base
- extend Deprecation
-
- Deprecation.silence(TitledObject) do
- has_metadata 'foo', type: ActiveFedora::SimpleDatastream do |m|
- m.field "title", :string
- end
- end
+ has_subresource 'foo', class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
Deprecation.silence(ActiveFedora::Attributes) do
has_attributes :title, datastream: 'foo', multiple: false
end
diff --git a/spec/integration/full_featured_model_spec.rb b/spec/integration/full_featured_model_spec.rb
deleted file mode 100644
index 22cd50f98..000000000
--- a/spec/integration/full_featured_model_spec.rb
+++ /dev/null
@@ -1,163 +0,0 @@
-require 'spec_helper'
-require 'rexml/document'
-
-include ActiveFedora
-
-describe ActiveFedora::Base do
- before(:all) do
- class OralHistory < ActiveFedora::Base
- extend Deprecation
- Deprecation.silence(OralHistory) do
- # These are all the properties that don't quite fit into Qualified DC
- # Put them on the object itself (in the properties datastream) for now.
- has_metadata name: "properties", type: ActiveFedora::SimpleDatastream do |m|
- m.field "narrator", :string
- m.field "interviewer", :string
- m.field "transcript_editor", :text
- m.field "bio", :string
- m.field "notes", :text
- m.field "hard_copy_availability", :text
- m.field "hard_copy_location", :text
- m.field "other_contributor", :string
- m.field "restrictions", :text
- m.field "series", :string
- m.field "location", :string
- end
-
- has_metadata name: "mods_article", type: Hydra::ModsArticleDatastream
-
- has_metadata name: "dublin_core", type: ActiveFedora::QualifiedDublinCoreDatastream do |_m|
- # Default :multiple => true
- #
- # on retrieval, these will be pluralized and returned as arrays
- # ie. subject_entries = my_oral_history.dublin_core.subjects
- #
- # aimint to use method-missing to support calling methods like
- # my_oral_history.subjects OR my_oral_history.titles OR EVEN my_oral_history.title whenever possible
-
- # Setting new Types for dates and text content
- # m.field "creation_date", :date, :xml_node => "date"
- # m.field "abstract", :text, :xml_node => "abstract"
- # m.field "rights", :text, :xml_node => "rights"
-
- # Setting up special named fields
- # m.field "subject_heading", :string, :xml_node => "subject", :encoding => "LCSH"
- # m.field "spatial_coverage", :string, :xml_node => "spatial", :encoding => "TGN"
- # m.field "temporal_coverage", :string, :xml_node => "temporal", :encoding => "Period"
- # m.field "type", :string, :xml_node => "type", :encoding => "DCMITYPE"
- # m.field "alt_title", :string, :xml_node => "alternative"
- end
-
- has_metadata name: "significant_passages", type: ActiveFedora::SimpleDatastream do |m|
- m.field "significant_passage", :text
- end
-
- has_metadata name: "sensitive_passages", type: ActiveFedora::SimpleDatastream do |m|
- m.field "sensitive_passage", :text
- end
- end
- end
- sample_location = "Boston, Massachusetts"
- sample_notes = 'Addelson, Frances. (1973?) "The Induced Abortion," American Journal of Ortho-Psychiatry, Addelson, Frances. "Abortion: Source of Guilt or Growth," National Journal of Gynecology and Obstetrics., Addelson, Frances. "First Zionist Novel," Jewish Frontier.'
- sample_other_contributor = 'any other contributors, people or corporate names (eg. Temple Israel)'
- sample_transcript_editor = 'Siegel, Cheryl'
- sample_hard_copy_availability = <<-END
- Yes, please contact the Jewish Women\\\'s Archive for more information on using this source.
- END
- sample_narrator = 'Addelson, Frances'
- sample_bio = <<-END
- Rochelle Ruthchild interviewed Frances Addleson on October 18, November 14, and December 10, 1997. The interview thoroughly examined the trajectory of Frances\' life from birth until the time of the interview. As a young child, Frances\' father died during the influenza eidemic, and her mother was not equipped to care for her and her siblings. Consequently, they were placed in a Jewish foster home. Although her experience was mostly positive, this experience would leave life-long effects. Frances attended Radcliffe upon the urging of a mentor and later obtained her Master\'s degree in social work from Simmons College in 1954. In the 1940\'s, she returned to work while her children were still young; a rather unusual event for that time period. While working as a social worker at Beth Israel Hospital in the early 1970\'s, she helped counsel countless women who came to the hospital seeking abortions before the procedure was officially legalized during the landmark Roe vs. Wade decision in 1973. Frances would later write two articles that were published in medical journals about her experience during this time. Although not a very religious person, Frances felt connected to the Jewish notion of social justice and remained very active until an accident in the late 1990\'s.
- END
- sample_interviewer = "Ruthchild, & Rochelle"
-
- @properties_sample_values2 = Hash[narrator: "Narrator1 & Narrator2", interviewer: "Interviewer", transcript_editor: "Transcript Editor", bio: "Biographic info",
- notes: "My Note\\\'s a good one", hard_copy_availability: "Yes", hard_copy_location: "Archives", other_contributor: "Sally Ride",
- restrictions: "None", series: "My Series", location: "location"]
-
- @properties_sample_values = Hash[narrator: sample_narrator, interviewer: sample_interviewer, transcript_editor: sample_transcript_editor, bio: sample_bio,
- notes: sample_notes, hard_copy_availability: sample_hard_copy_availability, hard_copy_location: "Archives", other_contributor: sample_other_contributor,
- restrictions: "None", series: "My Series", location: sample_location]
-
- @dublin_core_sample_values = Hash[creator: 'Matt && McClain', publisher: "Jewish Womens's Archive", description: "description", identifier: "jwa:sample_id",
- title: "title",
- #:alt_title => "alt_title", :subject => "subject",
- #:subject_heading => "subject heading",
- #:creation_date => "2008-07-02T05:09:42.015Z",
- language: "language",
- #:spatial_coverage => "spatial coverage",
- #:temporal_coverage => "temporal coverage",
- #:abstract => "abstract",
- rights: "rights", type: "type",
- #:extent => "extent",
- format: "format", medium: "medium"]
- @signigicant_passages_sample_values = {}
- @sensitive_passages_sample_values = {}
- @sample_xml = "REMOVEDREMOVEDOralHistorychangeme:14527subject headingtyperightspublishercreation datejwa:sample_idformatextentlanguagedescriptiontitlemediumspatial coveragealt_titletemporal coveragesubjectcreatorabstractSally RideTranscript EditorNoneBiographic infoMy SeriesMy NotelocationYesNarratorArchivesInterviewer"
- end
-
- before(:each) do
- @test_history = OralHistory.new
- end
-
- after(:each) do
- end
-
- after(:all) do
- Object.send(:remove_const, :OralHistory)
- end
-
- it "is an instance of ActiveFedora::Base" do
- expect(@test_history).to be_kind_of(described_class)
- end
-
- it "creates proxies to all the attached_files" do
- properties_ds = @test_history.attached_files["properties"]
- expect(@test_history.properties).to be properties_ds
- expect(@test_history).to respond_to(:properties)
- expect(OralHistory.new).to respond_to(:properties)
- end
-
- it "pushes all of the metadata fields into solr" do
- # TODO: test must test values using solr symbol names (ie. _field, _text and _date)
- properties_ds = @test_history.attached_files["properties"]
- dublin_core_ds = @test_history.attached_files["dublin_core"]
-
- @properties_sample_values.each_pair do |field, value|
- next if field == :hard_copy_availability # FIXME: HYDRA-824
- properties_ds.send("#{field}=", [value])
- end
-
- @dublin_core_sample_values.each_pair do |field, value|
- next if [:format, :type].include?(field) # format and type are methods declared on Object
- dublin_core_ds.send("#{field}=", [value])
- end
-
- @test_history.save
-
- @solr_result = OralHistory.search_with_conditions(id: @test_history.id)[0]
- @properties_sample_values.each_pair do |field, value|
- next if field == :hard_copy_availability # FIXME: HYDRA-824
- next if field == :location # FIXME HYDRA-825
- expect((@solr_result[ActiveFedora.index_field_mapper.solr_name(field, type: :string)] || @solr_result[ActiveFedora.index_field_mapper.solr_name(field, type: :date)])).to eq [::Solrizer::Extractor.format_node_value(value)]
- end
-
- @dublin_core_sample_values.each_pair do |field, value|
- next if [:format, :type].include?(field) # format and type are methods declared on Object
- expect(dublin_core_ds.send(field.to_s)).to eq [value]
- end
- end
-
- it "has Qualified Dublin core, with custom accessors" do
- dublin_core_ds = @test_history.attached_files["dublin_core"]
-
- dublin_core_ds.subject = "My Subject Heading"
- dc_xml = REXML::Document.new(dublin_core_ds.to_xml)
-
- expect(dc_xml.root.elements["dcterms:subject"].text).to eq "My Subject Heading"
- end
-
- it "supports #search_with_conditions" do
- solr_result = OralHistory.search_with_conditions({})
- expect(solr_result).to_not be_nil
- end
-end
diff --git a/spec/integration/json_serialization_spec.rb b/spec/integration/json_serialization_spec.rb
index 5d18ad5cc..082214fac 100644
--- a/spec/integration/json_serialization_spec.rb
+++ b/spec/integration/json_serialization_spec.rb
@@ -7,14 +7,16 @@
context "with properties and datastream attributes" do
before do
- class Foo < ActiveFedora::Base
- extend Deprecation
- Deprecation.silence(Foo) do
- has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m|
- m.field "foo", :text
- m.field "bar", :text
- end
+ class MyDS < ActiveFedora::OmDatastream
+ set_terminology do |t|
+ t.root(path: "durh")
+ t.foo
+ t.bar
end
+ end
+
+ class Foo < ActiveFedora::Base
+ has_subresource 'descMetadata', class_name: 'MyDS'
Deprecation.silence(ActiveFedora::Attributes) do
has_attributes :foo, datastream: 'descMetadata', multiple: true
has_attributes :bar, datastream: 'descMetadata', multiple: false
@@ -25,6 +27,7 @@ class Foo < ActiveFedora::Base
after do
Object.send(:remove_const, :Foo)
+ Object.send(:remove_const, :MyDS)
end
let(:obj) { Foo.new(foo: ["baz"], bar: 'quix', title: ['My Title']) }
diff --git a/spec/integration/solr_hit_spec.rb b/spec/integration/solr_hit_spec.rb
index ac15dd2d4..34c781452 100644
--- a/spec/integration/solr_hit_spec.rb
+++ b/spec/integration/solr_hit_spec.rb
@@ -2,14 +2,16 @@
describe ActiveFedora::SolrHit do
before do
- class Foo < ActiveFedora::Base
- extend Deprecation
- Deprecation.silence(self) do
- has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m|
- m.field "foo", :text
- m.field "bar", :text
- end
+ class MyDS < ActiveFedora::OmDatastream
+ set_terminology do |t|
+ t.root(path: "durh")
+ t.foo
+ t.bar
end
+ end
+
+ class Foo < ActiveFedora::Base
+ has_subresource 'descMetadata', class_name: 'MyDS'
Deprecation.silence(ActiveFedora::Attributes) do
has_attributes :foo, datastream: 'descMetadata', multiple: true
has_attributes :bar, datastream: 'descMetadata', multiple: false
@@ -32,6 +34,7 @@ class Foo < ActiveFedora::Base
after do
Object.send(:remove_const, :Foo)
+ Object.send(:remove_const, :MyDS)
end
describe "#reify" do
diff --git a/spec/integration/solr_instance_loader_spec.rb b/spec/integration/solr_instance_loader_spec.rb
index de7e02d03..021bbe16e 100644
--- a/spec/integration/solr_instance_loader_spec.rb
+++ b/spec/integration/solr_instance_loader_spec.rb
@@ -2,14 +2,17 @@
describe ActiveFedora::SolrInstanceLoader do
before do
+ class MyDS < ActiveFedora::OmDatastream
+ set_terminology do |t|
+ t.root(path: "durh")
+ t.foo
+ t.bar
+ end
+ end
+
class Foo < ActiveFedora::Base
extend Deprecation
- Deprecation.silence(Foo) do
- has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m|
- m.field "foo", :text
- m.field "bar", :text
- end
- end
+ has_subresource 'descMetadata', class_name: 'MyDS'
Deprecation.silence(ActiveFedora::Attributes) do
has_attributes :foo, datastream: 'descMetadata', multiple: true
has_attributes :bar, datastream: 'descMetadata', multiple: false
@@ -41,6 +44,7 @@ class Bar < ActiveFedora::Base
after do
Object.send(:remove_const, :Foo)
Object.send(:remove_const, :Bar)
+ Object.send(:remove_const, :MyDS)
end
context "without a solr doc" do
diff --git a/spec/unit/attached_files_spec.rb b/spec/unit/attached_files_spec.rb
index fc06a86fa..cbe580309 100644
--- a/spec/unit/attached_files_spec.rb
+++ b/spec/unit/attached_files_spec.rb
@@ -7,7 +7,7 @@
class Z < ActiveFedora::File
end
class FooHistory < ActiveFedora::Base
- has_subresource 'dsid', class_name: 'ActiveFedora::SimpleDatastream'
+ has_subresource 'dsid', class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
has_subresource 'complex_ds', autocreate: true, class_name: 'Z'
has_subresource 'thumbnail'
has_subresource 'child_resource', class_name: 'ActiveFedora::Base'
@@ -30,8 +30,8 @@ class FooHistory < ActiveFedora::Base
end
it "raises an error if you don't give a dsid" do
- expect { FooHistory.has_subresource nil, type: ActiveFedora::SimpleDatastream }.to raise_error ArgumentError,
- "You must provide a path name (f.k.a. dsid) for the resource"
+ expect { FooHistory.has_subresource nil, type: ActiveFedora::QualifiedDublinCoreDatastream }.to raise_error ArgumentError,
+ "You must provide a path name (f.k.a. dsid) for the resource"
end
end
@@ -42,7 +42,7 @@ class Z < ActiveFedora::File
class FooHistory < ActiveFedora::Base
extend Deprecation
Deprecation.silence(FooHistory) do
- has_metadata name: 'dsid', type: ActiveFedora::SimpleDatastream
+ has_metadata name: 'dsid', type: ActiveFedora::QualifiedDublinCoreDatastream
has_metadata 'complex_ds', autocreate: true, type: 'Z'
end
end
@@ -57,7 +57,7 @@ class FooHistory < ActiveFedora::Base
end
it "has reasonable defaults" do
- expect(FooHistory.child_resource_reflections[:dsid].options).to include(class_name: 'ActiveFedora::SimpleDatastream')
+ expect(FooHistory.child_resource_reflections[:dsid].options).to include(class_name: 'ActiveFedora::QualifiedDublinCoreDatastream')
end
it "lets you override defaults" do
@@ -77,7 +77,7 @@ class FooHistory < ActiveFedora::Base
it "raises an error if you don't give a dsid" do
expect {
Deprecation.silence(FooHistory) do
- FooHistory.has_metadata type: ActiveFedora::SimpleDatastream
+ FooHistory.has_metadata type: ActiveFedora::QualifiedDublinCoreDatastream
end
}.to raise_error ArgumentError,
"You must provide a path name (f.k.a. dsid) for the resource"
diff --git a/spec/unit/attributes_spec.rb b/spec/unit/attributes_spec.rb
index af079d28a..85afdae9e 100644
--- a/spec/unit/attributes_spec.rb
+++ b/spec/unit/attributes_spec.rb
@@ -114,23 +114,18 @@ class BarHistory4 < ActiveFedora::Base
describe "first level delegation" do
before do
- class BarHistory2 < ActiveFedora::Base
- extend Deprecation
- Deprecation.silence(self) do
- has_metadata type: ActiveFedora::SimpleDatastream, name: "someData" do |m|
- m.field "fubar", :string
- m.field "bandana", :string
- m.field "swank", :text
- m.field "animal_id", :string
- end
- has_metadata type: ActiveFedora::SimpleDatastream, name: "withText" do |m|
- m.field "fubar", :text
- end
- has_metadata type: ActiveFedora::SimpleDatastream, name: "withText2" do |m|
- m.field "fubar", :text
- end
+ class MyDS1 < ActiveFedora::NtriplesRDFDatastream
+ property :animal_id, predicate: ::RDF::Vocab::DC.publisher
+ end
+ class MyDS2 < ActiveFedora::OmDatastream
+ set_terminology do |t|
+ t.root(path: "durh")
+ t.fubar
end
-
+ end
+ class BarHistory2 < ActiveFedora::Base
+ has_subresource 'someData', class_name: 'MyDS1'
+ has_subresource "withText", class_name: 'MyDS2'
has_subresource 'xmlish', class_name: 'BarStream2'
Deprecation.silence(ActiveFedora::Attributes) do
has_attributes :cow, datastream: 'xmlish' # for testing the default value of multiple
@@ -345,7 +340,7 @@ class BarHistory3 < BarHistory2
describe ".datastream_class_for_name" do
it "returns the specifed class" do
- expect(BarHistory2.send(:datastream_class_for_name, 'someData')).to eq ActiveFedora::SimpleDatastream
+ expect(BarHistory2.send(:datastream_class_for_name, 'someData')).to eq MyDS1
end
end
end
diff --git a/spec/unit/core_spec.rb b/spec/unit/core_spec.rb
index 8e9274822..43d606ddc 100644
--- a/spec/unit/core_spec.rb
+++ b/spec/unit/core_spec.rb
@@ -8,14 +8,9 @@ class MyDatastream < ActiveFedora::NtriplesRDFDatastream
class Library < ActiveFedora::Base
end
class Book < ActiveFedora::Base
- extend Deprecation
belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent
- Deprecation.silence(Book) do
- has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m|
- m.field "title", :string
- end
- has_metadata "bar", type: MyDatastream
- end
+ has_subresource "foo", class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
+ has_subresource "bar", class_name: 'MyDatastream'
Deprecation.silence(ActiveFedora::Attributes) do
has_attributes :title, datastream: 'foo' # Om backed property
has_attributes :publisher, datastream: 'bar' # RDF backed property
@@ -68,7 +63,7 @@ class Book < ActiveFedora::Base
it "makes the om properties immutable" do
expect {
subject.title = "HEY"
- }.to raise_error RuntimeError, "can't modify frozen ActiveFedora::SimpleDatastream"
+ }.to raise_error RuntimeError, "can't modify frozen ActiveFedora::QualifiedDublinCoreDatastream"
expect(subject.title).to eq "War and Peace"
end
diff --git a/spec/unit/inheritance_spec.rb b/spec/unit/inheritance_spec.rb
index 143675f45..0010ac0c0 100644
--- a/spec/unit/inheritance_spec.rb
+++ b/spec/unit/inheritance_spec.rb
@@ -2,22 +2,16 @@
describe ActiveFedora::Base do
before do
+ class MyDS < ActiveFedora::OmDatastream
+ end
class Foo < ActiveFedora::Base
extend Deprecation
- Deprecation.silence(Foo) do
- has_metadata "foostream", type: ActiveFedora::SimpleDatastream do |m|
- m.field "foostream", :string
- end
- has_metadata 'dcstream', type: ActiveFedora::QualifiedDublinCoreDatastream
- end
+ has_subresource 'foostream', class_name: 'MyDS'
+ has_subresource 'dcstream', class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
end
class Bar < ActiveFedora::Base
extend Deprecation
- Deprecation.silence(Bar) do
- has_metadata 'barstream', type: ActiveFedora::SimpleDatastream do |m|
- m.field "barfield", :string
- end
- end
+ has_subresource 'barstream', class_name: 'MyDS'
end
end
@@ -25,7 +19,7 @@ class Bar < ActiveFedora::Base
f = Foo.new
expect(f.attached_files.size).to eq 2
streams = f.attached_files.values.map { |x| x.class.to_s }.sort
- expect(streams.pop).to eq "ActiveFedora::SimpleDatastream"
+ expect(streams.pop).to eq "MyDS"
expect(streams.pop).to eq "ActiveFedora::QualifiedDublinCoreDatastream"
end
@@ -42,5 +36,6 @@ class Bar < ActiveFedora::Base
after do
Object.send(:remove_const, :Bar)
Object.send(:remove_const, :Foo)
+ Object.send(:remove_const, :MyDS)
end
end
diff --git a/spec/unit/simple_datastream_spec.rb b/spec/unit/simple_datastream_spec.rb
index 3acab68d1..bd0105621 100644
--- a/spec/unit/simple_datastream_spec.rb
+++ b/spec/unit/simple_datastream_spec.rb
@@ -4,6 +4,8 @@
let(:sample_xml) { "coverage1coverage22012-01-15fake-datepublisher1" }
before do
+ @original_behavior = Deprecation.default_deprecation_behavior
+ Deprecation.default_deprecation_behavior = :silence
@test_ds = described_class.new
allow(@test_ds).to receive(:retrieve_content).and_return('') # DS grabs the old content to compare against the new
@test_ds.content = sample_xml
@@ -90,6 +92,7 @@ class FooHistory < ActiveFedora::Base
after do
Object.send(:remove_const, :FooHistory)
+ Deprecation.default_deprecation_behavior = @original_behavior
end
subject { FooHistory.find(foo.id) }
diff --git a/spec/unit/solr_config_options_spec.rb b/spec/unit/solr_config_options_spec.rb
index be3d935a6..57bab4040 100644
--- a/spec/unit/solr_config_options_spec.rb
+++ b/spec/unit/solr_config_options_spec.rb
@@ -43,7 +43,7 @@ class Basic < ActiveFedora::Base
end
it "prevents Base.save from calling update_index if false" do
- dirty_ds = ActiveFedora::SimpleDatastream.new
+ dirty_ds = ActiveFedora::QualifiedDublinCoreDatastream.new
@test_object.attached_files['ds1'] = dirty_ds
allow(@test_object).to receive(:datastreams).and_return(ds1: dirty_ds)
expect(@test_object).to receive(:update_index).never