active-fedora 1.1.8 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +5 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/active-fedora.gemspec +9 -7
- data/lib/active_fedora/base.rb +44 -50
- data/lib/active_fedora/metadata_datastream.rb +105 -33
- data/lib/active_fedora/metadata_datastream_helper.rb +3 -1
- data/lib/active_fedora/nokogiri_datastream.rb +51 -2
- data/lib/active_fedora/rels_ext_datastream.rb +0 -1
- data/lib/hydra.rb +1 -1
- data/lib/hydra/sample_mods_datastream.rb +100 -0
- data/spec/hydrangea_fixture_mods_article1.foxml.xml +225 -0
- data/spec/integration/full_featured_model_spec.rb +1 -2
- data/spec/integration/mods_article_integration_spec.rb +45 -0
- data/spec/unit/base_extra_spec.rb +11 -4
- data/spec/unit/base_spec.rb +64 -99
- data/spec/unit/metadata_datastream_spec.rb +109 -1
- data/spec/unit/nokogiri_datastream_spec.rb +154 -5
- data/spec/unit/solr_config_options_spec.rb +4 -2
- metadata +11 -9
- data/lib/hydra/mods_article.rb +0 -49
- data/lib/hydra/opinionated_mods_document.rb +0 -14
@@ -34,7 +34,6 @@ module ActiveFedora
|
|
34
34
|
# node.xpath("./foxml:datastreamVersion[last()]/foxml:xmlContent/rdf:RDF/rdf:Description/*").each do |f|
|
35
35
|
node.xpath("./foxml:datastreamVersion[last()]/foxml:xmlContent/rdf:RDF/rdf:Description/*", {"rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#", "foxml"=>"info:fedora/fedora-system:def/foxml#"}).each do |f|
|
36
36
|
r = ActiveFedora::Relationship.new(:subject=>:self, :predicate=>ActiveFedora::SemanticNode::PREDICATE_MAPPINGS.invert[f.name], :object=>f["resource"])
|
37
|
-
puts "adding #{r.inspect} to template"
|
38
37
|
tmpl.add_relationship(r)
|
39
38
|
end
|
40
39
|
tmpl.send(:dirty=, false)
|
data/lib/hydra.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
module Hydra;end
|
2
|
-
require "hydra/
|
2
|
+
require "hydra/sample_mods_datastream"
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require "hydra"
|
2
|
+
module Hydra
|
3
|
+
class Hydra::SampleModsDatastream < ActiveFedora::NokogiriDatastream
|
4
|
+
|
5
|
+
# have to call this in order to set namespace & schema
|
6
|
+
root_property :mods, "mods", "http://www.loc.gov/mods/v3", :attributes=>["id", "version"], :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd"
|
7
|
+
|
8
|
+
property :title_info, :path=>"titleInfo",
|
9
|
+
:convenience_methods => {
|
10
|
+
:main_title => {:path=>"title"},
|
11
|
+
:language => {:path=>{:attribute=>"lang"}},
|
12
|
+
}
|
13
|
+
property :abstract, :path=>"abstract"
|
14
|
+
property :topic_tag, :path=>'subject',:default_content_path => "topic"
|
15
|
+
|
16
|
+
property :name_, :path=>"name",
|
17
|
+
:attributes=>[:xlink, :lang, "xml:lang", :script, :transliteration, {:type=>["personal", "enumerated", "corporate"]} ],
|
18
|
+
:subelements=>["namePart", "displayForm", "affiliation", :role, "description"],
|
19
|
+
:default_content_path => "namePart",
|
20
|
+
:convenience_methods => {
|
21
|
+
:date => {:path=>"namePart", :attributes=>{:type=>"date"}},
|
22
|
+
:family_name => {:path=>"namePart", :attributes=>{:type=>"family"}},
|
23
|
+
:first_name => {:path=>"namePart", :attributes=>{:type=>"given"}},
|
24
|
+
:terms_of_address => {:path=>"namePart", :attributes=>{:type=>"termsOfAddress"}}
|
25
|
+
}
|
26
|
+
|
27
|
+
property :person, :variant_of=>:name_, :attributes=>{:type=>"personal"}
|
28
|
+
property :organizaton, :variant_of=>:name_, :attributes=>{:type=>"institutional"}
|
29
|
+
property :conference, :variant_of=>:name_, :attributes=>{:type=>"conference"}
|
30
|
+
|
31
|
+
property :role, :path=>"role",
|
32
|
+
:parents=>[:name_],
|
33
|
+
:convenience_methods => {
|
34
|
+
:text => {:path=>"roleTerm", :attributes=>{:type=>"text"}},
|
35
|
+
:code => {:path=>"roleTerm", :attributes=>{:type=>"code"}},
|
36
|
+
}
|
37
|
+
|
38
|
+
property :journal, :path=>'relatedItem', :attributes=>{:type=>"host"},
|
39
|
+
:subelements=>[:title_info, :origin_info, :issue],
|
40
|
+
:convenience_methods => {
|
41
|
+
:issn => {:path=>"identifier", :attributes=>{:type=>"issn"}},
|
42
|
+
}
|
43
|
+
|
44
|
+
property :origin_info, :path=>'originInfo',
|
45
|
+
:subelements=>["publisher","dateIssued"]
|
46
|
+
|
47
|
+
property :issue, :path=>'part',
|
48
|
+
:subelements=>[:start_page, :end_page],
|
49
|
+
:convenience_methods => {
|
50
|
+
:volume => {:path=>"detail", :attributes=>{:type=>"volume"}},
|
51
|
+
:level => {:path=>"detail", :attributes=>{:type=>"level"}},
|
52
|
+
:publication_date => {:path=>"date"}
|
53
|
+
}
|
54
|
+
property :start_page, :path=>"extent", :attributes=>{:unit=>"pages"}, :default_content_path => "start"
|
55
|
+
property :end_page, :path=>"extent", :attributes=>{:unit=>"pages"}, :default_content_path => "end"
|
56
|
+
|
57
|
+
generate_accessors_from_properties
|
58
|
+
# accessor :title_info, :relative_xpath=>'oxns:titleInfo', :children=>[
|
59
|
+
# {:main_title=>{:relative_xpath=>'oxns:title'}},
|
60
|
+
# {:language =>{:relative_xpath=>{:attribute=>"lang"} }}
|
61
|
+
# ]
|
62
|
+
# accessor :abstract
|
63
|
+
# accessor :topic_tag, :relative_xpath=>'oxns:subject/oxns:topic'
|
64
|
+
# accessor :person, :relative_xpath=>'oxns:name[@type="personal"]', :children=>[
|
65
|
+
# {:last_name=>{:relative_xpath=>'oxns:namePart[@type="family"]'}},
|
66
|
+
# {:first_name=>{:relative_xpath=>'oxns:namePart[@type="given"]'}},
|
67
|
+
# {:institution=>{:relative_xpath=>'oxns:affiliation'}},
|
68
|
+
# {:role=>{:children=>[
|
69
|
+
# {:text=>{:relative_xpath=>'oxns:roleTerm[@type="text"]'}},
|
70
|
+
# {:code=>{:relative_xpath=>'oxns:roleTerm[@type="code"]'}}
|
71
|
+
# ]}}
|
72
|
+
# ]
|
73
|
+
# accessor :organization, :relative_xpath=>'oxns:name[@type="institutional"]', :children=>[
|
74
|
+
# {:role=>{:children=>[
|
75
|
+
# {:text=>{:relative_xpath=>'oxns:roleTerm[@type="text"]'}},
|
76
|
+
# {:code=>{:relative_xpath=>'oxns:roleTerm[@type="code"]'}}
|
77
|
+
# ]}}
|
78
|
+
# ]
|
79
|
+
# accessor :conference, :relative_xpath=>'oxns:name[@type="conference"]', :children=>[
|
80
|
+
# {:role=>{:children=>[
|
81
|
+
# {:text=>{:relative_xpath=>'oxns:roleTerm[@type="text"]'}},
|
82
|
+
# {:code=>{:relative_xpath=>'oxns:roleTerm[@type="code"]'}}
|
83
|
+
# ]}}
|
84
|
+
# ]
|
85
|
+
# accessor :journal, :relative_xpath=>'oxns:relatedItem[@type="host"]', :children=>[
|
86
|
+
# {:title=>{:relative_xpath=>'oxns:titleInfo/oxns:title'}},
|
87
|
+
# {:publisher=>{:relative_xpath=>'oxns:originInfo/oxns:publisher'}},
|
88
|
+
# {:issn=>{:relative_xpath=>'oxns:identifier[@type="issn"]'}},
|
89
|
+
# {:date_issued=>{:relative_xpath=>'oxns:originInfo/oxns:dateIssued'}},
|
90
|
+
# {:issue => {:relative_xpath=>"oxns:part", :children=>[
|
91
|
+
# {:volume=>{:relative_xpath=>'oxns:detail[@type="volume"]'}},
|
92
|
+
# {:level=>{:relative_xpath=>'oxns:detail[@type="level"]'}},
|
93
|
+
# {:start_page=>{:relative_xpath=>'oxns:extent[@unit="pages"]/oxns:start'}},
|
94
|
+
# {:end_page=>{:relative_xpath=>'oxns:extent[@unit="pages"]/oxns:end'}},
|
95
|
+
# {:publication_date=>{:relative_xpath=>'oxns:date'}}
|
96
|
+
# ]}}
|
97
|
+
# ]
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,225 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<foxml:digitalObject VERSION="1.1" PID="hydrangea:fixture_mods_article1"
|
3
|
+
xmlns:foxml="info:fedora/fedora-system:def/foxml#"
|
4
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
5
|
+
xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
|
6
|
+
<foxml:objectProperties>
|
7
|
+
<foxml:property NAME="info:fedora/fedora-system:def/model#state" VALUE="Active"/>
|
8
|
+
<foxml:property NAME="info:fedora/fedora-system:def/model#label" VALUE=""/>
|
9
|
+
<foxml:property NAME="info:fedora/fedora-system:def/model#ownerId" VALUE="fedoraAdmin"/>
|
10
|
+
<foxml:property NAME="info:fedora/fedora-system:def/model#createdDate" VALUE="2010-06-17T19:56:19.301Z"/>
|
11
|
+
<foxml:property NAME="info:fedora/fedora-system:def/view#lastModifiedDate" VALUE="2010-06-17T19:57:30.688Z"/>
|
12
|
+
</foxml:objectProperties>
|
13
|
+
<foxml:datastream ID="AUDIT" STATE="A" CONTROL_GROUP="X" VERSIONABLE="false">
|
14
|
+
<foxml:datastreamVersion ID="AUDIT.0" LABEL="Audit Trail for this object" CREATED="2010-06-17T19:56:19.301Z" MIMETYPE="text/xml" FORMAT_URI="info:fedora/fedora-system:format/xml.fedora.audit">
|
15
|
+
<foxml:xmlContent>
|
16
|
+
<audit:auditTrail xmlns:audit="info:fedora/fedora-system:def/audit#">
|
17
|
+
<audit:record ID="AUDREC1">
|
18
|
+
<audit:process type="Fedora API-M"/>
|
19
|
+
<audit:action>addDatastream</audit:action>
|
20
|
+
<audit:componentID>descMetadata</audit:componentID>
|
21
|
+
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
22
|
+
<audit:date>2010-06-17T19:56:22.150Z</audit:date>
|
23
|
+
<audit:justification></audit:justification>
|
24
|
+
</audit:record>
|
25
|
+
<audit:record ID="AUDREC2">
|
26
|
+
<audit:process type="Fedora API-M"/>
|
27
|
+
<audit:action>addDatastream</audit:action>
|
28
|
+
<audit:componentID>RELS-EXT</audit:componentID>
|
29
|
+
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
30
|
+
<audit:date>2010-06-17T19:56:22.353Z</audit:date>
|
31
|
+
<audit:justification></audit:justification>
|
32
|
+
</audit:record>
|
33
|
+
<audit:record ID="AUDREC3">
|
34
|
+
<audit:process type="Fedora API-M"/>
|
35
|
+
<audit:action>addDatastream</audit:action>
|
36
|
+
<audit:componentID>rightsMetadata</audit:componentID>
|
37
|
+
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
38
|
+
<audit:date>2010-06-17T19:56:23.335Z</audit:date>
|
39
|
+
<audit:justification></audit:justification>
|
40
|
+
</audit:record>
|
41
|
+
<audit:record ID="AUDREC4">
|
42
|
+
<audit:process type="Fedora API-M"/>
|
43
|
+
<audit:action>addDatastream</audit:action>
|
44
|
+
<audit:componentID>properties</audit:componentID>
|
45
|
+
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
46
|
+
<audit:date>2010-06-17T19:56:23.477Z</audit:date>
|
47
|
+
<audit:justification></audit:justification>
|
48
|
+
</audit:record>
|
49
|
+
<audit:record ID="AUDREC5">
|
50
|
+
<audit:process type="Fedora API-M"/>
|
51
|
+
<audit:action>modifyObject</audit:action>
|
52
|
+
<audit:componentID></audit:componentID>
|
53
|
+
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
54
|
+
<audit:date>2010-06-17T19:57:30.688Z</audit:date>
|
55
|
+
<audit:justification></audit:justification>
|
56
|
+
</audit:record>
|
57
|
+
</audit:auditTrail>
|
58
|
+
</foxml:xmlContent>
|
59
|
+
</foxml:datastreamVersion>
|
60
|
+
</foxml:datastream>
|
61
|
+
<foxml:datastream ID="DC" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
62
|
+
<foxml:datastreamVersion ID="DC1.0" LABEL="Dublin Core Record for this object" CREATED="2010-06-17T19:56:19.301Z" MIMETYPE="text/xml" FORMAT_URI="http://www.openarchives.org/OAI/2.0/oai_dc/" SIZE="360">
|
63
|
+
<foxml:xmlContent>
|
64
|
+
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
|
65
|
+
<dc:identifier>hydrangea:fixture_mods_article1</dc:identifier>
|
66
|
+
</oai_dc:dc>
|
67
|
+
</foxml:xmlContent>
|
68
|
+
</foxml:datastreamVersion>
|
69
|
+
</foxml:datastream>
|
70
|
+
<foxml:datastream ID="descMetadata" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
71
|
+
<foxml:datastreamVersion ID="descMetadata.0" LABEL="" CREATED="2010-06-17T19:56:22.150Z" MIMETYPE="text/xml" SIZE="19">
|
72
|
+
<foxml:xmlContent>
|
73
|
+
<mods version="3.0" xsi:schemaLocation="http://www.loc.gov/mods/v3
|
74
|
+
http://www.loc.gov/standards/mods/v3/mods-3-0.xsd" xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
75
|
+
|
76
|
+
<titleInfo>
|
77
|
+
<nonSort>THE</nonSort>
|
78
|
+
<title>ARTICLE TITLE</title>
|
79
|
+
<subTitle>SUBTITLE</subTitle>
|
80
|
+
</titleInfo>
|
81
|
+
<titleInfo type="alternative">
|
82
|
+
<title>VARYING FORM OF TITLE</title>
|
83
|
+
</titleInfo>
|
84
|
+
|
85
|
+
<name type="personal">
|
86
|
+
<namePart type="family">FAMILY NAME</namePart>
|
87
|
+
<namePart type="given">GIVEN NAMES</namePart>
|
88
|
+
<namePart type="termsOfAddress">DR.</namePart>
|
89
|
+
<displayForm>NAME AS IT APPEARS</displayForm>
|
90
|
+
<affiliation>FACULTY, UNIVERSITY</affiliation>
|
91
|
+
<role>
|
92
|
+
<roleTerm authority="marcrelator" type="text">creator</roleTerm>
|
93
|
+
</role>
|
94
|
+
<role>
|
95
|
+
<roleTerm type="text">submitter</roleTerm>
|
96
|
+
</role>
|
97
|
+
</name>
|
98
|
+
<name type="personal">
|
99
|
+
<namePart type="family">Lacks</namePart>
|
100
|
+
<namePart type="given">Henrietta</namePart>
|
101
|
+
<displayForm>HeLa</displayForm>
|
102
|
+
<affiliation>Baltimore</affiliation>
|
103
|
+
<role>
|
104
|
+
<roleTerm type="text">contributor</roleTerm>
|
105
|
+
</role>
|
106
|
+
</name>
|
107
|
+
|
108
|
+
<typeOfResource>text</typeOfResource>
|
109
|
+
<genre authority="local">journal article</genre>
|
110
|
+
|
111
|
+
<abstract>ABSTRACT</abstract>
|
112
|
+
<subject>
|
113
|
+
<topic>TOPIC 1</topic>
|
114
|
+
<topic>TOPIC 2</topic>
|
115
|
+
</subject>
|
116
|
+
<subject authority="AUTHORITY SOURCE (RFCD, LCSH)">
|
117
|
+
<topic>CONTROLLED TERM</topic>
|
118
|
+
</subject>
|
119
|
+
|
120
|
+
<language>
|
121
|
+
<languageTerm authority="iso639-2b" type="code">en-aus </languageTerm>
|
122
|
+
</language>
|
123
|
+
|
124
|
+
<physicalDescription>
|
125
|
+
<internetMediaType>application/pdf</internetMediaType>
|
126
|
+
<extent>36 p.</extent>
|
127
|
+
</physicalDescription>
|
128
|
+
|
129
|
+
<relatedItem type="host">
|
130
|
+
<titleInfo>
|
131
|
+
<title>TITLE OF HOST JOURNAL</title>
|
132
|
+
</titleInfo>
|
133
|
+
<originInfo>
|
134
|
+
<publisher>PUBLISHER</publisher>
|
135
|
+
<dateIssued>DATE</dateIssued>
|
136
|
+
</originInfo>
|
137
|
+
<identifier type="issn">0013-8908</identifier>
|
138
|
+
<part>
|
139
|
+
<detail type="volume">
|
140
|
+
<number>2</number>
|
141
|
+
</detail>
|
142
|
+
<detail type="level">
|
143
|
+
<number>2</number>
|
144
|
+
</detail>
|
145
|
+
<extent unit="pages">
|
146
|
+
<start>195</start>
|
147
|
+
<end>230</end>
|
148
|
+
</extent>
|
149
|
+
<date>FEB. 2007</date>
|
150
|
+
</part>
|
151
|
+
</relatedItem>
|
152
|
+
|
153
|
+
<identifier type="uri">http://URL.edu.au/</identifier>
|
154
|
+
<identifier type="doi">doi:10.1006/jmbi.1995.0238</identifier>
|
155
|
+
<location>
|
156
|
+
<url>http://URL.edu.au/</url>
|
157
|
+
</location>
|
158
|
+
<accessCondition type="restrictionOnAccess">EMBARGO NOTE</accessCondition>
|
159
|
+
<accessCondition type="use and reproduction">OPEN ACCESS</accessCondition>
|
160
|
+
|
161
|
+
</mods>
|
162
|
+
</foxml:xmlContent>
|
163
|
+
</foxml:datastreamVersion>
|
164
|
+
</foxml:datastream>
|
165
|
+
<foxml:datastream ID="RELS-EXT" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
166
|
+
<foxml:datastreamVersion ID="RELS-EXT.0" LABEL="" CREATED="2010-06-17T19:56:22.353Z" MIMETYPE="text/xml" SIZE="306">
|
167
|
+
<foxml:xmlContent>
|
168
|
+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
169
|
+
<rdf:Description rdf:about="info:fedora/hydrangea:fixture_mods_article1">
|
170
|
+
<hasModel xmlns="info:fedora/fedora-system:def/relations-external#" rdf:resource="info:fedora/afmodel:HydrangeaArticle"></hasModel>
|
171
|
+
</rdf:Description>
|
172
|
+
</rdf:RDF>
|
173
|
+
</foxml:xmlContent>
|
174
|
+
</foxml:datastreamVersion>
|
175
|
+
</foxml:datastream>
|
176
|
+
<foxml:datastream ID="rightsMetadata" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
177
|
+
<foxml:datastreamVersion ID="rightsMetadata.0" LABEL="" CREATED="2010-06-17T19:56:23.335Z" MIMETYPE="text/xml" SIZE="19">
|
178
|
+
<foxml:xmlContent>
|
179
|
+
<rightsMetadata>
|
180
|
+
<copyright>
|
181
|
+
<human>(c)2009 The Hydra Project</human>
|
182
|
+
<human type="someSpecialisedType">Blah Blah</human>
|
183
|
+
<human type="aDifferentType">More blah</human>
|
184
|
+
<machine><a rel="license" href="http://creativecommons.org/licenses/publicdomain/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/publicdomain/88x31.png" /></a><br />This work is in the <a rel="license" href="http://creativecommons.org/licenses/publicdomain/">Public Domain</a>.</machine>
|
185
|
+
</copyright>
|
186
|
+
<access type="discover">
|
187
|
+
<human></human>
|
188
|
+
<machine>
|
189
|
+
<policy>hydra-policy:4502</policy>
|
190
|
+
<group>public</group>
|
191
|
+
</machine>
|
192
|
+
</access>
|
193
|
+
<access type="read">
|
194
|
+
<human></human>
|
195
|
+
<machine>
|
196
|
+
<group>public</group>
|
197
|
+
</machine>
|
198
|
+
</access>
|
199
|
+
<access type="edit">
|
200
|
+
<human></human>
|
201
|
+
<machine>
|
202
|
+
<person>researcher1</person>
|
203
|
+
<group>archivist</group>
|
204
|
+
</machine>
|
205
|
+
</access>
|
206
|
+
<access type="etc">
|
207
|
+
<!-- etc -->
|
208
|
+
</access>
|
209
|
+
<use>
|
210
|
+
<human>You are free to re-distribute this object, but you cannot change it or sell it. </human>
|
211
|
+
<machine><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-nd/3.0/us/88x31.png" /></a><br />This <span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Sound" rel="dc:type">work</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/">Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License</a>.</machine>
|
212
|
+
</use>
|
213
|
+
|
214
|
+
</rightsMetadata>
|
215
|
+
</foxml:xmlContent>
|
216
|
+
</foxml:datastreamVersion>
|
217
|
+
</foxml:datastream>
|
218
|
+
<foxml:datastream ID="properties" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
219
|
+
<foxml:datastreamVersion ID="properties.0" LABEL="" CREATED="2010-06-17T19:56:23.477Z" MIMETYPE="text/xml" SIZE="19">
|
220
|
+
<foxml:xmlContent>
|
221
|
+
<fields></fields>
|
222
|
+
</foxml:xmlContent>
|
223
|
+
</foxml:datastreamVersion>
|
224
|
+
</foxml:datastream>
|
225
|
+
</foxml:digitalObject>
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
-
|
3
2
|
require 'rexml/document'
|
4
3
|
require "hydra"
|
5
4
|
|
@@ -35,7 +34,7 @@ describe ActiveFedora::Base do
|
|
35
34
|
# m.root_property :myxml, "my_xml", "http://www.example.gov/schema/v3"
|
36
35
|
# end
|
37
36
|
|
38
|
-
has_metadata :name=>"mods_article", :type=> Hydra::
|
37
|
+
has_metadata :name=>"mods_article", :type=> Hydra::SampleModsDatastream
|
39
38
|
|
40
39
|
has_metadata :name => "dublin_core", :type => ActiveFedora::QualifiedDublinCoreDatastream do |m|
|
41
40
|
# Default :multiple => true
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
+
# require File.join( File.dirname(__FILE__), "..", "samples", "models", "mods_article" )
|
3
|
+
require "hydra"
|
4
|
+
describe ActiveFedora::Base do
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
class HydrangeaArticle < ActiveFedora::Base
|
8
|
+
|
9
|
+
has_relationship "parts", :is_part_of, :inbound => true
|
10
|
+
|
11
|
+
# Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
|
12
|
+
# has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata
|
13
|
+
|
14
|
+
# Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
|
15
|
+
has_metadata :name => "descMetadata", :type => Hydra::SampleModsDatastream
|
16
|
+
|
17
|
+
# A place to put extra metadata values
|
18
|
+
has_metadata :name => "properties", :type => ActiveFedora::MetadataDatastream do |m|
|
19
|
+
m.field 'collection', :string
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
before(:each) do
|
25
|
+
@test_article = HydrangeaArticle.load_instance("hydrangea:fixture_mods_article1")
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".update_indexed_attributes" do
|
29
|
+
before(:each) do
|
30
|
+
@test_article.update_indexed_attributes({[{:person=>0}, :first_name] => "GIVEN NAMES"}, :datastreams=>"descMetadata")
|
31
|
+
end
|
32
|
+
after(:each) do
|
33
|
+
@test_article.update_indexed_attributes({[{:person=>0}, :first_name] => "GIVEN NAMES"}, :datastreams=>"descMetadata")
|
34
|
+
end
|
35
|
+
it "should update the xml in the specified datatsream and save those changes to Fedora" do
|
36
|
+
@test_article.get_values_from_datastream("descMetadata", [{:person=>0}, :first_name]).should == ["GIVEN NAMES"]
|
37
|
+
test_args = {:params=>{[{:person=>0}, :first_name]=>{"0"=>"Replacement FirstName"}}, :opts=>{:datastreams=>"descMetadata"}}
|
38
|
+
@test_article.update_indexed_attributes(test_args[:params], test_args[:opts])
|
39
|
+
@test_article.get_values_from_datastream("descMetadata", [{:person=>0}, :first_name]).should == ["Replacement FirstName"]
|
40
|
+
@test_article.save
|
41
|
+
retrieved_article = HydrangeaArticle.load_instance("hydrangea:fixture_mods_article1")
|
42
|
+
retrieved_article.get_values_from_datastream("descMetadata", [{:person=>0}, :first_name]).should == ["Replacement FirstName"]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -14,17 +14,24 @@ describe ActiveFedora::Base do
|
|
14
14
|
describe ".metadata_streams" do
|
15
15
|
it "should return all of the datastreams from the object that are kinds of MetadataDatastreams " do
|
16
16
|
mock_mds1 = mock("metadata ds")
|
17
|
-
mock_mds1.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
|
18
17
|
mock_mds2 = mock("metadata ds")
|
19
|
-
mock_mds2.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
|
20
18
|
mock_fds = mock("file ds")
|
21
19
|
mock_fds.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(false)
|
22
|
-
|
20
|
+
mock_ngds = mock("nokogiri ds")
|
21
|
+
mock_ngds.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(false)
|
22
|
+
mock_ngds.expects(:kind_of?).with(ActiveFedora::NokogiriDatastream).returns(true)
|
23
|
+
|
24
|
+
|
25
|
+
[mock_mds1,mock_mds2].each {|ds| ds.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true) }
|
26
|
+
[mock_mds1,mock_mds2,mock_fds].each {|ds| ds.stubs(:kind_of?).with(ActiveFedora::NokogiriDatastream).returns(false) }
|
27
|
+
|
28
|
+
@test_object.expects(:datastreams).returns({:foo => mock_mds1, :bar => mock_mds2, :baz => mock_fds, :bork=>mock_ngds})
|
23
29
|
|
24
30
|
result = @test_object.metadata_streams
|
25
|
-
result.length.should ==
|
31
|
+
result.length.should == 3
|
26
32
|
result.should include(mock_mds1)
|
27
33
|
result.should include(mock_mds2)
|
34
|
+
result.should include(mock_ngds)
|
28
35
|
end
|
29
36
|
end
|
30
37
|
|
data/spec/unit/base_spec.rb
CHANGED
@@ -231,11 +231,14 @@ describe ActiveFedora::Base do
|
|
231
231
|
end
|
232
232
|
it "should update solr index with all metadata if any MetadataDatastreams have changed" do
|
233
233
|
Fedora::Repository.instance.stubs(:save)
|
234
|
-
|
234
|
+
dirty_ds = ActiveFedora::MetadataDatastream.new
|
235
|
+
dirty_ds.expects(:dirty?).returns(true)
|
236
|
+
dirty_ds.expects(:save).returns(true)
|
235
237
|
mock2 = mock("ds2", :dirty? => false, :new_object? => false)
|
236
|
-
@test_object.stubs(:datastreams_in_memory).returns({:ds1 =>
|
238
|
+
@test_object.stubs(:datastreams_in_memory).returns({:ds1 => dirty_ds, :ds2 => mock2})
|
237
239
|
@test_object.expects(:update_index)
|
238
240
|
@test_object.expects(:refresh)
|
241
|
+
|
239
242
|
@test_object.save
|
240
243
|
end
|
241
244
|
it "should NOT update solr index if no MetadataDatastreams have changed" do
|
@@ -246,18 +249,20 @@ describe ActiveFedora::Base do
|
|
246
249
|
@test_object.expects(:update_index).never
|
247
250
|
@test_object.expects(:refresh)
|
248
251
|
@test_object.instance_variable_set(:@new_object, false)
|
252
|
+
|
249
253
|
@test_object.save
|
250
254
|
end
|
251
255
|
it "should update solr index if RELS-EXT datastream has changed" do
|
252
256
|
Fedora::Repository.instance.stubs(:save)
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
@test_object.stubs(:datastreams_in_memory).returns({"RELS-EXT" =>
|
257
|
+
rels_ext = ActiveFedora::RelsExtDatastream.new
|
258
|
+
rels_ext.expects(:dirty?).returns(true)
|
259
|
+
rels_ext.expects(:save).returns(true)
|
260
|
+
clean_ds = mock("ds2", :dirty? => false, :new_object? => false)
|
261
|
+
@test_object.stubs(:datastreams_in_memory).returns({"RELS-EXT" => rels_ext, :clean_ds => clean_ds})
|
258
262
|
@test_object.instance_variable_set(:@new_object, false)
|
259
263
|
@test_object.expects(:refresh)
|
260
264
|
@test_object.expects(:update_index)
|
265
|
+
|
261
266
|
@test_object.save
|
262
267
|
end
|
263
268
|
end
|
@@ -283,12 +288,11 @@ describe ActiveFedora::Base do
|
|
283
288
|
end
|
284
289
|
|
285
290
|
it "should call .to_xml on all MetadataDatastreams and return the resulting document" do
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
mock2.expects(:included_modules).returns( [ActiveFedora::MetadataDatastreamHelper] )
|
291
|
+
ds1 = ActiveFedora::MetadataDatastream.new
|
292
|
+
ds2 = ActiveFedora::MetadataDatastream.new
|
293
|
+
[ds1,ds2].each {|ds| ds.expects(:to_xml)}
|
290
294
|
|
291
|
-
@test_object.expects(:datastreams).returns({:ds1 =>
|
295
|
+
@test_object.expects(:datastreams).returns({:ds1 => ds1, :ds2 => ds2})
|
292
296
|
@test_object.to_xml
|
293
297
|
end
|
294
298
|
end
|
@@ -411,15 +415,52 @@ describe ActiveFedora::Base do
|
|
411
415
|
f.pid.should == 'numbnuts:1'
|
412
416
|
|
413
417
|
end
|
418
|
+
|
419
|
+
describe "get_values_from_datastream" do
|
420
|
+
it "should look up the named datastream and call get_values with the given pointer/field_name" do
|
421
|
+
mock_ds = mock("Datastream", :get_values=>["value1", "value2"])
|
422
|
+
@test_object.stubs(:datastreams_in_memory).returns({"ds1"=>mock_ds})
|
423
|
+
@test_object.get_values_from_datastream("ds1", "--my xpath--").should == ["value1", "value2"]
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
describe "update_datastream_attributes" do
|
428
|
+
it "should look up any datastreams specified as keys in the given hash and call update_attributes on the datastream" do
|
429
|
+
mock_desc_metadata = mock("descMetadata")
|
430
|
+
mock_properties = mock("properties")
|
431
|
+
mock_ds_hash = {'descMetadata'=>mock_desc_metadata, 'properties'=>mock_properties}
|
432
|
+
|
433
|
+
ds_values_hash = {
|
434
|
+
"descMetadata"=>{ [{:person=>0}, :role]=>{"0"=>"role1", "1"=>"role2", "2"=>"role3"} },
|
435
|
+
"properties"=>{ "notes"=>"foo" }
|
436
|
+
}
|
437
|
+
m = FooHistory.new
|
438
|
+
m.stubs(:datastreams_in_memory).returns(mock_ds_hash)
|
439
|
+
mock_desc_metadata.expects(:update_attributes).with( ds_values_hash['descMetadata'] )
|
440
|
+
mock_properties.expects(:update_attributes).with( ds_values_hash['properties'] )
|
441
|
+
m.update_datastream_attributes( ds_values_hash )
|
442
|
+
end
|
443
|
+
it "should not do anything and should return an empty hash if the specified datastream does not exist" do
|
444
|
+
ds_values_hash = {
|
445
|
+
"nonexistentDatastream"=>{ "notes"=>"foo" }
|
446
|
+
}
|
447
|
+
m = FooHistory.new
|
448
|
+
untouched_xml = m.to_xml
|
449
|
+
m.update_datastream_attributes( ds_values_hash ).should == {}
|
450
|
+
m.to_xml.should == untouched_xml
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
414
454
|
describe "update_attributes" do
|
415
|
-
|
416
|
-
|
417
|
-
m =
|
418
|
-
|
419
|
-
|
420
|
-
ds.expects(:
|
421
|
-
m.update_attributes(
|
455
|
+
|
456
|
+
it "should call .update_attributes on all metadata datastreams & nokogiri datastreams" do
|
457
|
+
m = FooHistory.new
|
458
|
+
att= {"fubar"=>{"-1"=>"mork", "0"=>"york", "1"=>"mangle"}}
|
459
|
+
|
460
|
+
m.metadata_streams.each {|ds| ds.expects(:update_attributes)}
|
461
|
+
m.update_attributes(att)
|
422
462
|
end
|
463
|
+
|
423
464
|
it "should be able to update attr on text fields" do
|
424
465
|
m = FooHistory.new
|
425
466
|
m.should_not be_nil
|
@@ -474,92 +515,16 @@ describe ActiveFedora::Base do
|
|
474
515
|
end
|
475
516
|
|
476
517
|
describe "update_indexed_attributes" do
|
477
|
-
it "should
|
478
|
-
|
479
|
-
n = FooHistory.new
|
480
|
-
result = n.update_indexed_attributes(att)
|
481
|
-
result.should == {"swank"=>{"1"=>"york", "0"=>"mork"}}
|
482
|
-
n.datastreams["someData"].swank_values.should == ['mork', 'york']
|
483
|
-
n.datastreams["someData"].swank_values.should == ['mork', 'york']
|
484
|
-
att= {"swank"=>{"-1"=>"dork"}}
|
485
|
-
result2 = n.update_indexed_attributes(att)
|
486
|
-
result2.should == {"swank"=>{"2"=>"dork"}}
|
487
|
-
n.datastreams["someData"].swank_values.should == ['mork', 'york', 'dork']
|
488
|
-
end
|
489
|
-
|
490
|
-
it "should return the new index of any added values" do
|
491
|
-
n = FooHistory.new
|
492
|
-
n.datastreams["someData"].swank_values = ["my_val1","my_val2"]
|
493
|
-
result = n.update_indexed_attributes "swank"=>{"-1"=>"mork"}
|
494
|
-
result.should == {"swank"=>{"2"=>"mork"}}
|
495
|
-
end
|
496
|
-
|
497
|
-
it "should return accurate response when multiple values have been added in a single run" do
|
498
|
-
pending
|
499
|
-
att= {"swank"=>{"-1"=>"mork", "0"=>"york"}}
|
500
|
-
n = FooHistory.new
|
501
|
-
n.update_indexed_attributes(att).should == {"swank"=>{"0"=>"york", "1"=>"mork"}}
|
502
|
-
end
|
503
|
-
|
504
|
-
it "should apply submitted hash to corresponding datastream values" do
|
505
|
-
att= {"fubar"=>{"-1"=>"mork", "0"=>"york"}}
|
506
|
-
n = FooHistory.new
|
507
|
-
n.update_indexed_attributes(att)
|
508
|
-
n.datastreams["someData"].fubar_values.should == ['mork', 'york']
|
509
|
-
n.datastreams["someData"].fubar_values.should == ['mork', 'york']
|
510
|
-
|
511
|
-
att= {"fubar"=>{"0"=>"zork", "1"=>"tork", "2"=>'mangle'}}
|
512
|
-
n.update_indexed_attributes(att)
|
513
|
-
n.datastreams["someData"].fubar_values.should == ['zork', 'tork', 'mangle']
|
514
|
-
|
515
|
-
att= {"fubar"=>{"0"=>"hork", "1"=>"tork", '-1'=>'dang'}}
|
516
|
-
result = n.update_indexed_attributes(att)
|
517
|
-
result.should == {"fubar"=>{"0"=>"hork", "1"=>"tork", '3'=>'dang'}}
|
518
|
-
n.datastreams["someData"].fubar_values.should == ['hork', 'tork', 'mangle', 'dang']
|
519
|
-
|
520
|
-
#really? should it hit all matching datastreams?
|
521
|
-
n.datastreams["withText"].fubar_values.should == ['hork', 'tork', 'mangle', 'dang']
|
522
|
-
end
|
523
|
-
|
524
|
-
it "should deal gracefully with adding new values at explicitly declared indexes" do
|
525
|
-
n = FooHistory.new
|
526
|
-
n.datastreams["someData"].fubar_values = ["all", "for", "the"]
|
527
|
-
att = {"fubar"=>{"3"=>'glory'}}
|
528
|
-
result = n.update_indexed_attributes(att)
|
529
|
-
result.should == {"fubar"=>{"3"=>"glory"}}
|
530
|
-
n.datastreams["someData"].fubar_values.should == ["all", "for", "the", "glory"]
|
531
|
-
|
532
|
-
n.datastreams["withText"].fubar_values.should == ["glory"]
|
533
|
-
end
|
534
|
-
|
535
|
-
it "should allow deleting of values and should delete values so that to_xml does not return emtpy nodes" do
|
518
|
+
it "should call .update_indexed_attributes on all metadata datastreams & nokogiri datastreams" do
|
519
|
+
m = FooHistory.new
|
536
520
|
att= {"fubar"=>{"-1"=>"mork", "0"=>"york", "1"=>"mangle"}}
|
537
|
-
n = FooHistory.new
|
538
|
-
n.update_indexed_attributes(att)
|
539
|
-
n.datastreams["someData"].fubar_values.should == ['mork', 'york', 'mangle']
|
540
|
-
rexml = REXML::Document.new(n.datastreams["someData"].to_xml)
|
541
|
-
#puts rexml.root.elements.each {|el| el.to_s}
|
542
|
-
#puts rexml.root.elements.to_a.inspect
|
543
|
-
rexml.root.elements.to_a.length.should == 3
|
544
|
-
n.update_indexed_attributes({"fubar"=>{"1"=>""}})
|
545
|
-
n.datastreams["someData"].fubar_values.should == ['mork', 'mangle']
|
546
|
-
rexml = REXML::Document.new(n.datastreams["someData"].to_xml)
|
547
|
-
rexml.root.elements.to_a.length.should == 2
|
548
|
-
n.update_indexed_attributes({"fubar"=>{"0"=>:delete}})
|
549
|
-
n.datastreams["someData"].fubar_values.should == ['mangle']
|
550
|
-
rexml = REXML::Document.new(n.datastreams["someData"].to_xml)
|
551
|
-
rexml.root.elements.to_a.length.should == 1
|
552
521
|
|
553
|
-
|
554
|
-
|
555
|
-
n.datastreams["someData"].fubar_values.should == ["val1", "val2"]
|
522
|
+
m.datastreams_in_memory.each_value {|ds| ds.expects(:update_indexed_attributes)}
|
523
|
+
m.update_indexed_attributes(att)
|
556
524
|
end
|
557
|
-
|
558
|
-
|
559
525
|
it "should take a :datastreams argument" do
|
560
526
|
att= {"fubar"=>{"-1"=>"mork", "0"=>"york", "1"=>"mangle"}}
|
561
527
|
m = FooHistory.new
|
562
|
-
|
563
528
|
m.update_indexed_attributes(att, :datastreams=>"withText")
|
564
529
|
m.should_not be_nil
|
565
530
|
m.datastreams['someData'].fubar_values.should == []
|