cul_scv_hydra 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/config/fedora.yml +9 -3
- data/config/solr.yml +3 -12
- data/lib/cul_scv_hydra/active_fedora/model/aggregator.rb +29 -30
- data/lib/cul_scv_hydra/active_fedora/model/common.rb +168 -170
- data/lib/cul_scv_hydra/active_fedora/model/resource.rb +43 -44
- data/lib/cul_scv_hydra/controllers/terms.rb +64 -11
- data/lib/cul_scv_hydra/om/scv_mods_document.rb +1 -1
- data/lib/cul_scv_hydra/version.rb +2 -2
- metadata +40 -39
data/config/fedora.yml
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
development:
|
2
|
-
url: http://
|
2
|
+
:url: http://127.0.0.1:8983/fedora
|
3
|
+
:user: fedoraAdmin
|
4
|
+
:password: fedoraAdmin
|
3
5
|
test:
|
4
|
-
url: http://
|
6
|
+
:url: http://127.0.0.1:8983/fedora
|
7
|
+
:user: fedoraAdmin
|
8
|
+
:password: fedoraAdmin
|
5
9
|
default:
|
6
|
-
url: http://
|
10
|
+
:url: http://127.0.0.1:8983/fedora
|
11
|
+
:user: fedoraAdmin
|
12
|
+
:password: fedoraAdmin
|
data/config/solr.yml
CHANGED
@@ -1,15 +1,6 @@
|
|
1
1
|
development:
|
2
|
-
|
3
|
-
url: http://127.0.0.1:8983/solr/development
|
4
|
-
full_text:
|
5
|
-
url: http://127.0.0.1:8983/solr/development
|
2
|
+
url: http://127.0.0.1:8983/solr/development
|
6
3
|
test:
|
7
|
-
|
8
|
-
url: http://127.0.0.1:8983/solr/test
|
9
|
-
full_text:
|
10
|
-
url: http://127.0.0.1:8983/solr/test
|
4
|
+
url: http://127.0.0.1:8983/solr/test
|
11
5
|
default:
|
12
|
-
|
13
|
-
url: http://127.0.0.1:8983/solr/test
|
14
|
-
full_text:
|
15
|
-
url: http://127.0.0.1:8983/solr/test
|
6
|
+
url: http://127.0.0.1:8983/solr/test
|
@@ -6,40 +6,39 @@ module Aggregator
|
|
6
6
|
has_relationship "parts", :cul_member_of, :inbound => true
|
7
7
|
after_create :aggregator!
|
8
8
|
end
|
9
|
-
module InstanceMethods
|
10
|
-
def aggregator!
|
11
|
-
add_relationship(:rdf_type, Cul::Scv::Hydra::ActiveFedora::AGGREGATOR_TYPE.to_s)
|
12
|
-
@metadata_is_dirty = true
|
13
|
-
update
|
14
|
-
end
|
15
9
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
member.save
|
10
|
+
def aggregator!
|
11
|
+
add_relationship(:rdf_type, Cul::Scv::Hydra::ActiveFedora::AGGREGATOR_TYPE.to_s)
|
12
|
+
@metadata_is_dirty = true
|
13
|
+
update
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_member(member, container=self)
|
17
|
+
if container.respond_to?:internal_uri
|
18
|
+
container = container.internal_uri
|
26
19
|
end
|
20
|
+
if container =~ /\A[\w\-]+:[\w\-]+\Z/
|
21
|
+
container = "info:fedora/#{container}"
|
22
|
+
end
|
23
|
+
member.add_relationship(:cul_member_of, container)
|
24
|
+
member.datastreams["RELS-EXT"].dirty = true
|
25
|
+
member.save
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
rel = ActiveFedora::Relationship.new()
|
36
|
-
rel.subject_pid= :self
|
37
|
-
rel.object = container
|
38
|
-
rel.predicate = :cul_member_of
|
39
|
-
member.remove_relationship(rel)
|
40
|
-
member.datastreams["RELS-EXT"].dirty = true
|
41
|
-
member.save
|
28
|
+
def remove_member(member, container=self)
|
29
|
+
if container.respond_to?:internal_uri
|
30
|
+
container = container.internal_uri
|
31
|
+
end
|
32
|
+
if container =~ /\A[\w\-]+:[\w\-]+\Z/
|
33
|
+
container = "info:fedora/#{container}"
|
42
34
|
end
|
35
|
+
rel = ActiveFedora::Relationship.new()
|
36
|
+
rel.subject_pid= :self
|
37
|
+
rel.object = container
|
38
|
+
rel.predicate = :cul_member_of
|
39
|
+
member.remove_relationship(rel)
|
40
|
+
member.datastreams["RELS-EXT"].dirty = true
|
41
|
+
member.save
|
43
42
|
end
|
44
43
|
end
|
45
44
|
end
|
@@ -1,42 +1,41 @@
|
|
1
1
|
require "active-fedora"
|
2
2
|
require 'uri'
|
3
3
|
module Cul::Scv::Hydra::ActiveFedora::Model
|
4
|
-
|
5
|
-
|
4
|
+
module Common
|
5
|
+
extend ActiveSupport::Concern
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
included do
|
8
|
+
define_model_callbacks :create
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
has_relationship "containers", :cul_member_of
|
11
|
+
has_relationship "rdf_type", :rdf_type
|
12
|
+
has_metadata :name => "DC", :type=>Cul::Scv::Hydra::Om::DCMetadata, :versionable => true
|
13
|
+
has_metadata :name => "descMetadata", :type=>Cul::Scv::Hydra::Om::ModsDocument, :versionable => true
|
14
|
+
has_metadata :name => "rightsMetadata", :type=>::Hydra::RightsMetadata, :versionable => true
|
15
|
+
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
module ClassMethods
|
18
|
+
def pid_namespace
|
19
|
+
"ldpd"
|
20
|
+
end
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
23
|
+
def initialize(attrs = nil)
|
24
|
+
attrs = {} if attrs.nil?
|
25
|
+
attrs[:namespace] = self.class.pid_namespace unless attrs[:namespace]
|
26
|
+
super
|
27
|
+
end
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
def create
|
30
|
+
run_callbacks :create do
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
def resources(opts={})
|
36
|
+
if self.respond_to? :parts # aggregator
|
37
|
+
opts = {:rows=>25,:response_format=>:solr}.merge(opts)
|
38
|
+
self.parts(opts)
|
40
39
|
#opts = {:rows=>25,:response_format=>:solr}.merge(opts)
|
41
40
|
#query = self.class.inbound_relationship_query(self.pid, "parts")
|
42
41
|
#solr_result = ::ActiveFedora::SolrService.instance.conn.query(query, :rows=>opts[:rows])
|
@@ -55,167 +54,166 @@ module Cul::Scv::Hydra::ActiveFedora::Model
|
|
55
54
|
# return ::ActiveFedora::SolrService.reify_solr_results(solr_result)
|
56
55
|
# end
|
57
56
|
#end
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
else
|
58
|
+
logger.warn "parts not defined; was this an Aggregator?"
|
59
|
+
[]
|
60
|
+
end
|
61
|
+
end
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
63
|
+
def members(opts={})
|
64
|
+
resources(opts)
|
65
|
+
end
|
66
|
+
|
67
|
+
def members_ids(opts={})
|
68
|
+
opts = opts.merge({:response_format=>:id_array})
|
69
|
+
resources(opts)
|
70
|
+
end
|
71
|
+
|
73
72
|
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
def cmodel_pid(klass)
|
74
|
+
klass.pid_namespace + ":" + klass.name.split("::")[-1]
|
75
|
+
end
|
77
76
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
91
|
-
end
|
92
|
-
mds[dsid].new_object = false
|
77
|
+
def datastreams_in_fedora
|
78
|
+
mds = {}
|
79
|
+
self.datastreams_xml['datastream'].each do |ds|
|
80
|
+
dsid = ds["dsid"]
|
81
|
+
ds.merge!({:pid => self.pid, :dsID => dsid, :dsLabel => ds["label"]})
|
82
|
+
if dsid == "RELS-EXT"
|
83
|
+
mds.merge!({dsid => ActiveFedora::RelsExtDatastream.new(ds)})
|
84
|
+
else
|
85
|
+
if self.class.ds_specs.has_key? dsid
|
86
|
+
mds.merge!({dsid => self.class.ds_specs[dsid][0].new(ds)})
|
87
|
+
else
|
88
|
+
mds.merge!({dsid => ActiveFedora::Datastream.new(ds)})
|
93
89
|
end
|
94
|
-
mds
|
95
90
|
end
|
91
|
+
mds[dsid].new_object = false
|
96
92
|
end
|
93
|
+
mds
|
94
|
+
end
|
95
|
+
|
96
|
+
def route_as
|
97
|
+
"default"
|
98
|
+
end
|
97
99
|
|
98
|
-
|
99
|
-
|
100
|
+
def index_type_label
|
101
|
+
riquery = Cul::Scv::Hydra::ActiveFedora::MEMBER_QUERY.gsub(/%PID%/, self.pid)
|
102
|
+
begin
|
103
|
+
docs = ::ActiveFedora::RubydoraConnection.instance.connection.find_by_sparql riquery
|
104
|
+
rescue
|
105
|
+
docs = self.parts
|
100
106
|
end
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
docs = self.parts
|
108
|
-
end
|
109
|
-
if docs.length == 0
|
110
|
-
label = "EMPTY"
|
111
|
-
elsif docs.length == 1
|
112
|
-
label = "SINGLE PART"
|
113
|
-
else
|
114
|
-
label = "MULTIPART"
|
115
|
-
end
|
116
|
-
label
|
107
|
+
if docs.length == 0
|
108
|
+
label = "EMPTY"
|
109
|
+
elsif docs.length == 1
|
110
|
+
label = "SINGLE PART"
|
111
|
+
else
|
112
|
+
label = "MULTIPART"
|
117
113
|
end
|
118
|
-
|
119
|
-
|
114
|
+
label
|
115
|
+
end
|
116
|
+
|
117
|
+
def has_desc?
|
118
|
+
has_desc = false
|
119
|
+
begin
|
120
|
+
has_desc = self.datastreams.include? "descMetadata"
|
121
|
+
has_desc = has_desc and self.inner_object.datastreams["descMetadata"].content.length > 0
|
122
|
+
has_desc = self.datastreams["descMetadata"].term_values(:identifier).length > 0
|
123
|
+
rescue
|
120
124
|
has_desc = false
|
121
|
-
begin
|
122
|
-
has_desc = self.datastreams.include? "descMetadata"
|
123
|
-
has_desc = has_desc and self.inner_object.datastreams["descMetadata"].content.length > 0
|
124
|
-
has_desc = self.datastreams["descMetadata"].term_values(:identifier).length > 0
|
125
|
-
rescue
|
126
|
-
has_desc = false
|
127
|
-
end
|
128
|
-
has_desc
|
129
125
|
end
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
126
|
+
has_desc
|
127
|
+
end
|
128
|
+
|
129
|
+
def to_solr(solr_doc = Hash.new, opts={})
|
130
|
+
super
|
131
|
+
if has_desc?
|
132
|
+
solr_doc["descriptor_s"] = ["mods"]
|
133
|
+
else
|
134
|
+
solr_doc["descriptor_s"] = ["dublin core"]
|
135
|
+
end
|
136
|
+
# if no mods, pull some values from DC
|
137
|
+
if not (solr_doc["title_display"] and solr_doc["title_display"].length > 0)
|
138
|
+
if self.dc.term_values(:title).first
|
139
|
+
solr_doc["title_display"] = [self.dc.term_values(:title).first]
|
135
140
|
else
|
136
|
-
solr_doc["
|
141
|
+
solr_doc["title_display"] = [self.dc.term_values(:identifier).first]
|
137
142
|
end
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
if self.dc.term_values(:relation).first
|
146
|
-
self.dc.term_values(:relation).each {|val|
|
147
|
-
if val =~ /clio:/
|
148
|
-
solr_doc["clio_s"] ||= []
|
149
|
-
solr_doc["clio_s"] << val.split(':')[-1]
|
150
|
-
end
|
151
|
-
}
|
152
|
-
end
|
143
|
+
if self.dc.term_values(:relation).first
|
144
|
+
self.dc.term_values(:relation).each {|val|
|
145
|
+
if val =~ /clio:/
|
146
|
+
solr_doc["clio_s"] ||= []
|
147
|
+
solr_doc["clio_s"] << val.split(':')[-1]
|
148
|
+
end
|
149
|
+
}
|
153
150
|
end
|
154
|
-
solr_doc["format"] = [self.route_as]
|
155
|
-
solr_doc["index_type_label_s"] = [self.index_type_label]
|
156
|
-
solr_doc
|
157
151
|
end
|
152
|
+
solr_doc["format"] = [self.route_as]
|
153
|
+
solr_doc["index_type_label_s"] = [self.index_type_label]
|
154
|
+
solr_doc
|
155
|
+
end
|
158
156
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
else
|
174
|
-
result[dsid] = no_update(ds_params)
|
175
|
-
end
|
176
|
-
logger.debug "change detected? #{changed} digital_object? #{datastreams[dsid].changed?}"
|
157
|
+
def update_datastream_attributes(params={}, opts={})
|
158
|
+
logger.debug "Common.update_datastream_attributes"
|
159
|
+
result = params.dup
|
160
|
+
params.each_pair do |dsid, ds_params|
|
161
|
+
if datastreams.include?(dsid)
|
162
|
+
verify_params = ds_params.dup
|
163
|
+
current_indexed_attributes = {}
|
164
|
+
changed = false
|
165
|
+
verify_params.each { |pointer, values|
|
166
|
+
changed ||= value_changed?(datastreams[dsid],pointer,values)
|
167
|
+
}
|
168
|
+
if changed
|
169
|
+
logger.debug "Common.update_datastream_attributes calling update_indexed_attributes"
|
170
|
+
result[dsid] = datastreams[dsid].update_indexed_attributes(ds_params)
|
177
171
|
else
|
178
|
-
result
|
172
|
+
result[dsid] = no_update(ds_params)
|
179
173
|
end
|
174
|
+
logger.debug "change detected? #{changed} digital_object? #{datastreams[dsid].changed?}"
|
175
|
+
else
|
176
|
+
result.delete(dsid)
|
180
177
|
end
|
181
|
-
return result
|
182
178
|
end
|
183
|
-
|
184
|
-
|
185
|
-
|
179
|
+
return result
|
180
|
+
end
|
181
|
+
|
182
|
+
private
|
183
|
+
def value_changed?(ds,pointer,values)
|
184
|
+
if values.is_a? Hash
|
185
|
+
values = values.dup
|
186
|
+
else
|
187
|
+
values = {"0"=>values}
|
188
|
+
end
|
189
|
+
logger.debug "submitted values for #{pointer.inspect} : #{values.inspect}"
|
190
|
+
return true if values["-1"]
|
191
|
+
changed = false
|
192
|
+
old_values = ds.get_values(pointer)
|
193
|
+
indexed_values = {}
|
194
|
+
old_values.each_index {|ix| indexed_values[ix.to_s] = old_values[ix] }
|
195
|
+
indexed_values.each {|k,v|
|
196
|
+
new_val = values.delete(k)
|
197
|
+
puts "old: #{v} new: #{new_val} changed? #{!(v.eql? new_val)}"
|
198
|
+
logger.debug "old: #{v} new: #{new_val} changed? #{!(v.eql? new_val)}"
|
199
|
+
changed ||= !(v.eql? new_val)
|
200
|
+
}
|
201
|
+
puts "remaining values! #{values.inspect}" if values.length > 0
|
202
|
+
changed || (values.length > 0)
|
203
|
+
end
|
204
|
+
|
205
|
+
def no_update(ds_params)
|
206
|
+
response = {}
|
207
|
+
ds_params.each{|pointer, values|
|
208
|
+
returned = []
|
186
209
|
if values.is_a? Hash
|
187
|
-
|
210
|
+
keys = values.keys.sort {|x,y| x.to_i <=> y.to_i}
|
211
|
+
keys.each {|key| returned << values[key]}
|
188
212
|
else
|
189
|
-
|
213
|
+
returned << values
|
190
214
|
end
|
191
|
-
|
192
|
-
|
193
|
-
changed = false
|
194
|
-
old_values = ds.get_values(pointer)
|
195
|
-
indexed_values = {}
|
196
|
-
old_values.each_index {|ix| indexed_values[ix.to_s] = old_values[ix] }
|
197
|
-
indexed_values.each {|k,v|
|
198
|
-
new_val = values.delete(k)
|
199
|
-
puts "old: #{v} new: #{new_val} changed? #{!(v.eql? new_val)}"
|
200
|
-
logger.debug "old: #{v} new: #{new_val} changed? #{!(v.eql? new_val)}"
|
201
|
-
changed ||= !(v.eql? new_val)
|
202
|
-
}
|
203
|
-
puts "remaining values! #{values.inspect}" if values.length > 0
|
204
|
-
changed || (values.length > 0)
|
205
|
-
end
|
206
|
-
|
207
|
-
def no_update(ds_params)
|
208
|
-
response = {}
|
209
|
-
ds_params.each{|pointer, values|
|
210
|
-
returned = []
|
211
|
-
if values.is_a? Hash
|
212
|
-
keys = values.keys.sort {|x,y| x.to_i <=> y.to_i}
|
213
|
-
keys.each {|key| returned << values[key]}
|
214
|
-
else
|
215
|
-
returned << values
|
216
|
-
end
|
217
|
-
response[OM::XML::Terminology.term_hierarchical_name(pointer)] = returned
|
218
|
-
}
|
219
|
-
end
|
215
|
+
response[OM::XML::Terminology.term_hierarchical_name(pointer)] = returned
|
216
|
+
}
|
220
217
|
end
|
221
|
-
end
|
218
|
+
end
|
219
|
+
end
|
@@ -25,55 +25,54 @@ module Resource
|
|
25
25
|
has_datastream :name => "CONTENT", :type=>::ActiveFedora::Datastream, :versionable => true
|
26
26
|
end
|
27
27
|
end
|
28
|
-
module InstanceMethods
|
29
|
-
def resource!
|
30
|
-
add_relationship(:rdf_type, Cul::Scv::Hydra::ActiveFedora::RESOURCE_TYPE.to_s)
|
31
|
-
@metadata_is_dirty = true
|
32
|
-
update
|
33
|
-
end
|
34
28
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
is_literal = false
|
48
|
-
object = RDF::URI.new(node["resource"])
|
49
|
-
else
|
50
|
-
is_literal = true
|
51
|
-
object = RDF::Literal(node.text)
|
52
|
-
end
|
53
|
-
subject = RDF::URI(internal_uri)
|
54
|
-
predicate = RDF::URI("#{node.namespace.href}#{node.name}")
|
55
|
-
query = RDF::Query.new({ :subject => {predicate => :object}})
|
56
|
-
relationships(predicate).dup.each { |stmt|
|
57
|
-
relationships.delete(stmt)
|
58
|
-
}
|
59
|
-
add_relationship(predicate,object, is_literal)
|
60
|
-
relationships_are_dirty=true
|
61
|
-
}
|
62
|
-
# add mimetype to DC:format values
|
63
|
-
self.datastreams['DC'].update_values({[:format] => mime})
|
64
|
-
end
|
29
|
+
def resource!
|
30
|
+
add_relationship(:rdf_type, Cul::Scv::Hydra::ActiveFedora::RESOURCE_TYPE.to_s)
|
31
|
+
@metadata_is_dirty = true
|
32
|
+
update
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_content_blob(blob, opts)
|
36
|
+
file_name = opts[:file_name]
|
37
|
+
mime = opts[:mime_type].nil? ? mime_type(file_name) : opts[:mime_type]
|
38
|
+
add_file_datastream(blob, :label=>file_name, :mimeType=>mime, :dsid => 'CONTENT')
|
39
|
+
set_title_and_label( file_name, :only_if_blank=>true )
|
40
|
+
if IMAGE_MIME_TYPES.include? mime
|
65
41
|
blob.rewind
|
42
|
+
# retrieve Nokogiri of image property RDF
|
43
|
+
image_prop_nodes = Cul::Image::Properties.identify(blob).nodeset
|
44
|
+
relsext = datastreams['RELS-EXT']
|
45
|
+
image_prop_nodes.each { |node|
|
46
|
+
if node["resource"]
|
47
|
+
is_literal = false
|
48
|
+
object = RDF::URI.new(node["resource"])
|
49
|
+
else
|
50
|
+
is_literal = true
|
51
|
+
object = RDF::Literal(node.text)
|
52
|
+
end
|
53
|
+
subject = RDF::URI(internal_uri)
|
54
|
+
predicate = RDF::URI("#{node.namespace.href}#{node.name}")
|
55
|
+
query = RDF::Query.new({ :subject => {predicate => :object}})
|
56
|
+
relationships(predicate).dup.each { |stmt|
|
57
|
+
relationships.delete(stmt)
|
58
|
+
}
|
59
|
+
add_relationship(predicate,object, is_literal)
|
60
|
+
relationships_are_dirty=true
|
61
|
+
}
|
62
|
+
# add mimetype to DC:format values
|
63
|
+
self.datastreams['DC'].update_values({[:format] => mime})
|
66
64
|
end
|
65
|
+
blob.rewind
|
66
|
+
end
|
67
67
|
|
68
|
-
|
68
|
+
private
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
70
|
+
# Return the mimeType for a given file name
|
71
|
+
# @param [String] file_name The filename to use to get the mimeType
|
72
|
+
# @return [String] mimeType for filename passed in. Default: application/octet-stream if mimeType cannot be determined
|
73
|
+
def mime_type file_name
|
74
|
+
mime_types = MIME::Types.of(file_name)
|
75
|
+
mime_type = mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
|
77
76
|
end
|
78
77
|
end
|
79
78
|
end
|
@@ -22,6 +22,7 @@ module Terms
|
|
22
22
|
render :action=>params[:action], :layout=>layout
|
23
23
|
end
|
24
24
|
|
25
|
+
# this method should be overridden to use the appropriate terminology
|
25
26
|
def solr_name(term_id)
|
26
27
|
if term_id.nil?
|
27
28
|
raise "Cannot provide suggestions without a term name"
|
@@ -48,7 +49,6 @@ module Terms
|
|
48
49
|
solr_params['terms.sort'] = params.fetch(:sort,'count')
|
49
50
|
solr_params['terms.limit'] = -1
|
50
51
|
end
|
51
|
-
logger.debug solr_params.inspect
|
52
52
|
solr_response = Blacklight.solr.get 'terms', {:params => solr_params}
|
53
53
|
result = []
|
54
54
|
hash = {}
|
@@ -58,7 +58,6 @@ module Terms
|
|
58
58
|
result << [_t[jx], _t[jx + 1]]
|
59
59
|
}
|
60
60
|
}
|
61
|
-
logger.debug result.inspect
|
62
61
|
return result
|
63
62
|
end
|
64
63
|
|
@@ -71,19 +70,73 @@ module Terms
|
|
71
70
|
# end
|
72
71
|
# end
|
73
72
|
|
74
|
-
def field_key_from(
|
75
|
-
|
76
|
-
candidates = field_name.split('__')
|
73
|
+
def field_key_from(hier_field_name, t)
|
74
|
+
candidates = hier_field_name.split('_')
|
77
75
|
field_key = []
|
78
|
-
candidates.
|
79
|
-
if
|
80
|
-
|
76
|
+
candidates.inject(field_key) { |ptrs, term|
|
77
|
+
if term =~ /\d+/
|
78
|
+
ptr = {ptrs.pop=>term.to_i}
|
81
79
|
else
|
82
|
-
|
80
|
+
ptr = (ptrs.empty? or ptrs.last.is_a? Hash) ? term.to_sym : (ptrs.pop.to_s + "_" + term).to_sym
|
83
81
|
end
|
82
|
+
ptrs.push ptr
|
84
83
|
}
|
85
|
-
|
86
|
-
|
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
|
87
140
|
end
|
88
141
|
|
89
142
|
# ** largely copied from ActiveFedora::NokogiriDatastream.get_values **
|
@@ -17,7 +17,7 @@ module Om
|
|
17
17
|
:schema=>"http://www.loc.gov/standards/mods/v3/mods-3-4.xsd")
|
18
18
|
|
19
19
|
t.main_title_info(:path=>'titleInfo', :index_as=>[:not_searchable], :attributes=>{:type=>:none}){
|
20
|
-
t.main_title(:path=>"title", :index_as=>[:displayable,:searchable])
|
20
|
+
t.main_title(:path=>"title", :index_as=>[:displayable,:searchable, :sortable])
|
21
21
|
}
|
22
22
|
|
23
23
|
t.search_title_info(:path=>'titleInfo', :index_as=>[:not_searchable]){
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cul_scv_hydra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Benjamin Armintor
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-05-08 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: cul_image_props
|
@@ -39,11 +39,12 @@ dependencies:
|
|
39
39
|
requirements:
|
40
40
|
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
hash:
|
42
|
+
hash: 21
|
43
43
|
segments:
|
44
44
|
- 3
|
45
|
+
- 4
|
45
46
|
- 1
|
46
|
-
version:
|
47
|
+
version: 3.4.1
|
47
48
|
type: :runtime
|
48
49
|
version_requirements: *id002
|
49
50
|
- !ruby/object:Gem::Dependency
|
@@ -54,11 +55,11 @@ dependencies:
|
|
54
55
|
requirements:
|
55
56
|
- - ~>
|
56
57
|
- !ruby/object:Gem::Version
|
57
|
-
hash:
|
58
|
+
hash: 3
|
58
59
|
segments:
|
59
60
|
- 3
|
60
|
-
-
|
61
|
-
version: "3.
|
61
|
+
- 2
|
62
|
+
version: "3.2"
|
62
63
|
type: :runtime
|
63
64
|
version_requirements: *id003
|
64
65
|
- !ruby/object:Gem::Dependency
|
@@ -69,42 +70,42 @@ dependencies:
|
|
69
70
|
requirements:
|
70
71
|
- - ~>
|
71
72
|
- !ruby/object:Gem::Version
|
72
|
-
hash:
|
73
|
+
hash: 27
|
73
74
|
segments:
|
74
|
-
-
|
75
|
-
-
|
76
|
-
version: "
|
75
|
+
- 4
|
76
|
+
- 0
|
77
|
+
version: "4.0"
|
77
78
|
type: :runtime
|
78
79
|
version_requirements: *id004
|
79
80
|
- !ruby/object:Gem::Dependency
|
80
|
-
name:
|
81
|
+
name: rubydora
|
81
82
|
prerelease: false
|
82
83
|
requirement: &id005 !ruby/object:Gem::Requirement
|
83
84
|
none: false
|
84
85
|
requirements:
|
85
86
|
- - ~>
|
86
87
|
- !ruby/object:Gem::Version
|
87
|
-
hash:
|
88
|
+
hash: 27
|
88
89
|
segments:
|
89
|
-
-
|
90
|
-
-
|
91
|
-
|
90
|
+
- 0
|
91
|
+
- 5
|
92
|
+
- 8
|
93
|
+
version: 0.5.8
|
92
94
|
type: :runtime
|
93
95
|
version_requirements: *id005
|
94
96
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
97
|
+
name: hydra-head
|
96
98
|
prerelease: false
|
97
99
|
requirement: &id006 !ruby/object:Gem::Requirement
|
98
100
|
none: false
|
99
101
|
requirements:
|
100
|
-
- -
|
102
|
+
- - ~>
|
101
103
|
- !ruby/object:Gem::Version
|
102
104
|
hash: 27
|
103
105
|
segments:
|
106
|
+
- 4
|
104
107
|
- 0
|
105
|
-
|
106
|
-
- 6
|
107
|
-
version: 0.2.6
|
108
|
+
version: "4.0"
|
108
109
|
type: :runtime
|
109
110
|
version_requirements: *id006
|
110
111
|
- !ruby/object:Gem::Dependency
|
@@ -129,14 +130,14 @@ dependencies:
|
|
129
130
|
requirement: &id008 !ruby/object:Gem::Requirement
|
130
131
|
none: false
|
131
132
|
requirements:
|
132
|
-
- -
|
133
|
+
- - ~>
|
133
134
|
- !ruby/object:Gem::Version
|
134
|
-
hash:
|
135
|
+
hash: 15
|
135
136
|
segments:
|
136
137
|
- 1
|
137
|
-
-
|
138
|
-
-
|
139
|
-
version: 1.
|
138
|
+
- 6
|
139
|
+
- 0
|
140
|
+
version: 1.6.0
|
140
141
|
type: :runtime
|
141
142
|
version_requirements: *id008
|
142
143
|
- !ruby/object:Gem::Dependency
|
@@ -145,14 +146,14 @@ dependencies:
|
|
145
146
|
requirement: &id009 !ruby/object:Gem::Requirement
|
146
147
|
none: false
|
147
148
|
requirements:
|
148
|
-
- -
|
149
|
+
- - ~>
|
149
150
|
- !ruby/object:Gem::Version
|
150
|
-
hash:
|
151
|
+
hash: 31
|
151
152
|
segments:
|
152
153
|
- 1
|
153
|
-
- 1
|
154
154
|
- 2
|
155
|
-
|
155
|
+
- 0
|
156
|
+
version: 1.2.0
|
156
157
|
type: :runtime
|
157
158
|
version_requirements: *id009
|
158
159
|
- !ruby/object:Gem::Dependency
|
@@ -163,12 +164,12 @@ dependencies:
|
|
163
164
|
requirements:
|
164
165
|
- - ~>
|
165
166
|
- !ruby/object:Gem::Version
|
166
|
-
hash:
|
167
|
+
hash: 39
|
167
168
|
segments:
|
168
169
|
- 2
|
169
|
-
-
|
170
|
+
- 10
|
170
171
|
- 0
|
171
|
-
version: 2.
|
172
|
+
version: 2.10.0
|
172
173
|
type: :development
|
173
174
|
version_requirements: *id010
|
174
175
|
- !ruby/object:Gem::Dependency
|
@@ -179,12 +180,12 @@ dependencies:
|
|
179
180
|
requirements:
|
180
181
|
- - ~>
|
181
182
|
- !ruby/object:Gem::Version
|
182
|
-
hash:
|
183
|
+
hash: 39
|
183
184
|
segments:
|
184
185
|
- 2
|
185
|
-
-
|
186
|
-
-
|
187
|
-
version: 2.
|
186
|
+
- 10
|
187
|
+
- 0
|
188
|
+
version: 2.10.0
|
188
189
|
type: :development
|
189
190
|
version_requirements: *id011
|
190
191
|
- !ruby/object:Gem::Dependency
|