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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/cul/hydra/controller.rb +22 -0
  3. data/app/controllers/concerns/cul/hydra/resolver.rb +69 -0
  4. data/app/controllers/concerns/cul/hydra/thumbnails.rb +62 -0
  5. data/app/controllers/concerns/cul/scv/hydra/controller.rb +3 -19
  6. data/app/controllers/concerns/cul/scv/hydra/resolver.rb +2 -65
  7. data/app/controllers/concerns/cul/scv/hydra/thumbnails.rb +3 -59
  8. data/app/models/concept.rb +1 -1
  9. data/app/models/concerns/cul/hydra/models.rb +24 -0
  10. data/app/models/concerns/cul/hydra/models/aggregator.rb +121 -0
  11. data/app/models/concerns/cul/hydra/models/common.rb +220 -0
  12. data/app/models/concerns/cul/hydra/models/image_resource.rb +78 -0
  13. data/app/models/concerns/cul/hydra/models/linkable_resources.rb +108 -0
  14. data/app/models/concerns/cul/hydra/models/resource.rb +87 -0
  15. data/app/models/concerns/cul/scv/hydra/models.rb +1 -13
  16. data/app/models/concerns/cul/scv/hydra/models/aggregator.rb +1 -116
  17. data/app/models/concerns/cul/scv/hydra/models/common.rb +1 -213
  18. data/app/models/concerns/cul/scv/hydra/models/image_resource.rb +3 -75
  19. data/app/models/concerns/cul/scv/hydra/models/linkable_resources.rb +3 -105
  20. data/app/models/concerns/cul/scv/hydra/models/resource.rb +2 -83
  21. data/app/models/cul/hydra/datastreams/dc_metadata.rb +107 -0
  22. data/app/models/cul/hydra/datastreams/mods_document.rb +195 -0
  23. data/app/models/cul/hydra/datastreams/struct_metadata.rb +176 -0
  24. data/app/models/cul/scv/hydra/datastreams/dc_metadata.rb +5 -104
  25. data/app/models/cul/scv/hydra/datastreams/mods_document.rb +5 -178
  26. data/app/models/cul/scv/hydra/datastreams/struct_metadata.rb +5 -174
  27. data/app/models/dc_document.rb +1 -1
  28. data/app/models/generic_aggregator.rb +5 -5
  29. data/app/models/generic_object.rb +2 -2
  30. data/app/models/generic_resource.rb +4 -4
  31. data/app/models/mets_structured_aggregator.rb +2 -2
  32. data/app/models/resource.rb +3 -3
  33. data/app/models/resource_aggregator.rb +3 -3
  34. data/fixtures/spec/CUL_MODS/mods-subjects.xml +24 -0
  35. data/lib/cul_hydra.rb +18 -0
  36. data/lib/cul_hydra/access_controls_enforcement.rb +53 -0
  37. data/lib/cul_hydra/controllers.rb +13 -0
  38. data/lib/cul_hydra/controllers/aggregates.rb +93 -0
  39. data/lib/cul_hydra/controllers/aggregator_controller_helper.rb +27 -0
  40. data/lib/cul_hydra/controllers/catalog.rb +12 -0
  41. data/lib/cul_hydra/controllers/content_aggregators.rb +81 -0
  42. data/lib/cul_hydra/controllers/datastreams.rb +145 -0
  43. data/lib/cul_hydra/controllers/helpers.rb +10 -0
  44. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/active_fedora_helper_behavior.rb +1 -1
  45. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/application_helper_behavior.rb +1 -1
  46. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/dc_metadata_helper_behavior.rb +1 -1
  47. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_assets_helper_behavior.rb +1 -1
  48. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_autocomplete_helper_behavior.rb +1 -1
  49. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_uploader_helper_behavior.rb +1 -1
  50. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/resources_helper_behavior.rb +1 -1
  51. data/lib/cul_hydra/controllers/resources.rb +161 -0
  52. data/lib/cul_hydra/controllers/static_image_aggregators.rb +105 -0
  53. data/lib/cul_hydra/controllers/suggestions.rb +126 -0
  54. data/lib/cul_hydra/controllers/terms.rb +205 -0
  55. data/lib/cul_hydra/engine.rb +31 -0
  56. data/lib/cul_hydra/fedora.rb +41 -0
  57. data/lib/cul_hydra/fedora/dummy_object.rb +37 -0
  58. data/lib/cul_hydra/fedora/rubydora_patch.rb +16 -0
  59. data/lib/cul_hydra/fedora/url_helper_behavior.rb +32 -0
  60. data/lib/cul_hydra/indexer.rb +84 -0
  61. data/lib/cul_hydra/om.rb +7 -0
  62. data/lib/cul_hydra/om/standard_mods.rb +115 -0
  63. data/lib/cul_hydra/risearch_members.rb +92 -0
  64. data/lib/cul_hydra/solrizer.rb +10 -0
  65. data/lib/cul_hydra/solrizer/extractor.rb +27 -0
  66. data/lib/cul_hydra/solrizer/mods_fieldable.rb +435 -0
  67. data/lib/cul_hydra/solrizer/terminology_based_solrizer.rb +35 -0
  68. data/lib/cul_hydra/solrizer/value_mapper.rb +46 -0
  69. data/lib/{cul_scv_hydra/solrizer/field_mapper.rb → cul_hydra/solrizer_patch.rb} +0 -0
  70. data/lib/cul_hydra/version.rb +8 -0
  71. data/lib/cul_hydra/version.rb~ +8 -0
  72. data/lib/cul_scv_fedora/dummy_object.rb +1 -30
  73. data/lib/cul_scv_fedora/rubydora_patch.rb +3 -7
  74. data/lib/cul_scv_fedora/url_helper_behavior.rb +3 -23
  75. data/lib/cul_scv_hydra.rb +5 -32
  76. data/lib/cul_scv_hydra/access_controls_enforcement.rb +3 -50
  77. data/lib/cul_scv_hydra/controllers.rb +10 -10
  78. data/lib/cul_scv_hydra/controllers/aggregates.rb +1 -86
  79. data/lib/cul_scv_hydra/controllers/aggregator_controller_helper.rb +4 -23
  80. data/lib/cul_scv_hydra/controllers/catalog.rb +5 -9
  81. data/lib/cul_scv_hydra/controllers/content_aggregators.rb +4 -77
  82. data/lib/cul_scv_hydra/controllers/datastreams.rb +3 -140
  83. data/lib/cul_scv_hydra/controllers/helpers.rb +44 -8
  84. data/lib/cul_scv_hydra/controllers/resources.rb +4 -157
  85. data/lib/cul_scv_hydra/controllers/static_image_aggregators.rb +4 -100
  86. data/lib/cul_scv_hydra/controllers/suggestions.rb +4 -122
  87. data/lib/cul_scv_hydra/controllers/terms.rb +4 -201
  88. data/lib/cul_scv_hydra/engine.rb +1 -1
  89. data/lib/cul_scv_hydra/indexer.rb +3 -82
  90. data/lib/cul_scv_hydra/om.rb +2 -2
  91. data/lib/cul_scv_hydra/om/standard_mods.rb +1 -108
  92. data/lib/cul_scv_hydra/risearch_members.rb +4 -89
  93. data/lib/cul_scv_hydra/solrizer.rb +5 -6
  94. data/lib/cul_scv_hydra/solrizer/extractor.rb +1 -25
  95. data/lib/cul_scv_hydra/solrizer/scv_mods_fieldable.rb +4 -429
  96. data/lib/cul_scv_hydra/solrizer/terminology_based_solrizer.rb +4 -32
  97. data/lib/cul_scv_hydra/solrizer/value_mapper.rb +1 -44
  98. data/lib/cul_scv_hydra/version.rb +5 -5
  99. data/lib/tasks/index.rake +2 -2
  100. data/lib/tasks/transform.rake +23 -0
  101. metadata +55 -12
