enju_biblio 0.3.9 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/content_types_controller.rb +1 -1
- data/app/controllers/item_custom_properties_controller.rb +69 -0
- data/app/controllers/items_controller.rb +3 -0
- data/app/controllers/manifestation_custom_properties_controller.rb +69 -0
- data/app/controllers/manifestations_controller.rb +9 -6
- data/app/controllers/resource_import_results_controller.rb +6 -2
- data/app/models/agent_type.rb +0 -1
- data/app/models/carrier_type.rb +0 -1
- data/app/models/content_type.rb +0 -1
- data/app/models/form_of_work.rb +1 -2
- data/app/models/frequency.rb +0 -1
- data/app/models/identifier_type.rb +0 -1
- data/app/models/item.rb +17 -6
- data/app/models/item_custom_property.rb +18 -0
- data/app/models/item_custom_value.rb +17 -0
- data/app/models/license.rb +0 -1
- data/app/models/manifestation.rb +55 -11
- data/app/models/manifestation_custom_property.rb +18 -0
- data/app/models/manifestation_custom_value.rb +17 -0
- data/app/models/medium_of_performance.rb +1 -2
- data/app/models/picture_file.rb +0 -2
- data/app/models/resource_export_file.rb +4 -2
- data/app/models/resource_import_file.rb +151 -61
- data/app/policies/item_custom_property_policy.rb +21 -0
- data/app/policies/manifestation_custom_property_policy.rb +21 -0
- data/app/views/item_custom_properties/_form.html.erb +32 -0
- data/app/views/item_custom_properties/edit.html.erb +13 -0
- data/app/views/item_custom_properties/index.html.erb +43 -0
- data/app/views/item_custom_properties/new.html.erb +12 -0
- data/app/views/item_custom_properties/show.html.erb +28 -0
- data/app/views/items/_form.html.erb +13 -0
- data/app/views/items/show.html.erb +6 -0
- data/app/views/manifestation_custom_properties/_form.html.erb +32 -0
- data/app/views/manifestation_custom_properties/edit.html.erb +13 -0
- data/app/views/manifestation_custom_properties/index.html.erb +43 -0
- data/app/views/manifestation_custom_properties/new.html.erb +12 -0
- data/app/views/manifestation_custom_properties/show.html.erb +28 -0
- data/app/views/manifestations/_export_detail.html.erb +1 -0
- data/app/views/manifestations/_export_list.html.erb +1 -0
- data/app/views/manifestations/_form.html.erb +18 -0
- data/app/views/manifestations/_show_detail_librarian.html.erb +14 -0
- data/app/views/manifestations/_show_detail_user.html.erb +8 -0
- data/app/views/manifestations/show.json.jbuilder +2 -0
- data/app/views/picture_files/edit.html.erb +4 -0
- data/config/locales/translation_en.yml +22 -8
- data/config/locales/translation_ja.yml +22 -8
- data/config/routes.rb +2 -0
- data/db/migrate/20081027150907_create_picture_files.rb +0 -2
- data/db/migrate/20200425072340_create_manifestation_custom_properties.rb +12 -0
- data/db/migrate/20200425072349_create_item_custom_properties.rb +12 -0
- data/db/migrate/20200425074758_create_manifestation_custom_values.rb +12 -0
- data/db/migrate/20200425074822_create_item_custom_values.rb +12 -0
- data/lib/enju_biblio/openurl.rb +5 -1
- data/lib/enju_biblio/sru.rb +2 -0
- data/lib/enju_biblio/version.rb +1 -1
- data/spec/cassette_library/ResourceImportFile/when_its_mode_is_create_/when_it_is_written_in_utf-8/should_import_custom_values.yml +121 -0
- data/spec/cassette_library/resource_import_results/index_txt_ruby/renders_a_list_of_resource_import_results.yml +121 -0
- data/spec/controllers/content_types_controller_spec.rb +1 -1
- data/spec/controllers/item_custom_properties_controller_spec.rb +449 -0
- data/spec/controllers/items_controller_spec.rb +22 -0
- data/spec/controllers/manifestation_custom_properties_controller_spec.rb +449 -0
- data/spec/controllers/manifestations_controller_spec.rb +22 -0
- data/spec/dummy/db/schema.rb +43 -23
- data/spec/factories/item_custom_property.rb +6 -0
- data/spec/factories/item_custom_value.rb +6 -0
- data/spec/factories/manifestation_custom_property.rb +6 -0
- data/spec/factories/manifestation_custom_value.rb +6 -0
- data/spec/fixtures/creates.yml +2 -0
- data/spec/fixtures/item_custom_properties.yml +24 -0
- data/spec/fixtures/library_groups.yml +0 -2
- data/spec/fixtures/manifestation_custom_properties.yml +24 -0
- data/spec/fixtures/picture_files.yml +0 -2
- data/spec/fixtures/produces.yml +2 -0
- data/spec/fixtures/realizes.yml +2 -0
- data/spec/models/item_custom_property_spec.rb +18 -0
- data/spec/models/item_custom_value_spec.rb +17 -0
- data/spec/models/manifestation_custom_property_spec.rb +18 -0
- data/spec/models/manifestation_custom_value_spec.rb +17 -0
- data/spec/models/manifestation_spec.rb +16 -1
- data/spec/models/picture_file_spec.rb +0 -2
- data/spec/models/resource_export_file_spec.rb +61 -8
- data/spec/models/resource_import_file_spec.rb +43 -13
- data/spec/requests/item_custom_properties_spec.rb +129 -0
- data/spec/requests/manifestation_custom_properties_spec.rb +129 -0
- data/spec/routing/item_custom_properties_routing_spec.rb +38 -0
- data/spec/routing/manifestation_custom_properties_routing_spec.rb +38 -0
- data/spec/system/items_spec.rb +12 -0
- data/spec/system/manifestations_spec.rb +12 -0
- data/spec/views/item_custom_properties/edit.html.erb_spec.rb +21 -0
- data/spec/views/item_custom_properties/index.html.erb_spec.rb +25 -0
- data/spec/views/item_custom_properties/new.html.erb_spec.rb +21 -0
- data/spec/views/item_custom_properties/show.html.erb_spec.rb +16 -0
- data/spec/views/manifestation_custom_properties/edit.html.erb_spec.rb +21 -0
- data/spec/views/manifestation_custom_properties/index.html.erb_spec.rb +25 -0
- data/spec/views/manifestation_custom_properties/new.html.erb_spec.rb +21 -0
- data/spec/views/manifestation_custom_properties/show.html.erb_spec.rb +16 -0
- data/spec/views/manifestations/show.json.jbuilder_spec.rb +16 -0
- data/spec/views/resource_import_results/index.txt.ruby_spec.rb +4 -4
- metadata +560 -481
- data/db/migrate/20200322053443_add_default_custom_label_to_library_group.rb +0 -6
- data/db/migrate/20200322083313_create_custom_labels.rb +0 -10
- data/db/migrate/20200322083458_create_custom_properties.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ddb2060da09b931f698c95fe7183cea10953bb55d708d79cf118311af367c2b
|
4
|
+
data.tar.gz: de17c215f560054db264c931878c2a1ff2fd3ed0811911fb2feab4384afd03a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c577988123593c8b17f9cbe904492a4f148fb51d98f8294e863e639375303c9901a4fe8a67e3c471d1e406ab98399d86d6bd1b4bd6723ed547e2118f43c165a2
|
7
|
+
data.tar.gz: 6e65d6634be373354842dee7cf6fb8c6dd2e3b9683185b8ffbc5246e45061fe20e7f4c6566d24118a823598c439939ec7036bda2c9fc48e6eb82da6f3e187498
|
@@ -0,0 +1,69 @@
|
|
1
|
+
class ItemCustomPropertiesController < ApplicationController
|
2
|
+
before_action :set_item_custom_property, only: [:show, :edit, :update, :destroy]
|
3
|
+
before_action :check_policy, only: [:index, :new, :create ]
|
4
|
+
|
5
|
+
# GET /item_custom_properties
|
6
|
+
def index
|
7
|
+
@item_custom_properties = ItemCustomProperty.order(:position)
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /item_custom_properties/1
|
11
|
+
def show
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /item_custom_properties/new
|
15
|
+
def new
|
16
|
+
@item_custom_property = ItemCustomProperty.new
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /item_custom_properties/1/edit
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST /item_custom_properties
|
24
|
+
def create
|
25
|
+
@item_custom_property = ItemCustomProperty.new(item_custom_property_params)
|
26
|
+
|
27
|
+
if @item_custom_property.save
|
28
|
+
redirect_to @item_custom_property, notice: t('controller.successfully_created', model: t('activerecord.models.item_custom_property'))
|
29
|
+
else
|
30
|
+
render :new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# PATCH/PUT /item_custom_properties/1
|
35
|
+
def update
|
36
|
+
if params[:move]
|
37
|
+
move_position(@item_custom_property, params[:move])
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
if @item_custom_property.update(item_custom_property_params)
|
42
|
+
redirect_to @item_custom_property, notice: t('controller.successfully_updated', model: t('activerecord.models.item_custom_property'))
|
43
|
+
else
|
44
|
+
render :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# DELETE /item_custom_properties/1
|
49
|
+
def destroy
|
50
|
+
@item_custom_property.destroy
|
51
|
+
redirect_to item_custom_properties_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.item_custom_property'))
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
# Use callbacks to share common setup or constraints between actions.
|
56
|
+
def set_item_custom_property
|
57
|
+
@item_custom_property = ItemCustomProperty.find(params[:id])
|
58
|
+
authorize @item_custom_property
|
59
|
+
end
|
60
|
+
|
61
|
+
def check_policy
|
62
|
+
authorize ItemCustomProperty
|
63
|
+
end
|
64
|
+
|
65
|
+
# Only allow a trusted parameter "white list" through.
|
66
|
+
def item_custom_property_params
|
67
|
+
params.require(:item_custom_property).permit(:name, :display_name, :note)
|
68
|
+
end
|
69
|
+
end
|
@@ -274,6 +274,9 @@ class ItemsController < ApplicationController
|
|
274
274
|
:binding_item_identifier, :binding_call_number, :binded_at,
|
275
275
|
:use_restriction_id, :memo,
|
276
276
|
{item_has_use_restriction_attributes: :use_restriction_id}, # EnjuCirculation
|
277
|
+
{item_custom_values_attributes: [
|
278
|
+
:id, :item_custom_property_id, :item_id, :value,:_destroy
|
279
|
+
]}
|
277
280
|
)
|
278
281
|
end
|
279
282
|
|
@@ -0,0 +1,69 @@
|
|
1
|
+
class ManifestationCustomPropertiesController < ApplicationController
|
2
|
+
before_action :set_manifestation_custom_property, only: [:show, :edit, :update, :destroy]
|
3
|
+
before_action :check_policy, only: [:index, :new, :create ]
|
4
|
+
|
5
|
+
# GET /manifestation_custom_properties
|
6
|
+
def index
|
7
|
+
@manifestation_custom_properties = ManifestationCustomProperty.order(:position)
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /manifestation_custom_properties/1
|
11
|
+
def show
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /manifestation_custom_properties/new
|
15
|
+
def new
|
16
|
+
@manifestation_custom_property = ManifestationCustomProperty.new
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /manifestation_custom_properties/1/edit
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST /manifestation_custom_properties
|
24
|
+
def create
|
25
|
+
@manifestation_custom_property = ManifestationCustomProperty.new(manifestation_custom_property_params)
|
26
|
+
|
27
|
+
if @manifestation_custom_property.save
|
28
|
+
redirect_to @manifestation_custom_property, notice: t('controller.successfully_created', model: t('activerecord.models.manifestation_custom_property'))
|
29
|
+
else
|
30
|
+
render :new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# PATCH/PUT /manifestation_custom_properties/1
|
35
|
+
def update
|
36
|
+
if params[:move]
|
37
|
+
move_position(@manifestation_custom_property, params[:move])
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
if @manifestation_custom_property.update(manifestation_custom_property_params)
|
42
|
+
redirect_to @manifestation_custom_property, notice: t('controller.successfully_updated', model: t('activerecord.models.manifestation_custom_property'))
|
43
|
+
else
|
44
|
+
render :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# DELETE /manifestation_custom_properties/1
|
49
|
+
def destroy
|
50
|
+
@manifestation_custom_property.destroy
|
51
|
+
redirect_to manifestation_custom_properties_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.manifestation_custom_property'))
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
# Use callbacks to share common setup or constraints between actions.
|
56
|
+
def set_manifestation_custom_property
|
57
|
+
@manifestation_custom_property = ManifestationCustomProperty.find(params[:id])
|
58
|
+
authorize @manifestation_custom_property
|
59
|
+
end
|
60
|
+
|
61
|
+
def check_policy
|
62
|
+
authorize ManifestationCustomProperty
|
63
|
+
end
|
64
|
+
|
65
|
+
# Only allow a trusted parameter "white list" through.
|
66
|
+
def manifestation_custom_property_params
|
67
|
+
params.require(:manifestation_custom_property).permit(:name, :display_name, :note)
|
68
|
+
end
|
69
|
+
end
|
@@ -332,7 +332,7 @@ class ManifestationsController < ApplicationController
|
|
332
332
|
}
|
333
333
|
format.rdf
|
334
334
|
format.mods
|
335
|
-
format.json
|
335
|
+
format.json
|
336
336
|
format.txt
|
337
337
|
format.js
|
338
338
|
format.download {
|
@@ -549,6 +549,9 @@ class ManifestationsController < ApplicationController
|
|
549
549
|
{identifiers_attributes: [
|
550
550
|
:id, :body, :identifier_type_id,
|
551
551
|
:_destroy
|
552
|
+
]},
|
553
|
+
{manifestation_custom_values_attributes: [
|
554
|
+
:id, :manifestation_custom_property_id, :manifestation_id, :value,:_destroy
|
552
555
|
]}
|
553
556
|
)
|
554
557
|
end
|
@@ -734,12 +737,12 @@ class ManifestationsController < ApplicationController
|
|
734
737
|
end
|
735
738
|
|
736
739
|
def prepare_options
|
737
|
-
@carrier_types = CarrierType.select([:id, :display_name, :position])
|
738
|
-
@content_types = ContentType.select([:id, :display_name, :position])
|
740
|
+
@carrier_types = CarrierType.order(:position).select([:id, :display_name, :position])
|
741
|
+
@content_types = ContentType.order(:position).select([:id, :display_name, :position])
|
739
742
|
@roles = Role.select([:id, :display_name, :position])
|
740
|
-
@languages = Language.select([:id, :display_name, :position])
|
741
|
-
@frequencies = Frequency.select([:id, :display_name, :position])
|
742
|
-
@identifier_types = IdentifierType.select([:id, :display_name, :position])
|
743
|
+
@languages = Language.order(:position).select([:id, :display_name, :position])
|
744
|
+
@frequencies = Frequency.order(:position).select([:id, :display_name, :position])
|
745
|
+
@identifier_types = IdentifierType.order(:position).select([:id, :display_name, :position])
|
743
746
|
@nii_types = NiiType.select([:id, :display_name, :position]) if defined?(EnjuNii)
|
744
747
|
if defined?(EnjuSubject)
|
745
748
|
@subject_types = SubjectType.select([:id, :display_name, :position])
|
@@ -5,9 +5,13 @@ class ResourceImportResultsController < ApplicationController
|
|
5
5
|
# GET /resource_import_results
|
6
6
|
# GET /resource_import_results.json
|
7
7
|
def index
|
8
|
-
@resource_import_file = ResourceImportFile.
|
8
|
+
@resource_import_file = ResourceImportFile.find_by(id: params[:resource_import_file_id])
|
9
9
|
if @resource_import_file
|
10
|
-
|
10
|
+
if params[:format].to_s.downcase == 'txt'
|
11
|
+
@resource_import_results = @resource_import_file.resource_import_results
|
12
|
+
else
|
13
|
+
@resource_import_results = @resource_import_file.resource_import_results.page(params[:page])
|
14
|
+
end
|
11
15
|
else
|
12
16
|
@resource_import_results = ResourceImportResult.page(params[:page])
|
13
17
|
end
|
data/app/models/agent_type.rb
CHANGED
data/app/models/carrier_type.rb
CHANGED
data/app/models/content_type.rb
CHANGED
data/app/models/form_of_work.rb
CHANGED
data/app/models/frequency.rb
CHANGED
data/app/models/item.rb
CHANGED
@@ -19,10 +19,12 @@ class Item < ApplicationRecord
|
|
19
19
|
belongs_to :budget_type, optional: true
|
20
20
|
has_one :accept, dependent: :destroy
|
21
21
|
has_one :withdraw, dependent: :destroy
|
22
|
-
|
22
|
+
has_many :item_custom_values, -> { joins(:item_custom_property).order(:position) }
|
23
23
|
|
24
24
|
belongs_to :shelf, counter_cache: true
|
25
|
+
accepts_nested_attributes_for :item_custom_values, reject_if: :all_blank
|
25
26
|
|
27
|
+
scope :accepted_between, lambda{|from, to| includes(:accept).where('items.created_at BETWEEN ? AND ?', Time.zone.parse(from).beginning_of_day, Time.zone.parse(to).end_of_day)}
|
26
28
|
validates_associated :bookstore
|
27
29
|
validates :manifestation_id, presence: true
|
28
30
|
validates :item_identifier, allow_blank: true, uniqueness: true,
|
@@ -105,10 +107,11 @@ class Item < ApplicationRecord
|
|
105
107
|
record = {
|
106
108
|
item_id: id,
|
107
109
|
item_identifier: item_identifier,
|
110
|
+
binding_item_identifier: binding_item_identifier,
|
108
111
|
call_number: call_number,
|
109
|
-
shelf: shelf
|
112
|
+
shelf: shelf&.name,
|
110
113
|
item_note: note,
|
111
|
-
accepted_at: accept
|
114
|
+
accepted_at: accept&.created_at,
|
112
115
|
acquired_at: acquired_at,
|
113
116
|
item_created_at: created_at,
|
114
117
|
item_updated_at: updated_at
|
@@ -116,15 +119,23 @@ class Item < ApplicationRecord
|
|
116
119
|
|
117
120
|
if ['Administrator', 'Librarian'].include?(role)
|
118
121
|
record.merge!({
|
119
|
-
bookstore: bookstore
|
120
|
-
budget_type: budget_type
|
122
|
+
bookstore: bookstore&.name,
|
123
|
+
budget_type: budget_type&.name,
|
124
|
+
item_required_role: required_role.name,
|
121
125
|
item_price: price,
|
122
126
|
memo: memo
|
123
127
|
})
|
124
128
|
|
129
|
+
ItemCustomProperty.order(:position).each do |custom_property|
|
130
|
+
custom_value = item_custom_values.find_by(item_custom_property: custom_property)
|
131
|
+
record[:"item:#{custom_property.name}"] = custom_value.try(:value)
|
132
|
+
end
|
133
|
+
|
125
134
|
if defined?(EnjuCirculation)
|
126
135
|
record.merge!({
|
127
|
-
use_restriction: use_restriction
|
136
|
+
use_restriction: use_restriction&.name,
|
137
|
+
circulation_status: circulation_status&.name,
|
138
|
+
checkout_type: checkout_type&.name,
|
128
139
|
total_checkouts: checkouts.count
|
129
140
|
})
|
130
141
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ItemCustomProperty < ApplicationRecord
|
2
|
+
include MasterModel
|
3
|
+
validates :name, presence: true, uniqueness: true
|
4
|
+
acts_as_list
|
5
|
+
end
|
6
|
+
|
7
|
+
# == Schema Information
|
8
|
+
#
|
9
|
+
# Table name: item_custom_properties
|
10
|
+
#
|
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
|
+
#
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class ItemCustomValue < ApplicationRecord
|
2
|
+
belongs_to :item_custom_property
|
3
|
+
belongs_to :item, required: false
|
4
|
+
validates :item_custom_property, uniqueness: {scope: :item_id}
|
5
|
+
end
|
6
|
+
|
7
|
+
# == Schema Information
|
8
|
+
#
|
9
|
+
# Table name: item_custom_values
|
10
|
+
#
|
11
|
+
# id :integer not null, primary key
|
12
|
+
# item_custom_property_id :integer not null
|
13
|
+
# item_id :integer not null
|
14
|
+
# value :text
|
15
|
+
# created_at :datetime not null
|
16
|
+
# updated_at :datetime not null
|
17
|
+
#
|
data/app/models/license.rb
CHANGED
data/app/models/manifestation.rb
CHANGED
@@ -25,11 +25,13 @@ class Manifestation < ApplicationRecord
|
|
25
25
|
belongs_to :required_role, class_name: 'Role', foreign_key: 'required_role_id'
|
26
26
|
has_one :resource_import_result
|
27
27
|
has_many :identifiers, dependent: :destroy
|
28
|
+
has_many :manifestation_custom_values, -> { joins(:manifestation_custom_property).order(:position) }
|
28
29
|
accepts_nested_attributes_for :creators, allow_destroy: true, reject_if: :all_blank
|
29
30
|
accepts_nested_attributes_for :contributors, allow_destroy: true, reject_if: :all_blank
|
30
31
|
accepts_nested_attributes_for :publishers, allow_destroy: true, reject_if: :all_blank
|
31
32
|
accepts_nested_attributes_for :series_statements, allow_destroy: true, reject_if: :all_blank
|
32
33
|
accepts_nested_attributes_for :identifiers, allow_destroy: true, reject_if: :all_blank
|
34
|
+
accepts_nested_attributes_for :manifestation_custom_values, reject_if: :all_blank
|
33
35
|
|
34
36
|
searchable do
|
35
37
|
text :title, default_boost: 2 do
|
@@ -94,7 +96,7 @@ class Manifestation < ApplicationRecord
|
|
94
96
|
end
|
95
97
|
end
|
96
98
|
string :language do
|
97
|
-
language
|
99
|
+
language&.name
|
98
100
|
end
|
99
101
|
string :item_identifier, multiple: true do
|
100
102
|
if series_master?
|
@@ -118,7 +120,7 @@ class Manifestation < ApplicationRecord
|
|
118
120
|
end
|
119
121
|
time :date_of_publication
|
120
122
|
integer :pub_year do
|
121
|
-
date_of_publication
|
123
|
+
date_of_publication&.year
|
122
124
|
end
|
123
125
|
integer :creator_ids, multiple: true
|
124
126
|
integer :contributor_ids, multiple: true
|
@@ -355,7 +357,7 @@ class Manifestation < ApplicationRecord
|
|
355
357
|
# TODO: よりよい推薦方法
|
356
358
|
def self.pickup(keyword = nil, current_user = nil)
|
357
359
|
return nil if self.cached_numdocs < 5
|
358
|
-
if current_user
|
360
|
+
if current_user&.role
|
359
361
|
current_role_id = current_user.role.id
|
360
362
|
else
|
361
363
|
current_role_id = 1
|
@@ -431,7 +433,7 @@ class Manifestation < ApplicationRecord
|
|
431
433
|
end
|
432
434
|
|
433
435
|
def index_series_statement
|
434
|
-
series_statements.map{|s| s.index; s.root_manifestation
|
436
|
+
series_statements.map{|s| s.index; s.root_manifestation&.index}
|
435
437
|
end
|
436
438
|
|
437
439
|
def acquired_at
|
@@ -539,16 +541,34 @@ class Manifestation < ApplicationRecord
|
|
539
541
|
def to_hash(role: 'Guest')
|
540
542
|
record = {
|
541
543
|
manifestation_id: id,
|
542
|
-
|
544
|
+
original_title: original_title,
|
543
545
|
title_alternative: title_alternative,
|
544
546
|
title_transcription: title_transcription,
|
545
547
|
statement_of_responsibility: statement_of_responsibility,
|
546
548
|
serial: serial,
|
547
549
|
manifestation_identifier: manifestation_identifier,
|
548
|
-
creator:
|
549
|
-
|
550
|
-
|
551
|
-
|
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,
|
552
572
|
year_of_publication: year_of_publication,
|
553
573
|
publication_place: publication_place,
|
554
574
|
manifestation_created_at: created_at,
|
@@ -575,13 +595,13 @@ class Manifestation < ApplicationRecord
|
|
575
595
|
depth: depth,
|
576
596
|
price: price,
|
577
597
|
access_address: access_address,
|
578
|
-
|
598
|
+
manifestation_required_role: required_role.name,
|
579
599
|
description: description,
|
580
600
|
note: note
|
581
601
|
}
|
582
602
|
|
583
603
|
IdentifierType.find_each do |type|
|
584
|
-
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('//')
|
585
605
|
end
|
586
606
|
|
587
607
|
series = series_statements.order(:position)
|
@@ -606,6 +626,10 @@ class Manifestation < ApplicationRecord
|
|
606
626
|
record.merge!({
|
607
627
|
memo: memo
|
608
628
|
})
|
629
|
+
ManifestationCustomProperty.order(:position).each do |custom_property|
|
630
|
+
custom_value = manifestation_custom_values.find_by(manifestation_custom_property: custom_property)
|
631
|
+
record[:"manifestation:#{custom_property.name}"] = custom_value&.value
|
632
|
+
end
|
609
633
|
end
|
610
634
|
|
611
635
|
if defined?(EnjuSubject)
|
@@ -617,6 +641,14 @@ class Manifestation < ApplicationRecord
|
|
617
641
|
end
|
618
642
|
end
|
619
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
|
+
|
620
652
|
record
|
621
653
|
end
|
622
654
|
|
@@ -659,6 +691,18 @@ class Manifestation < ApplicationRecord
|
|
659
691
|
]
|
660
692
|
}.flatten
|
661
693
|
end
|
694
|
+
|
695
|
+
def set_custom_property(row)
|
696
|
+
ManifestationCustomProperty.all.each do |property|
|
697
|
+
if row[property]
|
698
|
+
custom_value = ManifestationCustomValue.new(
|
699
|
+
manifestation: self,
|
700
|
+
manifestation_custom_property: property,
|
701
|
+
value: row[property]
|
702
|
+
)
|
703
|
+
end
|
704
|
+
end
|
705
|
+
end
|
662
706
|
end
|
663
707
|
|
664
708
|
# == Schema Information
|