enju_biblio 0.1.0.pre69 → 0.1.0.pre70

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/items_controller.rb +5 -5
  3. data/app/controllers/manifestations_controller.rb +10 -85
  4. data/app/controllers/resource_import_files_controller.rb +1 -0
  5. data/app/models/enju_biblio/ability.rb +29 -19
  6. data/app/models/manifestation.rb +38 -11
  7. data/app/models/resource_import_file.rb +35 -12
  8. data/app/models/resource_import_file_state_machine.rb +1 -1
  9. data/app/views/agent_types/_form.html.erb +2 -1
  10. data/app/views/agents/_form.html.erb +1 -1
  11. data/app/views/import_requests/new.html.erb +2 -2
  12. data/app/views/items/_form.html.erb +7 -0
  13. data/app/views/items/edit.html.erb +0 -1
  14. data/app/views/items/new.html.erb +0 -1
  15. data/app/views/manifestations/_colorbox.html.erb +5 -0
  16. data/app/views/manifestations/_export_detail.html.erb +7 -0
  17. data/app/views/manifestations/_export_list.html.erb +6 -0
  18. data/app/views/manifestations/_manifestation.txt.erb +1 -0
  19. data/app/views/manifestations/index.html.erb +1 -0
  20. data/app/views/manifestations/index.txt.erb +2 -4
  21. data/app/views/manifestations/show.html.erb +2 -5
  22. data/app/views/manifestations/show.txt.erb +2 -0
  23. data/app/views/resource_import_files/_results.html.erb +23 -0
  24. data/app/views/resource_import_files/new.html.erb +2 -0
  25. data/app/views/resource_import_files/show.html.erb +8 -12
  26. data/app/views/resource_import_results/_list.html.erb +26 -0
  27. data/app/views/resource_import_results/_list_lines.html.erb +25 -0
  28. data/app/views/resource_import_results/index.html.erb +3 -30
  29. data/app/views/resource_import_results/show.html.erb +1 -1
  30. data/config/locales/translation_en.yml +8 -5
  31. data/config/locales/translation_ja.yml +4 -1
  32. data/lib/enju_biblio/version.rb +1 -1
  33. data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/ISBN_import/with_record_not_found/should_record_an_error_message.yml +155 -0
  34. data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_has_only_isbn/should_be_imported.yml +464 -374
  35. data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_shift_jis/should_be_imported.yml +232 -159
  36. data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_utf-8/should_be_imported.yml +234 -161
  37. data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_utf-8/should_send_message_when_import_is_completed.yml +234 -163
  38. data/spec/controllers/agent_types_controller_spec.rb +5 -0
  39. data/spec/controllers/content_types_controller_spec.rb +7 -0
  40. data/spec/controllers/frequencies_controller_spec.rb +7 -0
  41. data/spec/controllers/items_controller_spec.rb +18 -0
  42. data/spec/controllers/manifestations_controller_spec.rb +30 -0
  43. data/spec/factories/classification.rb +6 -0
  44. data/spec/fixtures/items.yml +2 -0
  45. data/spec/models/manifestation_spec.rb +16 -0
  46. data/spec/models/resource_export_file_spec.rb +19 -0
  47. data/spec/models/resource_import_file_spec.rb +58 -0
  48. data/spec/views/resource_import_files/index.html.erb_spec.rb +19 -0
  49. data/spec/views/resource_import_files/show.html.erb_spec.erb +27 -0
  50. data/spec/views/resource_import_results/index.html.erb_spec.rb +32 -0
  51. data/spec/views/resource_import_results/show.html.erb_spec.erb +27 -0
  52. metadata +427 -407
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c87605ac3274d5b4c6c9bb77fb9c33f470fa041
4
- data.tar.gz: a0a99e01e3536fbd8d59da33a2c7c1509cd71c6b
3
+ metadata.gz: 425bc780b4a2e2ffd787ed793b8fb766c360f509
4
+ data.tar.gz: 20f5029a1f52d193e2f59a5c764828dfc6486bca
5
5
  SHA512:
