enju_biblio 0.3.10.rc.1 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/item_custom_properties_controller.rb +8 -3
  3. data/app/controllers/items_controller.rb +13 -2
  4. data/app/controllers/manifestation_custom_properties_controller.rb +8 -3
  5. data/app/controllers/manifestations_controller.rb +36 -48
  6. data/app/models/item.rb +9 -5
  7. data/app/models/item_custom_property.rb +7 -7
  8. data/app/models/item_custom_value.rb +3 -3
  9. data/app/models/manifestation.rb +38 -12
  10. data/app/models/manifestation_custom_property.rb +7 -7
  11. data/app/models/manifestation_custom_value.rb +3 -3
  12. data/app/models/picture_file.rb +0 -2
  13. data/app/models/resource_export_file.rb +4 -2
  14. data/app/models/resource_import_file.rb +74 -56
  15. data/app/policies/item_custom_property_policy.rb +3 -3
  16. data/app/policies/manifestation_custom_property_policy.rb +3 -3
  17. data/app/views/item_custom_properties/edit.html.erb +12 -5
  18. data/app/views/item_custom_properties/index.html.erb +14 -7
  19. data/app/views/item_custom_properties/new.html.erb +11 -4
  20. data/app/views/item_custom_properties/show.html.erb +24 -17
  21. data/app/views/items/_item.json.jbuilder +17 -0
  22. data/app/views/items/index.json.jbuilder +5 -0
  23. data/app/views/items/show.json.jbuilder +1 -0
  24. data/app/views/manifestation_custom_properties/edit.html.erb +12 -5
  25. data/app/views/manifestation_custom_properties/index.html.erb +14 -7
  26. data/app/views/manifestation_custom_properties/new.html.erb +11 -4
  27. data/app/views/manifestation_custom_properties/show.html.erb +24 -17
  28. data/app/views/manifestations/_export_detail.html.erb +1 -0
  29. data/app/views/manifestations/_export_list.html.erb +1 -0
  30. data/app/views/manifestations/_form.html.erb +5 -0
  31. data/app/views/manifestations/_show_detail_librarian.html.erb +6 -0
  32. data/app/views/manifestations/_show_detail_user.html.erb +8 -0
  33. data/app/views/manifestations/show.json.jbuilder +2 -0
  34. data/config/locales/translation_en.yml +2 -0
  35. data/config/locales/translation_ja.yml +2 -0
  36. data/db/migrate/20081027150907_create_picture_files.rb +0 -2
  37. data/lib/enju_biblio.rb +0 -2
  38. data/lib/enju_biblio/openurl.rb +5 -1
  39. data/lib/enju_biblio/version.rb +1 -1
  40. data/spec/controllers/item_custom_properties_controller_spec.rb +449 -0
  41. data/spec/controllers/items_controller_spec.rb +36 -0
  42. data/spec/controllers/manifestation_custom_properties_controller_spec.rb +449 -0
  43. data/spec/controllers/manifestations_controller_spec.rb +0 -19
  44. data/spec/dummy/db/schema.rb +0 -2
  45. data/spec/fixtures/creates.yml +2 -0
  46. data/spec/fixtures/item_custom_properties.yml +7 -7
  47. data/spec/fixtures/manifestation_custom_properties.yml +7 -7
  48. data/spec/fixtures/picture_files.yml +0 -2
  49. data/spec/fixtures/produces.yml +2 -0
  50. data/spec/fixtures/realizes.yml +2 -0
  51. data/spec/models/item_custom_property_spec.rb +7 -7
  52. data/spec/models/item_custom_value_spec.rb +3 -3
  53. data/spec/models/manifestation_custom_property_spec.rb +7 -7
  54. data/spec/models/manifestation_custom_value_spec.rb +3 -3
  55. data/spec/models/manifestation_spec.rb +1 -66
  56. data/spec/models/picture_file_spec.rb +0 -2
  57. data/spec/models/resource_export_file_spec.rb +61 -8
  58. data/spec/models/resource_import_file_spec.rb +5 -1
  59. data/spec/views/item_custom_properties/index.html.erb_spec.rb +1 -0
  60. data/spec/views/items/index.json.jbuilder_spec.rb +15 -0
  61. data/spec/views/items/show.json.jbuilder_spec.rb +15 -0
  62. data/spec/views/manifestation_custom_properties/index.html.erb_spec.rb +1 -0
  63. data/spec/views/manifestations/show.json.jbuilder_spec.rb +16 -0
  64. metadata +535 -525
  65. data/app/views/manifestations/explain.sru +0 -9
  66. data/app/views/manifestations/index.sru.builder +0 -101
  67. data/lib/enju_biblio/porta_cql.rb +0 -282
  68. data/lib/enju_biblio/sru.rb +0 -83
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77d5c642a35ec134208140ee6fbf038219d633619ba7a4a50927bcd14522e685
4
- data.tar.gz: 814c6c8c7c795efa2cc55365805e1bbee2d7689d730593c56f00d012a7d4fa52
3
+ metadata.gz: 13bb317c73b54a9d6ff4bc74db706b224929d3474f1de724d53abd0a3c075e12
4
+ data.tar.gz: 3fc674acbf36775a9394609f1a3108230c94e62455fdf257371571b58d330990
5
5
  SHA512:
