Skip to content

Commit

Permalink
Merge pull request #7 from scientist-softserv/i564-create-various-wor…
Browse files Browse the repository at this point in the history
…k-types

I564 create various work types
  • Loading branch information
kirkkwang authored Sep 27, 2023
2 parents 6540a27 + fce6838 commit 456172e
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 44 deletions.
1 change: 0 additions & 1 deletion app/forms/hyrax/generic_work_form_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

Hyrax::GenericWorkForm.terms += %i[
aark_id
abstract
alt
bibliographic_citation
date_issued
Expand Down
1 change: 0 additions & 1 deletion app/forms/hyrax/image_form_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

Hyrax::ImageForm.terms += %i[
aark_id
abstract
alt
bibliographic_citation
date_issued
Expand Down
1 change: 1 addition & 0 deletions app/forms/hyrax/journal_article_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class JournalArticleForm < Hyrax::Forms::WorkForm
self.model_class = JournalArticle

self.terms -= DogBiscuits.config.base_properties
self.terms -= [:alternative_title, :access_right, :rights_notes]
self.terms += DogBiscuits.config.journal_article_properties

# Add any local properties here
Expand Down
5 changes: 4 additions & 1 deletion app/models/conference_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ConferenceItem < DogBiscuits::ConferenceItem

# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
# include ::Hyrax::BasicMetadata
include ::Hyrax::BasicMetadata
include SlugMetadata
include DogBiscuits::ConferenceItemMetadata
before_save :combine_dates
Expand All @@ -28,3 +28,6 @@ class ConferenceItem < DogBiscuits::ConferenceItem
]
)
end

ConferenceItem.instance_variable_set(:@generated_resource_class, nil)
ConferenceItem.resource_class.send(:include, ::Hyrax::BasicMetadata)
5 changes: 4 additions & 1 deletion app/models/dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Dataset < DogBiscuits::Dataset

# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
# include ::Hyrax::BasicMetadata
include ::Hyrax::BasicMetadata
include SlugMetadata
include DogBiscuits::DatasetMetadata
before_save :combine_dates
Expand All @@ -28,3 +28,6 @@ class Dataset < DogBiscuits::Dataset
]
)
end

Dataset.instance_variable_set(:@generated_resource_class, nil)
Dataset.resource_class.send(:include, ::Hyrax::BasicMetadata)
5 changes: 4 additions & 1 deletion app/models/exam_paper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ExamPaper < DogBiscuits::ExamPaper

# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
# include ::Hyrax::BasicMetadata
include ::Hyrax::BasicMetadata
include SlugMetadata
include DogBiscuits::ExamPaperMetadata
before_save :combine_dates
Expand All @@ -28,3 +28,6 @@ class ExamPaper < DogBiscuits::ExamPaper
]
)
end

ExamPaper.instance_variable_set(:@generated_resource_class, nil)
ExamPaper.resource_class.send(:include, ::Hyrax::BasicMetadata)
11 changes: 0 additions & 11 deletions app/models/generic_work_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,4 @@
GenericWork.include AdventistMetadata

GenericWork.instance_variable_set(:@generated_resource_class, nil)
GenericWork.resource_class

GenericWork.resource_class.send(:include, SlugMetadata)
GenericWork.resource_class.send(:include, AdventistMetadata)
GenericWork.resource_class.send(:include, VideoEmbedViewer)
GenericWork.resource_class.send(:include, DogBiscuits::Abstract)
GenericWork.resource_class.send(:include, DogBiscuits::BibliographicCitation)
GenericWork.resource_class.send(:include, DogBiscuits::DateIssued)
GenericWork.resource_class.send(:include, DogBiscuits::Geo)
GenericWork.resource_class.send(:include, DogBiscuits::PartOf)
GenericWork.resource_class.send(:include, DogBiscuits::PlaceOfPublication)
GenericWork.resource_class.send(:include, SlugBug)
27 changes: 13 additions & 14 deletions app/models/image_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
# frozen_string_literal: true