6
- metadata.gz: 4543b0dd500b4a549b712ca9399453f36eb1fa1fea6b4ccefba419e42746896a813eccef3c54efaa48722453d0b25f94788f256108f950e78c99bbe2ed36b55d
7
- data.tar.gz: 668a012e3957aa7d21b4aee275927baa5f8b67577ece0834de849bee2cf1f6212c78219ed28b4b73eb81e0c4e7757d3a3f946f9adfbf00445a9acde203d7c3e8
6
+ metadata.gz: 6e98d9db1f15ac100f3af35bc629728e08690a3ebc573d91d818ce7a4b7b99a2ccea8d9820120e4eebc09c52520adee7d1052ad94cf647b1d5b05f708c2c4b97
7
+ data.tar.gz: 74b3ced47eca6208bfce30fce662d40d1d91b3b77d3bf82eb1a104bc286ce806fc2920e180306b5e70188974abd37544f505fcbe99678a8de932b02c8e328de7
@@ -92,17 +92,17 @@ class ItemsController < ApplicationController
92
92
  rescue NoMethodError
93
93
  end
94
94
  end
95
- if params[:acquired_to].present?
95
+ if params[:acquired_until].present?
96
96
  begin
97
- acquired_to = @acquired_to = Time.zone.parse(params[:acquired_to]).end_of_day
98
- @acquired_to = acquired_to.strftime('%Y-%m-%d')
97
+ acquired_until = @acquired_until = Time.zone.parse(params[:acquired_until]).end_of_day
98
+ @acquired_until = acquired_until.strftime('%Y-%m-%d')
99
99
  rescue ArgumentError
100
100
  rescue NoMethodError
101
101
  end
102
102
  end
103
103
  search.build do
104
104
  with(:acquired_at).greater_than_or_equal_to acquired_from.beginning_of_day if acquired_from
105
- with(:acquired_at).less_than acquired_to.tomorrow.beginning_of_day if acquired_to
105
+ with(:acquired_at).less_than acquired_until.tomorrow.beginning_of_day if acquired_until
106
106
  end
107
107
 
108
108
  page = params[:page] || 1
@@ -158,7 +158,7 @@ class ItemsController < ApplicationController
158
158
  end
159
159
  @item = Item.new
160
160
  @item.shelf = @library.shelves.first
161
- @item.manifestation_id = @manifestation.id
161
+ @item.manifestation = @manifestation
162
162
  if defined?(EnjuCirculation)