6
- metadata.gz: 969d8e56c2adfdc2b82b63bf193d28092348c7cb01675cc19e59e936e9ab73ab9878f8403a82397420c3f9469d37bbbcdf610f3d465980c6d5607d9219be510b
7
- data.tar.gz: be66e593d2fd98df02e694169b53554aadd7a9d3369e731a96eede7bd3ef7336a48372025d55a4de462156d8d6018c4ee5b02954b49676f0d9a20cd90e161c96
6
+ metadata.gz: bad673e2ff6572eee73c8ba3314c28895876e41e86e24545f7c8dd090d059544f01c280bb4e0c9cd668d4daa19db04c03771a6b6ddc9d0d385ad42162bf8f51d
7
+ data.tar.gz: cc53497b07c0d9fea3e1186b9be7e401e47aabb4b32df2087b949e5b95eabb270a0cc056fefc7aea7f65edc31b1f7f02662e1403f1c6704bcad5e1b40eaf3f4f
@@ -25,7 +25,7 @@ class ItemCustomPropertiesController < ApplicationController
25
25
  @item_custom_property = ItemCustomProperty.new(item_custom_property_params)
26
26
 
27
27
  if @item_custom_property.save
28
- redirect_to @item_custom_property, notice: 'Item custom property was successfully created.'
28
+ redirect_to @item_custom_property, notice: t('controller.successfully_created', model: t('activerecord.models.item_custom_property'))
29
29
  else
30
30
  render :new
31
31
  end
@@ -33,8 +33,13 @@ class ItemCustomPropertiesController < ApplicationController
33
33
 
34
34
  # PATCH/PUT /item_custom_properties/1
35
35
  def update
36
+ if params[:move]
37
+ move_position(@item_custom_property, params[:move])
38
+ return
39
+ end
40
+
36
41
  if @item_custom_property.update(item_custom_property_params)
37
- redirect_to @item_custom_property, notice: 'Item custom property was successfully updated.'
42
+ redirect_to @item_custom_property, notice: t('controller.successfully_updated', model: t('activerecord.models.item_custom_property'))
38
43
  else
39
44
  render :edit
40
45
  end
@@ -43,7 +48,7 @@ class ItemCustomPropertiesController < ApplicationController
43
48
  # DELETE /item_custom_properties/1
44
49
  def destroy
45
50
  @item_custom_property.destroy
46
- redirect_to item_custom_properties_url, notice: 'Item custom property was successfully destroyed.'
51
+ redirect_to item_custom_properties_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.item_custom_property'))
47
52
  end
48
53
 
49
54
  private
@@ -51,6 +51,17 @@ class ItemsController < ApplicationController
51
51
 
52
52
  unless @inventory_file
53
53
  search = Sunspot.new_search(Item)