@@ -1,105 +1,9 @@
1
1
  require 'cul_scv_hydra/controllers/helpers/resources_helper_behavior'
2
2
  module Cul::Scv::Hydra::Controllers
3
- module StaticImageAggregators
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- include Hydra::AssetsControllerHelper
8
- include Cul::Scv::Hydra::Controllers::Helpers::ResourcesHelperBehavior
9
- include Hydra::RepositoryController
10
- include MediaShelf::ActiveFedoraHelper
11
- include Blacklight::SolrHelper
12
- before_filter :require_fedora
13
- prepend_before_filter :sanitize_update_params
14
- end
15
-
16
- def index
17
- if params[:layout] == "false"
18
- # action = "index_embedded"
19
- layout = false
20
- end
21
- if !params[:container_id].nil?
22
- container_uri = "info:fedora/#{params[:container_id]}"
23
- escaped_uri = container_uri.gsub(/(:)/, '\\:')
24
- extra_controller_params = {:q=>"cul_member_of_s:#{escaped_uri}"}
25
- @response, @document_list = get_search_results( extra_controller_params )
26
-
27
- # Including this line so permissions tests can be run against the container
28
- @container_response, @document = get_solr_response_for_doc_id(params[:container_id])
29
-
30
- # Including these lines for backwards compatibility (until we can use Rails3 callbacks)
31
- @container = ActiveFedora::Base.load_instance(params[:container_id])
32
- @solr_result = @container.file_objects(:response_format=>:solr)
33
- else
34
- # @solr_result = ActiveFedora::SolrService.instance.conn.query('has_model_field:info\:fedora/ldpd\:Resource', @search_params)
35
- @solr_result = Resource.find_by_solr(:all)
36
- end
37
- render :action=>params[:action], :layout=>layout
38
- end
39
-
40
- def new
41
- @asset = StaticImageAggregator.new
42
- apply_depositor_metadata(@asset)
43
- set_collection_type(@asset, params[:content_type])
44
- if !params[:container_id].nil?
45
- associate_resource_with_container(@asset, params[:container_id])
46
- end
47
- @asset.save
48
- @asset.refresh
49
- msg = "Created a Static Image Aggregator with pid #{@asset.pid}. Now it's ready to be edited."
50
- flash[:notice]= msg
51
-
52
- if params.has_key?(:Filedata)
53
- @file_asset = create_and_save_resource_from_params
54
- apply_depositor_metadata(@file_asset)
55
-
56
- flash[:notice] += " The file #{params[:Filename]} has been saved in <a href=\"#{asset_url(@file_asset.pid)}\">#{@file_asset.pid}</a>."
57
-
58
- if !params[:container_id].nil?
59
- associate_resource_with_container(@file_asset, @asset.pid)
60
- end
61
-
62
- ## Apply any posted file metadata
63
- unless params[:asset].nil?
64
- logger.debug("applying submitted file metadata: #{@sanitized_params.inspect}")
65
- @metadata_update_response = update_document(@file_asset, @sanitized_params)
66
- end
67
- @file_asset.save
68
- # If redirect_params has not been set, use {:action=>:index}
69
- logger.debug "Created #{@file_asset.pid}."
3
+ module StaticImageAggregators
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ include Cul::Hydra::Controllers::StaticImageAggregators
70
7
  end
