Skip to content

Commit

Permalink
🎁 Generate new resources
Browse files Browse the repository at this point in the history
This commit will run the follow commands:

```sh
rails g hyrax:work_resource AssetResource
rails g hyrax:work_resource PhysicalInstantiationResource
rails g hyrax:work_resource DigitalInstantiationResource
rails g hyrax:work_resource EssenceTrackResource
rails g hyrax:work_resource ContributionResource
```

This will generate new Valkyrie works for each of the existing work
types.

Note:  Because of dual booting I had to prepend `DEPENDENCIES_NEXT=1`
  • Loading branch information
kirkkwang committed Aug 25, 2023
1 parent 636286c commit 84b20dc
Show file tree
Hide file tree
Showing 46 changed files with 595 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/controllers/hyrax/asset_resources_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource AssetResource`
module Hyrax
# Generated controller for AssetResource
class AssetResourcesController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::AssetResource

# Use a Valkyrie aware form service to generate Valkyrie::ChangeSet style
# forms.
self.work_form_service = Hyrax::FormFactory.new
end
end
17 changes: 17 additions & 0 deletions app/controllers/hyrax/contribution_resources_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource ContributionResource`
module Hyrax
# Generated controller for ContributionResource
class ContributionResourcesController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::ContributionResource

# Use a Valkyrie aware form service to generate Valkyrie::ChangeSet style
# forms.
self.work_form_service = Hyrax::FormFactory.new
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource DigitalInstantiationResource`
module Hyrax
# Generated controller for DigitalInstantiationResource
class DigitalInstantiationResourcesController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::DigitalInstantiationResource

# Use a Valkyrie aware form service to generate Valkyrie::ChangeSet style
# forms.
self.work_form_service = Hyrax::FormFactory.new
end
end
17 changes: 17 additions & 0 deletions app/controllers/hyrax/essence_track_resources_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource EssenceTrackResource`
module Hyrax
# Generated controller for EssenceTrackResource
class EssenceTrackResourcesController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::EssenceTrackResource

# Use a Valkyrie aware form service to generate Valkyrie::ChangeSet style
# forms.
self.work_form_service = Hyrax::FormFactory.new
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource PhysicalInstantiationResource`
module Hyrax
# Generated controller for PhysicalInstantiationResource
class PhysicalInstantiationResourcesController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::PhysicalInstantiationResource

# Use a Valkyrie aware form service to generate Valkyrie::ChangeSet style
# forms.
self.work_form_service = Hyrax::FormFactory.new
end
end
20 changes: 20 additions & 0 deletions app/forms/asset_resource_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

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

# 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
20 changes: 20 additions & 0 deletions app/forms/contribution_resource_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

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

# 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
20 changes: 20 additions & 0 deletions app/forms/digital_instantiation_resource_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

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

# 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
20 changes: 20 additions & 0 deletions app/forms/essence_track_resource_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

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

# 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
20 changes: 20 additions & 0 deletions app/forms/physical_instantiation_resource_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

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

# 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
16 changes: 16 additions & 0 deletions app/indexers/asset_resource_indexer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource AssetResource`
class AssetResourceIndexer < Hyrax::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:asset_resource)

# 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
16 changes: 16 additions & 0 deletions app/indexers/contribution_resource_indexer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource ContributionResource`
class ContributionResourceIndexer < Hyrax::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:contribution_resource)

# 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
16 changes: 16 additions & 0 deletions app/indexers/digital_instantiation_resource_indexer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource DigitalInstantiationResource`
class DigitalInstantiationResourceIndexer < Hyrax::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:digital_instantiation_resource)

# 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
16 changes: 16 additions & 0 deletions app/indexers/essence_track_resource_indexer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource EssenceTrackResource`
class EssenceTrackResourceIndexer < Hyrax::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:essence_track_resource)

# 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
16 changes: 16 additions & 0 deletions app/indexers/physical_instantiation_resource_indexer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource PhysicalInstantiationResource`
class PhysicalInstantiationResourceIndexer < Hyrax::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:physical_instantiation_resource)

# 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: 8 additions & 0 deletions app/models/asset_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource AssetResource`
class AssetResource < Hyrax::Work
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:asset_resource)
end
8 changes: 8 additions & 0 deletions app/models/contribution_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource ContributionResource`
class ContributionResource < Hyrax::Work
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:contribution_resource)
end
8 changes: 8 additions & 0 deletions app/models/digital_instantiation_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource DigitalInstantiationResource`
class DigitalInstantiationResource < Hyrax::Work
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:digital_instantiation_resource)
end
8 changes: 8 additions & 0 deletions app/models/essence_track_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource EssenceTrackResource`
class EssenceTrackResource < Hyrax::Work
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:essence_track_resource)
end
8 changes: 8 additions & 0 deletions app/models/physical_instantiation_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work_resource PhysicalInstantiationResource`
class PhysicalInstantiationResource < Hyrax::Work
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:physical_instantiation_resource)
end
2 changes: 2 additions & 0 deletions app/views/hyrax/asset_resources/_asset_resource.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%# This is a search result view %>
<%= render 'catalog/document', document: asset_resource, document_counter: asset_resource_counter %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%# This is a search result view %>
<%= render 'catalog/document', document: contribution_resource, document_counter: contribution_resource_counter %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%# This is a search result view %>
<%= render 'catalog/document', document: digital_instantiation_resource, document_counter: digital_instantiation_resource_counter %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%# This is a search result view %>
<%= render 'catalog/document', document: essence_track_resource, document_counter: essence_track_resource_counter %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%# This is a search result view %>
<%= render 'catalog/document', document: physical_instantiation_resource, document_counter: physical_instantiation_resource_counter %>
10 changes: 10 additions & 0 deletions config/initializers/hyrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
config.register_curation_concern :essence_track
# Injected via `rails g hyrax:work Contribution`
config.register_curation_concern :contribution
# Injected via `rails g hyrax:work_resource AssetResource`
config.register_curation_concern :asset_resource
# Injected via `rails g hyrax:work_resource PhysicalInstantiationResource`
config.register_curation_concern :physical_instantiation_resource
# Injected via `rails g hyrax:work_resource DigitalInstantiationResource`
config.register_curation_concern :digital_instantiation_resource
# Injected via `rails g hyrax:work_resource EssenceTrackResource`
config.register_curation_concern :essence_track_resource
# Injected via `rails g hyrax:work_resource ContributionResource`
config.register_curation_concern :contribution_resource

# Register roles that are expected by your implementation.
# @see Hyrax::RoleRegistry for additional details.
Expand Down
22 changes: 22 additions & 0 deletions config/metadata/asset_resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Simple yaml config-driven schema which is used to define model attributes,
# index key names, and form properties.
#
# Attributes must have a type but all other configuration options are optional.
#
# attributes:
# attribute_name:
# type: string
# multiple: false
# index_keys:
# - "attribute_name_sim"
# form:
# required: true
# primary: true
# multiple: false
#
# @see config/metadata/basic_metadata.yaml for an example configuration
#
# Generated via
# `rails generate hyrax:work_resource AssetResource`

attributes: {}
Loading

0 comments on commit 84b20dc

Please sign in to comment.