54
+ selected_attributes = [
55
+ :id, :item_identifier, :call_number, :manifestation_id, :acquired_at,
56
+ :binding_item_identifier, :binding_call_number, :binded_at,
57
+ :include_supplements, :url, :note,
58
+ :circulation_status_id, :shelf_id,
59
+ :created_at, :updated_at
60
+ ]
61
+ selected_attributes += [
62
+ :memo, :required_role_id, :budget_type_id, :bookstore_id, :price
63
+ ] if current_user.try(:has_role?, 'Librarian')
64
+ search.data_accessor_for(Item).select = selected_attributes
54
65
  set_role_query(current_user, search)
55
66
 
56
67
  @query = query.dup
@@ -122,7 +133,7 @@ class ItemsController < ApplicationController
122
133
 
123
134
  respond_to do |format|
124
135
  format.html # index.html.erb
125
- format.json { render json: @items }
136
+ format.json
126
137
  format.txt { render layout: false }
127
138
  format.atom
128
139
  end
@@ -137,7 +148,7 @@ class ItemsController < ApplicationController
137
148
 
138
149
  respond_to do |format|
139
150
  format.html # show.html.erb
140
- format.json { render json: @item }
151
+ format.json
141
152
  end
142
153
  end
143
154
 
@@ -25,7 +25,7 @@ class ManifestationCustomPropertiesController < ApplicationController
25
25
  @manifestation_custom_property = ManifestationCustomProperty.new(manifestation_custom_property_params)
26
26
 
27
27
  if @manifestation_custom_property.save
28
- redirect_to @manifestation_custom_property, notice: 'Manifestation custom property was successfully created.'
28
+ redirect_to @manifestation_custom_property, notice: t('controller.successfully_created', model: t('activerecord.models.manifestation_custom_property'))
29
29
  else
30
30
  render :new
31
31
  end
@@ -33,8 +33,13 @@ class ManifestationCustomPropertiesController < ApplicationController
33
33
 
34
34
  # PATCH/PUT /manifestation_custom_properties/1
35
35
  def update
36
+ if params[:move]
37
+ move_position(@manifestation_custom_property, params[:move])
38
+ return
39
+ end
40
+
36
41
  if @manifestation_custom_property.update(manifestation_custom_property_params)
37
- redirect_to @manifestation_custom_property, notice: 'Manifestation custom property was successfully updated.'
42
+ redirect_to @manifestation_custom_property, notice: t('controller.successfully_updated', model: t('activerecord.models.manifestation_custom_property'))
38
43
  else
39
44
  render :edit
40
45
  end
@@ -43,7 +48,7 @@ class ManifestationCustomPropertiesController < ApplicationController
43
48
  # DELETE /manifestation_custom_properties/1
44
49
  def destroy
45
50
  @manifestation_custom_property.destroy
46
- redirect_to manifestation_custom_properties_url, notice: 'Manifestation custom property was successfully destroyed.'
51
+ redirect_to manifestation_custom_properties_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.manifestation_custom_property'))
47
52
  end
48
53
 
49
54
  private
@@ -33,25 +33,14 @@ class ManifestationsController < ApplicationController
33
33
  per_page = 65534
34
34
  end
35
35
 
36
- if params[:format] == 'sru'
37
- if params[:operation] == 'searchRetrieve'
38
- sru = Sru.new(params)
39
- query = sru.cql.to_sunspot
40
- sort = sru.sort_by
41
- else
42
- render template: 'manifestations/explain', layout: false
43
- return
44
- end
36
+ if params[:api] == 'openurl'
37
+ openurl = Openurl.new(params)
38
+ @manifestations = openurl.search
39
+ query = openurl.query_text
40
+ sort = set_search_result_order(params[:sort_by], params[:order])
45
41
  else
46
- if params[:api] == 'openurl'
47
- openurl = Openurl.new(params)
48
- @manifestations = openurl.search
49
- query = openurl.query_text
50
- sort = set_search_result_order(params[:sort_by], params[:order])
51
- else
52
- query = make_query(params[:query], params)
53
- sort = set_search_result_order(params[:sort_by], params[:order])
54
- end
42
+ query = make_query(params[:query], params)
43
+ sort = set_search_result_order(params[:sort_by], params[:order])
55
44
  end