163
163
  @circulation_statuses = CirculationStatus.where(
164
164
  name: [
@@ -26,28 +26,6 @@ class ManifestationsController < ApplicationController
26
26
  end
27
27
 
28
28
  @seconds = Benchmark.realtime do
29
- if defined?(EnjuOai)
30
- @oai = check_oai_params(params)
31
- next if @oai[:need_not_to_search]
32
- if params[:format] == 'oai'
33
- oai_search = true
34
- from_and_until_times = set_from_and_until(Manifestation, params[:from], params[:until])
35
- from_time = @from_time = from_and_until_times[:from]
36
- until_time = @until_time = from_and_until_times[:until]
37
- if params[:verb] == 'GetRecord' && params[:identifier]
38
- begin
39
- @manifestation = Manifestation.find_by_oai_identifier(params[:identifier])
40
- rescue ActiveRecord::RecordNotFound
41
- @oai[:errors] << "idDoesNotExist"
42
- render formats: :oai, layout: false
43
- return
44
- end
45
- render template: 'manifestations/show', formats: :oai, layout: false
46
- return
47
- end
48
- end
49
- end
50
-
51
29
  set_reservable if defined?(EnjuCirculation)
52
30
 
53
31
  sort, @count = {}, {}
@@ -117,8 +95,7 @@ class ManifestationsController < ApplicationController
117
95
 
118
96
  search.build do
119
97
  fulltext query unless query.blank?
120
- order_by sort[:sort_by], sort[:order] unless oai_search
121
- order_by :updated_at, :desc if oai_search
98
+ order_by sort[:sort_by], sort[:order]
122
99
  if defined?(EnjuSubject)
123
100
  with(:subject_ids).equal_to subject.id if subject
124
101
  end
@@ -173,25 +150,6 @@ class ManifestationsController < ApplicationController
173
150
  @count[:query_result] = all_result.total
174
151
  @reservable_facet = all_result.facet(:reservable).rows if defined?(EnjuCirculation)
175
152
  max_number_of_results = @library_group.settings[:max_number_of_results].to_i
176
- if defined?(EnjuOai)
177
- # OAI-PMHのデフォルトの件数
178
- oai_per_page = 200
179
- if params[:resumptionToken]
180
- token = params[:resumptionToken].split(',')
181
- if token.size == 3
182
- @cursor = token.reverse.first.to_i
183
- if @cursor <= @count[:query_result]
184
- page = (@cursor.to_i + oai_per_page).div(oai_per_page)
185
- else
186
- @oai[:errors] << 'badResumptionToken'
187
- end
188
- else
189
- @oai[:errors] << 'badResumptionToken'
190
- end
191
- end
192
- page ||= 1
193
- end
194
-
195
153
  if max_number_of_results == 0
196
154
  @max_number_of_results = count[:query_result]
197
155
  else
@@ -241,14 +199,10 @@ class ManifestationsController < ApplicationController
241
199
  end
242
200
 
243
201
  page ||= params[:page] || 1
244
- if oai_per_page and params[:format] == 'oai'
245
- per_page = 200
202
+ if params[:per_page].to_i > 0
203
+ per_page = params[:per_page].to_i
246
204
  else
247
- if params[:per_page].to_i > 0
248
- per_page = params[:per_page].to_i
249
- else
250
- per_page = Manifestation.default_per_page
251
- end
205
+ per_page = Manifestation.default_per_page
252
206
  end
253
207
  if params[:format] == 'sru'
254
208
  search.query.start_record(params[:startRecord] || 1, params[:maximumRecords] || 200)
@@ -314,20 +268,6 @@ class ManifestationsController < ApplicationController
314
268
  current_user.save_history(query, @manifestations.offset_value + 1, @count[:query_result], params[:format])
315
269
  end
316
270
  end
317
-
318
- if defined?(EnjuOai)
319
- if params[:format] == 'oai'
320
- unless @manifestations.empty?
321
- @resumption = set_resumption_token(
322
- params[:resumptionToken],
323
- @from_time || Manifestation.order(:updated_at).first.updated_at,
324
- @until_time || Manifestation.order(:updated_at).last.updated_at
325
- )
326
- else
327
- @oai[:errors] << 'noRecordsMatch'
328
- end
329
- end
330
- end
331
271
  end
332
272
 
333
273
  store_location # before_filter ではファセット検索のURLを記憶してしまう
@@ -344,23 +284,6 @@ class ManifestationsController < ApplicationController
344
284
  format.mods
345
285
  format.json { render json: @manifestations }
346
286
  format.js
347
- if defined?(EnjuOai)
348
- format.oai {
349
- case params[:verb]
350
- when 'Identify'
351
- render template: 'manifestations/identify'
352
- when 'ListMetadataFormats'
353
- render template: 'manifestations/list_metadata_formats'
354
- when 'ListSets'
355
- @series_statements = SeriesStatement.select([:id, :original_title])
356
- render template: 'manifestations/list_sets'
357
- when 'ListIdentifiers'
358
- render template: 'manifestations/list_identifiers'
359
- when 'ListRecords'
360
- render template: 'manifestations/list_records'
361
- end
362
- }
363
- end
364
287
  end
365
288
  end
366
289
 
@@ -426,7 +349,7 @@ class ManifestationsController < ApplicationController
426
349
  format.rdf
427
350
  format.mods
428
351
  format.json { render json: @manifestation }
429
- #format.atom { render template: 'manifestations/oai_ore' }
352
+ format.txt
430
353
  format.js
431
354
  format.download {
432
355
  if @manifestation.attachment.path
@@ -441,9 +364,6 @@ class ManifestationsController < ApplicationController
441
364
  render template: 'page/404', status: 404
442
365
  end
443
366
  }
444
- if defined?(EnjuOai)
445
- format.oai
446
- end
447
367
  end
448
368
  end
449
369
 
@@ -532,6 +452,7 @@ class ManifestationsController < ApplicationController
532
452
  # workaround
533
453
  @manifestation.identifiers.destroy_all
534
454
  @manifestation.creators.destroy_all
455
+ @manifestation.contributors.destroy_all
535
456
  @manifestation.publishers.destroy_all
536
457
  @manifestation.bookmarks.destroy_all if defined?(EnjuBookmark)
537
458
  @manifestation.reload
@@ -647,6 +568,10 @@ class ManifestationsController < ApplicationController
647
568
  #unless options[:subject].blank?
648
569
  # query = "#{query} subject_sm:#{options[:subject]}"
649
570
  #end
571
+ if options[:classification].present? and options[:classification_type].present?
572
+ classification_type = ClassificationType.find(options[:classification_type]).name
573
+ query = "#{query} classification_sm:#{classification_type}_#{options[:classification]}*"
574
+ end
650
575
 
651
576
  if options[:title].present?
652
577
  query = "#{query} title_text:#{options[:title]}"
@@ -21,6 +21,7 @@ class ResourceImportFilesController < ApplicationController
21
21
  file = @resource_import_file.resource_import.path
22
22
  end
23
23
  end
24
+ @resource_import_results = @resource_import_file.resource_import_results.page(params[:page])
24
25
 
25
26
  respond_to do |format|
26
27
  format.html # show.html.erb
@@ -59,19 +59,25 @@ module EnjuBiblio
59
59
  SeriesStatementMergeList
60
60
  ]
61
61
  can :manage, [
62
- AgentType,
63
62
  Country,
64
63
  Language,
65
64
  License,
66
65
  MediumOfPerformance
67
66
  ]
68
- can :manage, [
67
+ can [:destroy, :delete], [
69
68
  ContentType,
70
69
  Frequency
71
70
  ] do |record|
72
71
  record.manifestations.empty?
73
72
  end if LibraryGroup.site_config.network_access_allowed?(ip_address)
74
- can :read, [
73
+ can [:destroy, :delete], [
74
+ AgentType
75
+ ] do |record|
76
+ record.agents.empty?
77
+ end if LibraryGroup.site_config.network_access_allowed?(ip_address)
78
+ can [:create, :read, :update], [
79
+ AgentType,
80
+ AgentImportResult,
75
81
  CarrierType,
76
82
  ContentType,
77
83
  Country,
@@ -81,8 +87,6 @@ module EnjuBiblio
81
87
  Language,
82
88
  License,
83
89
  MediumOfPerformance,
84
- AgentImportResult,
85
- AgentType,
86
90
  ResourceImportResult
87
91
  ]
88
92
  when 'Librarian'
@@ -90,19 +94,25 @@ module EnjuBiblio
90
94
  can [:destroy, :delete], Item do |item|
91
95
  item.removable?
92
96
  end
93
- can :index, Manifestation
94
- can [:show, :create, :update], Manifestation
97
+ can [:index, :create], Manifestation
98
+ can [:show, :update], Manifestation do |manifestation|
99
+ manifestation.required_role_id <= 3
100
+ end
95
101
  can [:destroy, :delete], Manifestation do |manifestation|
96
- if manifestation.items.empty?
97
- if manifestation.series_master?
98
- if manifestation.children.empty?
99
- true
102
+ if manifestation.required_role_id <= 3
103
+ if manifestation.items.empty?
104
+ if manifestation.series_master?
105
+ if manifestation.children.empty?
106
+ true
107
+ else
108
+ false
109
+ end
100
110
  else
101
- false
111
+ true
102
112
  end
103
- else
104
- true
105
113
  end
114
+ else
115
+ false
106
116
  end
107
117
  end
108
118
  can [:index, :create], Agent
@@ -133,6 +143,9 @@ module EnjuBiblio
133
143
  SeriesStatementMergeList
134
144
  ]
135
145
  can :read, [
146
+ AgentType,
147
+ AgentImportResult,
148
+ AgentRelationshipType,
136
149
  CarrierType,
137
150
  ContentType,
138
151
  Country,
@@ -142,11 +155,8 @@ module EnjuBiblio
142
155
  Language,
143
156
  License,
144
157
  ManifestationRelationshipType,
145
- AgentImportResult,
146
- AgentRelationshipType,
147
- AgentType,
148
- ResourceImportResult,
149
- MediumOfPerformance
158
+ MediumOfPerformance,
159
+ ResourceImportResult
150
160
  ]
151
161
  when 'User'
152
162
  can :index, Item
@@ -46,9 +46,9 @@ class Manifestation < ActiveRecord::Base
46
46
  :statement_of_responsibility
47
47
  text :item_identifier do
48
48
  if series_master?
49
- root_series_statement.root_manifestation.items.pluck(:item_identifier)
49
+ root_series_statement.root_manifestation.items.pluck(:item_identifier) + root_series_statement.root_manifestation.items.pluck(:binding_item_identifier)
50
50
  else
51
- items.pluck(:item_identifier)
51
+ items.pluck(:item_identifier) + items.pluck(:binding_item_identifier)
52
52
  end
53
53
  end
54
54
  string :call_number, multiple: true do
@@ -100,9 +100,9 @@ class Manifestation < ActiveRecord::Base
100
100
  end
101
101
  string :item_identifier, multiple: true do
102
102
  if series_master?
103
- root_series_statement.root_manifestation.items.pluck(:item_identifier)
103
+ root_series_statement.root_manifestation.items.pluck(:item_identifier) + root_series_statement.root_manifestation.items.pluck(:binding_item_identifier)
104
104
  else
105
- items.collect(&:item_identifier)
105
+ items.pluck(:item_identifier) + items.pluck(:binding_item_identifier)
106
106
  end
107
107
  end
108
108
  string :shelf, multiple: true do
@@ -532,20 +532,34 @@ class Manifestation < ActiveRecord::Base
532
532
  creator
533
533
  publisher
534
534
  pub_date
535
- price
536
- isbn
537
- issn
535
+ manifestation_price
536
+ manifestation_created_at
537
+ manifestation_updated_at
538
+ manifestation_identifier
539
+ )
540
+ identifiers = {}
541
+ Identifier.find_each do |identifier|
542
+ identifiers[identifier.identifier_type.name] = true
543
+ end
544
+ identifiers = identifiers.keys.sort
545
+ header += identifiers
546
+ header += %w(
547
+ item_id
538
548
  item_identifier
539
549
  call_number
540
550
  item_price
541
551
  acquired_at
552
+ accepted_at
542
553
  bookstore
543
554
  budget_type
544
555
  circulation_status
545
556
  shelf
546
557
  library
547
- ).join("\t")
558
+ item_created_at
559
+ item_updated_at
560
+ )
548
561
  lines = []
