active-fedora 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/VERSION +1 -1
- data/active-fedora.gemspec +5 -7
- data/lib/active_fedora/base.rb +7 -1
- data/lib/active_fedora/model.rb +2 -2
- data/lib/active_fedora/rels_ext_datastream.rb +3 -1
- data/lib/active_fedora/solr_mapper.rb +5 -1
- data/lib/active_fedora/solr_service.rb +3 -1
- data/spec/fixtures/test_12.foxml.xml +1 -62
- data/spec/{unit → integration}/base_loader_spec.rb +18 -3
- data/spec/integration/base_spec.rb +4 -0
- data/spec/unit/base_extra_spec.rb +1 -1
- metadata +5 -7
- data/spec/active_fedora_spec.rb +0 -7
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
1.1.1 2010-03-22
|
2
|
+
|
3
|
+
Bug: .load_objects wipes out datastream attributes from model-defined datastreams (ie. label and mimeType)
|
4
|
+
|
5
|
+
1.1.0 2010-03-20
|
6
|
+
|
7
|
+
Feature #822: Export & Ingest Fedora Objects
|
8
|
+
|
1
9
|
1.0.9 2010-03-10
|
2
10
|
|
3
11
|
!! Requires a new Solr schema by default. We recommend updating solr with the schema.xml located at http://bitbucket.org/mediashelf/active_fedora/src/tip/solr/config/schema.xml. If you want to keep using the old schema.xml, you must save the solr mappings file from http://bitbucket.org/mediashelf/active_fedora/src/tip/config/solr_mappings_af_0.1.yml as config/solr_mappings.yml in your application(s).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
data/active-fedora.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{active-fedora}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Zumwalt", "McClain Looney"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-22}
|
13
13
|
s.description = %q{ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.}
|
14
14
|
s.email = %q{matt.zumwalt@yourmediashelf.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -214,12 +214,12 @@ Gem::Specification.new do |s|
|
|
214
214
|
"solr/config/schema-1.5.xml",
|
215
215
|
"solr/config/schema.xml",
|
216
216
|
"solr/config/solrconfig-1.5.xml",
|
217
|
-
"spec/active_fedora_spec.rb",
|
218
217
|
"spec/fixtures/changeme155.xml",
|
219
218
|
"spec/fixtures/dino.jpg",
|
220
219
|
"spec/fixtures/minivan.jpg",
|
221
220
|
"spec/fixtures/test_12.foxml.xml",
|
222
221
|
"spec/integration/base_file_management_spec.rb",
|
222
|
+
"spec/integration/base_loader_spec.rb",
|
223
223
|
"spec/integration/base_spec.rb",
|
224
224
|
"spec/integration/bug_spec.rb",
|
225
225
|
"spec/integration/datastream_spec.rb",
|
@@ -248,7 +248,6 @@ Gem::Specification.new do |s|
|
|
248
248
|
"spec/unit/base_datastream_management_spec.rb",
|
249
249
|
"spec/unit/base_extra_spec.rb",
|
250
250
|
"spec/unit/base_file_management_spec.rb",
|
251
|
-
"spec/unit/base_loader_spec.rb",
|
252
251
|
"spec/unit/base_spec.rb",
|
253
252
|
"spec/unit/connection_spec.rb",
|
254
253
|
"spec/unit/content_model_spec.rb",
|
@@ -277,8 +276,8 @@ Gem::Specification.new do |s|
|
|
277
276
|
s.rubygems_version = %q{1.3.6}
|
278
277
|
s.summary = %q{A convenience libary for manipulating MODS (Metadata Object Description Schema) documents.}
|
279
278
|
s.test_files = [
|
280
|
-
"spec/
|
281
|
-
"spec/integration/
|
279
|
+
"spec/integration/base_file_management_spec.rb",
|
280
|
+
"spec/integration/base_loader_spec.rb",
|
282
281
|
"spec/integration/base_spec.rb",
|
283
282
|
"spec/integration/bug_spec.rb",
|
284
283
|
"spec/integration/datastream_spec.rb",
|
@@ -303,7 +302,6 @@ Gem::Specification.new do |s|
|
|
303
302
|
"spec/unit/base_datastream_management_spec.rb",
|
304
303
|
"spec/unit/base_extra_spec.rb",
|
305
304
|
"spec/unit/base_file_management_spec.rb",
|
306
|
-
"spec/unit/base_loader_spec.rb",
|
307
305
|
"spec/unit/base_spec.rb",
|
308
306
|
"spec/unit/connection_spec.rb",
|
309
307
|
"spec/unit/content_model_spec.rb",
|
data/lib/active_fedora/base.rb
CHANGED
@@ -335,7 +335,7 @@ module ActiveFedora
|
|
335
335
|
doc.elements.each("//foxml:datastream[@ID='#{name}']") do |el|
|
336
336
|
# datastreams remain marked as new if the foxml doesn't have an entry for that datastream
|
337
337
|
ds.new_object = false
|
338
|
-
proto.datastreams[name]=ds.class.from_xml(ds, el)
|
338
|
+
proto.datastreams[name]=ds.class.from_xml(ds, el)
|
339
339
|
end
|
340
340
|
end
|
341
341
|
proto.inner_object.new_object = false
|
@@ -492,8 +492,14 @@ module ActiveFedora
|
|
492
492
|
def configure_defined_datastreams
|
493
493
|
if self.class.ds_specs
|
494
494
|
self.class.ds_specs.each do |name,ar|
|
495
|
+
if self.datastreams.has_key?(name)
|
496
|
+
attributes = self.datastreams[name].attributes
|
497
|
+
else
|
498
|
+
attributes = {:label=>""}
|
499
|
+
end
|
495
500
|
ds = ar.first.new(:dsid=>name)
|
496
501
|
ar.last.call(ds)
|
502
|
+
ds.attributes = attributes.merge(ds.attributes)
|
497
503
|
self.add_datastream(ds)
|
498
504
|
end
|
499
505
|
end
|
data/lib/active_fedora/model.rb
CHANGED
@@ -56,7 +56,7 @@ module ActiveFedora
|
|
56
56
|
def find(args)
|
57
57
|
if args == :all
|
58
58
|
escaped_class_name = self.name.gsub(/(:)/, '\\:')
|
59
|
-
q = "
|
59
|
+
q = "#{solr_name(:active_fedora_model, :symbol)}:#{escaped_class_name}"
|
60
60
|
elsif args.class == String
|
61
61
|
escaped_id = args.gsub(/(:)/, '\\:')
|
62
62
|
q = "#{SOLR_DOCUMENT_ID}:#{escaped_id}"
|
@@ -89,7 +89,7 @@ module ActiveFedora
|
|
89
89
|
def find_by_solr(query, args={})
|
90
90
|
if query == :all
|
91
91
|
escaped_class_name = self.name.gsub(/(:)/, '\\:')
|
92
|
-
SolrService.instance.conn.query("
|
92
|
+
SolrService.instance.conn.query("#{solr_name(:active_fedora_model, :symbol)}:#{escaped_class_name}", args)
|
93
93
|
elsif query.class == String
|
94
94
|
escaped_id = query.gsub(/(:)/, '\\:')
|
95
95
|
SolrService.instance.conn.query("#{SOLR_DOCUMENT_ID}:#{escaped_id}", args)
|
@@ -3,6 +3,8 @@ module ActiveFedora
|
|
3
3
|
class RelsExtDatastream < Datastream
|
4
4
|
|
5
5
|
include ActiveFedora::SemanticNode
|
6
|
+
include ActiveFedora::SolrMapper
|
7
|
+
|
6
8
|
|
7
9
|
def initialize(attrs=nil)
|
8
10
|
super
|
@@ -43,7 +45,7 @@ module ActiveFedora
|
|
43
45
|
if subject == :self || subject == "info:fedora/#{self.pid}"
|
44
46
|
predicates.each_pair do |predicate, values|
|
45
47
|
values.each do |val|
|
46
|
-
solr_doc << Solr::Field.new(
|
48
|
+
solr_doc << Solr::Field.new(solr_name(predicate, :symbol) => val)
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
@@ -4,7 +4,7 @@ module ActiveFedora
|
|
4
4
|
module SolrMapper
|
5
5
|
|
6
6
|
# Generates solr field names from settings in solr_mappings
|
7
|
-
def solr_name(field_name, field_type)
|
7
|
+
def self.solr_name(field_name, field_type)
|
8
8
|
name = field_name.to_s + ActiveFedora::SolrService.mappings[field_type.to_s].to_s
|
9
9
|
if field_name.kind_of?(Symbol)
|
10
10
|
return name.to_sym
|
@@ -13,5 +13,9 @@ module ActiveFedora
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
def solr_name(field_name, field_type)
|
17
|
+
ActiveFedora::SolrMapper.solr_name(field_name, field_type)
|
18
|
+
end
|
19
|
+
|
16
20
|
end
|
17
21
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'solr'
|
2
|
+
require "active_fedora/solr_mapper"
|
2
3
|
module ActiveFedora
|
3
4
|
class SolrService
|
5
|
+
|
4
6
|
@@mappings = {}
|
5
7
|
attr_reader :conn
|
6
8
|
|
@@ -25,7 +27,7 @@ module ActiveFedora
|
|
25
27
|
end
|
26
28
|
results = []
|
27
29
|
solr_result.hits.each do |hit|
|
28
|
-
model_value = hit["
|
30
|
+
model_value = hit[ActiveFedora::SolrMapper.solr_name("active_fedora_model", :symbol)].first
|
29
31
|
if model_value.include?("::")
|
30
32
|
classname = eval(model_value)
|
31
33
|
else
|
@@ -57,65 +57,4 @@ xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/
|
|
57
57
|
</foxml:xmlContent>
|
58
58
|
</foxml:datastreamVersion>
|
59
59
|
</foxml:datastream>
|
60
|
-
</foxml:digitalObject>
|
61
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
62
|
-
<foxml:digitalObject VERSION="1.1" PID="demo:12"
|
63
|
-
xmlns:foxml="info:fedora/fedora-system:def/foxml#"
|
64
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
65
|
-
xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
|
66
|
-
<foxml:objectProperties>
|
67
|
-
<foxml:property NAME="info:fedora/fedora-system:def/model#state" VALUE="Active"/>
|
68
|
-
<foxml:property NAME="info:fedora/fedora-system:def/model#label" VALUE="Service Definition Object for Document Transform Demo"/>
|
69
|
-
<foxml:property NAME="info:fedora/fedora-system:def/model#ownerId" VALUE="fedoraAdmin"/>
|
70
|
-
<foxml:property NAME="info:fedora/fedora-system:def/model#createdDate" VALUE="2008-07-02T05:09:42.015Z"/>
|
71
|
-
<foxml:property NAME="info:fedora/fedora-system:def/view#lastModifiedDate" VALUE="2009-07-07T23:37:13.950Z"/>
|
72
|
-
</foxml:objectProperties>
|
73
|
-
<foxml:datastream ID="AUDIT" STATE="A" CONTROL_GROUP="X" VERSIONABLE="false">
|
74
|
-
<foxml:datastreamVersion ID="AUDIT.0" LABEL="Audit Trail for this object" CREATED="2008-07-02T05:09:42.015Z" MIMETYPE="text/xml" FORMAT_URI="info:fedora/fedora-system:format/xml.fedora.audit">
|
75
|
-
<foxml:xmlContent>
|
76
|
-
<audit:auditTrail xmlns:audit="info:fedora/fedora-system:def/audit#">
|
77
|
-
<audit:record ID="AUDREC1">
|
78
|
-
<audit:process type="Fedora API-M"/>
|
79
|
-
<audit:action>ingest</audit:action>
|
80
|
-
<audit:componentID></audit:componentID>
|
81
|
-
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
82
|
-
<audit:date>2009-07-07T23:37:13.950Z</audit:date>
|
83
|
-
<audit:justification>Ingested from local file /Volumes/fedora-solr-testing/fedora/client/demo/foxml/local-server-demos/document-transform-demo/sdef_demo_12.xml</audit:justification>
|
84
|
-
</audit:record>
|
85
|
-
</audit:auditTrail>
|
86
|
-
</foxml:xmlContent>
|
87
|
-
</foxml:datastreamVersion>
|
88
|
-
</foxml:datastream>
|
89
|
-
<foxml:datastream ID="DC" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
90
|
-
<foxml:datastreamVersion ID="DC1.0" LABEL="Dublin Core Record for this object" CREATED="2008-07-02T05:09:42.515Z" MIMETYPE="text/xml" FORMAT_URI="http://www.openarchives.org/OAI/2.0/oai_dc/" SIZE="413">
|
91
|
-
<foxml:xmlContent>
|
92
|
-
<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">
|
93
|
-
<dc:title>Service Definition Object for Document Transform Demo</dc:title>
|
94
|
-
<dc:identifier>demo:12</dc:identifier>
|
95
|
-
</oai_dc:dc>
|
96
|
-
</foxml:xmlContent>
|
97
|
-
</foxml:datastreamVersion>
|
98
|
-
</foxml:datastream>
|
99
|
-
<foxml:datastream ID="RELS-EXT" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
100
|
-
<foxml:datastreamVersion ID="RELS-EXT1.0" LABEL="RDF Statements about this object" CREATED="2008-07-02T05:09:42.578Z" MIMETYPE="application/rdf+xml" FORMAT_URI="info:fedora/fedora-system:FedoraRELSExt-1.0" SIZE="356">
|
101
|
-
<foxml:xmlContent>
|
102
|
-
<rdf:RDF xmlns:fedora-model="info:fedora/fedora-system:def/model#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
103
|
-
<rdf:Description rdf:about="info:fedora/demo:12">
|
104
|
-
<fedora-model:hasModel rdf:resource="info:fedora/fedora-system:ServiceDefinition-3.0"></fedora-model:hasModel>
|
105
|
-
</rdf:Description>
|
106
|
-
</rdf:RDF>
|
107
|
-
</foxml:xmlContent>
|
108
|
-
</foxml:datastreamVersion>
|
109
|
-
</foxml:datastream>
|
110
|
-
<foxml:datastream ID="METHODMAP" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
111
|
-
<foxml:datastreamVersion ID="METHODMAP1.0" LABEL="Abstract Method Map" CREATED="2008-07-02T05:09:42.515Z" MIMETYPE="text/xml" FORMAT_URI="info:fedora/fedora-system:FedoraSDefMethodMap-1.0" SIZE="293">
|
112
|
-
<foxml:xmlContent>
|
113
|
-
<fmm:MethodMap xmlns:fmm="http://fedora.comm.nsdlib.org/service/methodmap" name="Fedora MethodMap for NSDL Exhibit (Style 1)">
|
114
|
-
<fmm:Method operationName="getDocumentStyle1"></fmm:Method>
|
115
|
-
<fmm:Method operationName="getDocumentStyle2"></fmm:Method>
|
116
|
-
</fmm:MethodMap>
|
117
|
-
</foxml:xmlContent>
|
118
|
-
</foxml:datastreamVersion>
|
119
|
-
</foxml:datastream>
|
120
|
-
</foxml:digitalObject>
|
121
|
-
foo
|
60
|
+
</foxml:digitalObject>
|
@@ -10,9 +10,9 @@ require File.join( File.dirname(__FILE__), "..","samples","oral_history_sample_m
|
|
10
10
|
|
11
11
|
describe ActiveFedora::Base do
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
before(:all) do
|
14
|
+
ActiveFedora::SolrService.register(ActiveFedora.solr_config[:url])
|
15
|
+
end
|
16
16
|
|
17
17
|
before(:each) do
|
18
18
|
@test_object = OralHistorySampleModel.new
|
@@ -39,5 +39,20 @@ describe ActiveFedora::Base do
|
|
39
39
|
result.datastreams_in_memory["sensitive_passages"].new_object?.should be_true
|
40
40
|
end
|
41
41
|
end
|
42
|
+
describe "load_instance" do
|
43
|
+
it "should retain all datastream attributes pulled from fedora" do
|
44
|
+
# raw_object = Fedora::Repository.instance.find_objects("pid=#{@test_object.pid}").first
|
45
|
+
raw_object = ActiveFedora::Base.new(:pid=>@test_object.pid, :new_object=>false)
|
46
|
+
loaded = OralHistorySampleModel.load_instance(@test_object.pid)
|
47
|
+
raw_datastreams = raw_object.datastreams
|
48
|
+
loaded_datastreams = loaded.datastreams
|
49
|
+
raw_datastreams.each_pair do |k,v|
|
50
|
+
v.attributes.each_pair do |attr_name, attr_value|
|
51
|
+
loaded_datastreams[k].attributes.should have_key(attr_name)
|
52
|
+
loaded_datastreams[k].attributes[attr_name].should == attr_value
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
42
57
|
|
43
58
|
end
|
@@ -2,6 +2,10 @@ require File.join( File.dirname(__FILE__), "../spec_helper" )
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
4
|
|
5
|
+
before(:all) do
|
6
|
+
ActiveFedora::SolrService.register(ActiveFedora.solr_config[:url])
|
7
|
+
end
|
8
|
+
|
5
9
|
before(:each) do
|
6
10
|
@test_object = ActiveFedora::Base.new
|
7
11
|
@test_object.save
|
@@ -90,7 +90,7 @@ describe ActiveFedora::Base do
|
|
90
90
|
it "should delete object from repository and index" do
|
91
91
|
@test_object.expects(:pid).returns("foo")
|
92
92
|
ActiveFedora::SolrService.instance.conn.expects(:delete).with("foo")
|
93
|
-
Fedora::Repository.
|
93
|
+
Fedora::Repository.instance.stubs(:delete).with(@test_object.inner_object)
|
94
94
|
@test_object.delete
|
95
95
|
end
|
96
96
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 1
|
9
|
+
version: 1.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Matt Zumwalt
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-03-
|
18
|
+
date: 2010-03-22 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -318,12 +318,12 @@ files:
|
|
318
318
|
- solr/config/schema-1.5.xml
|
319
319
|
- solr/config/schema.xml
|
320
320
|
- solr/config/solrconfig-1.5.xml
|
321
|
-
- spec/active_fedora_spec.rb
|
322
321
|
- spec/fixtures/changeme155.xml
|
323
322
|
- spec/fixtures/dino.jpg
|
324
323
|
- spec/fixtures/minivan.jpg
|
325
324
|
- spec/fixtures/test_12.foxml.xml
|
326
325
|
- spec/integration/base_file_management_spec.rb
|
326
|
+
- spec/integration/base_loader_spec.rb
|
327
327
|
- spec/integration/base_spec.rb
|
328
328
|
- spec/integration/bug_spec.rb
|
329
329
|
- spec/integration/datastream_spec.rb
|
@@ -352,7 +352,6 @@ files:
|
|
352
352
|
- spec/unit/base_datastream_management_spec.rb
|
353
353
|
- spec/unit/base_extra_spec.rb
|
354
354
|
- spec/unit/base_file_management_spec.rb
|
355
|
-
- spec/unit/base_loader_spec.rb
|
356
355
|
- spec/unit/base_spec.rb
|
357
356
|
- spec/unit/connection_spec.rb
|
358
357
|
- spec/unit/content_model_spec.rb
|
@@ -405,8 +404,8 @@ signing_key:
|
|
405
404
|
specification_version: 3
|
406
405
|
summary: A convenience libary for manipulating MODS (Metadata Object Description Schema) documents.
|
407
406
|
test_files:
|
408
|
-
- spec/active_fedora_spec.rb
|
409
407
|
- spec/integration/base_file_management_spec.rb
|
408
|
+
- spec/integration/base_loader_spec.rb
|
410
409
|
- spec/integration/base_spec.rb
|
411
410
|
- spec/integration/bug_spec.rb
|
412
411
|
- spec/integration/datastream_spec.rb
|
@@ -431,7 +430,6 @@ test_files:
|
|
431
430
|
- spec/unit/base_datastream_management_spec.rb
|
432
431
|
- spec/unit/base_extra_spec.rb
|
433
432
|
- spec/unit/base_file_management_spec.rb
|
434
|
-
- spec/unit/base_loader_spec.rb
|
435
433
|
- spec/unit/base_spec.rb
|
436
434
|
- spec/unit/connection_spec.rb
|
437
435
|
- spec/unit/content_model_spec.rb
|