Skip to content

Commit

Permalink
Get rid of the properties datastream
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Nov 3, 2014
1 parent 30055e1 commit 8fa3691
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 118 deletions.
26 changes: 2 additions & 24 deletions spec/models/generic_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
before do
@transfer_to = FactoryGirl.find_or_create(:jill)
end
after do
@file.destroy
end

it "transfers the request" do
@file.on_behalf_of = @transfer_to.user_key
Expand Down Expand Up @@ -160,9 +157,6 @@
end

describe "attributes" do
it "should have properties datastream for depositor" do
expect(subject.properties).to be_instance_of PropertiesDatastream
end
it "should have apply_depositor_metadata" do
expect(subject.edit_users).to eq ['jcoyne']
expect(subject.depositor).to eq 'jcoyne'
Expand All @@ -189,12 +183,10 @@
end
end

describe "delegations" do
it "should delegate methods to properties metadata" do
describe "metadata" do
it "should have descriptive metadata" do
expect(subject).to respond_to(:relative_path)
expect(subject).to respond_to(:depositor)
end
it "should delegate methods to descriptive metadata" do
expect(subject).to respond_to(:related_url)
expect(subject).to respond_to(:based_near)
expect(subject).to respond_to(:part_of)
Expand Down Expand Up @@ -229,10 +221,6 @@
end

describe "that have been saved" do
after do
subject.delete unless subject.new_record?
end

it "should have activity stream-related methods defined" do
subject.save
f = subject.reload
Expand Down Expand Up @@ -337,9 +325,6 @@
@f = GenericFile.new
@f.apply_depositor_metadata('mjg36')
end
after do
@f.delete
end
describe "with a video", if: Sufia.config.enable_ffmpeg do
before do
allow(@f).to receive(mime_type: 'video/quicktime') #Would get set by the characterization job
Expand Down Expand Up @@ -598,9 +583,6 @@
describe "file content validation" do
context "when file contains a virus" do
let(:f) { File.new(fixture_path + '/small_file.txt') }
after(:each) do
subject.destroy if subject.persisted?
end
it "populates the errors hash during validation" do
allow(Sufia::GenericFile::Actor).to receive(:virus_check).and_raise(Sufia::VirusFoundError, "A virus was found in #{f.path}: EL CRAPO VIRUS")
subject.add_file(f, 'content', 'small_file.txt')
Expand Down Expand Up @@ -651,10 +633,6 @@
file.to_solr
}

after do
subject.destroy
end

context "without terms" do
specify "title is nil" do
expect(no_terms[title_key]).to be_nil
Expand Down
42 changes: 0 additions & 42 deletions spec/models/properties_datastream_spec.rb

This file was deleted.

26 changes: 18 additions & 8 deletions sufia-models/app/models/concerns/sufia/generic_file/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ module Metadata
extend ActiveSupport::Concern

included do
contains "properties", class_name: 'PropertiesDatastream'
contains "content", class_name: 'FileContentDatastream'
contains "thumbnail"

has_attributes :relative_path, :import_url, datastream: :properties, multiple: false

property :label, predicate: RDF::DC.title

property :depositor, predicate: RDF::URI.new("http://id.loc.gov/vocabulary/relators/dpt") do |index|
index.as :symbol, :stored_searchable
end

property :relative_path, predicate: RDF::URI.new('http://scholarsphere.psu.edu/ns#relativePath')

property :import_url, predicate: RDF::URI.new('http://scholarsphere.psu.edu/ns#importUrl') do |index|
index.as :symbol
end

property :part_of, predicate: RDF::DC.isPartOf
property :resource_type, predicate: RDF::DC.type do |index|
index.as :stored_searchable, :facetable
Expand Down Expand Up @@ -84,13 +87,20 @@ module Metadata
puts "tables for vocabularies missing"
end

# For singular-valued properties
# Hack until https://github.com/no-reply/ActiveTriples/pull/37 is merged
def depositor
super.first
end

def relative_path
super.first
end

def depositor_with_first
depositor_without_first.first
def import_url
super.first
end
alias_method_chain :depositor, :first

# For singular-valued properties
# Hack until https://github.com/no-reply/ActiveTriples/pull/37 is merged

def label_with_first
label_without_first.first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,27 @@ module ProxyDeposit
extend ActiveSupport::Concern

included do
has_attributes :proxy_depositor, :on_behalf_of, datastream: :properties, multiple: false
property :proxy_depositor, predicate: RDF::URI.new('http://scholarsphere.psu.edu/ns#proxyDepositor') do |index|
index.as :symbol
end

# This value is set when a user indicates they are depositing this for someone else
property :on_behalf_of, predicate: RDF::URI.new('http://scholarsphere.psu.edu/ns#onBehalfOf') do |index|
index.as :symbol
end

after_create :create_transfer_request

def proxy_depositor
super.first
end

def on_behalf_of
super.first
end
end


def create_transfer_request
Sufia.queue.push(ContentDepositorChangeEventJob.new(pid, on_behalf_of)) if on_behalf_of.present?
end
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions sufia-models/app/models/datastreams/properties_datastream.rb

This file was deleted.

0 comments on commit 8fa3691

Please sign in to comment.