562
+ lines << header
549
563
  Manifestation.includes(:items, :identifiers => :identifier_type).find_each do |m|
550
564
  if m.items.exists?
551
565
  m.items.includes(:shelf => :library).each do |i|
@@ -556,17 +570,25 @@ class Manifestation < ActiveRecord::Base
556
570
  item_lines << m.publishers.pluck(:full_name).join("//")
557
571
  item_lines << m.pub_date
558
572
  item_lines << m.price
559
- item_lines << m.identifier_contents(:isbn).first
560
- item_lines << m.identifier_contents(:issn).first
573
+ item_lines << m.created_at
574
+ item_lines << m.updated_at
575
+ item_lines << m.manifestation_identifier
576
+ identifiers.each do |identifier_type|
577
+ item_lines << m.identifier_contents(identifier_type.to_sym).first
578
+ end
579
+ item_lines << i.id
561
580
  item_lines << i.item_identifier
562
581
  item_lines << i.call_number
563
582
  item_lines << i.price
564
583
  item_lines << i.acquired_at
584
+ item_lines << i.accept.try(:created_at)
565
585
  item_lines << i.bookstore.try(:name)
566
586
  item_lines << i.budget_type.try(:name)
567
587
  item_lines << i.circulation_status.try(:name)
568
588
  item_lines << i.shelf.name
