cul_scv_hydra 0.14.2 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGNiMWVjMGJkNjg5NzdlOTQ0MWViODRlNjE0YTc1YzcxODQxYTcxNg==
4
+ MjMwMTA4NzFkZDdjYzVlNDFkZWY4MTUxMzIwNWRjMzlhZjNkZjY5Mw==
5
5
  data.tar.gz: !binary |-
6
- ZDZmZWZhMzQwOGJkY2RjYmM0ZDg2Y2QxMjA2MTRjZDA2NjE2YWU5Mg==
6
+ YjYwYzkxNjFlY2VmY2UzOTRiY2MwZmJhNWEwMGJhOWJhODhhY2UwYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjlmZTg3YjdmODlhYWI1OGFkOTM3ZDFjNTI3N2I2NmVkNmUyNDJlOWRiNjlh
10
- YjFmZGQwNThjNGY3ZmZlNWM3ZGZhODNlZjlhMjc0NjExYzAxODMyODg4MzQ4
11
- ZGY4Y2FkMjRmYTAwZWExYjFjMDMzYTdhNTRiMTY1NGMxYTdmMjk=
9
+ M2NiZjkxOTQ4YjEyNGE1NTE0YWVhNzQxNTdlZDVmMGRlOTk0NmU4ZDNlMzgw
10
+ NWJhNDJlMGY4MmFkYWQzMjg5MmVjYjY4NGM5NjhhMDgzZTRkNzE3MWFhYWE1
11
+ MjllZTg4Y2NkODhlNDZjYmE1NDdiZWYwYTQxNDY3ZmUyODYzY2Q=
12
12
  data.tar.gz: !binary |-
13
- YmViODEyNGFjMzBiNzYzYmYyODkwZDdlMjMwMTMwMTEwMjdiYjY0MTVlZTk0
14
- OGIwYjBjMjYwNGVhNDcyMGQ5MjViNjI4ODE0Y2VjODg1OWJhY2FhNmEzMmFl
15
- MzU3NTlkYWE4NjliNDhjZTI1N2VmMjFjYjI2MTg1NzcyMzE4NmY=
13
+ NDY3Njc4ZTJjOTRjMzNjNWE0ZWE1YjZlNzVkM2Q4MTUxZGU4ZjI0NzYwMDE0
14
+ YmI4YmRmMzdhODUzNTNmNzNjN2YyZGExNGI3MzJlMmE5MGRjNGMwYWM1MDQ4
15
+ NTkyN2VmMjJkNjBhMTE5NmM5MWNiNmNlZDExZTBiMWYzMTZiNDA=
@@ -38,7 +38,7 @@ module Cul::Scv::Hydra::Models::Aggregator
38
38
  end
39
39
 
40
40
  def members(opts={})
41
- parts(opts)
41
+ parts({:response_format=>:solr}.merge(opts))
42
42
  end
43
43
 
44
44
  def member_ids(opts={})
@@ -75,6 +75,7 @@ module Cul::Scv::Hydra::Models::Common
75
75
 
76
76
  def to_solr(solr_doc = Hash.new, opts={})
77
77
  solr_doc = super(solr_doc, opts)
78
+
78
79
  if has_desc?
79
80
  solr_doc["descriptor_ssi"] = ["mods"]
80
81
  else
@@ -114,6 +115,7 @@ module Cul::Scv::Hydra::Models::Common
114
115
  end
115
116
  }
116
117
  solr_doc[:structured_bsi] = 'false' unless solr_doc.has_key? :structured_bsi
118
+
117
119
  solr_doc
118
120
  end
119
121
 
@@ -180,4 +182,19 @@ module Cul::Scv::Hydra::Models::Common
180
182
  response[OM::XML::Terminology.term_hierarchical_name(pointer)] = returned
181
183
  }
182
184
  end
