cul_scv_hydra 0.22.6 → 0.22.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/cul/hydra/controller.rb +22 -0
- data/app/controllers/concerns/cul/hydra/resolver.rb +69 -0
- data/app/controllers/concerns/cul/hydra/thumbnails.rb +62 -0
- data/app/controllers/concerns/cul/scv/hydra/controller.rb +3 -19
- data/app/controllers/concerns/cul/scv/hydra/resolver.rb +2 -65
- data/app/controllers/concerns/cul/scv/hydra/thumbnails.rb +3 -59
- data/app/models/concept.rb +1 -1
- data/app/models/concerns/cul/hydra/models.rb +24 -0
- data/app/models/concerns/cul/hydra/models/aggregator.rb +121 -0
- data/app/models/concerns/cul/hydra/models/common.rb +220 -0
- data/app/models/concerns/cul/hydra/models/image_resource.rb +78 -0
- data/app/models/concerns/cul/hydra/models/linkable_resources.rb +108 -0
- data/app/models/concerns/cul/hydra/models/resource.rb +87 -0
- data/app/models/concerns/cul/scv/hydra/models.rb +1 -13
- data/app/models/concerns/cul/scv/hydra/models/aggregator.rb +1 -116
- data/app/models/concerns/cul/scv/hydra/models/common.rb +1 -213
- data/app/models/concerns/cul/scv/hydra/models/image_resource.rb +3 -75
- data/app/models/concerns/cul/scv/hydra/models/linkable_resources.rb +3 -105
- data/app/models/concerns/cul/scv/hydra/models/resource.rb +2 -83
- data/app/models/cul/hydra/datastreams/dc_metadata.rb +107 -0
- data/app/models/cul/hydra/datastreams/mods_document.rb +195 -0
- data/app/models/cul/hydra/datastreams/struct_metadata.rb +176 -0
- data/app/models/cul/scv/hydra/datastreams/dc_metadata.rb +5 -104
- data/app/models/cul/scv/hydra/datastreams/mods_document.rb +5 -178
- data/app/models/cul/scv/hydra/datastreams/struct_metadata.rb +5 -174
- data/app/models/dc_document.rb +1 -1
- data/app/models/generic_aggregator.rb +5 -5
- data/app/models/generic_object.rb +2 -2
- data/app/models/generic_resource.rb +4 -4
- data/app/models/mets_structured_aggregator.rb +2 -2
- data/app/models/resource.rb +3 -3
- data/app/models/resource_aggregator.rb +3 -3
- data/fixtures/spec/CUL_MODS/mods-subjects.xml +24 -0
- data/lib/cul_hydra.rb +18 -0
- data/lib/cul_hydra/access_controls_enforcement.rb +53 -0
- data/lib/cul_hydra/controllers.rb +13 -0
- data/lib/cul_hydra/controllers/aggregates.rb +93 -0
- data/lib/cul_hydra/controllers/aggregator_controller_helper.rb +27 -0
- data/lib/cul_hydra/controllers/catalog.rb +12 -0
- data/lib/cul_hydra/controllers/content_aggregators.rb +81 -0
- data/lib/cul_hydra/controllers/datastreams.rb +145 -0
- data/lib/cul_hydra/controllers/helpers.rb +10 -0
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/active_fedora_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/application_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/dc_metadata_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_assets_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_autocomplete_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_uploader_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/resources_helper_behavior.rb +1 -1
- data/lib/cul_hydra/controllers/resources.rb +161 -0
- data/lib/cul_hydra/controllers/static_image_aggregators.rb +105 -0
- data/lib/cul_hydra/controllers/suggestions.rb +126 -0
- data/lib/cul_hydra/controllers/terms.rb +205 -0
- data/lib/cul_hydra/engine.rb +31 -0
- data/lib/cul_hydra/fedora.rb +41 -0
- data/lib/cul_hydra/fedora/dummy_object.rb +37 -0
- data/lib/cul_hydra/fedora/rubydora_patch.rb +16 -0
- data/lib/cul_hydra/fedora/url_helper_behavior.rb +32 -0
- data/lib/cul_hydra/indexer.rb +84 -0
- data/lib/cul_hydra/om.rb +7 -0
- data/lib/cul_hydra/om/standard_mods.rb +115 -0
- data/lib/cul_hydra/risearch_members.rb +92 -0
- data/lib/cul_hydra/solrizer.rb +10 -0
- data/lib/cul_hydra/solrizer/extractor.rb +27 -0
- data/lib/cul_hydra/solrizer/mods_fieldable.rb +435 -0
- data/lib/cul_hydra/solrizer/terminology_based_solrizer.rb +35 -0
- data/lib/cul_hydra/solrizer/value_mapper.rb +46 -0
- data/lib/{cul_scv_hydra/solrizer/field_mapper.rb → cul_hydra/solrizer_patch.rb} +0 -0
- data/lib/cul_hydra/version.rb +8 -0
- data/lib/cul_hydra/version.rb~ +8 -0
- data/lib/cul_scv_fedora/dummy_object.rb +1 -30
- data/lib/cul_scv_fedora/rubydora_patch.rb +3 -7
- data/lib/cul_scv_fedora/url_helper_behavior.rb +3 -23
- data/lib/cul_scv_hydra.rb +5 -32
- data/lib/cul_scv_hydra/access_controls_enforcement.rb +3 -50
- data/lib/cul_scv_hydra/controllers.rb +10 -10
- data/lib/cul_scv_hydra/controllers/aggregates.rb +1 -86
- data/lib/cul_scv_hydra/controllers/aggregator_controller_helper.rb +4 -23
- data/lib/cul_scv_hydra/controllers/catalog.rb +5 -9
- data/lib/cul_scv_hydra/controllers/content_aggregators.rb +4 -77
- data/lib/cul_scv_hydra/controllers/datastreams.rb +3 -140
- data/lib/cul_scv_hydra/controllers/helpers.rb +44 -8
- data/lib/cul_scv_hydra/controllers/resources.rb +4 -157
- data/lib/cul_scv_hydra/controllers/static_image_aggregators.rb +4 -100
- data/lib/cul_scv_hydra/controllers/suggestions.rb +4 -122
- data/lib/cul_scv_hydra/controllers/terms.rb +4 -201
- data/lib/cul_scv_hydra/engine.rb +1 -1
- data/lib/cul_scv_hydra/indexer.rb +3 -82
- data/lib/cul_scv_hydra/om.rb +2 -2
- data/lib/cul_scv_hydra/om/standard_mods.rb +1 -108
- data/lib/cul_scv_hydra/risearch_members.rb +4 -89
- data/lib/cul_scv_hydra/solrizer.rb +5 -6
- data/lib/cul_scv_hydra/solrizer/extractor.rb +1 -25
- data/lib/cul_scv_hydra/solrizer/scv_mods_fieldable.rb +4 -429
- data/lib/cul_scv_hydra/solrizer/terminology_based_solrizer.rb +4 -32
- data/lib/cul_scv_hydra/solrizer/value_mapper.rb +1 -44
- data/lib/cul_scv_hydra/version.rb +5 -5
- data/lib/tasks/index.rake +2 -2
- data/lib/tasks/transform.rake +23 -0
- metadata +55 -12
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'cul_hydra'
|
2
|
+
require 'json'
|
3
|
+
module Cul::Hydra::Controllers
|
4
|
+
module Suggestions
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
include Blacklight::SolrHelper
|
8
|
+
include MediaShelf::ActiveFedoraHelper
|
9
|
+
end
|
10
|
+
|
11
|
+
def index
|
12
|
+
stub = params[:term] || ""
|
13
|
+
if params[:term_id].nil?
|
14
|
+
raise "Cannot provide suggestions without a term name"
|
15
|
+
end
|
16
|
+
field_name = params[:term_id]
|
17
|
+
field_key = field_key_from(field_name, Cul::Hydra::Om::ModsDocument.terminology)
|
18
|
+
solr_name = get_solr_name(field_key, Cul::Hydra::Om::ModsDocument)
|
19
|
+
solr_params = {}
|
20
|
+
solr_params['wt'] = 'json'
|
21
|
+
solr_params['terms'] = 'true'
|
22
|
+
solr_params['terms.fl'] = solr_name
|
23
|
+
solr_params['terms.lower'] = stub
|
24
|
+
solr_params['terms.lower.incl'] = false
|
25
|
+
solr_params['terms.prefix'] = stub
|
26
|
+
solr_params['terms.sort'] = 'index'
|
27
|
+
solr_response = Blacklight.solr.get 'terms', {:params => solr_params}
|
28
|
+
result = []
|
29
|
+
hash = {}
|
30
|
+
(1...solr_response['terms'].length).step(2) { |ix|
|
31
|
+
solr_response['terms'][ix].each { |val|
|
32
|
+
result << val if val.is_a? String
|
33
|
+
}
|
34
|
+
}
|
35
|
+
send_data result.to_json, :disposition => 'inline', :type => 'text/plain'
|
36
|
+
return
|
37
|
+
end
|
38
|
+
|
39
|
+
## field_key_from(field_name) to reverse this method from HydraFedoraMetadataHelper
|
40
|
+
# def field_name_for(field_key)
|
41
|
+
# if field_key.kind_of?(Array)
|
42
|
+
# return OM::XML::Terminology.term_hierarchical_name(*field_key)
|
43
|
+
# else
|
44
|
+
# field_key.to_s
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
|
48
|
+
def field_key_from(field_name, terminology)
|
49
|
+
# this is a hack, but necessary until/unless OM generates names differently
|
50
|
+
candidates = field_name.split('__')
|
51
|
+
field_key = []
|
52
|
+
candidates.each_with_index { |candidate, ix|
|
53
|
+
if (candidates[ix + 1] and candidates[ix + 1].match(/\d+/))
|
54
|
+
field_key << {OM.destringify(candidate) => Integer(candidates.delete_at(ix + 1))}
|
55
|
+
else
|
56
|
+
field_key << OM.destringify(candidate)
|
57
|
+
end
|
58
|
+
}
|
59
|
+
logger.debug field_key.inspect
|
60
|
+
field_key
|
61
|
+
end
|
62
|
+
|
63
|
+
# ** largely copied from ActiveFedora::NokogiriDatastream.get_values **
|
64
|
+
def get_solr_name(term_pointer, dsClass)
|
65
|
+
term = dsClass.terminology.retrieve_term(*OM.pointers_to_flat_array(term_pointer, false))
|
66
|
+
names = []
|
67
|
+
if is_hierarchical_term_pointer?(*term_pointer)
|
68
|
+
bases = []
|
69
|
+
#add first item in term_pointer as start of bases
|
70
|
+
# then iterate through possible nodes that might exist
|
71
|
+
term_pointer.first.kind_of?(Hash) ? bases << term_pointer.first.keys.first : bases << term_pointer.first
|
72
|
+
for i in 1..(term_pointer.length-1)
|
73
|
+
#iterate in reverse so that we can modify the bases array while iterating
|
74
|
+
(bases.length-1).downto(0) do |j|
|
75
|
+
current_last = (term_pointer[i].kind_of?(Hash) ? term_pointer[i].keys.first : term_pointer[i])
|
76
|
+
if (term_pointer[i-1].kind_of?(Hash))
|
77
|
+
#just use index supplied instead of trying possibilities
|
78
|
+
index = term_pointer[i-1].values.first
|
79
|
+
solr_name_base = OM::XML::Terminology.term_hierarchical_name({bases[j]=>index},current_last)
|
80
|
+
solr_name = generate_solr_symbol(solr_name_base, term.data_type)
|
81
|
+
bases.delete_at(j)
|
82
|
+
#insert the new solr name base if found
|
83
|
+
bases.insert(j,solr_name_base) if has_solr_name?(solr_name,solr_doc)
|
84
|
+
else
|
85
|
+
#detect how many nodes exist
|
86
|
+
index = 0
|
87
|
+
current_base = bases[j]
|
88
|
+
bases.delete_at(j)
|
89
|
+
solr_name_base = OM::XML::Terminology.term_hierarchical_name({current_base=>index},current_last)
|
90
|
+
solr_name = generate_solr_symbol(solr_name_base, term.data_type)
|
91
|
+
bases.insert(j,solr_name_base)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
bases.each do |base|
|
96
|
+
names << generate_solr_symbol(base.to_sym, term.data_type)
|
97
|
+
end
|
98
|
+
else
|
99
|
+
#this is not hierarchical and we can simply look for the solr name created using the terms without any indexes
|
100
|
+
generic_field_name_base = OM::XML::Terminology.term_generic_name(*term_pointer)
|
101
|
+
names << generate_solr_symbol(generic_field_name_base, term.data_type)
|
102
|
+
end
|
103
|
+
names
|
104
|
+
end
|
105
|
+
|
106
|
+
# ** copied from ActiveFedora::NokogiriDatastream **
|
107
|
+
#@return true if the term_pointer contains an index
|
108
|
+
# ====Example:
|
109
|
+
# [:image, {:title_set=>1}, :title] return true
|
110
|
+
# [:image, :title_set, :title] return false
|
111
|
+
def is_hierarchical_term_pointer?(*term_pointer)
|
112
|
+
if term_pointer.length>1
|
113
|
+
term_pointer.each do |pointer|
|
114
|
+
if pointer.kind_of?(Hash)
|
115
|
+
return true
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
return false
|
120
|
+
end
|
121
|
+
# ** copied from ActiveFedora::NokogiriDatastream **
|
122
|
+
def generate_solr_symbol(base, data_type)
|
123
|
+
Solrizer::XML::TerminologyBasedSolrizer.default_field_mapper.solr_name(base.to_sym, data_type)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
require 'cul_hydra'
|
2
|
+
require 'json'
|
3
|
+
require 'blacklight'
|
4
|
+
module Cul::Hydra::Controllers
|
5
|
+
module Terms
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
included do
|
8
|
+
include ::Blacklight::SolrHelper
|
9
|
+
#include MediaShelf::ActiveFedoraHelper
|
10
|
+
end
|
11
|
+
|
12
|
+
def index
|
13
|
+
if params[:layout] == "false"
|
14
|
+
layout = false
|
15
|
+
end
|
16
|
+
if params[:term_id]
|
17
|
+
@solr_name = solr_name(params[:term_id])
|
18
|
+
else
|
19
|
+
@solr_name = params[:solr_name]
|
20
|
+
end
|
21
|
+
@terms = term_values
|
22
|
+
render :action=>params[:action], :layout=>layout
|
23
|
+
end
|
24
|
+
|
25
|
+
# this method should be overridden to use the appropriate terminology
|
26
|
+
def solr_name(term_id)
|
27
|
+
if term_id.nil?
|
28
|
+
raise "Cannot provide suggestions without a term name"
|
29
|
+
end
|
30
|
+
field_key = field_key_from(term_id, Cul::Hydra::Om::ModsDocument.terminology)
|
31
|
+
get_solr_name(field_key, Cul::Hydra::Om::ModsDocument)
|
32
|
+
end
|
33
|
+
def term_values
|
34
|
+
if @solr_name.nil?
|
35
|
+
logger.debug "no solr field name, return nil for term values"
|
36
|
+
return nil
|
37
|
+
end
|
38
|
+
stub = params[:term_value]
|
39
|
+
solr_params = {}
|
40
|
+
solr_params['wt'] = 'json'
|
41
|
+
solr_params['terms'] = 'true'
|
42
|
+
solr_params['terms.fl'] = @solr_name
|
43
|
+
if stub
|
44
|
+
solr_params['terms.lower'] = stub
|
45
|
+
solr_params['terms.lower.incl'] = false
|
46
|
+
solr_params['terms.prefix'] = stub
|
47
|
+
solr_params['terms.sort'] = 'index'
|
48
|
+
else
|
49
|
+
solr_params['terms.sort'] = params.fetch(:sort,'count')
|
50
|
+
solr_params['terms.limit'] = -1
|
51
|
+
end
|
52
|
+
solr_response = Blacklight.solr.get 'terms', {:params => solr_params}
|
53
|
+
result = []
|
54
|
+
hash = {}
|
55
|
+
(1...solr_response['terms'].length).step(2) { |ix|
|
56
|
+
_t = solr_response['terms'][ix]
|
57
|
+
(0..._t.length).step(2) { |jx|
|
58
|
+
result << [_t[jx], _t[jx + 1]]
|
59
|
+
}
|
60
|
+
}
|
61
|
+
return result
|
62
|
+
end
|
63
|
+
|
64
|
+
## field_key_from(field_name) to reverse this method from HydraFedoraMetadataHelper
|
65
|
+
# def field_name_for(field_key)
|
66
|
+
# if field_key.kind_of?(Array)
|
67
|
+
# return OM::XML::Terminology.term_hierarchical_name(*field_key)
|
68
|
+
# else
|
69
|
+
# field_key.to_s
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
|
73
|
+
def field_key_from(hier_field_name, t)
|
74
|
+
candidates = hier_field_name.split('_')
|
75
|
+
field_key = []
|
76
|
+
candidates.inject(field_key) { |ptrs, term|
|
77
|
+
if term =~ /\d+/
|
78
|
+
ptr = {ptrs.pop=>term.to_i}
|
79
|
+
else
|
80
|
+
ptr = (ptrs.empty? or ptrs.last.is_a? Hash) ? term.to_sym : (ptrs.pop.to_s + "_" + term).to_sym
|
81
|
+
end
|
82
|
+
ptrs.push ptr
|
83
|
+
}
|
84
|
+
return field_key if t.has_term? *field_key
|
85
|
+
# pointers are probably from ambiguous underscores
|
86
|
+
amb = field_key.dup
|
87
|
+
field_key = []
|
88
|
+
amb.each do |candidate|
|
89
|
+
key = (candidate.is_a? Hash) ? candidate.keys.first : candidate # no indexes should be included
|
90
|
+
parts = key.to_s.split('_')
|
91
|
+
ptrs = parts_to_terms(parts, t, field_key)
|
92
|
+
if ptrs.nil? or !t.has_term? *ptrs
|
93
|
+
raise "Couldn't generate pointer from term name going forward for \"" + hier_field_name + "\" (no matched term sequence)"
|
94
|
+
else
|
95
|
+
if candidate.is_a? Hash
|
96
|
+
ptr_key = ptrs.pop
|
97
|
+
ptrs.push({ptr_key => candidate[candidate.keys.first] })
|
98
|
+
end
|
99
|
+
field_key = ptrs
|
100
|
+
end
|
101
|
+
end
|
102
|
+
return field_key if t.has_term? *field_key
|
103
|
+
raise "Couldn't generate pointer from term name going forward for \"" + hier_field_name + "\", tried " + field_key.inspect
|
104
|
+
end
|
105
|
+
|
106
|
+
def parts_to_terms(parts, t, prefix=[])
|
107
|
+
return nil if parts.length == 0 # this should be short-circuited in the loop below rather than recurring
|
108
|
+
if parts.length == 1
|
109
|
+
new_term_ptr = prefix.dup.push parts[0].to_sym
|
110
|
+
if t.has_term? *new_term_ptr
|
111
|
+
return new_term_ptr
|
112
|
+
else
|
113
|
+
return nil
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
results = []
|
118
|
+
parts.each_index do |ix|
|
119
|
+
term_ptr = prefix.dup.push parts[0...(parts.length - ix)].join('_').to_sym
|
120
|
+
|
121
|
+
if t.has_term? *term_ptr
|
122
|
+
case ix
|
123
|
+
when 0
|
124
|
+
results.push term_ptr
|
125
|
+
when 1
|
126
|
+
new_term_ptr = term_ptr.concat [parts.last.to_sym]
|
127
|
+
results.push new_term_ptr if t.has_term? *new_term_ptr
|
128
|
+
else
|
129
|
+
new_term_ptr = parts_to_terms(parts[parts.length - ix, ix], t, term_ptr)
|
130
|
+
results.push new_term_ptr if !new_term_ptr.nil?
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
if results.length == 1
|
136
|
+
return results[0]
|
137
|
+
else
|
138
|
+
return nil
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# ** largely copied from ActiveFedora::NokogiriDatastream.get_values **
|
143
|
+
def get_solr_name(term_pointer, dsClass)
|
144
|
+
term = dsClass.terminology.retrieve_term(*OM.pointers_to_flat_array(term_pointer, false))
|
145
|
+
names = []
|
146
|
+
if is_hierarchical_term_pointer?(*term_pointer)
|
147
|
+
bases = []
|
148
|
+
#add first item in term_pointer as start of bases
|
149
|
+
# then iterate through possible nodes that might exist
|
150
|
+
term_pointer.first.kind_of?(Hash) ? bases << term_pointer.first.keys.first : bases << term_pointer.first
|
151
|
+
for i in 1..(term_pointer.length-1)
|
152
|
+
#iterate in reverse so that we can modify the bases array while iterating
|
153
|
+
(bases.length-1).downto(0) do |j|
|
154
|
+
current_last = (term_pointer[i].kind_of?(Hash) ? term_pointer[i].keys.first : term_pointer[i])
|
155
|
+
if (term_pointer[i-1].kind_of?(Hash))
|
156
|
+
#just use index supplied instead of trying possibilities
|
157
|
+
index = term_pointer[i-1].values.first
|
158
|
+
solr_name_base = OM::XML::Terminology.term_hierarchical_name({bases[j]=>index},current_last)
|
159
|
+
solr_name = generate_solr_symbol(solr_name_base, term.data_type)
|
160
|
+
bases.delete_at(j)
|
161
|
+
#insert the new solr name base if found
|
162
|
+
bases.insert(j,solr_name_base) if has_solr_name?(solr_name,solr_doc)
|
163
|
+
else
|
164
|
+
#detect how many nodes exist
|
165
|
+
index = 0
|
166
|
+
current_base = bases[j]
|
167
|
+
bases.delete_at(j)
|
168
|
+
solr_name_base = OM::XML::Terminology.term_hierarchical_name({current_base=>index},current_last)
|
169
|
+
solr_name = generate_solr_symbol(solr_name_base, term.data_type)
|
170
|
+
bases.insert(j,solr_name_base)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
bases.each do |base|
|
175
|
+
names << generate_solr_symbol(base.to_sym, term.data_type)
|
176
|
+
end
|
177
|
+
else
|
178
|
+
#this is not hierarchical and we can simply look for the solr name created using the terms without any indexes
|
179
|
+
generic_field_name_base = OM::XML::Terminology.term_generic_name(*term_pointer)
|
180
|
+
names << generate_solr_symbol(generic_field_name_base, term.data_type)
|
181
|
+
end
|
182
|
+
names
|
183
|
+
end
|
184
|
+
|
185
|
+
# ** copied from ActiveFedora::NokogiriDatastream **
|
186
|
+
#@return true if the term_pointer contains an index
|
187
|
+
# ====Example:
|
188
|
+
# [:image, {:title_set=>1}, :title] return true
|
189
|
+
# [:image, :title_set, :title] return false
|
190
|
+
def is_hierarchical_term_pointer?(*term_pointer)
|
191
|
+
if term_pointer.length>1
|
192
|
+
term_pointer.each do |pointer|
|
193
|
+
if pointer.kind_of?(Hash)
|
194
|
+
return true
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
return false
|
199
|
+
end
|
200
|
+
# ** copied from ActiveFedora::NokogiriDatastream **
|
201
|
+
def generate_solr_symbol(base, data_type)
|
202
|
+
Solrizer::XML::TerminologyBasedSolrizer.default_field_mapper.solr_name(base.to_sym, data_type)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# lib/cul_hydra/engine.rb
|
3
|
+
require "cul_hydra"
|
4
|
+
require "rails"
|
5
|
+
|
6
|
+
module Cul::Hydra
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
isolate_namespace Cul::Hydra
|
9
|
+
|
10
|
+
config.mount_at = '/'
|
11
|
+
|
12
|
+
config.autoload_paths += %W(
|
13
|
+
#{config.root}/app/controllers/concerns
|
14
|
+
#{config.root}/app/models/concerns
|
15
|
+
)
|
16
|
+
|
17
|
+
config.generators do |g|
|
18
|
+
g.test_framework :rspec
|
19
|
+
g.integration_tool :rspec
|
20
|
+
end
|
21
|
+
|
22
|
+
# Make the rake tasks visible.
|
23
|
+
rake_tasks do
|
24
|
+
Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..'))) do
|
25
|
+
Dir.glob(File.join('tasks', '*.rake')).each do |railtie|
|
26
|
+
#load railtie # Commenting this out for now because we appear to be loading rake tasks twice
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Cul
|
2
|
+
module Hydra
|
3
|
+
module Fedora
|
4
|
+
autoload :DummyObject, 'cul_hydra/fedora/dummy_object'
|
5
|
+
autoload :RubydoraPatch, 'cul_hydra/fedora/rubydora_patch'
|
6
|
+
autoload :UrlHelperBehavior, 'cul_hydra/fedora/url_helper_behavior'
|
7
|
+
module ClassMethods
|
8
|
+
def config_path
|
9
|
+
File.join(Rails.root.to_s, 'config', 'fedora.yml')
|
10
|
+
end
|
11
|
+
def config
|
12
|
+
ActiveFedora.fedora_config.credentials
|
13
|
+
end
|
14
|
+
def connection
|
15
|
+
@connection ||= ActiveFedora::RubydoraConnection.new(ActiveFedora.fedora_config.credentials)
|
16
|
+
end
|
17
|
+
|
18
|
+
def repository
|
19
|
+
@repository ||= begin
|
20
|
+
repo = connection.connection
|
21
|
+
repo.extend(RubydoraPatch)
|
22
|
+
repo
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def ds_for_uri(fedora_uri, fake_obj=nil)
|
27
|
+
return nil unless fedora_uri =~ /info\:fedora\/.*/
|
28
|
+
p = fedora_uri.split('/')
|
29
|
+
return ds_for_opts({pid: p[1], dsid: p[2]})
|
30
|
+
end
|
31
|
+
|
32
|
+
def ds_for_opts(opts={}, fake_obj=nil)
|
33
|
+
return nil unless opts[:pid] and opts[:dsid]
|
34
|
+
fake_obj = fake_obj.nil? ? DummyObject.new(opts[:pid]) : fake_obj.spawn(opts[:pid])
|
35
|
+
return (opts[:class] || ::Rubydora::Datastream).new(fake_obj, opts[:dsid])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
extend ClassMethods
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Cul
|
2
|
+
module Hydra
|
3
|
+
module Fedora
|
4
|
+
class DummyObject
|
5
|
+
attr_accessor :pid
|
6
|
+
def initialize(pid, isNew=false)
|
7
|
+
@pid = pid
|
8
|
+
@isNew = isNew
|
9
|
+
end
|
10
|
+
def new_record?
|
11
|
+
@isNew
|
12
|
+
end
|
13
|
+
def new_record=(val)
|
14
|
+
@isNew = val
|
15
|
+
end
|
16
|
+
def internal_uri
|
17
|
+
@uri ||= "info:fedora/#{@pid}"
|
18
|
+
end
|
19
|
+
def connection
|
20
|
+
Cul::Hydra::Fedora.connection
|
21
|
+
end
|
22
|
+
def repository
|
23
|
+
Cul::Hydra::Fedora.repository
|
24
|
+
end
|
25
|
+
def spawn(pid)
|
26
|
+
s = DummyObject.new(pid, @isNew)
|
27
|
+
s.connection= connection
|
28
|
+
s.repository= repository
|
29
|
+
s
|
30
|
+
end
|
31
|
+
protected
|
32
|
+
def connection=(connection); @connection = connection; end
|
33
|
+
def repository=(repo); @repository = repo; end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Cul
|
2
|
+
module Hydra
|
3
|
+
module Fedora
|
4
|
+
module RubydoraPatch
|
5
|
+
def find_by_itql query, options = {}
|
6
|
+
begin
|
7
|
+
self.risearch(query, {:lang => 'itql'}.merge(options))
|
8
|
+
rescue Exception => e
|
9
|
+
logger.error e if defined?(logger)
|
10
|
+
"{\"results\":[]}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|