Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valkyrize Knapsack + Review knapsacking effort #13

Merged
merged 31 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1b17a77
Ran generator for EtdResource
kirkkwang May 15, 2024
7051ffb
Correct EtdResoource properties and forms
kirkkwang May 16, 2024
6518dd6
Update WorkResourceGenerator
kirkkwang May 16, 2024
68fd0b7
Update WorkResourceGenerator
kirkkwang May 16, 2024
baa2aa4
Ran generator for OerResource and update hyrax.rb
kirkkwang May 16, 2024
1cccec2
Correct OerResoource properties and forms
kirkkwang May 16, 2024
a5de44c
Ran generater and corrected properties for Cdl
kirkkwang May 16, 2024
ee25656
AF records should reroute to resources
ShanaLMoore May 16, 2024
060d9da
Merge branch 'review-knapsacking-effort' of https://github.com/scient…
ShanaLMoore May 16, 2024
308a4a0
update indexers and inherit from ValkyrieWorkIndexer
ShanaLMoore May 16, 2024
7382b86
Create wings.rb
ShanaLMoore May 16, 2024
fe50ab0
Merge branch 'main' into review-knapsacking-effort
ShanaLMoore May 17, 2024
b3d7a5d
Update wings to specify knapsack specific overrides
ShanaLMoore May 17, 2024
1695788
Update wings so you only need one point of change
kirkkwang May 17, 2024
6696d80
Update engine to load decorators earlier
kirkkwang May 17, 2024
bb63948
:gift: customize indexers
ShanaLMoore May 17, 2024
673335d
Remove the controllers for migrated models
kirkkwang May 17, 2024
894dd41
:gift: Allow knapsack to override Hyku metadata
ShanaLMoore May 17, 2024
b51a93b
Review and adjusted some jobs
kirkkwang May 17, 2024
7550093
Update Image form, indexer, and yaml
kirkkwang May 20, 2024
84e8e6b
Valkyrize GenericWorkResourceDecorator
kirkkwang May 20, 2024
88a0742
update submodule
kirkkwang May 20, 2024
80c9417
:broom: Allow for custom metadata overrides
ShanaLMoore May 20, 2024
6fbe72b
:broom: replace glyphicon with font awesome
ShanaLMoore May 20, 2024
9e303dc
Update submodule
ShanaLMoore May 20, 2024
22b8d01
update submodule
ShanaLMoore May 20, 2024
1b5062b
Merge pull request #16 from scientist-softserv/valkyrize-indexers
ShanaLMoore May 20, 2024
307edee
Fix some Oer stuff
kirkkwang May 20, 2024
6da581c
Address CDL listener
kirkkwang May 20, 2024
45ec495
Fix CDLs
kirkkwang May 20, 2024
9732eb4
Fix some specs
kirkkwang May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/application_controller_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def deny_access_for_anonymous_user(exception, json_message)
# rubocop:disable Metrics/AbcSize
def global_request_logging
FileUtils.mkdir_p(Rails.root.join('log')) unless Dir.exist?(Rails.root.join('log'))
rl = ActiveSupport::Logger.new('log/request.log')
rl = ActiveSupport::Logger.new(Rails.root.join('log', 'request.log'))
if request.host&.match('blc.hykucommons')
http_request_header_keys = request.headers.env.keys.select { |header_name| header_name.match("^HTTP.*|^X-User.*") }
http_request_headers = request.headers.env.select { |header_name, _header_value| http_request_header_keys.index(header_name) }
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/hyrax/cdls_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ module Hyrax
class CdlsController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyku::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::Cdl
self.curation_concern_type = ::CdlResource

# Use a Valkyrie aware form service to generate Valkyrie::ChangeSet style
# forms.
self.work_form_service = Hyrax::FormFactory.new

# Use this line if you want to use a custom presenter
self.show_presenter = Hyrax::CdlPresenter
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/hyrax/etds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ module Hyrax
class EtdsController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyku::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::Etd
self.curation_concern_type = ::EtdResource

# Use a Valkyrie aware form service to generate Valkyrie::ChangeSet style
# forms.
self.work_form_service = Hyrax::FormFactory.new

# Use this line if you want to use a custom presenter
self.show_presenter = Hyrax::EtdPresenter
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/hyrax/oers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ module Hyrax
class OersController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyku::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::Oer
self.curation_concern_type = ::OerResource

# Use a Valkyrie aware form service to generate Valkyrie::ChangeSet style
# forms.
self.work_form_service = Hyrax::FormFactory.new

