enju_ndl 0.1.0.pre26 → 0.1.0.pre27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/ndl_books_controller.rb +1 -1
- data/app/helpers/ndl_books_helper.rb +5 -5
- data/app/models/ndl_book.rb +10 -6
- data/app/views/ndl_books/index.html.erb +1 -1
- data/lib/enju_ndl/ndl_search.rb +8 -2
- data/lib/enju_ndl/version.rb +1 -1
- data/spec/cassette_library/ImportRequest/should_import_isbn.yml +354 -352
- data/spec/cassette_library/Manifestation/should_imporrt_a_bibliographic_record.yml +650 -648
- data/spec/cassette_library/Manifestation/should_import_isbn.yml +355 -353
- data/spec/cassette_library/NdlBook/import/should_get_series_title.yml +61 -55
- data/spec/cassette_library/NdlBook/import/should_get_volume_number.yml +58 -56
- data/spec/cassette_library/NdlBook/import/should_import_audio_cd.yml +8 -8
- data/spec/cassette_library/NdlBook/import/should_import_bibliographic_record.yml +96 -96
- data/spec/cassette_library/NdlBook/import/should_import_bibliographic_record_that_does_not_have_any_classifications.yml +7 -7
- data/spec/cassette_library/NdlBook/import/should_import_pud_date_is_nil.yml +55 -55
- data/spec/cassette_library/NdlBook/import/should_import_series_statement.yml +7 -7
- data/spec/cassette_library/NdlBook/import/should_import_series_statement_if_the_resource_is_periodical.yml +190 -248
- data/spec/cassette_library/NdlBook/import/should_import_title_alternative.yml +165 -163
- data/spec/cassette_library/NdlBook/import/should_import_url_contain_whitespace.yml +8 -8
- data/spec/cassette_library/NdlBook/import/should_import_video_dvd.yml +7 -7
- data/spec/cassette_library/NdlBook/import/should_import_volume_number_string.yml +155 -152
- data/spec/cassette_library/NdlBook/import/should_not_get_series_title_if_book_has_not_series_title.yml +64 -62
- data/spec/cassette_library/NdlBook/import/should_not_get_volume_number_if_book_has_not_volume.yml +54 -52
- data/spec/cassette_library/NdlBook/search/should_not_distinguish_double_byte_space_from_one-byte_space_in_a_query.yml +625 -609
- data/spec/cassette_library/NdlBook/search/should_search_bibliographic_record.yml +353 -347
- data/spec/cassette_library/NdlBooksController/GET_index/should_get_index.yml +425 -423
- data/spec/cassette_library/NdlBooksController/POST_create/should_create_a_bibliographic_record_if_jpno_is_set.yml +7 -7
- data/spec/cassette_library/NdlBooksController/POST_create/should_not_create_a_bibliographic_record_if_jpno_is_not_set.yml +11 -11
- data/spec/cassette_library/Question/should_respond_to_search_crd.yml +296 -497
- data/spec/controllers/ndl_books_controller_spec.rb +1 -1
- data/spec/dummy/config/initializers/devise.rb +2 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/models/ndl_book_spec.rb +12 -11
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 642a6b6fc3846571a344ef0b97c270897bdd6dbb
|
4
|
+
data.tar.gz: 71ff1acdc57df33ee51e753e3e1f1a5b64930ed4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a926ae573d2fc136dba65e0f6762b9ae066f0ba2300f94b34612b2ea0493c67aa7436678dbb92009e76e7f562119eada39c57e92739021a0eddf32d781e295ba
|
7
|
+
data.tar.gz: 5d9dcbaeb9b58d979129d23460657e43721c1fa9d14e3fd394055364cf6ee344a984279fe383f301ed58b67cae0c11c20c3b5c7ff07c089817eee04ac8cd17ce
|
@@ -22,7 +22,7 @@ class NdlBooksController < ApplicationController
|
|
22
22
|
def create
|
23
23
|
if params[:book]
|
24
24
|
begin
|
25
|
-
@manifestation = NdlBook.import_from_sru_response(params[:book][:
|
25
|
+
@manifestation = NdlBook.import_from_sru_response(params[:book][:iss_itemno])
|
26
26
|
rescue EnjuNdl::RecordNotFound
|
27
27
|
end
|
28
28
|
respond_to do |format|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
module NdlBooksHelper
|
3
|
-
def link_to_import_from_ndl(
|
4
|
-
if
|
3
|
+
def link_to_import_from_ndl(iss_itemno)
|
4
|
+
if iss_itemno.blank?
|
5
5
|
t('enju_ndl.not_available')
|
6
6
|
else
|
7
|
-
identifier_type = IdentifierType.where(:name => '
|
7
|
+
identifier_type = IdentifierType.where(:name => 'iss_itemno').first
|
8
8
|
if identifier_type
|
9
|
-
manifestation = Identifier.where(:body =>
|
9
|
+
manifestation = Identifier.where(:body => iss_itemno, :identifier_type_id => identifier_type.id).first.try(:manifestation)
|
10
10
|
end
|
11
11
|
unless manifestation
|
12
|
-
link_to t('enju_ndl.add'), ndl_books_path(:book => {:
|
12
|
+
link_to t('enju_ndl.add'), ndl_books_path(:book => {:iss_itemno => iss_itemno}), :method => :post
|
13
13
|
else
|
14
14
|
link_to t('enju_ndl.already_exists'), manifestation
|
15
15
|
end
|
data/app/models/ndl_book.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
class NdlBook
|
3
|
-
attr_reader :jpno, :permalink, :title, :creator, :publisher, :issued, :isbn
|
3
|
+
attr_reader :jpno, :permalink, :title, :creator, :publisher, :issued, :isbn,
|
4
|
+
:itemno
|
4
5
|
|
5
6
|
def initialize(node)
|
6
7
|
@node = node
|
@@ -14,6 +15,10 @@ class NdlBook
|
|
14
15
|
@node.at('./link').try(:content).to_s
|
15
16
|
end
|
16
17
|
|
18
|
+
def itemno
|
19
|
+
URI.parse(permalink).path.split('/').last
|
20
|
+
end
|
21
|
+
|
17
22
|
def title
|
18
23
|
@node.at('./title').try(:content).to_s
|
19
24
|
end
|
@@ -61,15 +66,14 @@ class NdlBook
|
|
61
66
|
end
|
62
67
|
end
|
63
68
|
|
64
|
-
def self.import_from_sru_response(
|
65
|
-
identifier = Identifier.where(:body =>
|
69
|
+
def self.import_from_sru_response(itemno)
|
70
|
+
identifier = Identifier.where(:body => itemno, :identifier_type_id => IdentifierType.where(:name => 'iss_itemno').first_or_create.id).first
|
66
71
|
return if identifier
|
67
|
-
url = "http://iss.ndl.go.jp/api/sru?operation=searchRetrieve&recordSchema=dcndl
|
72
|
+
url = "http://iss.ndl.go.jp/api/sru?operation=searchRetrieve&recordSchema=dcndl&maximumRecords=1&query=%28itemno=#{itemno}%29&onlyBib=true"
|
68
73
|
xml = open(url).read
|
69
74
|
response = Nokogiri::XML(xml).at('//xmlns:recordData')
|
70
75
|
return unless response.try(:content)
|
71
|
-
|
72
|
-
Manifestation.import_record(doc)
|
76
|
+
Manifestation.import_record(Nokogiri::XML(response.content))
|
73
77
|
end
|
74
78
|
|
75
79
|
attr_accessor :url
|
@@ -22,7 +22,7 @@
|
|
22
22
|
<% @books.each do |book| %>
|
23
23
|
<tr class="line<%= cycle("0", "1") -%>">
|
24
24
|
<td>
|
25
|
-
<%= link_to_import_from_ndl(book.
|
25
|
+
<%= link_to_import_from_ndl(book.itemno) %>
|
26
26
|
</td>
|
27
27
|
<td>
|
28
28
|
<strong><%= link_to "#{book.title} #{book.volume}".strip , book.permalink %></strong>
|
data/lib/enju_ndl/ndl_search.rb
CHANGED
@@ -27,10 +27,12 @@ module EnjuNdl
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def import_record(doc)
|
30
|
-
|
31
|
-
identifier = Identifier.where(:body =>
|
30
|
+
iss_itemno = URI.parse(doc.at('//dcndl:BibAdminResource[@rdf:about]').values.first).path.split('/').last
|
31
|
+
identifier = Identifier.where(:body => iss_itemno, :identifier_type_id => IdentifierType.where(:name => 'iss_itemno').first_or_create.id).first
|
32
32
|
return identifier.manifestation if identifier
|
33
33
|
|
34
|
+
jpno = doc.at('//dcterms:identifier[@rdf:datatype="http://ndl.go.jp/dcndl/terms/JPNO"]').try(:content)
|
35
|
+
|
34
36
|
publishers = get_publishers(doc)
|
35
37
|
|
36
38
|
# title
|
@@ -111,6 +113,10 @@ module EnjuNdl
|
|
111
113
|
identifier[:isbn] = Identifier.new(:body => isbn)
|
112
114
|
identifier[:isbn].identifier_type = IdentifierType.where(:name => 'isbn').first_or_create
|
113
115
|
end
|
116
|
+
if iss_itemno
|
117
|
+
identifier[:iss_itemno] = Identifier.new(:body => iss_itemno)
|
118
|
+
identifier[:iss_itemno].identifier_type = IdentifierType.where(:name => 'iss_itemno').first_or_create
|
119
|
+
end
|
114
120
|
if jpno
|
115
121
|
identifier[:jpno] = Identifier.new(:body => jpno)
|
116
122
|
identifier[:jpno].identifier_type = IdentifierType.where(:name => 'jpno').first_or_create
|
data/lib/enju_ndl/version.rb
CHANGED