oai 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README +80 -0
- data/Rakefile +113 -0
- data/bin/oai +68 -0
- data/examples/models/file_model.rb +63 -0
- data/examples/providers/dublin_core.rb +474 -0
- data/lib/oai.rb +7 -13
- data/lib/oai/client.rb +133 -83
- data/lib/oai/{get_record.rb → client/get_record.rb} +0 -0
- data/lib/oai/{header.rb → client/header.rb} +2 -2
- data/lib/oai/{identify.rb → client/identify.rb} +0 -0
- data/lib/oai/{list_identifiers.rb → client/list_identifiers.rb} +0 -0
- data/lib/oai/{list_metadata_formats.rb → client/list_metadata_formats.rb} +0 -0
- data/lib/oai/{list_records.rb → client/list_records.rb} +0 -0
- data/lib/oai/{list_sets.rb → client/list_sets.rb} +1 -1
- data/lib/oai/{metadata_format.rb → client/metadata_format.rb} +0 -0
- data/lib/oai/{record.rb → client/record.rb} +0 -0
- data/lib/oai/{response.rb → client/response.rb} +1 -1
- data/lib/oai/constants.rb +34 -0
- data/lib/oai/exception.rb +72 -1
- data/lib/oai/harvester.rb +38 -0
- data/lib/oai/harvester/config.rb +41 -0
- data/lib/oai/harvester/harvest.rb +144 -0
- data/lib/oai/harvester/logging.rb +70 -0
- data/lib/oai/harvester/mailer.rb +17 -0
- data/lib/oai/harvester/shell.rb +334 -0
- data/lib/oai/provider.rb +300 -0
- data/lib/oai/provider/metadata_format.rb +72 -0
- data/lib/oai/provider/metadata_format/oai_dc.rb +29 -0
- data/lib/oai/provider/model.rb +71 -0
- data/lib/oai/provider/model/activerecord_caching_wrapper.rb +135 -0
- data/lib/oai/provider/model/activerecord_wrapper.rb +136 -0
- data/lib/oai/provider/partial_result.rb +18 -0
- data/lib/oai/provider/response.rb +119 -0
- data/lib/oai/provider/response/error.rb +16 -0
- data/lib/oai/provider/response/get_record.rb +32 -0
- data/lib/oai/provider/response/identify.rb +24 -0
- data/lib/oai/provider/response/list_identifiers.rb +29 -0
- data/lib/oai/provider/response/list_metadata_formats.rb +21 -0
- data/lib/oai/provider/response/list_records.rb +32 -0
- data/lib/oai/provider/response/list_sets.rb +23 -0
- data/lib/oai/provider/response/record_response.rb +68 -0
- data/lib/oai/provider/resumption_token.rb +106 -0
- data/lib/oai/set.rb +14 -5
- data/test/activerecord_provider/config/connection.rb +5 -0
- data/test/activerecord_provider/config/database.yml +6 -0
- data/test/activerecord_provider/database/ar_migration.rb +59 -0
- data/test/activerecord_provider/database/oaipmhtest +0 -0
- data/test/activerecord_provider/fixtures/dc.yml +1501 -0
- data/test/activerecord_provider/helpers/providers.rb +44 -0
- data/test/activerecord_provider/helpers/set_provider.rb +36 -0
- data/test/activerecord_provider/models/dc_field.rb +7 -0
- data/test/activerecord_provider/models/dc_set.rb +6 -0
- data/test/activerecord_provider/models/oai_token.rb +3 -0
- data/test/activerecord_provider/tc_ar_provider.rb +93 -0
- data/test/activerecord_provider/tc_ar_sets_provider.rb +66 -0
- data/test/activerecord_provider/tc_caching_paging_provider.rb +53 -0
- data/test/activerecord_provider/tc_simple_paging_provider.rb +55 -0
- data/test/activerecord_provider/test_helper.rb +4 -0
- data/test/client/helpers/provider.rb +68 -0
- data/test/client/helpers/test_wrapper.rb +11 -0
- data/test/client/tc_exception.rb +36 -0
- data/test/{tc_get_record.rb → client/tc_get_record.rb} +11 -7
- data/test/client/tc_identify.rb +13 -0
- data/test/{tc_libxml.rb → client/tc_libxml.rb} +20 -10
- data/test/{tc_list_identifiers.rb → client/tc_list_identifiers.rb} +10 -8
- data/test/{tc_list_metadata_formats.rb → client/tc_list_metadata_formats.rb} +4 -1
- data/test/{tc_list_records.rb → client/tc_list_records.rb} +4 -1
- data/test/{tc_list_sets.rb → client/tc_list_sets.rb} +4 -2
- data/test/{tc_xpath.rb → client/tc_xpath.rb} +1 -1
- data/test/client/test_helper.rb +5 -0
- data/test/provider/models.rb +230 -0
- data/test/provider/tc_exceptions.rb +63 -0
- data/test/provider/tc_functional_tokens.rb +42 -0
- data/test/provider/tc_provider.rb +69 -0
- data/test/provider/tc_resumption_tokens.rb +46 -0
- data/test/provider/tc_simple_provider.rb +85 -0
- data/test/provider/test_helper.rb +36 -0
- metadata +123 -27
- data/test/tc_exception.rb +0 -38
- data/test/tc_identify.rb +0 -8
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ExceptionTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_http_error
|
6
|
+
client = OAI::Client.new 'http://www.example.com'
|
7
|
+
assert_raises(OAI::Exception) { client.identify }
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_xml_error
|
11
|
+
client = OAI::Client.new 'http://www.yahoo.com'
|
12
|
+
begin
|
13
|
+
client.identify
|
14
|
+
rescue OAI::Exception => e
|
15
|
+
assert_match /response not well formed XML/, e.to_s, 'xml error'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_oai_error
|
20
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
21
|
+
assert_raises(OAI::Exception) do
|
22
|
+
client.list_identifiers :resumption_token => 'bogus'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# must pass in options as a hash
|
27
|
+
def test_parameter_error
|
28
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
29
|
+
assert_raises(OAI::ArgumentException) {client.get_record('foo')}
|
30
|
+
assert_raises(OAI::ArgumentException) {client.list_identifiers('foo')}
|
31
|
+
assert_raises(OAI::ArgumentException) {client.list_records('foo')}
|
32
|
+
assert_raises(OAI::ArgumentException) {client.list_metadata_formats('foo')}
|
33
|
+
assert_raises(OAI::ArgumentException) {client.list_sets('foo')}
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -1,22 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
1
3
|
class GetRecordTest < Test::Unit::TestCase
|
4
|
+
|
2
5
|
def test_get_one
|
3
|
-
client = OAI::Client.new 'http://
|
4
|
-
response = client.get_record :identifier => 'oai:
|
6
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
7
|
+
response = client.get_record :identifier => 'oai:test/3'
|
5
8
|
assert_kind_of OAI::GetRecordResponse, response
|
6
9
|
assert_kind_of OAI::Record, response.record
|
7
10
|
assert_kind_of REXML::Element, response.record.metadata
|
8
11
|
assert_kind_of OAI::Header, response.record.header
|
9
12
|
|
10
13
|
# minimal check that the header is working
|
11
|
-
assert_equal 'oai:
|
14
|
+
assert_equal 'oai:test/3',
|
12
15
|
response.record.header.identifier
|
13
16
|
|
14
17
|
# minimal check that the metadata is working
|
15
|
-
assert 'en', response.record.metadata.elements['.//dc:language'].text
|
18
|
+
#assert 'en', response.record.metadata.elements['.//dc:language'].text
|
16
19
|
end
|
17
20
|
|
18
21
|
def test_missing_identifier
|
19
|
-
client = OAI::Client.new 'http://
|
22
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
20
23
|
begin
|
21
24
|
client.get_record :metadata_prefix => 'oai_dc'
|
22
25
|
flunk 'invalid get_record did not throw OAI::Exception'
|
@@ -26,8 +29,9 @@ class GetRecordTest < Test::Unit::TestCase
|
|
26
29
|
end
|
27
30
|
|
28
31
|
def test_deleted_record
|
29
|
-
client = OAI::Client.new 'http://
|
30
|
-
record = client.get_record :identifier => 'oai:
|
32
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
33
|
+
record = client.get_record :identifier => 'oai:test/275'
|
31
34
|
assert record.deleted?
|
32
35
|
end
|
36
|
+
|
33
37
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class IdentifyTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_ok
|
6
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
7
|
+
response = client.identify
|
8
|
+
assert_kind_of OAI::IdentifyResponse, response
|
9
|
+
assert_equal 'Complex Provider [http://localhost]', response.to_s
|
10
|
+
#assert_equal 'PubMed Central (PMC3 - NLM DTD) [http://www.pubmedcentral.gov/oai/oai.cgi]', response.to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
1
3
|
class LibXMLTest < Test::Unit::TestCase
|
2
4
|
|
3
5
|
def test_oai_exception
|
4
6
|
return unless have_libxml
|
5
7
|
|
6
|
-
uri = 'http://
|
8
|
+
uri = 'http://localhost:3333/oai'
|
7
9
|
client = OAI::Client.new uri, :parser => 'libxml'
|
8
10
|
assert_raises(OAI::Exception) {client.get_record(:identifier => 'nosuchid')}
|
9
11
|
end
|
@@ -14,36 +16,44 @@ class LibXMLTest < Test::Unit::TestCase
|
|
14
16
|
# since there is regex magic going on to remove default oai namespaces
|
15
17
|
# it's worth trying a few different oai targets
|
16
18
|
oai_targets = %w{
|
17
|
-
http://
|
18
|
-
http://ir.library.oregonstate.edu/dspace-oai/request
|
19
|
-
http://libeprints.open.ac.uk/perl/oai2
|
20
|
-
http://memory.loc.gov/cgi-bin/oai2_0
|
19
|
+
http://localhost:3333/oai
|
21
20
|
}
|
22
21
|
|
22
|
+
#oai_targets = %w{
|
23
|
+
# http://etd.caltech.edu:80/ETD-db/OAI/oai
|
24
|
+
# http://ir.library.oregonstate.edu/dspace-oai/request
|
25
|
+
# http://memory.loc.gov/cgi-bin/oai2_0
|
26
|
+
# http://libeprints.open.ac.uk/perl/oai2
|
27
|
+
#}
|
28
|
+
|
29
|
+
|
23
30
|
oai_targets.each do |uri|
|
24
31
|
client = OAI::Client.new uri, :parser => 'libxml'
|
25
32
|
records = client.list_records
|
26
33
|
records.each do |record|
|
27
34
|
assert record.header.identifier
|
28
|
-
next
|
35
|
+
next if record.deleted?
|
29
36
|
assert_kind_of XML::Node, record.metadata
|
30
37
|
end
|
31
38
|
end
|
32
39
|
end
|
33
40
|
|
34
41
|
def test_deleted_record
|
35
|
-
|
42
|
+
return unless have_libxml
|
43
|
+
|
44
|
+
uri = 'http://localhost:3333/oai'
|
36
45
|
client = OAI::Client.new(uri, :parser => 'libxml')
|
37
|
-
|
46
|
+
response = client.get_record :identifier => 'oai:test/275'
|
47
|
+
assert response.record.deleted?
|
38
48
|
end
|
39
|
-
|
49
|
+
|
40
50
|
private
|
41
51
|
|
42
52
|
def have_libxml
|
43
53
|
begin
|
44
54
|
require 'xml/libxml'
|
45
55
|
return true
|
46
|
-
rescue
|
56
|
+
rescue LoadError
|
47
57
|
return false
|
48
58
|
end
|
49
59
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
1
3
|
class ListIdentifiersTest < Test::Unit::TestCase
|
2
4
|
|
3
5
|
def test_list_with_resumption_token
|
4
|
-
client = OAI::Client.new 'http://
|
6
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
5
7
|
|
6
8
|
# get a list of identifier headers
|
7
9
|
response = client.list_identifiers :metadata_prefix => 'oai_dc'
|
@@ -26,16 +28,16 @@ class ListIdentifiersTest < Test::Unit::TestCase
|
|
26
28
|
end
|
27
29
|
|
28
30
|
def test_list_with_date_range
|
29
|
-
client = OAI::Client.new 'http://
|
30
|
-
from_date = Date.new(
|
31
|
-
until_date = Date.new(
|
31
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
32
|
+
from_date = Date.new(1998,1,1)
|
33
|
+
until_date = Date.new(2002,1,1)
|
32
34
|
response = client.list_identifiers :from => from_date, :until => until_date
|
33
35
|
assert response.entries.size > 0
|
34
36
|
end
|
35
37
|
|
36
38
|
def test_list_with_datetime_range
|
37
39
|
# xtcat should support higher granularity
|
38
|
-
client = OAI::Client.new 'http://
|
40
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
39
41
|
from_date = DateTime.new(2001,1,1)
|
40
42
|
until_date = DateTime.now
|
41
43
|
response = client.list_identifiers :from => from_date, :until => until_date
|
@@ -43,8 +45,8 @@ class ListIdentifiersTest < Test::Unit::TestCase
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def test_invalid_argument
|
46
|
-
client = OAI::Client.new 'http://
|
47
|
-
assert_raise(OAI::
|
48
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
49
|
+
assert_raise(OAI::ArgumentException) {client.list_identifiers :foo => 'bar'}
|
48
50
|
end
|
49
|
-
|
51
|
+
|
50
52
|
end
|
@@ -1,6 +1,8 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
1
3
|
class ListMetadataFormatsTest < Test::Unit::TestCase
|
2
4
|
def test_list
|
3
|
-
client = OAI::Client.new 'http://
|
5
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
4
6
|
response = client.list_metadata_formats
|
5
7
|
assert_kind_of OAI::ListMetadataFormatsResponse, response
|
6
8
|
assert response.entries.size > 0
|
@@ -11,5 +13,6 @@ class ListMetadataFormatsTest < Test::Unit::TestCase
|
|
11
13
|
assert_equal 'http://www.openarchives.org/OAI/2.0/oai_dc.xsd', format.schema
|
12
14
|
assert_equal 'http://www.openarchives.org/OAI/2.0/oai_dc/', format.namespace
|
13
15
|
end
|
16
|
+
|
14
17
|
end
|
15
18
|
|
@@ -1,9 +1,12 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
1
3
|
class GetRecordsTest < Test::Unit::TestCase
|
2
4
|
def test_get_records
|
3
|
-
client = OAI::Client.new 'http://
|
5
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
4
6
|
response = client.list_records
|
5
7
|
assert_kind_of OAI::ListRecordsResponse, response
|
6
8
|
assert response.entries.size > 0
|
7
9
|
assert_kind_of OAI::Record, response.entries[0]
|
8
10
|
end
|
11
|
+
|
9
12
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
1
3
|
class ListSetsTest < Test::Unit::TestCase
|
2
4
|
|
3
5
|
def test_list
|
4
|
-
client = OAI::Client.new 'http://
|
6
|
+
client = OAI::Client.new 'http://localhost:3333/oai'
|
5
7
|
response = client.list_sets
|
6
8
|
assert_kind_of OAI::ListSetsResponse, response
|
7
9
|
assert response.entries.size > 0
|
@@ -12,6 +14,6 @@ class ListSetsTest < Test::Unit::TestCase
|
|
12
14
|
assert_kind_of OAI::Set, set
|
13
15
|
end
|
14
16
|
end
|
15
|
-
|
17
|
+
|
16
18
|
end
|
17
19
|
|
@@ -0,0 +1,230 @@
|
|
1
|
+
class Record
|
2
|
+
attr_accessor :id, :titles, :creator, :tags, :sets, :updated_at, :deleted
|
3
|
+
|
4
|
+
def initialize(id,
|
5
|
+
titles = 'title',
|
6
|
+
creator = 'creator',
|
7
|
+
tags = 'tag',
|
8
|
+
sets = nil,
|
9
|
+
deleted = false,
|
10
|
+
updated_at = Time.new.utc)
|
11
|
+
|
12
|
+
@id = id;
|
13
|
+
@titles = titles
|
14
|
+
@creator = creator
|
15
|
+
@tags = tags
|
16
|
+
@sets = sets
|
17
|
+
@deleted = deleted
|
18
|
+
@updated_at = updated_at
|
19
|
+
end
|
20
|
+
|
21
|
+
# Override Object.id
|
22
|
+
def id
|
23
|
+
@id
|
24
|
+
end
|
25
|
+
|
26
|
+
def in_set(spec)
|
27
|
+
if @sets.respond_to?(:each)
|
28
|
+
@sets.each { |set| return true if set.spec == spec }
|
29
|
+
else
|
30
|
+
return true if @sets.spec == spec
|
31
|
+
end
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
class TestModel < OAI::Provider::Model
|
38
|
+
include OAI::Provider
|
39
|
+
|
40
|
+
def initialize(limit = nil)
|
41
|
+
super(limit)
|
42
|
+
@records = []
|
43
|
+
@sets = []
|
44
|
+
@earliest = Time.now
|
45
|
+
end
|
46
|
+
|
47
|
+
def earliest
|
48
|
+
(@records.min {|a,b| a.updated_at <=> b.updated_at }).updated_at
|
49
|
+
end
|
50
|
+
|
51
|
+
def latest
|
52
|
+
@records.max {|a,b| a.updated_at <=> b.updated_at }.updated_at
|
53
|
+
end
|
54
|
+
|
55
|
+
def sets
|
56
|
+
@sets
|
57
|
+
end
|
58
|
+
|
59
|
+
def find(selector, opts={})
|
60
|
+
return nil unless selector
|
61
|
+
|
62
|
+
case selector
|
63
|
+
when :all
|
64
|
+
if opts[:resumption_token]
|
65
|
+
raise OAI::ResumptionTokenException.new unless @limit
|
66
|
+
begin
|
67
|
+
token = ResumptionToken.parse(opts[:resumption_token])
|
68
|
+
|
69
|
+
if token.last < @groups.size - 1
|
70
|
+
PartialResult.new(@groups[token.last], token.next(token.last + 1))
|
71
|
+
else
|
72
|
+
@groups[token.last]
|
73
|
+
end
|
74
|
+
rescue
|
75
|
+
raise OAI::ResumptionTokenException.new
|
76
|
+
end
|
77
|
+
else
|
78
|
+
records = @records.select do |rec|
|
79
|
+
((opts[:set].nil? || rec.in_set(opts[:set])) &&
|
80
|
+
(opts[:from].nil? || rec.updated_at >= opts[:from]) &&
|
81
|
+
(opts[:until].nil? || rec.updated_at <= opts[:until]))
|
82
|
+
end
|
83
|
+
|
84
|
+
if @limit && records.size > @limit
|
85
|
+
@groups = generate_chunks(records, @limit)
|
86
|
+
return PartialResult.new(@groups[0],
|
87
|
+
ResumptionToken.new(opts.merge({:last => 1})))
|
88
|
+
end
|
89
|
+
return records
|
90
|
+
end
|
91
|
+
else
|
92
|
+
begin
|
93
|
+
@records.each do |record|
|
94
|
+
return record if record.id.to_s == selector
|
95
|
+
end
|
96
|
+
rescue
|
97
|
+
end
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def generate_chunks(records, limit)
|
103
|
+
groups = []
|
104
|
+
records.each_slice(limit) do |group|
|
105
|
+
groups << group
|
106
|
+
end
|
107
|
+
groups
|
108
|
+
end
|
109
|
+
|
110
|
+
def generate_records(number, timestamp = Time.now, sets = [], deleted = false)
|
111
|
+
@earliest = timestamp.dup if @earliest.nil? || timestamp < @earliest
|
112
|
+
|
113
|
+
# Add any sets we don't already have
|
114
|
+
sets = [sets] unless sets.respond_to?(:each)
|
115
|
+
sets.each do |set|
|
116
|
+
@sets << set unless @sets.include?(set)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Generate some records
|
120
|
+
number.times do |id|
|
121
|
+
rec = Record.new(@records.size, "title_#{id}", "creator_#{id}", "tag_#{id}")
|
122
|
+
rec.updated_at = timestamp.utc
|
123
|
+
rec.sets = sets
|
124
|
+
rec.deleted = deleted
|
125
|
+
@records << rec
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
class SimpleModel < TestModel
|
132
|
+
|
133
|
+
def initialize
|
134
|
+
super
|
135
|
+
# Create a couple of sets
|
136
|
+
set_one = OAI::Set.new()
|
137
|
+
set_one.name = "Test Set One"
|
138
|
+
set_one.spec = "A"
|
139
|
+
set_one.description = "This is test set one."
|
140
|
+
|
141
|
+
set_two = OAI::Set.new()
|
142
|
+
set_two.name = "Test Set Two"
|
143
|
+
set_two.spec = "A:B"
|
144
|
+
set_two.description = "This is test set two."
|
145
|
+
|
146
|
+
generate_records(5, Chronic.parse("oct 5 2002"), set_one)
|
147
|
+
generate_records(1, Chronic.parse("nov 5 2002"), [set_two], true)
|
148
|
+
generate_records(4, Chronic.parse("nov 5 2002"), [set_two])
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
class BigModel < TestModel
|
154
|
+
|
155
|
+
def initialize(limit = nil)
|
156
|
+
super(limit)
|
157
|
+
generate_records(100, Chronic.parse("October 2 2000"))
|
158
|
+
generate_records(100, Chronic.parse("November 2 2000"))
|
159
|
+
generate_records(100, Chronic.parse("December 2 2000"))
|
160
|
+
generate_records(100, Chronic.parse("January 2 2001"))
|
161
|
+
generate_records(100, Chronic.parse("February 2 2001"))
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
class MappedModel < TestModel
|
167
|
+
|
168
|
+
def initialize
|
169
|
+
super
|
170
|
+
set_one = OAI::Set.new()
|
171
|
+
set_one.name = "Test Set One"
|
172
|
+
set_one.spec = "A"
|
173
|
+
set_one.description = "This is test set one."
|
174
|
+
|
175
|
+
generate_records(5, Chronic.parse("dec 1 2006"), set_one)
|
176
|
+
end
|
177
|
+
|
178
|
+
def map_oai_dc
|
179
|
+
{:title => :creator, :creator => :titles, :subject => :tags}
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
class ComplexModel < TestModel
|
185
|
+
|
186
|
+
def initialize(limit = nil)
|
187
|
+
super(limit)
|
188
|
+
# Create a couple of sets
|
189
|
+
set_one = OAI::Set.new
|
190
|
+
set_one.name = "Set One"
|
191
|
+
set_one.spec = "One"
|
192
|
+
set_one.description = "This is test set one."
|
193
|
+
|
194
|
+
set_two = OAI::Set.new
|
195
|
+
set_two.name = "Set Two"
|
196
|
+
set_two.spec = "Two"
|
197
|
+
set_two.description = "This is test set two."
|
198
|
+
|
199
|
+
set_three = OAI::Set.new
|
200
|
+
set_three.name = "Set Three"
|
201
|
+
set_three.spec = "Three"
|
202
|
+
set_three.description = "This is test set three."
|
203
|
+
|
204
|
+
set_four = OAI::Set.new
|
205
|
+
set_four.name = "Set Four"
|
206
|
+
set_four.spec = "Four"
|
207
|
+
set_four.description = "This is test set four."
|
208
|
+
|
209
|
+
set_one_two = OAI::Set.new
|
210
|
+
set_one_two.name = "Set One and Two"
|
211
|
+
set_one_two.spec = "One:Two"
|
212
|
+
set_one_two.description = "This is combination set of One and Two."
|
213
|
+
|
214
|
+
set_three_four = OAI::Set.new
|
215
|
+
set_three_four.name = "Set Three and Four"
|
216
|
+
set_three_four.spec = "Three:Four"
|
217
|
+
set_three_four.description = "This is combination set of Three and Four."
|
218
|
+
|
219
|
+
generate_records(250, Chronic.parse("May 2 1998"), [set_one, set_one_two])
|
220
|
+
generate_records(50, Chronic.parse("June 2 1998"), [set_one, set_one_two], true)
|
221
|
+
generate_records(50, Chronic.parse("October 10 1998"), [set_three, set_three_four], true)
|
222
|
+
generate_records(250, Chronic.parse("July 2 2002"), [set_two, set_one_two])
|
223
|
+
|
224
|
+
generate_records(250, Chronic.parse("September 15 2004"), [set_three, set_three_four])
|
225
|
+
generate_records(50, Chronic.parse("October 10 2004"), [set_three, set_three_four], true)
|
226
|
+
generate_records(250, Chronic.parse("December 25 2005"), [set_four, set_three_four])
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|