56
45
 
57
46
  # 絞り込みを行わない状態のクエリ
@@ -191,37 +180,37 @@ class ManifestationsController < ApplicationController
191
180
  else
192
181
  per_page = Manifestation.default_per_page
193
182
  end
194
- if params[:format] == 'sru'
195
- #search.query.start_record(params[:startRecord] || 1, params[:maximumRecords] || 200)
183
+
184
+ pub_dates = parse_pub_date(params)
185
+ pub_date_range = {}
186
+
187
+ if pub_dates[:from] == '*'
188
+ pub_date_range[:from] = 0
196
189
  else
197
- pub_dates = parse_pub_date(params)
198
- pub_date_range = {}
199
- if pub_dates[:from] == '*'
200
- pub_date_range[:from] = 0
201
- else
202
- pub_date_range[:from] = Time.zone.parse(pub_dates[:from]).year
203
- end
204
- if pub_dates[:until] == '*'
205
- pub_date_range[:until] = 10000
206
- else
207
- pub_date_range[:until] = Time.zone.parse(pub_dates[:until]).year
208
- end
209
- if params[:pub_year_range_interval]
210
- pub_year_range_interval = params[:pub_year_range_interval].to_i
211
- else
212
- pub_year_range_interval = @library_group.pub_year_facet_range_interval || 10
213
- end
190
+ pub_date_range[:from] = Time.zone.parse(pub_dates[:from]).year
191
+ end
192
+ if pub_dates[:until] == '*'
193
+ pub_date_range[:until] = 10000
194
+ else
195
+ pub_date_range[:until] = Time.zone.parse(pub_dates[:until]).year
196
+ end
214
197
 
215
- search.build do
216
- facet :reservable if defined?(EnjuCirculation)
217
- facet :carrier_type
218
- facet :library
219
- facet :language
220
- facet :pub_year, range: pub_date_range[:from]..pub_date_range[:until], range_interval: pub_year_range_interval
221
- facet :subject_ids if defined?(EnjuSubject)
222
- paginate page: page.to_i, per_page: per_page
223
- end
198
+ if params[:pub_year_range_interval]
199
+ pub_year_range_interval = params[:pub_year_range_interval].to_i
200
+ else
201
+ pub_year_range_interval = @library_group.pub_year_facet_range_interval || 10
202
+ end
203
+
204
+ search.build do
205
+ facet :reservable if defined?(EnjuCirculation)
206
+ facet :carrier_type
207
+ facet :library
208
+ facet :language
209
+ facet :pub_year, range: pub_date_range[:from]..pub_date_range[:until], range_interval: pub_year_range_interval
210
+ facet :subject_ids if defined?(EnjuSubject)
211
+ paginate page: page.to_i, per_page: per_page
224
212
  end
213
+
225
214
  search_result = search.execute
226
215
  if @count[:query_result] > @max_number_of_results
227
216
  max_count = @max_number_of_results
@@ -261,7 +250,6 @@ class ManifestationsController < ApplicationController
261
250
  format.html
262
251
  format.html.phone
263
252
  format.xml { render xml: @manifestations }
264
- format.sru { render layout: false }
265
253
  format.rss { render layout: false }
266
254
  format.txt { render layout: false }
267
255
  format.rdf { render layout: false }
@@ -332,7 +320,7 @@ class ManifestationsController < ApplicationController
332
320
  }
333
321
  format.rdf
334
322
  format.mods
335
- format.json { render json: @manifestation }
323
+ format.json
336
324
  format.txt
337
325
  format.js