569
589
  item_lines << i.shelf.library.name
590
+ item_lines << i.created_at
591
+ item_lines << i.updated_at
570
592
  lines << item_lines
571
593
  end
572
594
  else
@@ -577,7 +599,12 @@ class Manifestation < ActiveRecord::Base
577
599
  line << m.publishers.pluck(:full_name).join("//")
578
600
  line << m.pub_date
579
601
  line << m.price
580
- line << m.identifier_contents(:isbn).first
602
+ line << m.created_at
603
+ line << m.updated_at
604
+ line << m.manifestation_identifier
605
+ identifiers.each do |identifier_type|
606
+ line << m.identifier_contents(identifier_type.to_sym).first
607
+ end
581
608
  lines << line
582
609
  end
583
610
  end
@@ -127,15 +127,28 @@ class ResourceImportFile < ActiveRecord::Base
127
127
  end
128
128
 
129
129
  unless manifestation
130
- if row['isbn'].present?
131
- isbn = StdNum::ISBN.normalize(row['isbn'])
132
- identifier_type_isbn = IdentifierType.where(name: 'isbn').first
133
- identifier_type_isbn = IdentifierType.where(name: 'isbn').create! unless identifier_type_isbn
134
- m = Identifier.where(body: isbn, identifier_type_id: identifier_type_isbn.id).first.try(:manifestation)
130
+ if row['ncid'].present?
131
+ ncid = row['ncid'].to_s.strip
132
+ identifier_type_ncid = IdentifierType.where(name: 'ncid').first
133
+ identifier_type_ncid = IdentifierType.where(name: 'ncid').create! unless identifier_type_ncid
134
+ manifestation = Identifier.where(body: ncid, identifier_type_id: identifier_type_ncid.id).first.try(:manifestation)
135
135
  end
