Skip to content

Commit

Permalink
Merge branch 'release/1.16'
Browse files Browse the repository at this point in the history
# Conflicts:
#	config/application.rb
  • Loading branch information
peichman-umd committed Jul 1, 2024
2 parents 3a105b2 + ea5ff01 commit 483a6d2
Show file tree
Hide file tree
Showing 25 changed files with 577 additions and 383 deletions.
1 change: 0 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//= require rails-ujs
//= require activestorage
//= require jquery
//= require jquery_ujs

// Required by Blacklight
//= require blacklight/blacklight
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class CatalogController < ApplicationController # rubocop:disable Metrics/ClassL
# :index_range can be an array or range of prefixes that will be used to create the navigation
# (note: It is case sensitive when searching values)

config.add_facet_field 'collection_title_facet', label: 'Collection', limit: 10, collapse: false, sort: 'index'
config.add_facet_field 'presentation_set_label', label: 'Presentation Set', limit: 10, collapse: false,
sort: 'index', if: :collection_facet_selected?
sort: 'index'
config.add_facet_field 'collection_title_facet', label: 'Administrative Set', limit: 10, sort: 'index'
config.add_facet_field 'author_not_tokenized', label: 'Author', limit: 10
config.add_facet_field 'type', label: 'Type', limit: 10
config.add_facet_field 'component_not_tokenized', label: 'Resource Type', limit: 10
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/export_jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,27 @@ def index
end
end

def show
id = params[:id]
@job = ExportJob.find(id)
@cas_user = CasUser.find(@job.cas_user_id)
end

def new
@job = ExportJob.new(params.key?(:export_job) ? export_job_params : default_job_params)
export_uris = bookmarks.map(&:document_id)
@mime_types = MimeTypes.mime_types(export_uris)
end

def destroy
job = ExportJob.find(params[:id])

File.delete(job.path) if File.exist? job.path

ExportJob.destroy(params[:id])
redirect_to export_jobs_path, status: :see_other
end

def review # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
@job = ExportJob.new(export_job_params)
@job.item_count = bookmarks.count
Expand Down
11 changes: 11 additions & 0 deletions app/cron_jobs/delete_old_export_jobs_cron_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

# Deletes old export jobs on a cron-like schedule
class DeleteOldExportJobsCronJob < CronJob
# Run every day at 4am
self.cron_expression = '0 4 * * *'

def perform
DeleteOldExportsJob.perform_now
end
end
6 changes: 6 additions & 0 deletions app/javascript/components/ControlledURIRef.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ class ControlledURIRef extends React.Component {
);
};

componentWillUnmount() {
if (this.props.notifyContainer && !this.props.value.isNew) {
this.props.notifyContainer(this.initialStatement)
}
}