71
- @asset.save
72
-
73
- session[:scripts] = params[:combined] == "true"
74
- redirect_to url_for(:action=>"edit", :id=>@asset.pid, :new_asset=>true, :controller=>'catalog')
75
-
76
8
  end
77
-
78
- # Common destroy method for all AssetsControllers
79
- def destroy
80
- # The correct implementation, with garbage collection:
81
- # if params.has_key?(:container_id)
82
- # container = ActiveFedora::Base.load_instance(params[:container_id])
83
- # container.file_objects_remove(params[:id])
84
- # FileAsset.garbage_collect(params[:id])
85
- # else
86
-
87
- # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers)
88
- ActiveFedora::Base.load_instance(params[:id]).delete
89
- render :text => "Deleted #{params[:id]} from #{params[:container_id]}."
90
- end
91
-
92
-
93
- def show
94
- @image_agg = StaticImageAggregator.find(params[:id])
95
- if (@image_agg.nil?)
96
- logger.warn("No such object: " + params[:id])
97
- flash[:notice]= "No such object."
98
- redirect_to(:action => 'index', :q => nil , :f => nil)
99
- else
100
- @id_array = @image_agg.containers(:response_format => :id_array)
101
- end
102
- render :action=>params[:action], :layout=>(params[:layout]=="false")
103
- end
104
- end
105
9
  end
@@ -1,126 +1,8 @@
1
- require 'cul_scv_hydra'
2
- require 'json'
3
1
  module Cul::Scv::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::Scv::Hydra::Om::ModsDocument.terminology)
18
- solr_name = get_solr_name(field_key, Cul::Scv::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)
2
+ module Suggestions
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ include Cul::Hydra::Controllers::Suggestions
102
6
  end
103
- names
104
7
  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
8
  end
@@ -1,205 +1,8 @@
1
- require 'cul_scv_hydra'
2
- require 'json'
3
- require 'blacklight'
4
1
  module Cul::Scv::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::Scv::Hydra::Om::ModsDocument.terminology)
31
- get_solr_name(field_key, Cul::Scv::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)
2
+ module Terms
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ include Cul::Hydra::Controllers::Terms
181
6
  end
182
- names
183
7
  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
8
  end