136
- if m
137
- if m.series_statements.exists?
138
- manifestation = m
136
+ end
137
+
138
+ unless manifestation
139
+ if row['isbn'].present?
140
+ if StdNum::ISBN.valid?(row['isbn'])
141
+ isbn = StdNum::ISBN.normalize(row['isbn'])
142
+ identifier_type_isbn = IdentifierType.where(name: 'isbn').first
143
+ identifier_type_isbn = IdentifierType.where(name: 'isbn').create! unless identifier_type_isbn
144
+ m = Identifier.where(body: isbn, identifier_type_id: identifier_type_isbn.id).first.try(:manifestation)
145
+ if m
146
+ if m.series_statements.exists?
147
+ manifestation = m
148
+ end
149
+ end
150
+ else
151
+ import_result.error_message = "line #{row_num}: #{I18n.t('import.isbn_invalid')}"
139
152
  end
140
153
  end
141
154
  end
@@ -154,8 +167,10 @@ class ResourceImportFile < ActiveRecord::Base
154
167
  end
155
168
  rescue EnjuNdl::InvalidIsbn
156
169
  manifestation = nil
170
+ import_result.error_message = "line #{row_num}: #{I18n.t('import.isbn_invalid')}"
157
171
  rescue EnjuNdl::RecordNotFound
158
172
  manifestation = nil
173
+ import_result.error_message = "line #{row_num}: #{I18n.t('import.isbn_record_not_found')}"
159
174
  end
160
175
  end
161
176
  end
@@ -168,7 +183,6 @@ class ResourceImportFile < ActiveRecord::Base
168
183
 
169
184
  if manifestation && item_identifier.present?
170
185
  import_result.item = create_item(row, manifestation)
171
- manifestation.index
172
186
  else
173
187
  if manifestation.try(:fulltext_content?)
174
188
  item = Item.new
@@ -285,8 +299,10 @@ class ResourceImportFile < ActiveRecord::Base
285
299
  rows.shift
286
300
  row_num = 1
287
301
 
302
+ ResourceImportResult.create!(resource_import_file_id: id, body: rows.headers.join("\t"))
288
303
  rows.each do |row|
289
304
  row_num += 1
305
+ import_result = ResourceImportResult.create!(resource_import_file_id: id, body: row.fields.join("\t"))
290
306
  item_identifier = row['item_identifier'].to_s.strip
291
307
  item = Item.where(item_identifier: item_identifier).first if item_identifier.present?
292
308
  if item
@@ -317,7 +333,9 @@ class ResourceImportFile < ActiveRecord::Base
317
333
  binding_item_identifier binding_call_number binded_at
318
334
  )
319
335
  item_columns.each do |column|
320
- item.assign_attributes(:"#{column}" => row[column])
336
+ if row[column].present?
337
+ item.assign_attributes(:"#{column}" => row[column])
338
+ end
321
339
  end
322
340
 
323
341
  item.price = row['item_price'] if row['item_price'].present?
@@ -332,6 +350,7 @@ class ResourceImportFile < ActiveRecord::Base
332
350
  end
333
351
  end
334
352
  item.save!
353
+ import_result.item = item
335
354
  else
336
355
  manifestation_identifier = row['manifestation_identifier'].to_s.strip
337
356
  manifestation = Manifestation.where(manifestation_identifier: manifestation_identifier).first if manifestation_identifier.present?
@@ -340,8 +359,10 @@ class ResourceImportFile < ActiveRecord::Base
340
359
  end
341
360
  if manifestation
342
361
  fetch(row, edit_mode: 'update')
362
+ import_result.manifestation = manifestation
343
363
  end
