active-fedora 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +30 -21
- data/History.txt +9 -0
- data/Rakefile +11 -0
- data/VERSION +1 -1
- data/active-fedora.gemspec +2 -2
- data/config/solr_mappings.yml +15 -13
- data/config/solr_mappings_af_0.1.yml +8 -15
- data/config/solr_mappings_bl_2.4.yml +16 -13
- data/lib/active_fedora.rb +5 -4
- data/lib/active_fedora/base.rb +7 -7
- data/lib/active_fedora/metadata_datastream_helper.rb +3 -3
- data/lib/active_fedora/model.rb +6 -6
- data/lib/active_fedora/nokogiri_datastream.rb +2 -2
- data/lib/active_fedora/rels_ext_datastream.rb +2 -2
- data/lib/active_fedora/solr_service.rb +7 -18
- data/spec/unit/solr_config_options_spec.rb +3 -4
- metadata +4 -4
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -7,10 +7,12 @@ gem 'multipart-post'
|
|
7
7
|
gem 'nokogiri'
|
8
8
|
gem 'om', '>= 1.0'
|
9
9
|
gem 'solrizer', '>=0.3.0'
|
10
|
-
|
10
|
+
gem 'activeresource', '>3.0.0'
|
11
|
+
gem 'mediashelf-loggable'
|
11
12
|
|
12
13
|
group :development, :test do
|
13
|
-
gem "
|
14
|
+
gem "jeweler"
|
15
|
+
gem "rspec", "<2.0.0"
|
14
16
|
gem "mocha", ">= 0.9.8"
|
15
17
|
gem "ruby-debug"
|
16
18
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,27 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
activemodel (3.0.1)
|
5
|
+
activesupport (= 3.0.1)
|
6
|
+
builder (~> 2.1.2)
|
7
|
+
i18n (~> 0.4.1)
|
8
|
+
activeresource (3.0.1)
|
9
|
+
activemodel (= 3.0.1)
|
10
|
+
activesupport (= 3.0.1)
|
11
|
+
activesupport (3.0.1)
|
12
|
+
builder (2.1.2)
|
11
13
|
columnize (0.3.1)
|
12
|
-
diff-lcs (1.1.2)
|
13
14
|
facets (2.9.0)
|
15
|
+
gemcutter (0.6.1)
|
16
|
+
git (1.2.5)
|
17
|
+
i18n (0.4.2)
|
18
|
+
jeweler (1.4.0)
|
19
|
+
gemcutter (>= 0.1.0)
|
20
|
+
git (>= 1.2.5)
|
21
|
+
rubyforge (>= 2.0.0)
|
22
|
+
json_pure (1.4.6)
|
14
23
|
linecache (0.43)
|
24
|
+
mediashelf-loggable (0.4.0)
|
15
25
|
mime-types (1.16)
|
16
26
|
mocha (0.9.9)
|
17
27
|
rake
|
@@ -21,37 +31,36 @@ GEM
|
|
21
31
|
facets
|
22
32
|
nokogiri (>= 1.4.2)
|
23
33
|
rake (0.8.7)
|
24
|
-
rspec (
|
25
|
-
rspec-core (~> 2.0.1)
|
26
|
-
rspec-expectations (~> 2.0.1)
|
27
|
-
rspec-mocks (~> 2.0.1)
|
28
|
-
rspec-core (2.0.1)
|
29
|
-
rspec-expectations (2.0.1)
|
30
|
-
diff-lcs (>= 1.1.2)
|
31
|
-
rspec-mocks (2.0.1)
|
32
|
-
rspec-core (~> 2.0.1)
|
33
|
-
rspec-expectations (~> 2.0.1)
|
34
|
+
rspec (1.3.1)
|
34
35
|
ruby-debug (0.10.3)
|
35
36
|
columnize (>= 0.1)
|
36
37
|
ruby-debug-base (~> 0.10.3.0)
|
37
38
|
ruby-debug-base (0.10.3)
|
38
39
|
linecache (>= 0.3)
|
40
|
+
rubyforge (2.0.4)
|
41
|
+
json_pure (>= 1.1.7)
|
39
42
|
solr-ruby (0.0.8)
|
40
43
|
solrizer (0.3.0)
|
41
|
-
|
42
|
-
|
44
|
+
mediashelf-loggable
|
45
|
+
nokogiri
|
46
|
+
nokogiri
|
47
|
+
om
|
48
|
+
solr-ruby
|
43
49
|
xml-simple (1.0.12)
|
44
50
|
|
45
51
|
PLATFORMS
|
46
52
|
ruby
|
47
53
|
|
48
54
|
DEPENDENCIES
|
55
|
+
activeresource (> 3.0.0)
|
56
|
+
jeweler
|
57
|
+
mediashelf-loggable
|
49
58
|
mime-types (>= 1.16)
|
50
59
|
mocha (>= 0.9.8)
|
51
60
|
multipart-post
|
52
61
|
nokogiri
|
53
62
|
om (>= 1.0)
|
54
|
-
rspec (
|
63
|
+
rspec (< 2.0.0)
|
55
64
|
ruby-debug
|
56
65
|
solr-ruby (>= 0.0.6)
|
57
66
|
solrizer (>= 0.3.0)
|
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
1.2.6
|
2
|
+
|
3
|
+
Requires Solrizer 0.3.0 or higher
|
4
|
+
|
5
|
+
HYDRA-274 Configurable Facets
|
6
|
+
HYDRA-275 Update ActiveFedora to use Solrizer::XML::TermBasedSolrizer when indexing NokogiriDatastreams
|
7
|
+
|
8
|
+
1.2.5 -- botched version release
|
9
|
+
|
1
10
|
1.2.4
|
2
11
|
|
3
12
|
Bug: Base.file_objects_append wasn't saving the child object after modifying its RELS-EXT
|
data/Rakefile
CHANGED
@@ -14,6 +14,17 @@ begin
|
|
14
14
|
gem.homepage = "http://yourmediashelf.com/activefedora"
|
15
15
|
gem.authors = ["Matt Zumwalt", "McClain Looney"]
|
16
16
|
gem.rubyforge_project = 'rubyfedora'
|
17
|
+
gem.add_dependency('solr-ruby', '>= 0.0.6')
|
18
|
+
gem.add_dependency('xml-simple', '>= 1.0.12')
|
19
|
+
gem.add_dependency('mime-types', '>= 1.16')
|
20
|
+
gem.add_dependency('multipart-post')
|
21
|
+
gem.add_dependency('nokogiri')
|
22
|
+
gem.add_dependency('om', '>= 1.0')
|
23
|
+
gem.add_dependency('solrizer', '>=0.3.0')
|
24
|
+
gem.add_dependency("activeresource", "<3.0.0")
|
25
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
26
|
+
gem.add_development_dependency "mocha", ">= 0.9.8"
|
27
|
+
gem.add_development_dependency "ruby-debug"
|
17
28
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
29
|
end
|
19
30
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.6
|
data/active-fedora.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{active-fedora}
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matt Zumwalt", "McClain Looney"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-27}
|
13
13
|
s.description = %q{ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.}
|
14
14
|
s.email = %q{matt.zumwalt@yourmediashelf.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/config/solr_mappings.yml
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
id: id
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
default: searchable
|
3
|
+
searchable:
|
4
|
+
date: _dt
|
5
|
+
string: _t
|
6
|
+
text: _t
|
7
|
+
symbol: _s
|
8
|
+
integer: _i
|
9
|
+
long: _l
|
10
|
+
boolean: _b
|
11
|
+
float: _f
|
12
|
+
double: _d
|
13
|
+
displayable: _display
|
14
|
+
facetable: _facet
|
15
|
+
sortable: _sort
|
16
|
+
unstemmed_searchable: _unstem_search
|
@@ -1,16 +1,9 @@
|
|
1
1
|
id: id
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
double: _field
|
11
|
-
facet: _facet
|
12
|
-
display: _display
|
13
|
-
sort: _sort
|
14
|
-
unstemmed_search: _unstem_search
|
15
|
-
|
16
|
-
|
2
|
+
default: searchable
|
3
|
+
searchable:
|
4
|
+
default: _field
|
5
|
+
date: _date
|
6
|
+
displayable: _display
|
7
|
+
facetable: _facet
|
8
|
+
sortable: _sort
|
9
|
+
unstemmed_searchable: _unstem_search
|
@@ -1,14 +1,17 @@
|
|
1
1
|
id: id
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
default: searchable
|
3
|
+
searchable:
|
4
|
+
id: id
|
5
|
+
date: _dt
|
6
|
+
string: _t
|
7
|
+
text: _t
|
8
|
+
symbol: _s
|
9
|
+
integer: _i
|
10
|
+
long: _l
|
11
|
+
boolean: _b
|
12
|
+
float: _f
|
13
|
+
double: _d
|
14
|
+
displayable: _display
|
15
|
+
facetable: _facet
|
16
|
+
sortable: _sort
|
17
|
+
unstemmed_searchable: _unstem_search
|
data/lib/active_fedora.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
gem 'solr-ruby'
|
3
|
+
require "loggable"
|
3
4
|
|
4
5
|
$: << 'lib'
|
5
6
|
require 'logger'
|
6
7
|
require 'active_fedora/solr_service.rb'
|
7
|
-
require
|
8
|
-
|
9
|
-
SOLR_DOCUMENT_ID = Solrizer::FieldNameMapper.mappings["id"] unless defined?(SOLR_DOCUMENT_ID)
|
10
|
-
ENABLE_SOLR_UPDATES = true unless defined?(ENABLE_SOLR_UPDATES)
|
8
|
+
require "solrizer"
|
11
9
|
|
12
10
|
require 'ruby-fedora'
|
13
11
|
require 'active_fedora/base.rb'
|
@@ -24,6 +22,9 @@ require 'active_fedora/relationship.rb'
|
|
24
22
|
require 'active_fedora/rels_ext_datastream.rb'
|
25
23
|
require 'active_fedora/semantic_node.rb'
|
26
24
|
|
25
|
+
SOLR_DOCUMENT_ID = ActiveFedora::SolrService.id_field unless defined?(SOLR_DOCUMENT_ID)
|
26
|
+
ENABLE_SOLR_UPDATES = true unless defined?(ENABLE_SOLR_UPDATES)
|
27
|
+
|
27
28
|
module ActiveFedora #:nodoc:
|
28
29
|
|
29
30
|
class << self
|
data/lib/active_fedora/base.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'util/class_level_inheritable_attributes'
|
2
2
|
require 'active_fedora/model'
|
3
3
|
require 'active_fedora/semantic_node'
|
4
|
-
require
|
4
|
+
require "solrizer"
|
5
5
|
require 'nokogiri'
|
6
6
|
|
7
|
-
SOLR_DOCUMENT_ID = "id" unless defined?(SOLR_DOCUMENT_ID)
|
7
|
+
SOLR_DOCUMENT_ID = "id" unless (defined?(SOLR_DOCUMENT_ID) && !SOLR_DOCUMENT_ID.nil?)
|
8
8
|
ENABLE_SOLR_UPDATES = true unless defined?(ENABLE_SOLR_UPDATES)
|
9
9
|
|
10
10
|
module ActiveFedora
|
@@ -831,7 +831,7 @@ module ActiveFedora
|
|
831
831
|
# If opts[:model_only] == true, the base object metadata and the RELS-EXT datastream will be omitted. This is mainly to support shelver, which calls .to_solr for each model an object subscribes to.
|
832
832
|
def to_solr(solr_doc = Solr::Document.new, opts={})
|
833
833
|
unless opts[:model_only]
|
834
|
-
solr_doc << {SOLR_DOCUMENT_ID.to_sym => pid, solr_name(:system_create, :date) => self.create_date, solr_name(:system_modified, :date) => self.modified_date, solr_name(:active_fedora_model, :symbol) => self.class.inspect}
|
834
|
+
solr_doc << {SOLR_DOCUMENT_ID.to_sym => pid, ActiveFedora::SolrService.solr_name(:system_create, :date) => self.create_date, ActiveFedora::SolrService.solr_name(:system_modified, :date) => self.modified_date, ActiveFedora::SolrService.solr_name(:active_fedora_model, :symbol) => self.class.inspect}
|
835
835
|
end
|
836
836
|
datastreams.each_value do |ds|
|
837
837
|
# solr_doc = ds.to_solr(solr_doc) if ds.class.included_modules.include?(ActiveFedora::MetadataDatastreamHelper) ||( ds.kind_of?(ActiveFedora::RelsExtDatastream) || ( ds.kind_of?(ActiveFedora::QualifiedDublinCoreDatastream) && !opts[:model_only] )
|
@@ -869,8 +869,8 @@ module ActiveFedora
|
|
869
869
|
raise "Solr document record id and pid do not match" unless pid == solr_doc[SOLR_DOCUMENT_ID]
|
870
870
|
end
|
871
871
|
|
872
|
-
create_date = solr_doc[
|
873
|
-
modified_date = solr_doc[
|
872
|
+
create_date = solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date)].nil? ? solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date).to_s] : solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date)]
|
873
|
+
modified_date = solr_doc[ActiveFedora::SolrService.solr_name(:system_create, :date)].nil? ? solr_doc[ActiveFedora::SolrService.solr_name(:system_modified, :date).to_s] : solr_doc[ActiveFedora::SolrService.solr_name(:system_modified, :date)]
|
874
874
|
obj = self.new({:pid=>solr_doc[SOLR_DOCUMENT_ID],:create_date=>create_date,:modified_date=>modified_date})
|
875
875
|
obj.new_object = false
|
876
876
|
#set by default to load any dependent relationship objects from solr as well
|
@@ -887,9 +887,9 @@ module ActiveFedora
|
|
887
887
|
|
888
888
|
# Updates Solr index with self.
|
889
889
|
def update_index
|
890
|
-
if defined?( Solrizer::Solrizer )
|
890
|
+
if defined?( Solrizer::Fedora::Solrizer )
|
891
891
|
#logger.info("Trying to solrize pid: #{pid}")
|
892
|
-
solrizer = Solrizer::Solrizer.new
|
892
|
+
solrizer = Solrizer::Fedora::Solrizer.new
|
893
893
|
solrizer.solrize( self )
|
894
894
|
else
|
895
895
|
#logger.info("Trying to update solr for pid: #{pid}")
|
@@ -40,7 +40,7 @@ module ActiveFedora::MetadataDatastreamHelper
|
|
40
40
|
def to_solr(solr_doc = Solr::Document.new) # :nodoc:
|
41
41
|
fields.each do |field_key, field_info|
|
42
42
|
if field_info.has_key?(:values) && !field_info[:values].nil?
|
43
|
-
field_symbol = solr_name(field_key, field_info[:type])
|
43
|
+
field_symbol = ActiveFedora::SolrService.solr_name(field_key, field_info[:type])
|
44
44
|
field_info[:values].each do |val|
|
45
45
|
solr_doc << Solr::Field.new(field_symbol => val)
|
46
46
|
end
|
@@ -55,14 +55,14 @@ module ActiveFedora::MetadataDatastreamHelper
|
|
55
55
|
# This is utilized by ActiveFedora::Base.load_instance_from_solr to set
|
56
56
|
# metadata values in this object using the Solr document passed in.
|
57
57
|
# Any keys in the solr document that map to a metadata field key within a MetadataDatastream object
|
58
|
-
# are set to the corresponding value. Any others are ignored.
|
58
|
+
# are set to the corresponding value. Any others are ignored. ActiveFedora::SolrService.solr_name
|
59
59
|
# is used to map solr key to field key name.
|
60
60
|
#
|
61
61
|
# ====Warning
|
62
62
|
# Solr must be synchronized with data in Fedora.
|
63
63
|
def from_solr(solr_doc)
|
64
64
|
fields.each do |field_key, field_info|
|
65
|
-
field_symbol =
|
65
|
+
field_symbol = ActiveFedora::SolrService.solr_name(field_key, field_info[:type])
|
66
66
|
value = (solr_doc[field_symbol].nil? ? solr_doc[field_symbol.to_s]: solr_doc[field_symbol])
|
67
67
|
unless value.nil?
|
68
68
|
if value.is_a? Array
|
data/lib/active_fedora/model.rb
CHANGED
@@ -56,7 +56,7 @@ module ActiveFedora
|
|
56
56
|
def find(args)
|
57
57
|
if args == :all
|
58
58
|
escaped_class_name = self.name.gsub(/(:)/, '\\:')
|
59
|
-
q = "#{
|
59
|
+
q = "#{ActiveFedora::SolrService.solr_name(:active_fedora_model, :symbol)}:#{escaped_class_name}"
|
60
60
|
elsif args.class == String
|
61
61
|
escaped_id = args.gsub(/(:)/, '\\:')
|
62
62
|
q = "#{SOLR_DOCUMENT_ID}:#{escaped_id}"
|
@@ -89,7 +89,7 @@ module ActiveFedora
|
|
89
89
|
def find_by_solr(query, args={})
|
90
90
|
if query == :all
|
91
91
|
escaped_class_name = self.name.gsub(/(:)/, '\\:')
|
92
|
-
SolrService.instance.conn.query("#{
|
92
|
+
SolrService.instance.conn.query("#{ActiveFedora::SolrService.solr_name(:active_fedora_model, :symbol)}:#{escaped_class_name}", args)
|
93
93
|
elsif query.class == String
|
94
94
|
escaped_id = query.gsub(/(:)/, '\\:')
|
95
95
|
SolrService.instance.conn.query("#{SOLR_DOCUMENT_ID}:#{escaped_id}", args)
|
@@ -114,7 +114,7 @@ module ActiveFedora
|
|
114
114
|
def find_by_fields_by_solr(query_fields,opts={})
|
115
115
|
#create solr_args from fields passed in, needs to be comma separated list of form field1=value1,field2=value2,...
|
116
116
|
escaped_class_name = self.name.gsub(/(:)/, '\\:')
|
117
|
-
query = "#{
|
117
|
+
query = "#{ActiveFedora::SolrService.solr_name(:active_fedora_model, :symbol)}:#{escaped_class_name}"
|
118
118
|
|
119
119
|
query_fields.each_pair do |key,value|
|
120
120
|
unless value.nil?
|
@@ -125,7 +125,7 @@ module ActiveFedora
|
|
125
125
|
if class_fields.has_key?(key) && class_fields[key].has_key?(:type)
|
126
126
|
type = class_fields[key][:type]
|
127
127
|
type = :string unless type.kind_of?(Symbol)
|
128
|
-
solr_key =
|
128
|
+
solr_key = ActiveFedora::SolrService.solr_name(key,type)
|
129
129
|
end
|
130
130
|
|
131
131
|
escaped_value = value.gsub(/(:)/, '\\:')
|
@@ -143,7 +143,7 @@ module ActiveFedora
|
|
143
143
|
|
144
144
|
#set default sort to created date ascending
|
145
145
|
unless query_opts.include?(:sort)
|
146
|
-
query_opts.merge!({:sort=>[
|
146
|
+
query_opts.merge!({:sort=>[ActiveFedora::SolrService.solr_name(:system_create,:date)=>:ascending]})
|
147
147
|
else
|
148
148
|
#need to convert to solr names for all fields
|
149
149
|
sort_array =[]
|
@@ -169,7 +169,7 @@ module ActiveFedora
|
|
169
169
|
|
170
170
|
solr_name = field_name
|
171
171
|
if class_fields.include?(field_name.to_sym)
|
172
|
-
solr_name =
|
172
|
+
solr_name = ActiveFedora::SolrService.solr_name(key,class_fields[field_name.to_sym][:type])
|
173
173
|
end
|
174
174
|
sort_array.push({solr_name=>sort_direction})
|
175
175
|
end
|
@@ -114,13 +114,13 @@ class ActiveFedora::NokogiriDatastream < ActiveFedora::Datastream
|
|
114
114
|
|
115
115
|
def solrize_node(node, accessor_pointer, solr_doc = Solr::Document.new)
|
116
116
|
generic_field_name_base = self.class.accessor_generic_name(*accessor_pointer)
|
117
|
-
generic_field_name =
|
117
|
+
generic_field_name = ActiveFedora::SolrService.solr_name(generic_field_name_base, :text)
|
118
118
|
|
119
119
|
solr_doc << Solr::Field.new(generic_field_name => node.text)
|
120
120
|
|
121
121
|
if accessor_pointer.length > 1
|
122
122
|
hierarchical_field_name_base = self.class.accessor_hierarchical_name(*accessor_pointer)
|
123
|
-
hierarchical_field_name =
|
123
|
+
hierarchical_field_name = ActiveFedora::SolrService.solr_name(hierarchical_field_name_base, :text)
|
124
124
|
solr_doc << Solr::Field.new(hierarchical_field_name => node.text)
|
125
125
|
end
|
126
126
|
end
|
@@ -58,7 +58,7 @@ module ActiveFedora
|
|
58
58
|
#
|
59
59
|
# This is utilized by ActiveFedora::Base.load_instance_from_solr to load
|
60
60
|
# the relationships hash using the Solr document passed in instead of from the RELS-EXT datastream
|
61
|
-
# in Fedora. Utilizes Solrizer::FieldNameMapper
|
61
|
+
# in Fedora. Utilizes solr_name method (provided by Solrizer::FieldNameMapper) to map solr key to
|
62
62
|
# relationship predicate.
|
63
63
|
#
|
64
64
|
# ====Warning
|
@@ -66,7 +66,7 @@ module ActiveFedora
|
|
66
66
|
def from_solr(solr_doc)
|
67
67
|
#cycle through all possible predicates
|
68
68
|
PREDICATE_MAPPINGS.keys.each do |predicate|
|
69
|
-
predicate_symbol =
|
69
|
+
predicate_symbol = ActiveFedora::SolrService.solr_name(predicate, :symbol)
|
70
70
|
value = (solr_doc[predicate_symbol].nil? ? solr_doc[predicate_symbol.to_s]: solr_doc[predicate_symbol])
|
71
71
|
unless value.nil?
|
72
72
|
if value.is_a? Array
|
@@ -1,8 +1,13 @@
|
|
1
1
|
require 'solr'
|
2
|
-
require "solrizer
|
2
|
+
require "solrizer"
|
3
3
|
|
4
4
|
module ActiveFedora
|
5
5
|
class SolrService
|
6
|
+
|
7
|
+
include Solrizer::FieldNameMapper
|
8
|
+
include Loggable
|
9
|
+
|
10
|
+
load_mappings
|
6
11
|
|
7
12
|
attr_reader :conn
|
8
13
|
|
@@ -27,7 +32,7 @@ module ActiveFedora
|
|
27
32
|
end
|
28
33
|
results = []
|
29
34
|
solr_result.hits.each do |hit|
|
30
|
-
model_value = hit[
|
35
|
+
model_value = hit[solr_name("active_fedora_model", :symbol)].first
|
31
36
|
if model_value.include?("::")
|
32
37
|
classname = eval(model_value)
|
33
38
|
else
|
@@ -56,22 +61,6 @@ module ActiveFedora
|
|
56
61
|
return uri.gsub(/(:)/, '\\:')
|
57
62
|
end
|
58
63
|
|
59
|
-
def self.mappings
|
60
|
-
Solrizer::FieldNameMapper.mappings
|
61
|
-
end
|
62
|
-
def self.mappings=(mappings)
|
63
|
-
Solrizer::FieldNameMapper.mappings = mappings
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.logger
|
67
|
-
@logger ||= defined?(RAILS_DEFAULT_LOGGER) ? RAILS_DEFAULT_LOGGER : Logger.new(STDOUT)
|
68
|
-
end
|
69
|
-
|
70
|
-
# (re)load solr field name mappings
|
71
|
-
def self.load_mappings( config_path=nil )
|
72
|
-
Solrizer::FieldNameMapper.load_mappings(config_path)
|
73
|
-
end
|
74
|
-
|
75
64
|
|
76
65
|
end #SolrService
|
77
66
|
class SolrNotInitialized < StandardError;end
|
@@ -27,13 +27,12 @@ describe ActiveFedora do
|
|
27
27
|
describe "field name mappings" do
|
28
28
|
it "should default to using the mappings for the current schema" do
|
29
29
|
from_default_yml = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "..", "config", "solr_mappings.yml")))
|
30
|
-
ActiveFedora::SolrService.mappings.should == from_default_yml
|
31
|
-
ActiveFedora::SolrService.mappings["date"].should == "_dt"
|
30
|
+
ActiveFedora::SolrService.mappings[:searchable].data_types[:date].opts[:suffix].should == from_default_yml["searchable"]["date"]
|
32
31
|
end
|
33
32
|
it "should allow you to provide your own mappings file" do
|
34
33
|
ActiveFedora::SolrService.load_mappings(File.join(File.dirname(__FILE__), "..", "..", "config", "solr_mappings_af_0.1.yml"))
|
35
|
-
ActiveFedora::SolrService.mappings[
|
36
|
-
ActiveFedora::SolrService.mappings[
|
34
|
+
ActiveFedora::SolrService.mappings[:searchable].data_types[:date].opts[:suffix].should == "_date"
|
35
|
+
ActiveFedora::SolrService.mappings[:searchable].data_types[:default].opts[:suffix].should == "_field"
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 6
|
10
|
+
version: 1.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Zumwalt
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-10-
|
19
|
+
date: 2010-10-27 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|