185
+
186
+ def legacy_content_path(ds, ds_root=ActiveFedora.config.credentials[:datastreams_root])
187
+ unless ds.controlGroup == 'M'
188
+ return ds.dsLocation
189
+ end
190
+ cd = ds.dsCreateDate
191
+ tz = ActiveFedora.config.credentials[:time_zone]
192
+ tzi = ActiveSupport::TimeZone.find_tzinfo(tz)
193
+ ld = tzi.utc_to_local(cd)
194
+ month = (ld.month < 10) ? "0#{ld.month}" : ld.month.to_s
195
+ day = (ld.day < 10) ? "0#{ld.day}" : ld.day.to_s
196
+ hour = (ld.hour < 10) ? "0#{ld.hour}" : ld.hour.to_s
197
+ min = (ld.min < 10) ? "0#{ld.min}" : ld.min.to_s
198
+ return File.join(ds_root,"#{ld.year}/#{month}#{day}/#{hour}/#{min}", ds.dsLocation.sub(':','_'))
199
+ end
183
200
  end
@@ -32,4 +32,10 @@ class GenericAggregator < ::ActiveFedora::Base
32
32
  label
33
33
  end
34
34
 
35
+ def to_solr(solr_doc = Hash.new, opts={})
36
+ solr_doc = super(solr_doc, opts)
37
+ solr_doc["cul_number_of_members_isi"] = Cul::Scv::Hydra::RisearchMembers.get_direct_member_pids(pid).length
38
+ solr_doc
39
+ end
40
+
35
41
  end
@@ -61,7 +61,7 @@ class GenericResource < ::ActiveFedora::Base
61
61
  if self.zooming?
62
62
  fz = rels_int.relationships(datastreams['content'], :foaf_zooming).first.object.to_s.split('/')[-1]
63
63
  ds = datastreams[fz]
64
- rft_id = ds.controlGroup == 'E' ? datastreams[fz].dsLocation : fedora_ds_url(pid, ds.dsid) + '/content'
64
+ rft_id = ds.controlGroup == 'E' ? datastreams[fz].dsLocation : legacy_content_path(ds,'info:fedora/datastreams/')
65
65
  solr_doc['rft_id_ss'] = rft_id
66
66
  end
67
67
  solr_doc
data/config/jetty.yml ADDED
@@ -0,0 +1,6 @@
1
+ default:
2
+ startup_wait: 90
3
+ jetty_port: 8983
4
+ java_opts:
5
+ - "-Xmx256m"
6
+ - "-XX:MaxPermSize=128m"
@@ -3,7 +3,12 @@ module Cul
3
3
  module Fedora
4
4
  module RubydoraPatch
5
5
  def find_by_itql query, options = {}
6
- self.risearch(query, {:lang => 'itql'}.merge(options))
6
+ begin
7
+ self.risearch(query, {:lang => 'itql'}.merge(options))
8
+ rescue Exception => e
9
+ logger.error e
10
+ "{\"results\":[]}"
11
+ end
7
12
  end
8
13
  end
9
14
  end
@@ -25,24 +25,7 @@ module Cul::Scv::Hydra::Indexer
25
25
 
26
26
  puts 'Recursively retreieving and indexing all members...'
27
27
 