338
326
  format.download {
data/app/models/item.rb CHANGED
@@ -107,10 +107,11 @@ class Item < ApplicationRecord
107
107
  record = {
108
108
  item_id: id,
109
109
  item_identifier: item_identifier,
110
+ binding_item_identifier: binding_item_identifier,
110
111
  call_number: call_number,
111
- shelf: shelf.name,
112
+ shelf: shelf&.name,
112
113
  item_note: note,
113
- accepted_at: accept.try(:created_at),
114
+ accepted_at: accept&.created_at,
114
115
  acquired_at: acquired_at,
115
116
  item_created_at: created_at,
116
117
  item_updated_at: updated_at
@@ -118,8 +119,9 @@ class Item < ApplicationRecord
118
119
 
119
120
  if ['Administrator', 'Librarian'].include?(role)
120
121
  record.merge!({
121
- bookstore: bookstore.try(:name),
122
- budget_type: budget_type.try(:name),
122
+ bookstore: bookstore&.name,
123
+ budget_type: budget_type&.name,
124
+ item_required_role: required_role.name,
123
125
  item_price: price,
124
126
  memo: memo
125
127
  })
@@ -131,7 +133,9 @@ class Item < ApplicationRecord
131
133
 
132
134
  if defined?(EnjuCirculation)
133
135
  record.merge!({
134
- use_restriction: use_restriction.try(:name),
136
+ use_restriction: use_restriction&.name,
137
+ circulation_status: circulation_status&.name,
138
+ checkout_type: checkout_type&.name,
135
139
  total_checkouts: checkouts.count
136
140
  })
137
141
  end
@@ -8,11 +8,11 @@ end
8
8
  #
9
9
  # Table name: item_custom_properties
10
10
  #
11
- # id :bigint not null, primary key
12
- # name :string not null
13
- # display_name_translations :jsonb not null
14
- # note :text
15
- # position :integer default(1), not null
16
- # created_at :datetime not null
17
- # updated_at :datetime not null
11
+ # id :integer not null, primary key
12
+ # name :string not null
13
+ # display_name :text not null
14
+ # note :text
15
+ # position :integer default(1), not null
16
+ # created_at :datetime not null
17
+ # updated_at :datetime not null
18
18
  #
@@ -8,9 +8,9 @@ end
8
8
  #
9
9
  # Table name: item_custom_values
10
10
  #
11
- # id :bigint not null, primary key
12
- # item_custom_property_id :bigint not null
13
- # item_id :bigint not null
11
+ # id :integer not null, primary key
12
+ # item_custom_property_id :integer not null
13
+ # item_id :integer not null
14
14
  # value :text
15
15
  # created_at :datetime not null
16
16
  # updated_at :datetime not null
@@ -96,7 +96,7 @@ class Manifestation < ApplicationRecord
96
96
  end
97
97
  end
98
98
  string :language do
99
- language.try(:name)
99
+ language&.name
100
100
  end
101
101
  string :item_identifier, multiple: true do
102
102
  if series_master?
@@ -120,7 +120,7 @@ class Manifestation < ApplicationRecord
120
120
  end
121
121
  time :date_of_publication
122
122
  integer :pub_year do
123
- date_of_publication.try(:year)
123
+ date_of_publication&.year
124
124
  end
125
125
  integer :creator_ids, multiple: true
126
126
  integer :contributor_ids, multiple: true
@@ -357,7 +357,7 @@ class Manifestation < ApplicationRecord
357
357
  # TODO: よりよい推薦方法
358
358
  def self.pickup(keyword = nil, current_user = nil)
359
359
  return nil if self.cached_numdocs < 5
360
- if current_user.try(:role)
360
+ if current_user&.role
361
361
  current_role_id = current_user.role.id
362
362
  else
363
363
  current_role_id = 1
@@ -433,7 +433,7 @@ class Manifestation < ApplicationRecord
433
433
  end
434
434
 
435
435
  def index_series_statement
436
- series_statements.map{|s| s.index; s.root_manifestation.try(:index)}
436
+ series_statements.map{|s| s.index; s.root_manifestation&.index}
437
437
  end
438
438
 
439
439
  def acquired_at
@@ -541,16 +541,34 @@ class Manifestation < ApplicationRecord
541
541
  def to_hash(role: 'Guest')
542
542
  record = {
543
543
  manifestation_id: id,
544
- title: original_title,
544
+ original_title: original_title,
545
545
  title_alternative: title_alternative,
546
546
  title_transcription: title_transcription,
547
547
  statement_of_responsibility: statement_of_responsibility,
548
548
  serial: serial,
549
549
  manifestation_identifier: manifestation_identifier,
550
- creator: creators.pluck(:full_name).join('//'),
551
- contributor: contributors.pluck(:full_name).join('//'),
552
- publisher: publishers.pluck(:full_name).join('//'),
553
- date_of_publication: date_of_publication,
550
+ creator: creates.map{|create|
551
+ if create.create_type
552
+ "#{create.agent.full_name}||#{create.create_type.name}"
553
+ else
554
+ "#{create.agent.full_name}"
555
+ end
556
+ }.join('//'),
557
+ contributor: realizes.map{|realize|
558
+ if realize.realize_type
559
+ "#{realize.agent.full_name}||#{realize.realize_type.name}"
560
+ else
561
+ "#{realize.agent.full_name}"
562
+ end
563
+ }.join('//'),
564
+ publisher: produces.map{|produce|
565
+ if produce.produce_type
566
+ "#{produce.agent.full_name}||#{produce.produce_type.name}"
567
+ else
568
+ "#{produce.agent.full_name}"
569
+ end
570
+ }.join('//'),
571
+ pub_date: date_of_publication,
554
572
  year_of_publication: year_of_publication,
555
573
  publication_place: publication_place,
556
574
  manifestation_created_at: created_at,
@@ -577,13 +595,13 @@ class Manifestation < ApplicationRecord
577
595
  depth: depth,
578
596
  price: price,
579
597
  access_address: access_address,
580
- required_role: required_role.name,
598
+ manifestation_required_role: required_role.name,
581
599
  description: description,
582
600
  note: note
583
601
  }
584
602
 
585
603
  IdentifierType.find_each do |type|
586
- record[type.name.to_sym] = identifiers.where(identifier_type: type).pluck(:body).join('//')
604
+ record[:"identifier:#{type.name.to_sym}"] = identifiers.where(identifier_type: type).pluck(:body).join('//')
587
605
  end
588
606
 
589
607
  series = series_statements.order(:position)
@@ -610,7 +628,7 @@ class Manifestation < ApplicationRecord
610
628
  })