render () {
let statement = this.getStatement(this.state.uri);
let valueIsUnchanged = (this.initialStatement === statement);
Expand Down
21 changes: 21 additions & 0 deletions app/jobs/delete_old_exports_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

# Deletes Export Jobs that are over 30 days old
class DeleteOldExportsJob < ApplicationJob
queue_as :default

def perform # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
Rails.logger.info 'Running DeleteOldExportsJob'
export_jobs = ExportJob.where('created_at > ? ', 30.days.ago)

if export_jobs.any?
export_jobs.each do |job|
Rails.logger.info("Deleting export job: #{job.name}")
File.delete(job.path) if File.exist? job.path
job.destroy
end
else
Rails.logger.info('No export jobs to delete')
end
end
end
1 change: 1 addition & 0 deletions app/models/publish_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# STOMP client not being connected
class PublishJob < ApplicationRecord
belongs_to :cas_user
has_many :publish_job_request, dependent: :destroy
serialize :solr_ids, Array

enum state: {
Expand Down
21 changes: 17 additions & 4 deletions app/services/vocabulary_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class VocabularyService
def self.get_vocabulary(identifier)
url = generate_url(identifier)
json_rest_result = retrieve(url)
terms = parse(json_rest_result)
terms = parse(identifier, json_rest_result)
Vocabulary.new(identifier, terms)
end

Expand All @@ -34,6 +34,7 @@ def self.vocab_options_hash(content_model_field)
vocab = VocabularyService.get_vocabulary(vocab_identifier)

filtered_terms = filter_terms(vocab.terms, allowed_terms)

filtered_options = parse_options(filtered_terms)
Rails.logger.debug { "filtered_options: #{filtered_options}" }

Expand Down Expand Up @@ -77,15 +78,15 @@ def retrieve(url)
json_rest_result
end

# Parses the JSON result from the network requestm returning either an
# Parses the JSON result from the network request, returning either an
# empty array, or an array of VocabularyTerm objects.
def parse(json_rest_result)
def parse(identifier, json_rest_result)
return [] if json_rest_result.error_occurred?

graph = json_rest_result.parsed_json['@graph']

# @graph element exists for vocabularies with two or more elements
return graph.map { |g| parse_entry(g) } if graph.present?
return parse_graph(identifier, graph) if graph.present?

# Single term vocabularies don't have "@graph" element, but do have
# "@id" and (possibly) "@rdfs.label" elements, so we can just go
Expand All @@ -105,6 +106,18 @@ def filter_terms(terms, allowed_terms)
terms.select { |term| allowed_terms.include?(term.label) }
end

# Parses a vocabulary graph, returning an array of VocabularyTerm objects.
def parse_graph(identifier, graph)
entries = graph.map { |g| parse_entry(g) }

# Assume that the vocab URI is the same as the URL
vocab_uri = generate_url(identifier)

# Filter out any term with a uri exactly matching the vocabulary URI,
# as it is just a label for the vocabulary itself, not an actual term.
entries.reject { |v| v.uri == vocab_uri }
end

# Parses a single term from the graph, returning a VocabularyTerm object
def parse_entry(graph_entry)
id = graph_entry['@id']
Expand Down
3 changes: 3 additions & 0 deletions app/views/catalog/_show_default.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<%
fields = @resource[:content_model][level]
fields.each do |field|
# Skip display of any fields that are "edit_only"
next if field[:edit_only]

# special handling for the access field
if field[:name] == 'access'
vocab = VocabularyService.get_vocabulary(field[:vocab])
Expand Down
4 changes: 2 additions & 2 deletions app/views/catalog/_show_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="panel-body">
<ul class="nav">
<% pages.first(8).each do |v| %>
<li><%= link_to "Page #{v['page_number']}", solr_document_path(v['id']) %></li>
<li><%= link_to v['display_title'], solr_document_path(v['id']) %></li>
<% end %>
<% if pages.length > 8 %>
<li><a href="#pages" data-toggle="modal">more »</a></li>
Expand Down Expand Up @@ -82,7 +82,7 @@
<% end %>

<% if ExportJob.exportable? @document %>
<%
<%
selected_count = current_user.bookmarks.count
max_selction = max_bookmarks_selection_limit
%>
Expand Down
2 changes: 1 addition & 1 deletion app/views/download_urls/generate_download_url.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<div class="row">
<%= f.submit class: 'btn btn-success' %>
<%= link_to 'Cancel', (@download_url.new_record? ? download_urls_path : download_url_path(@download_url)), class: 'btn btn-danger' %>
<%= link_to 'Cancel', (@download_url.new_record? ? solr_document_url(@download_url.url) : download_url_path(@download_url)), class: 'btn btn-danger' %>
</div>
<% end %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/export_jobs/_export_job_table_row.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
format_label = ExportJob::FORMATS[export_job.format] || export_job.format
%>
<tr class="export-job" data-export-job-id="<%= export_job.id %>" data-subscribe="<%= not export_job.export_complete? %>">
<td><%= export_job.id %></td>
<td><%= link_to export_job.id, export_job_url(export_job) %></td>
<td><%= export_job.name %></td>
<td><%= export_job.cas_user&.name%></td>
<td><%= export_job.timestamp %></td>
Expand Down
26 changes: 26 additions & 0 deletions app/views/export_jobs/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<h1> Export Job: <%= @job.name %> </h1>

<h3> Job Info </h2>
<hr>

<p> Job ID: <%= @job.id %> </p>
<p> Status: <%= @job.status_text %> </p>
<p> # of Records: <%= @job.item_count %> </p>
<p> # of Binaries: <%= @job.binaries_count == nil ? "n/a" : @job.binaries_count %> </p>
<p> Size of Binaries: <%= @job.binaries_size == nil ? "n/a" : number_to_human_size(@job.binaries_size) %> </p>
<p> User: <%= @cas_user.name %>

<hr>

<%= link_to "Back", export_jobs_path, class: "btn btn-danger"%>
<%= button_to "Delete Job", export_job_url(@job), method: :delete, class:"btn btn-danger", data: { confirm: 'Delete job?' } %>

<style>
.button_to {
display: inline;
}

.button_to div {
display: inline;
}
</style>
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Bundler.require(*Rails.groups)

module Archelon
VERSION = '1.15.0'
VERSION = '1.16.0'
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
Expand Down
87 changes: 63 additions & 24 deletions config/content_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ Item:
type: :PlainLiteral
repeatable: true

- name: 'access'
label: 'Access Level'
type: :ControlledURIRef
vocab: 'access'
terms: ['Public', 'Campus']

recommended:
- name: 'format'
uri: 'http://www.europeana.eu/schemas/edm/hasType'
Expand Down Expand Up @@ -109,6 +103,17 @@ Item:
type: :LabeledThing
repeatable: true

- name: 'terms_of_use'
uri: 'http://purl.org/dc/terms/license'
label: 'Terms of Use'
type: :ControlledURIRef
vocab: 'termsOfUse'

- name: 'copyright_notice'
uri: 'https://schema.org/copyrightNotice'
label: 'Copyright Notice'
type: :PlainLiteral

- name: 'bibliographic_citation'
uri: 'http://purl.org/dc/terms/bibliographicCitation'
label: 'Collection Information'
Expand All @@ -132,6 +137,7 @@ Item:
type: :ControlledURIRef
vocab: 'set'
repeatable: true
edit_only: true


Letter:
Expand All @@ -152,12 +158,6 @@ Letter:
label: 'Title'
type: :PlainLiteral

- name: 'access'
label: 'Access Level'
type: :ControlledURIRef
vocab: 'access'
terms: ['Public', 'Campus']

- name: 'type'
uri: 'http://www.europeana.eu/schemas/edm/hasType'
label: 'Resource Type'
Expand Down Expand Up @@ -223,6 +223,23 @@ Letter:
type: :LabeledThing
repeatable: true

- name: 'terms_of_use'
uri: 'http://purl.org/dc/terms/license'
label: 'Terms of Use'
type: :ControlledURIRef
vocab: 'termsOfUse'

- name: 'copyright_notice'
uri: 'https://schema.org/copyrightNotice'
label: 'Copyright Notice'
type: :PlainLiteral

- name: 'handle'
uri: 'http://purl.org/dc/terms/identifier'
label: 'Handle'
type: :TypedLiteral
datatype: http://vocab.lib.umd.edu/datatype#handle

- name: 'presentation_set'
uri: 'http://www.openarchives.org/ore/terms/isAggregatedBy'
label: 'Presentation Set'
Expand All @@ -244,12 +261,6 @@ Poster:
type: :PlainLiteral
repeatable: true

- name: 'access'
label: 'Access Level'
type: :ControlledURIRef
vocab: 'access'
terms: ['Public', 'Campus']

- name: 'type'
uri: 'http://www.europeana.eu/schemas/edm/hasType'
label: 'Resource Type'
Expand Down Expand Up @@ -337,6 +348,23 @@ Poster:
label: 'Longitude'
type: :TypedLiteral

- name: 'terms_of_use'
uri: 'http://purl.org/dc/terms/license'
label: 'Terms of Use'
type: :ControlledURIRef
vocab: 'termsOfUse'

- name: 'copyright_notice'
uri: 'https://schema.org/copyrightNotice'
label: 'Copyright Notice'
type: :PlainLiteral

- name: 'handle'
uri: 'http://purl.org/dc/terms/identifier'
label: 'Handle'
type: :TypedLiteral
datatype: http://vocab.lib.umd.edu/datatype#handle

- name: 'presentation_set'
uri: 'http://www.openarchives.org/ore/terms/isAggregatedBy'
label: 'Presentation Set'
Expand All @@ -352,12 +380,6 @@ Issue:
label: 'Title'
type: :PlainLiteral

- name: 'access'
label: 'Access Level'
type: :ControlledURIRef
vocab: 'access'
terms: ['Public', 'Campus']

- name: 'date'
uri: 'http://purl.org/dc/elements/1.1/date'
label: 'Date'
Expand All @@ -380,6 +402,23 @@ Issue:

recommended: []
optional:
- name: 'terms_of_use'
uri: 'http://purl.org/dc/terms/license'
label: 'Terms of Use'
type: :ControlledURIRef
vocab: 'termsOfUse'

- name: 'copyright_notice'
uri: 'https://schema.org/copyrightNotice'
label: 'Copyright Notice'
type: :PlainLiteral

- name: 'handle'
uri: 'http://purl.org/dc/terms/identifier'
label: 'Handle'
type: :TypedLiteral
datatype: http://vocab.lib.umd.edu/datatype#handle

- name: 'presentation_set'
uri: 'http://www.openarchives.org/ore/terms/isAggregatedBy'
label: 'Presentation Set'
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ en:
true: 'Yes'
false: 'No'
cas_user: User
collection: Collection
collection: Administrative Set
id: Job ID
metadata_file: Metadata File
model: Content Model
Expand Down
Loading

0 comments on commit 483a6d2

Please sign in to comment.