module ImageDecorator
extend ActiveSupport::Concern
include ::Hyrax::WorkBehavior
include SlugBug
include DogBiscuits::Abstract
include DogBiscuits::BibliographicCitation
include DogBiscuits::DateIssued
include DogBiscuits::Geo
include DogBiscuits::PartOf
include DogBiscuits::PlaceOfPublication
include IiifPrint.model_configuration(
Image.include(::Hyrax::WorkBehavior)
Image.include(SlugBug)
Image.include(DogBiscuits::Abstract)
Image.include(DogBiscuits::BibliographicCitation)
Image.include(DogBiscuits::DateIssued)
Image.include(DogBiscuits::Geo)
Image.include(DogBiscuits::PartOf)
Image.include(DogBiscuits::PlaceOfPublication)
Image.include(IiifPrint.model_configuration(
pdf_split_child_model: self,
pdf_splitter_service: IiifPrint::SplitPdfs::AdventistPagesToJpgsSplitter,
derivative_service_plugins: [
IiifPrint::TextExtractionDerivativeService
]
)
end
))

Image.prepend ImageDecorator
# This must come after the properties because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
Image.include SlugMetadata
Image.include AdventistMetadata

Image.instance_variable_set(:@generated_resource_class, nil)
Image.resource_class.send(:include, AdventistMetadata)
5 changes: 4 additions & 1 deletion app/models/journal_article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class JournalArticle < DogBiscuits::JournalArticle

# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
# include ::Hyrax::BasicMetadata
include ::Hyrax::BasicMetadata
include SlugMetadata
include DogBiscuits::JournalArticleMetadata
before_save :combine_dates
Expand All @@ -32,3 +32,6 @@ class JournalArticle < DogBiscuits::JournalArticle
]
)
end

JournalArticle.instance_variable_set(:@generated_resource_class, nil)
JournalArticle.resource_class.send(:include, ::Hyrax::BasicMetadata)
5 changes: 4 additions & 1 deletion app/models/published_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PublishedWork < DogBiscuits::PublishedWork

# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
# include ::Hyrax::BasicMetadata
include ::Hyrax::BasicMetadata
include SlugMetadata
include DogBiscuits::PublishedWorkMetadata
before_save :combine_dates
Expand All @@ -33,3 +33,6 @@ class PublishedWork < DogBiscuits::PublishedWork
]
)
end

PublishedWork.instance_variable_set(:@generated_resource_class, nil)
PublishedWork.resource_class.send(:include, ::Hyrax::BasicMetadata)
5 changes: 4 additions & 1 deletion app/models/thesis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Thesis < DogBiscuits::Thesis

# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
# include ::Hyrax::BasicMetadata
include ::Hyrax::BasicMetadata
include SlugMetadata
include DogBiscuits::ThesisMetadata
before_save :combine_dates
Expand All @@ -35,3 +35,6 @@ class Thesis < DogBiscuits::Thesis
]
)
end

Thesis.instance_variable_set(:@generated_resource_class, nil)
Thesis.resource_class.send(:include, ::Hyrax::BasicMetadata)
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<% if f.object.class.multiple? key %>
<%= f.input key, as: :multi_value, input_html: { data: { provide: 'datepicker', 'date-force-parse': 'false', 'date-autoclose': 'true' } }, required: f.object.required?(key) %>
<% else %>
<%= f.input key, input_html: { value: f.object.model[key].first, data: { provide: 'datepicker', 'date-force-parse': 'false', 'date-autoclose': 'true' } }, required: f.object.required?(key) %>
<%= f.input key, input_html: { value: f.object.model[key]&.first, data: { provide: 'datepicker', 'date-force-parse': 'false', 'date-autoclose': 'true' } }, required: f.object.required?(key) %>
<% end %>
1 change: 1 addition & 0 deletions config/initializers/hyrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
# See https://github.com/scientist-softserv/adventist-dl/issues/183
# Also, we will continue to extract txt file's text using Adventist::TextFileTextExtractionService
config.extract_full_text = false
config.work_requires_files = false
end
70 changes: 70 additions & 0 deletions config/initializers/knapsack_authorities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# frozen_string_literal: true

# The main purpose of these overrides is to handle multiple authorities directories.
# Questioning Authority gem only allows one directory for local authorities, which by
# default is looking at the Hyku's `config/authorities directory` instead of Knapsack's
# `config/authorities` directory.
#
# We want have the ability to add HykuKnapsack's authorities directory in addition to
# Hyku's. If two are of the same name, then the one in HykuKnapsack should override the
# one in Hyku.

