Skip to content

Commit

Permalink
No way it's this easy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Trey Terrell committed Apr 5, 2014
1 parent c49d2d2 commit 3eba4b8
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 11 deletions.
32 changes: 25 additions & 7 deletions app/models/datastream/oregon_rdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def self.resource_class
index.as :searchable, :facetable, :displayable
end
property :coverage, :predicate => RDF::DC11.coverage do |index|
index.as :searchable, :facetable, :displayable
index.as :searchable, :facetable, :displayable
end
property :rights, :predicate => RDF::DC.rights, :class_name => OregonDigital::ControlledVocabularies::RightsStatement do |index|
index.as :displayable
Expand Down Expand Up @@ -83,7 +83,7 @@ def self.resource_class
index.as :displayable
end
property :replacesUrl, :predicate => RDF::DC.replaces

# MARCRel
property :photographer, :predicate => OregonDigital::Vocabularies::MARCREL.pht do |index|
index.as :searchable, :facetable, :displayable
Expand Down Expand Up @@ -139,7 +139,7 @@ def self.resource_class
# PREMIS
property :preservation, :predicate => OregonDigital::Vocabularies::PREMIS.hasOriginalName
property :hasFixity, :predicate => OregonDigital::Vocabularies::PREMIS.hasFixity

# MODS RDF
property :physicalExtent, :predicate => RDF::URI('http://www.loc.gov/standards/mods/modsrdf/v1/#physicalExtent') do |index|
index.as :displayable
Expand All @@ -150,7 +150,7 @@ def self.resource_class
property :locationCopyShelfLocator, :predicate => RDF::URI('http://www.loc.gov/standards/mods/modsrdf/v1/#locationCopyShelfLocator') do |index|
index.as :displayable
end

# CCO
property :view, :predicate => RDF::URI('http://opaquenamespace.org/ns/cco/viewDescription') do |index|
index.as :displayable
Expand Down Expand Up @@ -201,13 +201,13 @@ def self.resource_class
end
property :firstLine, :predicate => OregonDigital::Vocabularies::SHEETMUSIC.firstLine do |index|
index.as :searchable, :displayable
end
end
property :firstLineChorus, :predicate => OregonDigital::Vocabularies::SHEETMUSIC.firstLineChorus do |index|
index.as :searchable, :displayable
end
end
property :largerWork, :predicate => OregonDigital::Vocabularies::SHEETMUSIC.largerWork do |index|
index.as :searchable, :displayable
end
end
property :hostItem, :predicate => OregonDigital::Vocabularies::SHEETMUSIC.hostItem do |index|
index.as :displayable
end
Expand All @@ -231,4 +231,22 @@ def to_solr(solr_doc = Hash.new)
solr_doc
end

def resource
@resource ||= begin
r = self.singleton_class.resource_class.new(digital_object ? self.class.rdf_subject.call(self) : nil)
r.singleton_class.properties = self.class.properties
r.singleton_class.properties.keys.each do |property|
r.singleton_class.send(:register_property, property)
end
r.datastream = self
r.singleton_class.accepts_nested_attributes_for(*nested_attributes_options.keys) unless nested_attributes_options.blank?
r
end
end

def save(*args)
resource.persist!
super(*args)
end

end
6 changes: 3 additions & 3 deletions lib/oregon_digital/controlled_vocabularies/set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module OregonDigital::ControlledVocabularies
class Set < OregonDigital::RDF::ObjectResource
include OregonDigital::RDF::Controlled

def self.repository
:parent
end
#def self.repository
# :parent
#end

use_vocabulary :set

Expand Down
7 changes: 6 additions & 1 deletion lib/oregon_digital/rdf/object_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ module OregonDigital::RDF
# with a Datastream and ActiveFedora::Base object.
#
# @see OregonDigital::RdfResourceDatastream
class ObjectResource < ActiveFedora::Rdf::ObjectResource
class ObjectResource < ActiveFedora::Rdf::Resource
configure :base_uri => "http://oregondigital.org/resource/"
configure :repository => :vocabs
attr_accessor :datastream

def persisted?
@persisted ||= (not datastream.new?)
end
# No point in fetching - everything comes from Fedora and is loaded by the datastream.
def fetch
end
Expand Down
31 changes: 31 additions & 0 deletions spec/models/fun_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'spec_helper'

describe "fun functionality" do
let(:asset) {GenericAsset.new}
context "when content is set" do
before(:each) do
asset.title = "Test Title"
end
it "should return" do
expect(asset.title).to eq "Test Title"
end
context "after it is saved" do
before(:each) do
asset.save
end
it "should maintain that data" do
a = GenericAsset.find(asset.pid)
expect(a.title).to eq "Test Title"
end
it "should work on reload" do
asset.reload
expect(asset.title).to eq "Test Title"
end
it "should not call datastream content" do
asset.reload
expect(asset.descMetadata).not_to receive(:datastream_content)
expect(asset.title).to eq "Test Title"
end
end
end
end

0 comments on commit 3eba4b8

Please sign in to comment.