611
629
  ManifestationCustomProperty.order(:position).each do |custom_property|
612
630
  custom_value = manifestation_custom_values.find_by(manifestation_custom_property: custom_property)
613
- record[:"manifestation:#{custom_property.name}"] = custom_value.try(:value)
631
+ record[:"manifestation:#{custom_property.name}"] = custom_value&.value
614
632
  end
615
633
  end
616
634
 
@@ -623,6 +641,14 @@ class Manifestation < ApplicationRecord
623
641
  end
624
642
  end
625
643
 
644
+ if defined?(EnjuNdl)
645
+ record["jpno"] = identifier_contents(:jpno).first
646
+ end
647
+
648
+ if defined?(EnjuNii)
649
+ record["ncid"] = identifier_contents(:ncid).first
650
+ end
651
+
626
652
  record
627
653
  end
628
654
 
@@ -8,11 +8,11 @@ end
8
8
  #
9
9
  # Table name: manifestation_custom_properties
10
10
  #
11
- # id :bigint not null, primary key
12
- # name :string not null
13
- # display_name_translations :jsonb not null
14
- # note :text
15
- # position :integer default(1), not null
16
- # created_at :datetime not null
17
- # updated_at :datetime not null
11
+ # id :integer not null, primary key
12
+ # name :string not null
13
+ # display_name :text not null
14
+ # note :text
15
+ # position :integer default(1), not null
16
+ # created_at :datetime not null
17
+ # updated_at :datetime not null
18
18
  #
@@ -8,9 +8,9 @@ end
8
8
  #
9
9
  # Table name: manifestation_custom_values
10
10
  #
11
- # id :bigint not null, primary key
12
- # manifestation_custom_property_id :bigint not null
13
- # manifestation_id :bigint not null
11
+ # id :integer not null, primary key
12
+ # manifestation_custom_property_id :integer not null
13
+ # manifestation_id :integer not null
14
14
  # value :text
15
15
  # created_at :datetime not null
16
16
  # updated_at :datetime not null