sufia-models 5.0.0 → 6.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/actors/sufia/generic_file/actor.rb +8 -10
- data/app/jobs/active_fedora_pid_based_job.rb +2 -3
- data/app/jobs/audit_job.rb +46 -32
- data/app/jobs/batch_update_job.rb +9 -8
- data/app/jobs/import_url_job.rb +2 -2
- data/app/models/batch.rb +11 -12
- data/app/models/checksum_audit_log.rb +12 -10
- data/app/models/concerns/sufia/ability.rb +4 -6
- data/app/models/concerns/sufia/collection.rb +4 -5
- data/app/models/concerns/sufia/generic_file/batches.rb +29 -0
- data/app/models/concerns/sufia/generic_file/characterization.rb +3 -3
- data/app/models/concerns/sufia/generic_file/content.rb +13 -0
- data/app/models/concerns/sufia/generic_file/derivatives.rb +5 -5
- data/app/models/concerns/sufia/generic_file/export.rb +4 -0
- data/app/models/concerns/sufia/generic_file/full_text_indexing.rb +2 -2
- data/app/models/concerns/sufia/generic_file/indexing.rb +23 -0
- data/app/models/concerns/sufia/generic_file/metadata.rb +80 -11
- data/app/models/concerns/sufia/generic_file/proxy_deposit.rb +12 -3
- data/app/models/concerns/sufia/generic_file/versions.rb +4 -4
- data/app/models/concerns/sufia/generic_file/web_form.rb +14 -6
- data/app/models/concerns/sufia/generic_file.rb +3 -86
- data/app/models/concerns/sufia/model_methods.rb +11 -9
- data/app/models/concerns/sufia/user.rb +11 -33
- data/app/models/datastreams/file_content_datastream.rb +1 -1
- data/app/models/datastreams/fits_datastream.rb +1 -1
- data/app/models/file_usage.rb +3 -3
- data/app/models/local_authority.rb +2 -2
- data/app/models/proxy_deposit_request.rb +1 -1
- data/app/services/sufia/generic_file_audit_service.rb +83 -0
- data/app/services/sufia/id_service.rb +5 -5
- data/app/services/sufia/noid.rb +10 -7
- data/app/services/sufia/repository_audit_service.rb +9 -0
- data/lib/generators/sufia/models/cached_stats_generator.rb +47 -3
- data/lib/generators/sufia/models/install_generator.rb +31 -11
- data/lib/generators/sufia/models/proxies_generator.rb +31 -2
- data/lib/generators/sufia/models/templates/config/sufia.rb +10 -0
- data/lib/generators/sufia/models/upgrade400_generator.rb +33 -2
- data/lib/sufia/models/engine.rb +13 -4
- data/lib/sufia/models/file_content/versions.rb +9 -11
- data/lib/sufia/models/stats/user_stat_importer.rb +5 -9
- data/lib/sufia/models/version.rb +1 -1
- data/lib/sufia/permissions/writable.rb +34 -16
- data/sufia-models.gemspec +4 -2
- metadata +54 -33
- data/app/models/concerns/sufia/generic_file/audit.rb +0 -116
- data/app/models/concerns/sufia/generic_file/reload_on_save.rb +0 -18
- data/app/models/concerns/sufia/properties_datastream_behavior.rb +0 -32
- data/app/models/datastreams/batch_rdf_datastream.rb +0 -6
- data/app/models/datastreams/generic_file_rdf_datastream.rb +0 -69
- data/app/models/datastreams/paranoid_rights_datastream.rb +0 -22
- data/app/models/datastreams/properties_datastream.rb +0 -4
- data/app/models/sufia/orcid_validator.rb +0 -8
- data/lib/generators/sufia/models/abstract_migration_generator.rb +0 -30
- data/lib/generators/sufia/models/orcid_field_generator.rb +0 -19
- data/lib/generators/sufia/models/templates/migrations/add_orcid_to_users.rb +0 -5
- data/lib/generators/sufia/models/user_stats_generator.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4314a9ee6401c790ffce36c91f621c9c3fa9ec4a
|
4
|
+
data.tar.gz: d8cb9e5007c3d8130ceaf6e59a279f88a03ec622
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1e0ab2d2b46c88005855ae5d609a9d1f4a474a4c5cfa912ca0f59d29f72f486fbc6d062f04c0949c1287d36a28d17e100747d31fab6eb6b0111be93c2d43a63
|
7
|
+
data.tar.gz: b174426b321d1921c85264409f27c7f6a5b984a690061a5e81e32755bc309b2f0c5e37abbd4348fe1d8eed293def5fca38e7482eb0aee7207f61cef022be842e
|
@@ -20,7 +20,7 @@ module Sufia::GenericFile
|
|
20
20
|
generic_file.creator = [user.name]
|
21
21
|
|
22
22
|
if batch_id
|
23
|
-
generic_file.batch_id =
|
23
|
+
generic_file.batch_id = batch_id
|
24
24
|
else
|
25
25
|
ActiveFedora::Base.logger.warn "unable to find batch to attach to"
|
26
26
|
end
|
@@ -28,8 +28,7 @@ module Sufia::GenericFile
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def create_content(file, file_name, dsid)
|
31
|
-
|
32
|
-
generic_file.add_file(file, dsid, fname)
|
31
|
+
generic_file.add_file(file, dsid, file_name.truncate(255))
|
33
32
|
save_characterize_and_record_committer do
|
34
33
|
if Sufia.config.respond_to?(:after_create_content)
|
35
34
|
Sufia.config.after_create_content.call(generic_file, user)
|
@@ -37,9 +36,9 @@ module Sufia::GenericFile
|
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
|
-
def revert_content(revision_id
|
41
|
-
|
42
|
-
generic_file.
|
39
|
+
def revert_content(revision_id)
|
40
|
+
generic_file.content.restore_version(revision_id)
|
41
|
+
generic_file.content.create_version
|
43
42
|
save_characterize_and_record_committer do
|
44
43
|
if Sufia.config.respond_to?(:after_revert_content)
|
45
44
|
Sufia.config.after_revert_content.call(generic_file, user, revision_id)
|
@@ -69,11 +68,10 @@ module Sufia::GenericFile
|
|
69
68
|
end
|
70
69
|
|
71
70
|
def destroy
|
72
|
-
pid = generic_file.pid #Work around for https://github.com/projecthydra/active_fedora/issues/422
|
73
71
|
generic_file.destroy
|
74
|
-
FeaturedWork.where(generic_file_id:
|
72
|
+
FeaturedWork.where(generic_file_id: generic_file.id).destroy_all
|
75
73
|
if Sufia.config.respond_to?(:after_destroy)
|
76
|
-
Sufia.config.after_destroy.call(
|
74
|
+
Sufia.config.after_destroy.call(generic_file.id, user)
|
77
75
|
end
|
78
76
|
end
|
79
77
|
|
@@ -103,7 +101,7 @@ module Sufia::GenericFile
|
|
103
101
|
end
|
104
102
|
|
105
103
|
def push_characterize_job
|
106
|
-
Sufia.queue.push(CharacterizeJob.new(@generic_file.
|
104
|
+
Sufia.queue.push(CharacterizeJob.new(@generic_file.id))
|
107
105
|
end
|
108
106
|
|
109
107
|
class << self
|
@@ -10,10 +10,9 @@ class ActiveFedoraPidBasedJob
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def object
|
13
|
-
@object ||= ActiveFedora::Base.find(pid
|
14
|
-
f.reload_on_save = true
|
15
|
-
end
|
13
|
+
@object ||= ActiveFedora::Base.find(pid)
|
16
14
|
end
|
15
|
+
|
17
16
|
alias_method :generic_file, :object
|
18
17
|
alias_method :generic_file_id, :pid
|
19
18
|
|
data/app/jobs/audit_job.rb
CHANGED
@@ -6,44 +6,58 @@ class AuditJob < ActiveFedoraPidBasedJob
|
|
6
6
|
PASS = 'Passing Audit Run'
|
7
7
|
FAIL = 'Failing Audit Run'
|
8
8
|
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :uri, :pid, :path
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
# URI of the resource to audit.
|
12
|
+
# This URI could include the actual resource (e.g. content) and the version to audit:
|
13
|
+
# http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content/fcr:versions/version1
|
14
|
+
# but it could also just be:
|
15
|
+
# http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content
|
16
|
+
def initialize(id, path, uri)
|
17
|
+
super(uri)
|
18
|
+
self.pid = id
|
19
|
+
self.path = path
|
20
|
+
self.uri = uri
|
15
21
|
end
|
16
22
|
|
17
23
|
def run
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
24
|
+
fixity_ok = false
|
25
|
+
log = run_audit
|
26
|
+
fixity_ok = (log.pass == 1)
|
27
|
+
unless fixity_ok
|
28
|
+
# send the user a message about the failing audit
|
29
|
+
login = generic_file.depositor
|
30
|
+
user = User.find_by_user_key(login)
|
31
|
+
logger.warn "User '#{login}' not found" unless user
|
32
|
+
job_user = User.audituser()
|
33
|
+
file_title = generic_file.title.first
|
34
|
+
message = "The audit run at #{log.created_at} for #{file_title} (#{uri}) failed."
|
35
|
+
subject = FAIL
|
36
|
+
job_user.send_message(user, message, subject)
|
37
|
+
end
|
38
|
+
fixity_ok
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
|
43
|
+
def run_audit
|
44
|
+
begin
|
45
|
+
fixity_ok = ActiveFedora::FixityService.new(uri).check
|
46
|
+
rescue Ldp::NotFound
|
47
|
+
error_msg = "resource not found"
|
48
|
+
end
|
49
|
+
|
50
|
+
if fixity_ok
|
51
|
+
passing = 1
|
52
|
+
ChecksumAuditLog.prune_history(pid, path)
|
37
53
|
else
|
38
|
-
|
54
|
+
logger.warn "***AUDIT*** Audit failed for #{uri} #{error_msg}"
|
55
|
+
passing = 0
|
39
56
|
end
|
40
|
-
|
41
|
-
ActiveFedora::Base.logger.warn "No generic file for data stream audit!!!!! pid: #{pid} dsid: #{datastream_id}"
|
57
|
+
ChecksumAuditLog.create!(pass: passing, pid: pid, version: uri, dsid: path)
|
42
58
|
end
|
43
|
-
end
|
44
59
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
60
|
+
def logger
|
61
|
+
ActiveFedora::Base.logger
|
62
|
+
end
|
49
63
|
end
|
@@ -10,7 +10,7 @@ class BatchUpdateJob
|
|
10
10
|
|
11
11
|
def initialize(login, params)
|
12
12
|
self.login = login
|
13
|
-
self.title = params[:title]
|
13
|
+
self.title = params[:title] || {}
|
14
14
|
self.file_attributes = params[:generic_file]
|
15
15
|
self.visibility = params[:visibility]
|
16
16
|
self.batch_id = params[:id]
|
@@ -25,7 +25,9 @@ class BatchUpdateJob
|
|
25
25
|
batch.generic_files.each do |gf|
|
26
26
|
update_file(gf, user)
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
|
+
batch.update(status: ["Complete"])
|
30
|
+
|
29
31
|
if denied.empty?
|
30
32
|
send_user_success_message(user, batch) unless saved.empty?
|
31
33
|
else
|
@@ -35,12 +37,12 @@ class BatchUpdateJob
|
|
35
37
|
|
36
38
|
def update_file(gf, user)
|
37
39
|
unless user.can? :edit, gf
|
38
|
-
ActiveFedora::Base.logger.error "User #{user.user_key} DENIED access to #{gf.
|
40
|
+
ActiveFedora::Base.logger.error "User #{user.user_key} DENIED access to #{gf.id}!"
|
39
41
|
denied << gf
|
40
42
|
return
|
41
43
|
end
|
42
|
-
gf.title = title[gf.
|
43
|
-
gf.attributes=file_attributes
|
44
|
+
gf.title = title[gf.id] if title[gf.id]
|
45
|
+
gf.attributes = file_attributes
|
44
46
|
gf.visibility= visibility
|
45
47
|
|
46
48
|
save_tries = 0
|
@@ -48,13 +50,13 @@ class BatchUpdateJob
|
|
48
50
|
gf.save!
|
49
51
|
rescue RSolr::Error::Http => error
|
50
52
|
save_tries += 1
|
51
|
-
ActiveFedora::Base.logger.warn "BatchUpdateJob caught RSOLR error on #{gf.
|
53
|
+
ActiveFedora::Base.logger.warn "BatchUpdateJob caught RSOLR error on #{gf.id}: #{error.inspect}"
|
52
54
|
# fail for good if the tries is greater than 3
|
53
55
|
raise error if save_tries >=3
|
54
56
|
sleep 0.01
|
55
57
|
retry
|
56
58
|
end #
|
57
|
-
Sufia.queue.push(ContentUpdateEventJob.new(gf.
|
59
|
+
Sufia.queue.push(ContentUpdateEventJob.new(gf.id, login))
|
58
60
|
saved << gf
|
59
61
|
end
|
60
62
|
|
@@ -67,5 +69,4 @@ class BatchUpdateJob
|
|
67
69
|
message = denied.count > 1 ? multiple_failure(batch.noid, denied) : single_failure(batch.noid, denied.first)
|
68
70
|
User.batchuser.send_message(user, message, failure_subject, sanitize_text = false)
|
69
71
|
end
|
70
|
-
|
71
72
|
end
|
data/app/jobs/import_url_job.rb
CHANGED
@@ -11,12 +11,12 @@ class ImportUrlJob < ActiveFedoraPidBasedJob
|
|
11
11
|
def run
|
12
12
|
user = User.find_by_user_key(generic_file.depositor)
|
13
13
|
|
14
|
-
Tempfile.open(
|
14
|
+
Tempfile.open(pid.gsub('/', '_')) do |f|
|
15
15
|
path = copy_remote_file(generic_file.import_url, f)
|
16
16
|
# attach downloaded file to generic file stubbed out
|
17
17
|
if Sufia::GenericFile::Actor.new(generic_file, user).create_content(f, path, 'content')
|
18
18
|
# add message to user for downloaded file
|
19
|
-
message = "The file (#{generic_file.
|
19
|
+
message = "The file (#{generic_file.label}) was successfully imported."
|
20
20
|
job_user.send_message(user, message, 'File Import')
|
21
21
|
else
|
22
22
|
job_user.send_message(user, generic_file.errors.full_messages.join(', '), 'File Import Error')
|
data/app/models/batch.rb
CHANGED
@@ -3,24 +3,23 @@ class Batch < ActiveFedora::Base
|
|
3
3
|
include Sufia::ModelMethods
|
4
4
|
include Sufia::Noid
|
5
5
|
|
6
|
-
|
6
|
+
has_many :generic_files, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
property :creator, predicate: ::RDF::DC.creator
|
9
|
+
property :title, predicate: ::RDF::DC.title
|
10
|
+
property :status, predicate: ::RDF::DC.type
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
def self.find_or_create(pid)
|
12
|
+
def self.find_or_create(id)
|
14
13
|
begin
|
15
|
-
Batch.find(
|
14
|
+
Batch.find(id)
|
16
15
|
rescue ActiveFedora::ObjectNotFoundError
|
17
|
-
Batch.create(
|
16
|
+
Batch.create(id: id)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
|
-
def to_solr(solr_doc={}
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
def to_solr(solr_doc={})
|
21
|
+
super.tap do |solr_doc|
|
22
|
+
solr_doc[Solrizer.solr_name('noid', Sufia::GenericFile::Indexing.noid_indexer)] = noid
|
23
|
+
end
|
25
24
|
end
|
26
25
|
end
|
@@ -1,19 +1,21 @@
|
|
1
1
|
class ChecksumAuditLog < ActiveRecord::Base
|
2
2
|
|
3
|
-
def
|
4
|
-
ChecksumAuditLog.
|
5
|
-
dsid: version.dsid,
|
6
|
-
version: version.versionID)
|
3
|
+
def self.get_audit_log(id, path, version_uri)
|
4
|
+
ChecksumAuditLog.find_or_create_by(pid: id, dsid: path, version: version_uri)
|
7
5
|
end
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
list =
|
7
|
+
# Check to see if there are previous passing logs that we can delete
|
8
|
+
# we want to keep the first passing event after a failure, the most current passing event,
|
9
|
+
# and all failures so that this table doesn't grow too large
|
10
|
+
# Simple way (a little naieve): if the last 2 were passing, delete the first one
|
11
|
+
def self.prune_history(id, path)
|
12
|
+
list = logs_for(id, path).limit(2)
|
15
13
|
if list.size > 1 && (list[0].pass == 1) && (list[1].pass == 1)
|
16
14
|
list[0].destroy
|
17
15
|
end
|
18
16
|
end
|
17
|
+
|
18
|
+
def self.logs_for(id, path)
|
19
|
+
ChecksumAuditLog.where(pid: id, dsid: path).order('created_at desc, id desc')
|
20
|
+
end
|
19
21
|
end
|
@@ -15,8 +15,8 @@ module Sufia
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def proxy_deposit_abilities
|
18
|
-
can :transfer, String do |
|
19
|
-
|
18
|
+
can :transfer, String do |id|
|
19
|
+
depositor_for_document(id) == current_user.user_key
|
20
20
|
end
|
21
21
|
can :create, ProxyDepositRequest if user_groups.include? 'registered'
|
22
22
|
can :accept, ProxyDepositRequest, receiving_user_id: current_user.id, status: 'pending'
|
@@ -47,10 +47,8 @@ module Sufia
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
-
def
|
51
|
-
::GenericFile.load_instance_from_solr(
|
52
|
-
rescue
|
53
|
-
nil
|
50
|
+
def depositor_for_document(document_id)
|
51
|
+
::GenericFile.load_instance_from_solr(document_id).depositor
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
@@ -11,7 +11,6 @@ module Sufia
|
|
11
11
|
before_save :update_permissions
|
12
12
|
validates :title, presence: true
|
13
13
|
|
14
|
-
has_metadata "properties", type: PropertiesDatastream
|
15
14
|
end
|
16
15
|
|
17
16
|
def terms_for_display
|
@@ -35,10 +34,10 @@ module Sufia
|
|
35
34
|
noid
|
36
35
|
end
|
37
36
|
|
38
|
-
def to_solr(solr_doc={}
|
39
|
-
super
|
40
|
-
|
41
|
-
|
37
|
+
def to_solr(solr_doc={})
|
38
|
+
super.tap do |solr_doc|
|
39
|
+
solr_doc[Solrizer.solr_name("noid", Sufia::GenericFile::Indexing.noid_indexer)] = noid
|
40
|
+
end
|
42
41
|
end
|
43
42
|
|
44
43
|
def update_permissions
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Sufia
|
2
|
+
module GenericFile
|
3
|
+
module Batches
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
belongs_to :batch, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
7
|
+
end
|
8
|
+
|
9
|
+
# Get the files with a sibling relationship (belongs_to :batch)
|
10
|
+
# The batch id is minted when visiting the upload screen and attached
|
11
|
+
# to each file when it is done uploading. The Batch object is not created
|
12
|
+
# until all objects are done uploading and the user is redirected to
|
13
|
+
# BatchController#edit. Therefore, we must handle the case where
|
14
|
+
# self.batch_id is set but self.batch returns nil.
|
15
|
+
def related_files
|
16
|
+
return [] if batch.nil?
|
17
|
+
batch.generic_files.reject { |sibling| sibling.id == id }
|
18
|
+
end
|
19
|
+
|
20
|
+
# Is this file in the middle of being processed by a batch?
|
21
|
+
def processing?
|
22
|
+
return false if self.batch.blank? || !self.batch.methods.include?(:status)
|
23
|
+
(!self.batch.status.empty?) && (self.batch.status.count == 1) && (self.batch.status[0] == "processing")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -3,7 +3,7 @@ module Sufia
|
|
3
3
|
module Characterization
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
included do
|
6
|
-
|
6
|
+
contains "characterization", class_name: 'FitsDatastream'
|
7
7
|
has_attributes :mime_type, datastream: :characterization, multiple: false
|
8
8
|
has_attributes :format_label, :file_size, :last_modified,
|
9
9
|
:filename, :original_checksum, :rights_basis,
|
@@ -45,11 +45,11 @@ module Sufia
|
|
45
45
|
metadata = content.extract_metadata
|
46
46
|
characterization.ng_xml = metadata if metadata.present?
|
47
47
|
append_metadata
|
48
|
-
self.filename = [
|
48
|
+
self.filename = [content.original_name]
|
49
49
|
save
|
50
50
|
end
|
51
51
|
|
52
|
-
# Populate
|
52
|
+
# Populate GenericFile's properties with fields from FITS (e.g. Author from pdfs)
|
53
53
|
def append_metadata
|
54
54
|
terms = self.characterization_terms
|
55
55
|
Sufia.config.fits_to_desc_mapping.each_pair do |k, v|
|
@@ -9,15 +9,15 @@ module Sufia
|
|
9
9
|
makes_derivatives do |obj|
|
10
10
|
case obj.mime_type
|
11
11
|
when *pdf_mime_types
|
12
|
-
obj.
|
12
|
+
obj.transform_file :content, { thumbnail: { format: 'jpg', size: '338x493', datastream: 'thumbnail' } }
|
13
13
|
when *office_document_mime_types
|
14
|
-
obj.
|
14
|
+
obj.transform_file :content, { thumbnail: { format: 'jpg', size: '200x150>', datastream: 'thumbnail' } }, processor: :document
|
15
15
|
when *audio_mime_types
|
16
|
-
obj.
|
16
|
+
obj.transform_file :content, { mp3: { format: 'mp3', datastream: 'mp3' }, ogg: { format: 'ogg', datastream: 'ogg' } }, processor: :audio
|
17
17
|
when *video_mime_types
|
18
|
-
obj.
|
18
|
+
obj.transform_file :content, { webm: { format: 'webm', datastream: 'webm' }, mp4: { format: 'mp4', datastream: 'mp4' }, thumbnail: { format: 'jpg', datastream: 'thumbnail' } }, processor: :video
|
19
19
|
when *image_mime_types
|
20
|
-
obj.
|
20
|
+
obj.transform_file :content, { thumbnail: { format: 'jpg', size: '200x150>', datastream: 'thumbnail' } }
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -4,7 +4,7 @@ module Sufia
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
7
|
+
contains 'full_text'
|
8
8
|
end
|
9
9
|
|
10
10
|
def append_metadata
|
@@ -27,7 +27,7 @@ module Sufia
|
|
27
27
|
extracted_text = JSON.parse(resp.body)[''].rstrip
|
28
28
|
full_text.content = extracted_text if extracted_text.present?
|
29
29
|
rescue => e
|
30
|
-
logger.error("Error extracting content from #{self.
|
30
|
+
logger.error("Error extracting content from #{self.id}: #{e.inspect}")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Sufia
|
2
|
+
module GenericFile
|
3
|
+
module Indexing
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
# Unstemmed, searchable, stored
|
7
|
+
def self.noid_indexer
|
8
|
+
@noid_indexer ||= Solrizer::Descriptor.new(:text, :indexed, :stored)
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_solr(solr_doc={})
|
12
|
+
super.tap do |solr_doc|
|
13
|
+
solr_doc[Solrizer.solr_name('label')] = label
|
14
|
+
solr_doc[Solrizer.solr_name('noid', Sufia::GenericFile::Indexing.noid_indexer)] = noid
|
15
|
+
solr_doc[Solrizer.solr_name('file_format')] = file_format
|
16
|
+
solr_doc[Solrizer.solr_name('file_format', :facetable)] = file_format
|
17
|
+
solr_doc['all_text_timv'] = full_text.content
|
18
|
+
solr_doc = index_collection_ids(solr_doc)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -4,17 +4,86 @@ module Sufia
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
|
8
|
+
property :label, predicate: ::RDF::DC.title, multiple: false
|
9
|
+
|
10
|
+
property :depositor, predicate: ::RDF::URI.new("http://id.loc.gov/vocabulary/relators/dpt"), multiple: false do |index|
|
11
|
+
index.as :symbol, :stored_searchable
|
12
|
+
end
|
13
|
+
|
14
|
+
property :relative_path, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#relativePath'), multiple: false
|
15
|
+
|
16
|
+
property :import_url, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#importUrl'), multiple: false do |index|
|
17
|
+
index.as :symbol
|
18
|
+
end
|
19
|
+
|
20
|
+
property :part_of, predicate: ::RDF::DC.isPartOf
|
21
|
+
property :resource_type, predicate: ::RDF::DC.type do |index|
|
22
|
+
index.as :stored_searchable, :facetable
|
23
|
+
end
|
24
|
+
property :title, predicate: ::RDF::DC.title do |index|
|
25
|
+
index.as :stored_searchable, :facetable
|
26
|
+
end
|
27
|
+
property :creator, predicate: ::RDF::DC.creator do |index|
|
28
|
+
index.as :stored_searchable, :facetable
|
29
|
+
end
|
30
|
+
property :contributor, predicate: ::RDF::DC.contributor do |index|
|
31
|
+
index.as :stored_searchable, :facetable
|
32
|
+
end
|
33
|
+
property :description, predicate: ::RDF::DC.description do |index|
|
34
|
+
index.type :text
|
35
|
+
index.as :stored_searchable
|
36
|
+
end
|
37
|
+
property :tag, predicate: ::RDF::DC.relation do |index|
|
38
|
+
index.as :stored_searchable, :facetable
|
39
|
+
end
|
40
|
+
property :rights, predicate: ::RDF::DC.rights do |index|
|
41
|
+
index.as :stored_searchable
|
42
|
+
end
|
43
|
+
property :publisher, predicate: ::RDF::DC.publisher do |index|
|
44
|
+
index.as :stored_searchable, :facetable
|
45
|
+
end
|
46
|
+
property :date_created, predicate: ::RDF::DC.created do |index|
|
47
|
+
index.as :stored_searchable
|
48
|
+
end
|
49
|
+
property :date_uploaded, predicate: ::RDF::DC.dateSubmitted, multiple: false do |index|
|
50
|
+
index.type :date
|
51
|
+
index.as :stored_sortable
|
52
|
+
end
|
53
|
+
property :date_modified, predicate: ::RDF::DC.modified, multiple: false do |index|
|
54
|
+
index.type :date
|
55
|
+
index.as :stored_sortable
|
56
|
+
end
|
57
|
+
property :subject, predicate: ::RDF::DC.subject do |index|
|
58
|
+
index.as :stored_searchable, :facetable
|
59
|
+
end
|
60
|
+
property :language, predicate: ::RDF::DC.language do |index|
|
61
|
+
index.as :stored_searchable, :facetable
|
62
|
+
end
|
63
|
+
property :identifier, predicate: ::RDF::DC.identifier do |index|
|
64
|
+
index.as :stored_searchable
|
65
|
+
end
|
66
|
+
property :based_near, predicate: ::RDF::FOAF.based_near do |index|
|
67
|
+
index.as :stored_searchable, :facetable
|
68
|
+
end
|
69
|
+
property :related_url, predicate: ::RDF::RDFS.seeAlso do |index|
|
70
|
+
index.as :stored_searchable
|
71
|
+
end
|
72
|
+
property :bibliographic_citation, predicate: ::RDF::DC.bibliographicCitation do |index|
|
73
|
+
index.as :stored_searchable
|
74
|
+
end
|
75
|
+
property :source, predicate: ::RDF::DC.source do |index|
|
76
|
+
index.as :stored_searchable
|
77
|
+
end
|
78
|
+
|
79
|
+
# TODO: Move this somewhere more appropriate
|
80
|
+
begin
|
81
|
+
LocalAuthority.register_vocabulary(self, "subject", "lc_subjects")
|
82
|
+
LocalAuthority.register_vocabulary(self, "language", "lexvo_languages")
|
83
|
+
LocalAuthority.register_vocabulary(self, "tag", "lc_genres")
|
84
|
+
rescue
|
85
|
+
puts "tables for vocabularies missing"
|
86
|
+
end
|
18
87
|
end
|
19
88
|
|
20
89
|
# Add a schema.org itemtype
|
@@ -4,18 +4,27 @@ module Sufia
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
7
|
+
property :proxy_depositor, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#proxyDepositor'), multiple: false do |index|
|
8
|
+
index.as :symbol
|
9
|
+
end
|
10
|
+
|
11
|
+
# This value is set when a user indicates they are depositing this for someone else
|
12
|
+
property :on_behalf_of, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#onBehalfOf'), multiple: false do |index|
|
13
|
+
index.as :symbol
|
14
|
+
end
|
15
|
+
|
8
16
|
after_create :create_transfer_request
|
9
17
|
end
|
10
18
|
|
19
|
+
|
11
20
|
def create_transfer_request
|
12
|
-
Sufia.queue.push(ContentDepositorChangeEventJob.new(
|
21
|
+
Sufia.queue.push(ContentDepositorChangeEventJob.new(id, on_behalf_of)) if on_behalf_of.present?
|
13
22
|
end
|
14
23
|
|
15
24
|
def request_transfer_to(target)
|
16
25
|
raise ArgumentError, "Must provide a target" unless target
|
17
26
|
deposit_user = ::User.find_by_user_key(depositor)
|
18
|
-
ProxyDepositRequest.create!(pid:
|
27
|
+
ProxyDepositRequest.create!(pid: id, receiving_user: target, sending_user: deposit_user)
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|