enju_nii 0.2.0.beta.2 → 0.2.0.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/enju_nii/cinii_book.rb +47 -45
- data/lib/enju_nii/version.rb +1 -1
- data/spec/cassette_library/CiniiBook/should_import_a_bibliographic_record.yml +345 -346
- data/spec/controllers/cinii_books_controller_spec.rb +1 -1
- data/spec/controllers/nii_types_controller_spec.rb +2 -2
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/db/migrate/149_create_message_templates.rb +18 -0
- data/spec/dummy/db/migrate/154_create_messages.rb +23 -0
- data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +18 -0
- data/spec/dummy/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +11 -0
- data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +6 -0
- data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20160703185015_add_most_recent_to_message_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20160813203039_add_user_id_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20160814165332_add_most_recent_to_message_request_transitions.rb +9 -0
- data/spec/dummy/db/schema.rb +78 -5
- data/spec/fixtures/library_groups.yml +1 -1
- data/spec/models/cinii_book_spec.rb +3 -1
- data/spec/rails_helper.rb +49 -0
- data/spec/spec_helper.rb +84 -41
- metadata +216 -192
- data/spec/dummy/config/initializers/enju_leaf.rb +0 -2
- data/spec/dummy/db/migrate/20160813130535_add_email_to_library_group.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbdbc98847c6bfb68f4cb0e54122bc7ba806ddab
|
4
|
+
data.tar.gz: ae43df156ae97e4a0a4ff0aa0711d938cda28046
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f80270cdfd6d10e55333716f7acb3c0723aff1386d4fa9b62109e505a9021c031c363dd05d8f74173e5848780abe5f9407557785e507626597af7dc887be37db
|
7
|
+
data.tar.gz: f884ceee8a6dff616f7ddffed77e14fe731cef7eb13cb188c544f25e6933f5f640adcd28b439e1ec588df95278b3bce56784fdf743b17a7576cdd302f6dfd70a
|
data/lib/enju_nii/cinii_book.rb
CHANGED
@@ -8,8 +8,8 @@ module EnjuNii
|
|
8
8
|
module ClassMethods
|
9
9
|
def import_from_cinii_books(options)
|
10
10
|
#if options[:isbn]
|
11
|
-
|
12
|
-
|
11
|
+
lisbn = Lisbn.new(options[:isbn])
|
12
|
+
raise EnjuNii::InvalidIsbn unless lisbn.valid?
|
13
13
|
#end
|
14
14
|
|
15
15
|
manifestation = Manifestation.find_by_isbn(lisbn.isbn)
|
@@ -51,6 +51,8 @@ module EnjuNii
|
|
51
51
|
manifestation.pub_date = pub_date
|
52
52
|
|
53
53
|
manifestation.statement_of_responsibility = doc.at('//dc:creator').try(:content)
|
54
|
+
manifestation.extent = doc.at('//dcterms:extent').try(:content)
|
55
|
+
manifestation.dimensions = doc.at('//cinii:size').try(:content)
|
54
56
|
|
55
57
|
language = Language.where(:iso_639_3 => get_cinii_language(doc)).first
|
56
58
|
if language
|
@@ -68,21 +70,21 @@ module EnjuNii
|
|
68
70
|
end
|
69
71
|
|
70
72
|
identifier = {}
|
71
|
-
|
72
|
-
|
73
|
+
if ncid
|
74
|
+
identifier[:ncid] = Identifier.new(body: ncid)
|
73
75
|
identifier_type_ncid = IdentifierType.where(name: 'ncid').first
|
74
76
|
identifier_type_ncid = IdentifierType.where(name: 'ncid').create! unless identifier_type_ncid
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
identifier[:ncid].identifier_type = identifier_type_ncid
|
78
|
+
end
|
79
|
+
if isbn
|
80
|
+
identifier[:isbn] = Identifier.new(body: isbn)
|
79
81
|
identifier_type_isbn = IdentifierType.where(name: 'isbn').first
|
80
82
|
identifier_type_isbn = IdentifierType.where(name: 'isbn').create! unless identifier_type_isbn
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
identifier[:isbn].identifier_type = identifier_type_isbn
|
84
|
+
end
|
85
|
+
identifier.each do |k, v|
|
86
|
+
manifestation.identifiers << v
|
87
|
+
end
|
86
88
|
|
87
89
|
manifestation.carrier_type = CarrierType.where(name: 'volume').first
|
88
90
|
manifestation.manifestation_content_type = ContentType.where(name: 'text').first
|
@@ -96,12 +98,12 @@ module EnjuNii
|
|
96
98
|
manifestation.publishers = publisher_patrons
|
97
99
|
manifestation.creators = creator_patrons
|
98
100
|
if defined?(EnjuSubject)
|
99
|
-
|
101
|
+
subjects = get_cinii_subjects(doc)
|
100
102
|
subject_heading_type = SubjectHeadingType.where(name: 'bsh').first
|
101
103
|
subject_heading_type = SubjectHeadingType.create!(name: 'bsh') unless subject_heading_type
|
102
104
|
subjects.each do |term|
|
103
105
|
subject = Subject.where(:term => term[:term]).first
|
104
|
-
|
106
|
+
unless subject
|
105
107
|
subject = Subject.new(term)
|
106
108
|
subject.subject_heading_type = subject_heading_type
|
107
109
|
subject_type = SubjectType.where(name: 'concept').first
|
@@ -185,44 +187,44 @@ module EnjuNii
|
|
185
187
|
|
186
188
|
def get_cinii_language(doc)
|
187
189
|
language = doc.at("//dc:language").try(:content)
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
190
|
+
if language.size > 3
|
191
|
+
language[0..2]
|
192
|
+
else
|
193
|
+
language
|
194
|
+
end
|
193
195
|
end
|
194
196
|
|
195
197
|
def get_cinii_subjects(doc)
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
198
|
+
subjects = []
|
199
|
+
doc.xpath('//foaf:topic').each do |s|
|
200
|
+
subjects << { :term => s["dc:title"] }
|
201
|
+
end
|
202
|
+
subjects
|
201
203
|
end
|
202
204
|
|
203
205
|
def create_cinii_series_statements(doc, manifestation)
|
204
206
|
series = doc.at("//dcterms:isPartOf")
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
207
|
+
if series and parent_url = series["rdf:resource"]
|
208
|
+
ptbl = series["dc:title"]
|
209
|
+
parent_url = parent_url.gsub(/\#\w+\Z/, "")
|
210
|
+
parent_doc = Nokogiri::XML(Faraday.get(parent_url+".rdf").body)
|
211
|
+
parent_titles = get_cinii_title(parent_doc)
|
212
|
+
series_statement = SeriesStatement.new(parent_titles)
|
213
|
+
series_statement.series_statement_identifier = parent_url
|
214
|
+
manifestation.series_statements << series_statement
|
215
|
+
if parts = ptbl.split(/ \. /)
|
216
|
+
parts[1..-1].each do |part|
|
217
|
+
title, volume_number, = part.split(/ ; /)
|
218
|
+
original_title, title_transcription, = title.split(/\|\|/)
|
219
|
+
series_statement = SeriesStatement.new(
|
220
|
+
:original_title => original_title,
|
221
|
+
:title_transcription => title_transcription,
|
222
|
+
:volume_number_string => volume_number,
|
223
|
+
)
|
224
|
+
manifestation.series_statements << series_statement
|
225
|
+
end
|
224
226
|
end
|
225
|
-
|
227
|
+
end
|
226
228
|
end
|
227
229
|
end
|
228
230
|
|
data/lib/enju_nii/version.rb
CHANGED