28
- member_query =
29
- 'select $child $parent $cmodel from <#ri>
30
- where
31
- walk($child <http://purl.oclc.org/NET/CUL/memberOf> <fedora:' + pid + '> and $child <http://purl.oclc.org/NET/CUL/memberOf> $parent)
32
- and
33
- $child <fedora-model:hasModel> $cmodel'
34
-
35
- puts 'Performing query:' if verbose_output
36
- puts member_query if verbose_output
37
-
38
- search_response = JSON(Cul::Scv::Fedora.repository.find_by_itql(member_query, {
39
- :type => 'tuples',
40
- :format => 'json',
41
- :limit => '',
42
- :stream => 'on'
43
- }))
44
-
45
- unique_pids = search_response['results'].map{|result| result['child'].gsub('info:fedora/', '') }.uniq
28
+ unique_pids = Cul::Scv::Hydra::RisearchMembers.get_recursive_member_pids(pid, true)
46
29
 
47
30
  total_number_of_members = unique_pids.length
48
31
  puts 'Recursive search found ' + total_number_of_members.to_s + ' members.' if verbose_output
@@ -0,0 +1,51 @@
1
+ module Cul::Scv::Hydra::RisearchMembers
2
+
3
+ def self.get_recursive_member_pids(pid, verbose_output=false)
4
+
5
+ recursive_member_query =
6
+ 'select $child $parent $cmodel from <#ri>
7
+ where
8
+ walk($child <http://purl.oclc.org/NET/CUL/memberOf> <fedora:' + pid + '> and $child <http://purl.oclc.org/NET/CUL/memberOf> $parent)
9
+ and
10
+ $child <fedora-model:hasModel> $cmodel'
11
+
12
+ puts 'Performing query:' if verbose_output
13
+ puts recursive_member_query if verbose_output
14
+
15
+ search_response = JSON(Cul::Scv::Fedora.repository.find_by_itql(recursive_member_query, {
16
+ :type => 'tuples',
17
+ :format => 'json',
18
+ :limit => '',
19
+ :stream => 'on'
20
+ }))
21
+
22
+ unique_pids = search_response['results'].map{|result| result['child'].gsub('info:fedora/', '') }.uniq
23
+
24
+ return unique_pids
25
+
26
+ end
27
+
28
+ def self.get_direct_member_pids(pid, verbose_output=false)
29
+
30
+ direct_member_query =
31
+ 'select $pid $cmodel from <#ri>
32
+ where $pid <http://purl.oclc.org/NET/CUL/memberOf> <fedora:' + pid + '>
33
+ and $pid <fedora-model:hasModel> $cmodel'
34
+
35
+ puts 'Performing query:' if verbose_output
36
+ puts direct_member_query if verbose_output
37
+
38
+ search_response = JSON(Cul::Scv::Fedora.repository.find_by_itql(direct_member_query, {
39
+ :type => 'tuples',
40
+ :format => 'json',
41
+ :limit => '',
42
+ :stream => 'on'
43
+ }))
44
+
45
+ unique_pids = search_response['results'].map{|result| result['pid'].gsub('info:fedora/', '') }.uniq
46
+
47
+ return unique_pids
48
+
49
+ end
50
+
51
+ end
@@ -1,7 +1,7 @@
1
1
  module Cul
2
2
  module Scv
3
3
  module Hydra
4
- VERSION = '0.14.2'
4
+ VERSION = '0.15.0'
5
5
  def self.version
6
6
  VERSION
7
7
  end
data/lib/cul_scv_hydra.rb CHANGED
@@ -45,6 +45,7 @@ require "cul_scv_hydra/access_controls_enforcement"
45
45
  require "cul_scv_hydra/controllers"
46
46
  require "cul_scv_hydra/om"
47
47
  require "cul_scv_hydra/indexer"
48
+ require "cul_scv_hydra/risearch_members"
48
49
  require "cul_scv_hydra/solrizer"
49
50
  require "cul_scv_hydra/version"
50
51
  require "cul_scv_hydra/engine" if defined? Rails
@@ -1,4 +1,9 @@
1
1
  APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../")
2
+ require 'active-fedora'
3
+
4
+ def logger
5
+ @logger ||= Logger.new($stdout)
6
+ end
2
7
 
3
8
  def filename_for_pid(pid)
4
9
  pid.gsub(/\:/,'_') + '.xml'
@@ -27,9 +32,9 @@ def config_subs
27
32
  cfile = File.join(APP_ROOT,'config','subs.yml')
28
33
  subs = {}
29
34
  if File.exists? cfile
30
- open(cfile) {|blob| subs = YAML::load(blob)[Rails.env] }
35
+ open(cfile) {|blob| subs = YAML::load(blob)[ENV['RAILS_ENV'] || 'test'] }
31
36
  else
32
- Rails.logger.warn("No subs.yml found; CModels will be loaded without inline substitutions")
37
+ logger.warn("No subs.yml found; CModels will be loaded without inline substitutions")
33
38
  end
34
39
  subs
35
40
  end
@@ -0,0 +1,43 @@
1
+ APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../")
2
+
3
+ require 'jettywrapper'
4
+ JETTY_ZIP_BASENAME = 'master'
5
+ Jettywrapper.url = "https://github.com/projecthydra/hydra-jetty/archive/#{JETTY_ZIP_BASENAME}.zip"
6
+
7
+ namespace :cul_hydra do
8
+ require 'rspec/core/rake_task'
9
+ RSpec::Core::RakeTask.new(:rspec) do |spec|
10
+ spec.pattern = FileList['spec/**/*_spec.rb']
11
+ spec.pattern += FileList['spec/*_spec.rb']
12
+ spec.rspec_opts = ['--backtrace'] if ENV['CI']
13
+ end
14
+
15
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
16
+ spec.pattern = FileList['spec/**/*_spec.rb']
17
+ spec.pattern += FileList['spec/*_spec.rb']
18
+ spec.rcov = true
19
+ end
20
+
21
+ desc "CI build"
22
+ task :ci do
23
+ ENV['environment'] = "test"
24
+ #Rake::Task["active_fedora:configure_jetty"].invoke
25
+ jetty_params = Jettywrapper.load_config
26
+ error = Jettywrapper.wrap(jetty_params) do
27
+ Rake::Task["cul_scv_hydra:cmodel:reload_all"].invoke
28
+ Rake::Task['cul_hydra:coverage'].invoke
29
+ end
30
+ raise "test failures: #{error}" if error
31
+ end
32
+
33
+ desc "Execute specs with coverage"
34
+ task :coverage do
35
+ # Put spec opts in a file named .rspec in root
36
+ ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
37
+ ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
38
+
39
+ # Rake::Task["active_fedora:fixtures"].invoke
40
+ Rake::Task["cul_hydra:rspec"].invoke
41
+ end
42
+
43
+ end
data/lib/tasks/index.rake CHANGED
@@ -20,7 +20,8 @@ namespace :cul_scv_hydra do
20
20
  begin
21
21
  Cul::Scv::Hydra::Indexer.recursively_index_fedora_objects(pid, skip_top_level_object_indexing, true)
22
22
  rescue => e
23
- puts e
23
+ puts 'Error: ' + e.message
24
+ puts e.backtrace
24
25
  next
25
26
  end
26
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cul_scv_hydra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Armintor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-15 00:00:00.000000000 Z
11
+ date: 2014-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blacklight
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ~>
165
165
  - !ruby/object:Gem::Version
166
166
  version: '2.10'
167
+ - !ruby/object:Gem::Dependency
168
+ name: jettywrapper
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: 1.4.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ! '>='
179
+ - !ruby/object:Gem::Version
180
+ version: 1.4.0
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: equivalent-xml
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -238,6 +252,7 @@ files:
238
252
  - app/models/static_image_aggregator.rb
239
253
  - bin/rails
240
254
  - config/fedora.yml
255
+ - config/jetty.yml
241
256
  - config/predicate_mappings.yml
242
257
  - config/solr_mappings.yml
243
258
  - config/solr_value_maps.yml
@@ -269,6 +284,7 @@ files:
269
284
  - lib/cul_scv_hydra/indexer.rb
270
285
  - lib/cul_scv_hydra/om.rb
271
286
  - lib/cul_scv_hydra/om/standard_mods.rb
287
+ - lib/cul_scv_hydra/risearch_members.rb
272
288
  - lib/cul_scv_hydra/solrizer.rb
273
289
  - lib/cul_scv_hydra/solrizer/extractor.rb
274
290
  - lib/cul_scv_hydra/solrizer/field_mapper.rb
@@ -277,6 +293,7 @@ files:
277
293
  - lib/cul_scv_hydra/solrizer/value_mapper.rb
278
294
  - lib/cul_scv_hydra/version.rb
279
295
  - lib/tasks/cmodel.rake
296
+ - lib/tasks/cul_hydra_dev.rake
280
297
  - lib/tasks/index.rake
281
298
  homepage: https://github.com/cul/cul_scv_hydra
282
299
  licenses: []