344
364
  end
365
+ import_result.save!
345
366
  end
346
367
  transition_to!(:completed)
347
368
  rescue => e
@@ -424,6 +445,7 @@ class ResourceImportFile < ActiveRecord::Base
424
445
  width height depth number_of_pages jpno lccn budget_type bookstore
425
446
  language fulltext_content required_role doi content_type frequency
426
447
  extent start_page end_page dimensions
448
+ ncid
427
449
  statement_of_responsibility acquired_at call_number circulation_status
428
450
  binding_item_identifier binding_call_number binded_at item_price
429
451
  use_restriction include_supplements item_note item_url
@@ -517,7 +539,7 @@ class ResourceImportFile < ActiveRecord::Base
517
539
  url: row['item_url'],
518
540
  note: row['item_note']
519
541
  )
520
- item.manifestation = manifestation
542
+ manifestation.items << item
521
543
  if defined?(EnjuCirculation)
522
544
  circulation_status = CirculationStatus.where(name: row['circulation_status'].to_s.strip).first || CirculationStatus.where(name: 'In Process').first
523
545
  item.circulation_status = circulation_status
@@ -535,6 +557,7 @@ class ResourceImportFile < ActiveRecord::Base
535
557
  if %w(t true).include?(row['include_supplements'].to_s.downcase.strip)
536
558
  item.include_supplements = true
537
559
  end
560
+ item.save!
538
561
  item
539
562
  end
540
563
 
@@ -737,7 +760,7 @@ class ResourceImportFile < ActiveRecord::Base
737
760
 
738
761
  def set_identifier(row)
739
762
  identifier = {}
740
- %w(isbn issn doi jpno).each do |id_type|
763
+ %w(isbn issn doi jpno ncid).each do |id_type|
741
764
  if row["#{id_type}"].present?
742
765
  import_id = Identifier.new(body: row["#{id_type}"])
743
766
  identifier_type = IdentifierType.where(name: id_type).first
@@ -14,6 +14,6 @@ class ResourceImportFileStateMachine
14
14
  end
15
15
 
16
16
  before_transition(from: :started, to: :completed) do |resource_import_file|
17
- resource_import_file.error_message = nil
17
+ #resource_import_file.error_message = nil
18
18
  end
19
19
  end
@@ -1,4 +1,5 @@
1
- <%= form_for(@agent_type) do |f| %>
1
+ <%= render 'page/required_field' %>
2
+ <%= simple_form_for(@agent_type) do |f| %>
2
3
  <%= f.error_messages %>
3
4
 
4
5
  <div class="field">
@@ -19,7 +19,7 @@
19
19
  <%= f.text_field :full_name, class: 'resource_title' -%><br />
20
20
  <%= f.label :full_name_transcription -%><br />
21
21
  <%= f.text_field :full_name_transcription, class: 'resource_title' -%><br />
22
- <%= link_to "#", { onclick: "$('#full_name_alternative').toggle(); return false;"} do t('activerecord.attributes.agent.full_name_alternative') end %>)
22
+ <%= link_to "#", { onclick: "$('#full_name_alternative').toggle(); return false;"} do t('activerecord.attributes.agent.full_name_alternative') end %>
23
23
  <span id="full_name_alternative" style="display: none">
24
24
  <br />
25
25
  <%= f.text_area :full_name_alternative, class: 'resource_textarea' -%>
@@ -21,7 +21,7 @@
21
21
  <ul>
22
22
  <li><%= link_to t('page.back'), :back -%></li>
23
23
  <li><%= link_to t('page.listing', model: t('activerecord.models.import_request')), import_requests_path -%></li>
24
- <li><%= link_to t('manifestation.add'), new_manifestation_path -%></li>
25
- <li><%= link_to t('page.import_from_file'), page_import_path -%></li>
24
+ <li><%= link_to t('page.add_resource_manually'), new_manifestation_path -%></li>
25
+ <li><%= link_to t('page.import_from_file'), new_resource_import_file_path -%></li>
26
26
  </ul>
27
27
  </div>
