active-fedora 6.4.0.rc3 → 6.4.0.rc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active_fedora/delegating.rb +2 -6
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +54 -2
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/rdf_list.rb +29 -0
- data/lib/active_fedora/rdf_node/term_proxy.rb +13 -6
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/complex_rdf_datastream_spec.rb +6 -1
- data/spec/unit/base_delegate_spec.rb +10 -3
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
- data/spec/unit/rdf_list_nested_attributes_spec.rb +110 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6a491ed123f54d269d0768d80a8cb526c1d4b0b
|
4
|
+
data.tar.gz: 1ba1f6930603d6095d178d9762e6c4f465788fce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e93d7508557149bdf107c7bb44b32751e4508506fd562d19d4cff9f74a148e771dc6cbc018e05fa8e603139d7f065046c324fe03ad9c5c7bde924e1b648daf68
|
7
|
+
data.tar.gz: 89d830d304a2ff251d8c4a0f3f2d37b3f370342a99c9432b05861028bb0e1c30420fba0c93184769d053be695a53cd6fa1fad4f5edfc86925de15b271d665fe4
|
@@ -4,7 +4,7 @@ module ActiveFedora
|
|
4
4
|
|
5
5
|
# Calling inspect may trigger a bunch of loads, but it's mainly for debugging, so no worries.
|
6
6
|
def inspect
|
7
|
-
values = self.class.
|
7
|
+
values = self.class.delegates.keys.map {|r| "#{r}:#{send(r).inspect}"}
|
8
8
|
"#<#{self.class} pid:\"#{pretty_pid}\", #{values.join(', ')}>"
|
9
9
|
end
|
10
10
|
|
@@ -32,7 +32,7 @@ module ActiveFedora
|
|
32
32
|
|
33
33
|
module ClassMethods
|
34
34
|
def delegates
|
35
|
-
@local_delegates ||= {}
|
35
|
+
@local_delegates ||= {}.with_indifferent_access
|
36
36
|
return @local_delegates unless superclass.respond_to?(:delegates) and value = superclass.delegates
|
37
37
|
@local_delegates = value.dup if @local_delegates.empty?
|
38
38
|
@local_delegates
|
@@ -75,10 +75,6 @@ module ActiveFedora
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
def delegate_registry
|
79
|
-
self.delegates.keys
|
80
|
-
end
|
81
|
-
|
82
78
|
# Allows you to delegate multiple terminologies to the same datastream, instead
|
83
79
|
# having to call the method each time for each term. The target datastream is the
|
84
80
|
# first argument, followed by an array of the terms that will point to that
|
@@ -24,8 +24,60 @@ module ActiveFedora
|
|
24
24
|
|
25
25
|
#A frozen array of Dublincore Terms.
|
26
26
|
DCTERMS = [
|
27
|
-
|
28
|
-
|
27
|
+
:abstract,
|
28
|
+
:accessRights,
|
29
|
+
:accrualMethod,
|
30
|
+
:accrualPeriodicity,
|
31
|
+
:accrualPolicy,
|
32
|
+
:alternative,
|
33
|
+
:audience,
|
34
|
+
:available,
|
35
|
+
:bibliographicCitation,
|
36
|
+
:conformsTo,
|
37
|
+
:contributor,
|
38
|
+
:coverage,
|
39
|
+
:created,
|
40
|
+
:creator,
|
41
|
+
:date,
|
42
|
+
:dateAccepted,
|
43
|
+
:dateCopyrighted,
|
44
|
+
:dateSubmitted,
|
45
|
+
:description,
|
46
|
+
:educationLevel,
|
47
|
+
:extent,
|
48
|
+
:hasFormat,
|
49
|
+
:hasPart,
|
50
|
+
:hasVersion,
|
51
|
+
:identifier,
|
52
|
+
:instructionalMethod,
|
53
|
+
:isFormatOf,
|
54
|
+
:isPartOf,
|
55
|
+
:isReferencedBy,
|
56
|
+
:isReplacedBy,
|
57
|
+
:isRequiredBy,
|
58
|
+
:isVersionOf,
|
59
|
+
:issued,
|
60
|
+
:language,
|
61
|
+
:license,
|
62
|
+
:mediator,
|
63
|
+
:medium,
|
64
|
+
:modified,
|
65
|
+
:provenance,
|
66
|
+
:publisher,
|
67
|
+
:references,
|
68
|
+
:relation,
|
69
|
+
:replaces,
|
70
|
+
:requires,
|
71
|
+
:rights,
|
72
|
+
:rightsHolder,
|
73
|
+
:source,
|
74
|
+
:spatial,
|
75
|
+
:subject,
|
76
|
+
:tableOfContents,
|
77
|
+
:temporal,
|
78
|
+
:title,
|
79
|
+
:valid
|
80
|
+
] # removed :type, :format
|
29
81
|
DCTERMS.freeze
|
30
82
|
|
31
83
|
#Constructor. this class will call self.field for each DCTERM. In short, all DCTERMS fields will already exist
|
@@ -131,7 +131,7 @@ module ActiveFedora
|
|
131
131
|
def condition_to_clauses(key, value)
|
132
132
|
unless value.nil?
|
133
133
|
# if the key is a property name, turn it into a solr field
|
134
|
-
if self.
|
134
|
+
if self.delegates.key?(key)
|
135
135
|
# TODO Check to see if `key' is a possible solr field for this class, if it isn't try :searchable instead
|
136
136
|
key = ActiveFedora::SolrService.solr_name(key, :stored_searchable, type: :string)
|
137
137
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module ActiveFedora
|
2
2
|
module RdfList
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include ActiveFedora::RdfNode
|
5
|
+
|
3
6
|
attr_reader :graph, :subject
|
7
|
+
|
4
8
|
def initialize(graph, subject)
|
5
9
|
@graph = graph
|
6
10
|
@subject = subject
|
@@ -8,6 +12,31 @@ module ActiveFedora
|
|
8
12
|
graph.insert([subject, RDF.first, RDF.nil]) unless first
|
9
13
|
graph.insert([subject, RDF.rest, RDF.nil])
|
10
14
|
end
|
15
|
+
|
16
|
+
# Override assign_nested_attributes
|
17
|
+
def assign_nested_attributes_for_collection_association(association_name, attributes_collection)
|
18
|
+
options = self.nested_attributes_options[association_name]
|
19
|
+
|
20
|
+
# TODO
|
21
|
+
#check_record_limit!(options[:limit], attributes_collection)
|
22
|
+
|
23
|
+
if attributes_collection.is_a?(Hash) || attributes_collection.is_a?(String)
|
24
|
+
attributes_collection = [attributes_collection]
|
25
|
+
end
|
26
|
+
|
27
|
+
association = self.send(association_name)
|
28
|
+
|
29
|
+
original_length_of_list = self.size
|
30
|
+
attributes_collection.each_with_index do |attributes, index|
|
31
|
+
if attributes.instance_of? Hash
|
32
|
+
attributes = attributes.with_indifferent_access
|
33
|
+
minted_node = association.mint_node(attributes.except(*UNASSIGNABLE_KEYS))
|
34
|
+
else
|
35
|
+
minted_node = association.mint_node(attributes)
|
36
|
+
end
|
37
|
+
self[original_length_of_list+index] = minted_node
|
38
|
+
end
|
39
|
+
end
|
11
40
|
|
12
41
|
def rdf_subject
|
13
42
|
subject
|
@@ -18,18 +18,22 @@ module ActiveFedora
|
|
18
18
|
|
19
19
|
|
20
20
|
def build(attributes=nil)
|
21
|
-
|
22
|
-
parent.graph.insert([subject, predicate,
|
23
|
-
parent.target_class(predicate).new(parent.graph, new_subject).tap do |node|
|
24
|
-
node.attributes = attributes if attributes
|
25
|
-
end
|
21
|
+
node = mint_node(attributes)
|
22
|
+
parent.graph.insert([subject, predicate, node.rdf_subject])
|
26
23
|
reset!
|
27
|
-
target.find { |n| n.rdf_subject ==
|
24
|
+
target.find { |n| n.rdf_subject == node.rdf_subject}
|
28
25
|
end
|
29
26
|
|
30
27
|
def reset!
|
31
28
|
@target = nil
|
32
29
|
end
|
30
|
+
|
31
|
+
def mint_node(attributes=nil)
|
32
|
+
new_subject = RDF::Node.new
|
33
|
+
return parent.target_class(predicate).new(parent.graph, new_subject).tap do |node|
|
34
|
+
node.attributes = attributes if attributes
|
35
|
+
end
|
36
|
+
end
|
33
37
|
|
34
38
|
def <<(*values)
|
35
39
|
values.each { |value| parent.append(subject, predicate, value) }
|
@@ -85,6 +89,9 @@ module ActiveFedora
|
|
85
89
|
# Two classes may be valid for the same predicate (e.g. hasMember)
|
86
90
|
# If no RDF.type assertion is found, fall back to using target_class
|
87
91
|
def class_from_rdf_type(subject)
|
92
|
+
unless subject.kind_of?(RDF::Node)
|
93
|
+
raise ArgumentError, "Expected the value of #{predicate} to be an RDF object but it is a #{subject.class} #{subject.inspect}"
|
94
|
+
end
|
88
95
|
q = RDF::Query.new do
|
89
96
|
pattern [subject, RDF.type, :value]
|
90
97
|
end
|
@@ -27,7 +27,12 @@ describe "Nested Rdf Objects" do
|
|
27
27
|
ds = SpecDatastream.new(mock_obj)
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
it "should not choke on invalid data" do
|
31
|
+
# set a string in the graph where model expects a node
|
32
|
+
ds.parts = ["foo"]
|
33
|
+
expect {ds.parts.inspect}.to raise_error(ArgumentError, "Expected the value of http://purl.org/dc/terms/hasPart to be an RDF object but it is a String \"foo\"")
|
34
|
+
end
|
35
|
+
|
31
36
|
it "should be able to nest a complex object" do
|
32
37
|
comp = SpecDatastream::Component.new(ds.graph)
|
33
38
|
comp.label = ["Alternator"]
|
@@ -93,9 +93,16 @@ describe ActiveFedora::Base do
|
|
93
93
|
@n.duck.should == ["Quack", "Peep"]
|
94
94
|
end
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
describe "array getters and setters" do
|
97
|
+
it "should accept symbol keys" do
|
98
|
+
@n[:duck]= ["Cluck", "Gobble"]
|
99
|
+
@n[:duck].should == ["Cluck", "Gobble"]
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should accept string keys" do
|
103
|
+
@n['duck']= ["Cluck", "Gobble"]
|
104
|
+
@n['duck'].should == ["Cluck", "Gobble"]
|
105
|
+
end
|
99
106
|
end
|
100
107
|
|
101
108
|
end
|
@@ -45,7 +45,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should create the right number of fields" do
|
48
|
-
ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS.size.should ==
|
48
|
+
ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS.size.should == 53
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should have unmodifiable constants" do
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::RdfList do
|
4
|
+
before :each do
|
5
|
+
class MADS < RDF::Vocabulary("http://www.loc.gov/mads/rdf/v1#")
|
6
|
+
property :MADSScheme
|
7
|
+
property :isMemberOfMADSScheme
|
8
|
+
property :authoritativeLabel
|
9
|
+
property :elementList
|
10
|
+
property :elementValue
|
11
|
+
property :Topic
|
12
|
+
property :TopicElement
|
13
|
+
property :TemporalElement
|
14
|
+
property :hasExactExternalAuthority
|
15
|
+
end
|
16
|
+
|
17
|
+
class TopicElement
|
18
|
+
include ActiveFedora::RdfObject
|
19
|
+
rdf_type MADS.TopicElement
|
20
|
+
map_predicates do |map|
|
21
|
+
map.elementValue(:in=> MADS)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
class TemporalElement
|
25
|
+
include ActiveFedora::RdfObject
|
26
|
+
rdf_type MADS.TemporalElement
|
27
|
+
map_predicates do |map|
|
28
|
+
map.elementValue(:in=> MADS)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
class ElementList
|
32
|
+
include ActiveFedora::RdfList
|
33
|
+
|
34
|
+
map_predicates do |map|
|
35
|
+
map.topicElement(:in=> MADS, :to =>"TopicElement", :class_name => "TopicElement")
|
36
|
+
map.temporalElement(:in=> MADS, :to =>"TemporalElement", :class_name => "TemporalElement")
|
37
|
+
end
|
38
|
+
accepts_nested_attributes_for :topicElement, :temporalElement
|
39
|
+
end
|
40
|
+
|
41
|
+
class Topic
|
42
|
+
include ActiveFedora::RdfObject
|
43
|
+
rdf_type MADS.Topic
|
44
|
+
rdf_subject { |ds| RDF::URI.new(Rails.configuration.id_namespace + ds.pid)}
|
45
|
+
map_predicates do |map|
|
46
|
+
map.name(:in => MADS, :to => 'authoritativeLabel')
|
47
|
+
map.elementList(:in => MADS, :class_name=>'ElementList')
|
48
|
+
map.externalAuthority(:in => MADS, :to => 'hasExactExternalAuthority')
|
49
|
+
end
|
50
|
+
accepts_nested_attributes_for :elementList
|
51
|
+
end
|
52
|
+
end
|
53
|
+
after(:each) do
|
54
|
+
Object.send(:remove_const, :Topic)
|
55
|
+
Object.send(:remove_const, :ElementList)
|
56
|
+
Object.send(:remove_const, :TopicElement)
|
57
|
+
Object.send(:remove_const, :TemporalElement)
|
58
|
+
Object.send(:remove_const, :MADS)
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "nested_attributes" do
|
62
|
+
it "should insert new nodes into RdfLists (rather than calling .build)" do
|
63
|
+
params = {
|
64
|
+
topic: {
|
65
|
+
name: "Baseball",
|
66
|
+
externalAuthority: "http://id.loc.gov/authorities/subjects/sh85012026",
|
67
|
+
elementList_attributes: [
|
68
|
+
topicElement_attributes: [{ elementValue: "Baseball" }, elementValue: "Football"],
|
69
|
+
]
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
topic = Topic.new(RDF::Graph.new)
|
74
|
+
topic.attributes = params[:topic]
|
75
|
+
# puts topic.graph.dump(:ntriples)
|
76
|
+
topic.elementList.first.size.should == 2
|
77
|
+
topic.elementList.first[0].should be_kind_of(TopicElement)
|
78
|
+
topic.elementList.first[0].elementValue.should == ["Baseball"]
|
79
|
+
topic.elementList.first[1].should be_kind_of(TopicElement)
|
80
|
+
topic.elementList.first[1].elementValue.should == ["Football"]
|
81
|
+
end
|
82
|
+
it "should insert new nodes of varying types into RdfLists (rather than calling .build)" do
|
83
|
+
# It's Not clear what the syntax should be when an RDF list contains multiple types of sub-nodes.
|
84
|
+
# This is a guess, which currently works.
|
85
|
+
params = {
|
86
|
+
topic: {
|
87
|
+
name: "Baseball",
|
88
|
+
externalAuthority: "http://id.loc.gov/authorities/subjects/sh85012026",
|
89
|
+
elementList_attributes: [
|
90
|
+
topicElement_attributes: [{ elementValue: "Baseball" }, elementValue: "Football"],
|
91
|
+
temporalElement_attributes: [{elementValue: "1960"}, {elementValue:"Twentieth Century"}],
|
92
|
+
]
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
topic = Topic.new(RDF::Graph.new)
|
97
|
+
topic.attributes = params[:topic]
|
98
|
+
# puts topic.graph.dump(:ntriples)
|
99
|
+
topic.elementList.first.size.should == 4
|
100
|
+
topic.elementList.first[0].should be_kind_of(TopicElement)
|
101
|
+
topic.elementList.first[0].elementValue.should == ["Baseball"]
|
102
|
+
topic.elementList.first[1].should be_kind_of(TopicElement)
|
103
|
+
topic.elementList.first[1].elementValue.should == ["Football"]
|
104
|
+
topic.elementList.first[2].should be_kind_of(TemporalElement)
|
105
|
+
topic.elementList.first[2].elementValue.should == ["1960"]
|
106
|
+
topic.elementList.first[3].should be_kind_of(TemporalElement)
|
107
|
+
topic.elementList.first[3].elementValue.should == ["Twentieth Century"]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.4.0.
|
4
|
+
version: 6.4.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-06-
|
13
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -512,6 +512,7 @@ files:
|
|
512
512
|
- spec/unit/qualified_dublin_core_datastream_spec.rb
|
513
513
|
- spec/unit/query_spec.rb
|
514
514
|
- spec/unit/rdf_datastream_spec.rb
|
515
|
+
- spec/unit/rdf_list_nested_attributes_spec.rb
|
515
516
|
- spec/unit/rdf_list_spec.rb
|
516
517
|
- spec/unit/rdf_xml_writer_spec.rb
|
517
518
|
- spec/unit/rdfxml_rdf_datastream_spec.rb
|
@@ -677,6 +678,7 @@ test_files:
|
|
677
678
|
- spec/unit/qualified_dublin_core_datastream_spec.rb
|
678
679
|
- spec/unit/query_spec.rb
|
679
680
|
- spec/unit/rdf_datastream_spec.rb
|
681
|
+
- spec/unit/rdf_list_nested_attributes_spec.rb
|
680
682
|
- spec/unit/rdf_list_spec.rb
|
681
683
|
- spec/unit/rdf_xml_writer_spec.rb
|
682
684
|
- spec/unit/rdfxml_rdf_datastream_spec.rb
|