cul_scv_hydra 0.22.2 → 0.22.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cul_scv_hydra/indexer.rb +19 -14
- data/lib/cul_scv_hydra/risearch_members.rb +35 -2
- data/lib/cul_scv_hydra/version.rb +1 -1
- data/lib/cul_scv_hydra/version.rb~ +1 -1
- data/lib/tasks/index.rake +25 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 978a755b275967be31524d7f5353f87bb5f8b1f6
|
4
|
+
data.tar.gz: 3472e7787729f6d4e55fd342ad02904fa7fcaae4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 751f9996118553e9750610bd8f03eee3bf5783e5d23b79a78e62e98531700a0796b17afb3af7277780350dddef55ea2aecdae22f4671d2199ab9675e4e504e64
|
7
|
+
data.tar.gz: 8e107fea323d41e5ff4b1b87ef54a7e0a9c1d61db2fa3f38a355dec6bdaaf0d7a23f5e4f5c5d3021a282c73faff61d597aad05ad3c9b70549f138122551aee82
|
@@ -58,23 +58,28 @@ module Cul::Scv::Hydra::Indexer
|
|
58
58
|
def self.recursively_index_fedora_objects(top_pid, pids_to_omit=nil, skip_generic_resources=false, verbose_output=false)
|
59
59
|
|
60
60
|
descend_from(top_pid, pids_to_omit, verbose_output) do |pid|
|
61
|
+
self.index_pid(pid, skip_generic_resources, verbose_output)
|
62
|
+
end
|
61
63
|
|
62
|
-
|
63
|
-
begin
|
64
|
-
active_fedora_object = ActiveFedora::Base.find(pid, :cast => true)
|
65
|
-
|
66
|
-
if skip_generic_resources && active_fedora_object.is_a?(GenericResource)
|
67
|
-
puts 'Object was skipped because GenericResources are being skipped and it is a GenericResource.'
|
68
|
-
else
|
69
|
-
active_fedora_object.update_index
|
70
|
-
puts 'done.' if verbose_output
|
71
|
-
end
|
72
|
-
rescue Exception => e
|
73
|
-
puts "Encountered problem with #{pid}. Skipping record. Exception: #{e.message}"
|
74
|
-
end
|
64
|
+
end
|
75
65
|
|
76
|
-
|
66
|
+
def self.index_pid(pid, skip_generic_resources=false, verbose_output=false)
|
67
|
+
# We found an object with the desired PID. Let's reindex it
|
68
|
+
begin
|
69
|
+
active_fedora_object = ActiveFedora::Base.find(pid, :cast => true)
|
77
70
|
|
71
|
+
if skip_generic_resources && active_fedora_object.is_a?(GenericResource)
|
72
|
+
puts 'Object was skipped because GenericResources are being skipped and it is a GenericResource.'
|
73
|
+
else
|
74
|
+
active_fedora_object.update_index
|
75
|
+
puts 'done.' if verbose_output
|
76
|
+
end
|
77
|
+
rescue SystemExit, Interrupt => e
|
78
|
+
# Allow system interrupt (ctrl+c)
|
79
|
+
raise e
|
80
|
+
rescue Exception => e
|
81
|
+
puts "Encountered problem with #{pid}. Skipping record. Exception: #{e.message}"
|
82
|
+
end
|
78
83
|
end
|
79
84
|
|
80
85
|
end
|
@@ -5,7 +5,7 @@ module Cul::Scv::Hydra::RisearchMembers
|
|
5
5
|
recursive_member_query =
|
6
6
|
'select $child $parent from <#ri>
|
7
7
|
where
|
8
|
-
walk($child <http://purl.oclc.org/NET/CUL/memberOf> <fedora:' + pid + '> and $child <http://purl.oclc.org/NET/CUL/memberOf> $parent)'
|
8
|
+
walk($child <http://purl.oclc.org/NET/CUL/memberOf> <fedora:' + pid + '> and $child <http://purl.oclc.org/NET/CUL/memberOf> $parent)'
|
9
9
|
|
10
10
|
unless cmodel_type == 'all'
|
11
11
|
recursive_member_query += ' and $child <fedora-model:hasModel> $cmodel'
|
@@ -51,9 +51,42 @@ module Cul::Scv::Hydra::RisearchMembers
|
|
51
51
|
unique_pids = get_direct_member_results(pid,verbose_output,'json')
|
52
52
|
unique_pids.map{|result| result['pid'].gsub('info:fedora/', '') }.uniq
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
def self.get_direct_member_count(pid, verbose_output=false)
|
56
56
|
count = get_direct_member_results(pid,verbose_output,'count/json')
|
57
57
|
return count.blank? ? 0 : count[0]['count'].to_i
|
58
58
|
end
|
59
|
+
|
60
|
+
|
61
|
+
#Project constituents
|
62
|
+
|
63
|
+
def self.get_project_constituent_results(pid, verbose_output=false, format='json')
|
64
|
+
|
65
|
+
project_constituent_query =
|
66
|
+
'select $pid from <#ri>
|
67
|
+
where $pid <info:fedora/fedora-system:def/relations-external#isConstituentOf> <fedora:' + pid + '>'
|
68
|
+
|
69
|
+
puts 'Performing query:' if verbose_output
|
70
|
+
puts project_constituent_query if verbose_output
|
71
|
+
|
72
|
+
search_response = JSON(Cul::Scv::Fedora.repository.find_by_itql(project_constituent_query, {
|
73
|
+
:type => 'tuples',
|
74
|
+
:format => format,
|
75
|
+
:limit => '',
|
76
|
+
:stream => 'on'
|
77
|
+
}))
|
78
|
+
|
79
|
+
return search_response['results']
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.get_project_constituent_pids(pid, verbose_output=false)
|
83
|
+
unique_pids = get_project_constituent_results(pid,verbose_output,'json')
|
84
|
+
unique_pids.map{|result| result['pid'].gsub('info:fedora/', '') }.uniq
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.get_project_constituent_count(pid, verbose_output=false)
|
88
|
+
count = get_project_constituent_results(pid,verbose_output,'count/json')
|
89
|
+
return count.blank? ? 0 : count[0]['count'].to_i
|
90
|
+
end
|
91
|
+
|
59
92
|
end
|
data/lib/tasks/index.rake
CHANGED
@@ -40,6 +40,31 @@ namespace :cul_scv_hydra do
|
|
40
40
|
|
41
41
|
end
|
42
42
|
|
43
|
+
task :by_project_pid => :environment do
|
44
|
+
|
45
|
+
puts '---------------------------'
|
46
|
+
puts 'Fedora URL: ' + ActiveFedora.config.credentials[:url]
|
47
|
+
puts 'Solr URL: ' + ActiveFedora.solr_config[:url]
|
48
|
+
puts '---------------------------'
|
49
|
+
|
50
|
+
if ENV['PID']
|
51
|
+
project_pid = ENV['PID']
|
52
|
+
else
|
53
|
+
puts 'Please specify a project PID (e.g. PID=cul:123)'
|
54
|
+
next
|
55
|
+
end
|
56
|
+
|
57
|
+
START_TIME = Time.now
|
58
|
+
pids = Cul::Scv::Hydra::RisearchMembers.get_project_constituent_pids(project_pid, true)
|
59
|
+
|
60
|
+
puts "Found #{pids.length} project members."
|
61
|
+
|
62
|
+
pids.each do |pid|
|
63
|
+
Cul::Scv::Hydra::Indexer.index_pid(pid, false, false)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
43
68
|
end
|
44
69
|
|
45
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cul_scv_hydra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.22.
|
4
|
+
version: 0.22.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Armintor
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: blacklight
|
@@ -481,3 +481,4 @@ signing_key:
|
|
481
481
|
specification_version: 4
|
482
482
|
summary: ActiveFedora, OM, and Solrizer implementations for CUL Staff Collection Viewer
|
483
483
|
test_files: []
|
484
|
+
has_rdoc:
|