# Using relative path because when this gets called we are in the submodule
HykuKnapsack::AUTHORITIES_PATH = File.expand_path('../config/authorities', Rails.root)

module Qa
module Authorities
# OVERRIDE Questioning Authority v5.10.0 to load knapsack authorities
# see: https://github.com/samvera/questioning_authority/blob/14d233a8404a8d805f1213ae9431ad4ff82a9937/lib/qa/authorities/local.rb
module LocalDecorator
# Overidding to handle to return an array of paths
def subauthorities_path(knapsack_authorities_path: HykuKnapsack::AUTHORITIES_PATH)
# knapsack_authorities_path should be first to allow for overriding in case of duplicate names
authorities_paths = [knapsack_authorities_path, config[:local_path]]

authorities_paths.map do |path|
path if File.directory?(path)
end.compact
end

# Overriding to handle an array of paths to return names of all files
def names
paths = subauthorities_path # Assuming this now returns an array
all_names = []

paths.each do |path|
unless Dir.exist? path
raise Qa::ConfigDirectoryNotFound,
"There's no directory at #{path}. You must create it in order to use local authorities"
end

all_names += Dir.entries(path).map { |f| File.basename(f, '.yml') if f =~ /yml$/ }.compact
end

all_names.uniq
end
end
end
end

module Qa
module Authorities
module Local
# OVERRIDE Questioning Authority v5.10.0 to return first file found from an array of paths
# see: https://github.com/samvera/questioning_authority/blob/14d233a8404a8d805f1213ae9431ad4ff82a9937/lib/qa/authorities/local/file_based_authority.rb
module FileBasedAuthorityDecorator
def subauthority_filename
subauthorities_paths = Local.subauthorities_path

subauthorities_paths.each do |path|
yaml_file = File.join(path, "#{subauthority}.yml")
return yaml_file if File.exist?(yaml_file)
end
end
end
end
end
end

Qa::Authorities::Local.singleton_class.send(:prepend, Qa::Authorities::LocalDecorator)
Qa::Authorities::Local::FileBasedAuthority.prepend(Qa::Authorities::Local::FileBasedAuthorityDecorator)
14 changes: 5 additions & 9 deletions lib/dog_biscuits/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def required_properties
# Omitting bibliographic_citation
def base_properties
%i[title
abstract
creator
contributor
description
Expand Down Expand Up @@ -270,8 +271,7 @@ def restricted_role
attr_writer :conference_item_properties

def conference_item_properties
properties = %i[abstract
date_published
properties = %i[date_published
date_available
date_accepted
date_submitted
Expand Down Expand Up @@ -323,8 +323,7 @@ def digital_archival_object_properties_required

attr_writer :published_work_properties
def published_work_properties
properties = %i[abstract
date_published
properties = %i[date_published
date_available
date_accepted
date_submitted
Expand Down Expand Up @@ -354,8 +353,7 @@ def published_work_properties_required
attr_writer :journal_article_properties

def journal_article_properties
properties = %i[abstract
date_published
properties = %i[date_published
date_available
date_accepted
date_submitted
Expand All @@ -380,8 +378,7 @@ def journal_article_properties_required
attr_writer :thesis_properties
# omitting orcid
def thesis_properties
properties = %i[abstract
advisor
properties = %i[advisor
date_of_award
awarding_institution
qualification_level
Expand Down Expand Up @@ -422,7 +419,6 @@ def exam_paper_properties_required
# these are admin info, not for standard form/view
def dataset_properties
properties = %i[
abstract
content_version
date_accepted
date_available
Expand Down
2 changes: 1 addition & 1 deletion lib/dog_biscuits/indexers/concerns/indexes_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def solr_doc_for_contributors(solr_doc)
# Extract years from all date fields and index into 'date_range_sim'
def solr_doc_for_dates(solr_doc)
DogBiscuits.config.date_properties.each do |d|
next unless (object.respond_to? d && object.send(d).respond_to?(:each))
next unless (object.respond_to?(d) && object.send(d).respond_to?(:each))
object.send(d).each do |dd|
dd.to_s.scan(/\b\d{4}\b/).each do |year|
if solr_doc['date_range_sim']
Expand Down

0 comments on commit 456172e

Please sign in to comment.