# Use this line if you want to use a custom presenter
self.show_presenter = Hyrax::OerPresenter
Expand Down
22 changes: 22 additions & 0 deletions app/forms/cdl_resource_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource CdlResource`
#
# @see https://github.com/samvera/hyrax/wiki/Hyrax-Valkyrie-Usage-Guide#forms
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
class CdlResourceForm < Hyrax::Forms::ResourceForm(CdlResource)
# include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:cdl_resource)
include Hyrax::FormFields(:with_pdf_viewer)
include Hyrax::FormFields(:with_video_embed)

# Define custom form fields using the Valkyrie::ChangeSet interface
#
# property :my_custom_form_field

# if you want a field in the form, but it doesn't have a directly corresponding
# model attribute, make it virtual
#
# property :user_input_not_destined_for_the_model, virtual: true
end
23 changes: 23 additions & 0 deletions app/forms/etd_resource_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource EtdResource`
#
# @see https://github.com/samvera/hyrax/wiki/Hyrax-Valkyrie-Usage-Guide#forms
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
class EtdResourceForm < Hyrax::Forms::ResourceForm(EtdResource)
# Commented out basic_metadata because these terms were added to etd_resource so we can customize it.
# include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:etd_resource)
include Hyrax::FormFields(:with_pdf_viewer)
include Hyrax::FormFields(:with_video_embed)
include VideoEmbedBehavior::Validation
# Define custom form fields using the Valkyrie::ChangeSet interface
#
# property :my_custom_form_field

# if you want a field in the form, but it doesn't have a directly corresponding
# model attribute, make it virtual
#
# property :user_input_not_destined_for_the_model, virtual: true
end
86 changes: 86 additions & 0 deletions app/forms/oer_resource_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource OerResource`
#
# @see https://github.com/samvera/hyrax/wiki/Hyrax-Valkyrie-Usage-Guide#forms
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
class OerResourceForm < Hyrax::Forms::ResourceForm(OerResource)
# Commented out basic_metadata because these terms were added to etd_resource so we can customize it.
# include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:oer_resource)
include Hyrax::FormFields(:with_pdf_viewer)
include Hyrax::FormFields(:with_video_embed)
include VideoEmbedBehavior::Validation
# Define custom form fields using the Valkyrie::ChangeSet interface
#
# property :my_custom_form_field

# if you want a field in the form, but it doesn't have a directly corresponding
# model attribute, make it virtual
#
# property :user_input_not_destined_for_the_model, virtual: true

delegate :related_members_attributes=, :previous_version, :newer_version, :alternate_version, :related_item,
:previous_version_id, :newer_version_id, :alternate_version_id, :related_item_id, to: :model

def self.build_permitted_params
super + [
{
related_members_attributes: %i[id _destroy relationship]
}
]
end

def previous_version_json
return unless previous_version.present?

previous_version.map do |child|
{
id: child.id,
label: child.to_s,
path: @controller.url_for(child),
relationship: "previous-version"
}
end.to_json
end

def newer_version_json
return unless newer_version.present?

newer_version.map do |child|
{
id: child.id,
label: child.to_s,
path: @controller.url_for(child),
relationship: "newer-version"
}
end.to_json
end

def alternate_version_json
return unless alternate_version.present?

alternate_version.map do |child|
{
id: child.id,
label: child.to_s,
path: @controller.url_for(child),
relationship: "alternate-version"
}
end.to_json
end

def related_item_json
return unless related_item.present?

related_item.map do |child|
{
id: child.id,
label: child.to_s,
path: @controller.url_for(child),
relationship: "related-item"
}
end.to_json
end
end
2 changes: 1 addition & 1 deletion app/helpers/hyrax/override_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def truncate_and_iconify_auto_link(field, show_link = true)
# this block is only executed when a link is inserted;
# if we pass text containing no links, it just returns text.
auto_link(html_escape(text)) do |value|
"<span class='glyphicon glyphicon-new-window'></span>#{('&nbsp;' + value) if show_link}"
"<span class='fa fa-external-link'></span>#{('&nbsp;' + value) if show_link}"
end
text.truncate(230, separator: ' ')
end
Expand Down
1 change: 1 addition & 0 deletions app/indexers/cdl_indexer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Generated via
# `rails generate hyrax:work Cdl`
class CdlIndexer < AppIndexer
Expand Down
18 changes: 18 additions & 0 deletions app/indexers/cdl_resource_indexer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource CdlResource`
class CdlResourceIndexer < Hyrax::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:cdl_resource)

include HykuIndexing

# Uncomment this block if you want to add custom indexing behavior:
# def to_solr
# super.tap do |index_document|
# index_document[:my_field_tesim] = resource.my_field.map(&:to_s)
# index_document[:other_field_ssim] = resource.other_field
# end
# end
end
22 changes: 8 additions & 14 deletions app/indexers/etd_resource_indexer.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
# frozen_string_literal: true


# TODO: temporarily added to see if iiif print engine spec error would resolve. (it did)
# so some of the spec failures is because the models haven't been
# valkyrized

# Generated via
# `rails generate hyrax:work_resource GenericWorkResource`
# `rails generate hyrax:work_resource EtdResource`
class EtdResourceIndexer < Hyrax::ValkyrieWorkIndexer
# TODO: specify custom properties for this work type