@@ -1,3 +1,10 @@
1
+ <%= render 'manifestations/title', manifestation: @item.manifestation -%>
2
+ <p>
3
+ <%= t('activerecord.models.classification') -%>:
4
+ <%- @item.manifestation.classifications.each do |classification| -%>
5
+ <%= link_to "#{classification.classification_type.display_name.localize}: #{classification.category}", manifestations_path(query: "classification_sm:#{classification.classification_type.name}_#{classification.category}") -%>
6
+ <%- end -%>
7
+ </p>
1
8
  <%= render 'page/required_field' %>
2
9
  <%= simple_form_for(@item) do |f| -%>
3
10
  <%= f.error_messages -%>
@@ -1,7 +1,6 @@
1
1
  <div id="content_detail" class="ui-corner-all ui-widget-content">
2
2
  <h1 class="title"><%= t('page.editing', model: t('activerecord.models.item')) -%></h1>
3
3
  <div id="content_list">
4
- <%= render 'manifestations/title', manifestation: @item.manifestation -%>
5
4
  <%= render 'form' %>
6
5
  </div>
7
6
  </div>
@@ -1,7 +1,6 @@
1
1
  <div id="content_detail" class="ui-corner-all ui-widget-content">
2
2
  <h1 class="title"><%= t('page.new', model: t('activerecord.models.item')) -%></h1>
3
3
  <div id="content_list">
4
- <%= render 'manifestations/title', manifestation: @manifestation if @manifestation -%>
5
4
  <%= render 'form' %>
6
5
  </div>
7
6
  </div>
@@ -0,0 +1,5 @@
1
+ <script>
2
+ $(document).ready(function(){
3
+ $('a[rel="manifestation_<%= @manifestation.id -%>"]').colorbox({transition:"none", photo:true});
4
+ })
5
+ </script>
@@ -0,0 +1,7 @@
1
+ <h4><%= t('page.other_format') %></h4>
2
+
3
+ <ul>
4
+ <li><%= link_to 'RDF/XML', manifestation_url(@manifestation, format: :rdf) %></li>
5
+ <li><%= link_to 'MODS', manifestation_url(@manifestation, format: :mods) %></li>
6
+ <li><%= link_to 'TSV', manifestation_url(@manifestation, format: :txt) %></li>
7
+ </ul>
@@ -0,0 +1,6 @@
1
+ <h4><%= t('page.other_format') %></h4>
2
+ <ul>
3
+ <li><%= link_to 'RDF/XML', url_for(params.merge(format: :rdf, only_path: true)) %>
4
+ <li><%= link_to 'MODS', url_for(params.merge(format: :mods, only_path: true)) %></li>
5
+ <li><%= link_to 'TSV', url_for(params.merge(format: :txt, only_path: true)) %></li>
6
+ </ul>
@@ -0,0 +1 @@
1
+ <%= manifestation.manifestation_identifier %> "<%=raw manifestation.original_title.gsub(/"/, '""') -%>" <%=raw manifestation.creators.pluck(:full_name).join('; ') -%> <%=raw manifestation.publishers.pluck(:full_name).join('; ') -%> <%= manifestation.identifier_contents(:isbn) -%> <%= manifestation.pub_date -%> <%= manifestation.note -%><%= "\n" -%>
@@ -95,6 +95,7 @@
95
95
  <%= link_to((image_tag 'icons/feed.png', size: '16x16', alt: t('page.feed'), class: 'icon'), url_for(params.merge(format: :rss, page: nil, only_path: true))) -%> <%= link_to t('page.search_result_feed'), url_for(params.merge(format: :rss, page: nil, commit: nil, only_path: true)) -%>
96
96
  <%- end -%>
97
97
  </div>
98
+ <%= render 'manifestations/export_list' %>
98
99
  </div>
99
100
 
100
101
  <% if defined?(EnjuBookmark) %>
@@ -1,4 +1,2 @@
1
- manifestation_identifier original_title creator publisher isbn pub_date note
2
- <%- @manifestations.each do |manifestation| -%>
3
- <%= manifestation.manifestation_identifier %> "<%=raw manifestation.original_title.gsub(/"/, '""') -%>" <%=raw manifestation.creators.pluck(:full_name).join('; ') -%> <%=raw manifestation.publishers.pluck(:full_name).join('; ') -%> <%= manifestation.identifier_contents(:isbn) -%> <%= manifestation.pub_date -%> <%= manifestation.note -%><%= "\n" -%>
4
- <%- end -%>
1
+ manifestation_identifier original_title creator publisher isbn pub_date note
2
+ <%= render @manifestations %>