# include Hyrax::Indexer(:basic_metadata)
# include Hyrax::Indexer(:bulkrax_metadata)
# include Hyrax::Indexer(:generic_work_resource)
# include Hyrax::Indexer(:with_pdf_viewer)
# include Hyrax::Indexer(:with_video_embed)
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:bulkrax_metadata)
include Hyrax::Indexer(:etd_resource)
include Hyrax::Indexer(:with_pdf_viewer)
include Hyrax::Indexer(:with_video_embed)

include HykuIndexing

# Uncomment this block if you want to add custom indexing behavior:
# def to_solr
# super.tap do |index_document|
# index_document[:my_field_tesim] = resource.my_field.map(&:to_s)
# index_document[:other_field_ssim] = resource.other_field
# end
# end
end
end
21 changes: 21 additions & 0 deletions app/indexers/oer_resource_indexer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource OerResource`
class OerResourceIndexer < Hyrax::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:bulkrax_metadata)
include Hyrax::Indexer(:oer_resource)
include Hyrax::Indexer(:with_pdf_viewer)
include Hyrax::Indexer(:with_video_embed)

include HykuIndexing

# Uncomment this block if you want to add custom indexing behavior:
# def to_solr
# super.tap do |index_document|
# index_document[:my_field_tesim] = resource.my_field.map(&:to_s)
# index_document[:other_field_ssim] = resource.other_field
# end
# end
end
8 changes: 4 additions & 4 deletions app/jobs/create_group_and_add_members_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class CreateGroupAndAddMembersJob < ApplicationJob
queue_as :default

def perform(cdl_id, retries = 0)
work = Cdl.where(id: cdl_id).first
work = Hyrax.query_service.find_by(id: cdl_id)
return if work.nil?

page_count = work.file_sets.first.page_count.first.to_i
page_count = work.members.first.original_file.page_count.first.to_i
child_model = work.iiif_print_config.pdf_split_child_model
child_works_count = work.members.select { |member| member.is_a?(child_model) }.count

Expand All @@ -28,7 +28,7 @@ def perform(cdl_id, retries = 0)
assign_read_groups(member, group.name)
end

work.save
Hyrax.persister.save(resource: work)
group.save
else
return if retries > RETRY_MAX
Expand All @@ -42,7 +42,7 @@ def perform(cdl_id, retries = 0)

def assign_read_groups(member, group_name)
member.read_groups = [group_name]
member.save
Hyrax.persister.save(resource: member)
member.members.each do |sub_member|
assign_read_groups(sub_member, group_name)
end
Expand Down
4 changes: 4 additions & 0 deletions app/jobs/destroy_cdl_group_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# frozen_string_literal: true

# Probably not needed because we're only going to ever
# be destroying one group so a background job is unnecessary.
# Leaving it here for now because the Cdl model still references it.
# But in Valkyrie, we're going to just destroy the group in the Listener.
class DestroyCdlGroupJob < ApplicationJob
queue_as :default

Expand Down
2 changes: 1 addition & 1 deletion app/jobs/iiif_print/create_relationships_job_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def perform(parent_id:, parent_model:, child_model:, retries: 0, **)
# report failures & keep pending relationships
raise "CreateRelationshipsJob failed for parent id: #{@parent_id} " \
"had #{@number_of_successes} successes & #{@number_of_failures} failures, " \
"with errors: #{@errors}. Wanted #{@pending_children} children."
"with errors: #{@errors}. Wanted #{@pending_children.count} children."
end

# OVERRIDE begin
Expand Down
23 changes: 23 additions & 0 deletions app/models/cdl_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource CdlResource`
class CdlResource < Hyrax::Work
# Commented out basic_metadata because these terms were added to etd_resource so we can customize it.
# include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:cdl_resource)
include Hyrax::Schema(:bulkrax_metadata)
include Hyrax::Schema(:with_pdf_viewer)
include Hyrax::Schema(:with_video_embed)
include Hyrax::ArResource
include Hyrax::NestedWorks

Hyrax::ValkyrieLazyMigration.migrating(self, from: Cdl)

include IiifPrint.model_configuration(
pdf_split_child_model: GenericWorkResource,
pdf_splitter_service: IiifPrint::TenantConfig::PdfSplitter
)

prepend OrderAlready.for(:creator)
end
23 changes: 23 additions & 0 deletions app/models/etd_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource EtdResource`
class EtdResource < Hyrax::Work
# Commented out basic_metadata because these terms were added to etd_resource so we can customize it.
# include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:etd_resource)
include Hyrax::Schema(:bulkrax_metadata)
include Hyrax::Schema(:with_pdf_viewer)
include Hyrax::Schema(:with_video_embed)
include Hyrax::ArResource
include Hyrax::NestedWorks

Hyrax::ValkyrieLazyMigration.migrating(self, from: Etd)

include IiifPrint.model_configuration(
pdf_split_child_model: GenericWorkResource,
pdf_splitter_service: IiifPrint::TenantConfig::PdfSplitter
)

prepend OrderAlready.for(:creator)
end
Loading
Loading