cul_scv_hydra 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,4 @@
1
1
  require "active-fedora"
2
- require "hydra"
3
2
  class BagAggregator < ::ActiveFedora::Base
4
3
  extend ActiveModel::Callbacks
5
4
  include ::ActiveFedora::DatastreamCollections
@@ -1,5 +1,4 @@
1
1
  require "active-fedora"
2
- require "hydra"
3
2
  class ContentAggregator < ::ActiveFedora::Base
4
3
  extend ActiveModel::Callbacks
5
4
  include ::ActiveFedora::DatastreamCollections
@@ -1,9 +1,37 @@
1
1
  require "active-fedora"
2
- require "hydra"
3
2
  class DcDocument < ActiveFedora::Base
4
3
  include ::ActiveFedora::DatastreamCollections
5
4
  include ::ActiveFedora::Relationships
6
5
  include Hydra::ModelMethods
7
6
  include Cul::Scv::Hydra::ActiveFedora::Model::Common
8
7
  alias :file_objects :resources
8
+
9
+ has_relationship "parts", :cul_member_of, :inbound => true
10
+
11
+ def self.load_instance_from_solr(pid,solr_doc=nil)
12
+ if solr_doc.nil?
13
+ result = find_by_solr(pid)
14
+ raise "Object #{pid} not found in solr" if result.nil?
15
+ solr_doc = result.hits.first
16
+ #double check pid and id in record match
17
+ raise "Object #{pid} not found in Solr" unless !result.nil? && !solr_doc.nil? && pid == solr_doc[SOLR_DOCUMENT_ID]
18
+ else
19
+ raise "Solr document record id and pid do not match" unless pid == solr_doc[SOLR_DOCUMENT_ID]
20
+ end
21
+
22
+ 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)]
23
+ 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)]
24
+ obj = DcDocument.new({:pid=>solr_doc[SOLR_DOCUMENT_ID],:create_date=>create_date,:modified_date=>modified_date})
25
+ obj.new_object = false
26
+ #set by default to load any dependent relationship objects from solr as well
27
+ obj.load_from_solr = true
28
+ #need to call rels_ext once so it exists when iterating over datastreams
29
+ obj.rels_ext
30
+ obj.datastreams.each_value do |ds|
31
+ if ds.respond_to?(:from_solr)
32
+ ds.from_solr(solr_doc) if ds.kind_of?(::ActiveFedora::MetadataDatastream) || ds.kind_of?(::ActiveFedora::NokogiriDatastream) || ( ds.kind_of?(::ActiveFedora::RelsExtDatastream))
33
+ end
34
+ end
35
+ obj
36
+ end
9
37
  end
@@ -1,5 +1,4 @@
1
1
  require "active-fedora"
2
- require "hydra"
3
2
  class GenericAggregator < ::ActiveFedora::Base
4
3
  extend ActiveModel::Callbacks
5
4
  include ::ActiveFedora::DatastreamCollections
@@ -1,5 +1,4 @@
1
1
  require "active-fedora"
2
- require "hydra"
3
2
  class GenericObject < ::ActiveFedora::Base
4
3
  extend ActiveModel::Callbacks
5
4
  include ::ActiveFedora::DatastreamCollections
@@ -1,5 +1,4 @@
1
1
  require "active-fedora"
2
- require "hydra"
3
2
  class JP2ImageAggregator < ::ActiveFedora::Base
4
3
  extend ActiveModel::Callbacks
5
4
  include ::ActiveFedora::DatastreamCollections
@@ -1,5 +1,4 @@
1
1
  require "active-fedora"
2
- require "hydra"
3
2
  class METSStructuredAggregator < ::ActiveFedora::Base
4
3
  extend ActiveModel::Callbacks
5
4
  include ::ActiveFedora::DatastreamCollections
@@ -1,6 +1,5 @@
1
1
  require "active-fedora"
2
2
  require "cul_image_props"
3
- require "hydra"
4
3
  require "mime/types"
5
4
  require "uri"
6
5
  class Resource < ::ActiveFedora::Base
@@ -1,5 +1,4 @@
1
1
  require "active-fedora"
2
- require "hydra"
3
2
  class StaticAudioAggregator < ::ActiveFedora::Base
4
3
  extend ActiveModel::Callbacks
5
4
 
@@ -1,5 +1,4 @@
1
1
  require "active-fedora"
2
- require "hydra"
3
2
  class StaticImageAggregator < ::ActiveFedora::Base
4
3
  extend ActiveModel::Callbacks
5
4
 
@@ -4,5 +4,4 @@ end
4
4
  end
5
5
  require 'cul_scv_hydra/active_fedora/model/aggregator'
6
6
  require 'cul_scv_hydra/active_fedora/model/common'
7
- require 'cul_scv_hydra/active_fedora/model/dcdocument'
8
7
  require 'cul_scv_hydra/active_fedora/model/resource'
@@ -1,20 +1,20 @@
1
1
  require 'cul_scv_hydra/controllers/aggregator_controller_helper'
2
2
  require 'cul_scv_hydra/controllers/helpers/resources_helper_behavior'
3
3
  module Cul::Scv::Hydra::Controllers
4
- module Aggregates
5
- extend ActiveSupport::Concern
6
- included do
7
- include Hydra::AssetsControllerHelper
8
- include Cul::Scv::Hydra::Controllers::AggregatorControllerHelper
9
- include Cul::Scv::Hydra::Controllers::Helpers::ResourcesHelperBehavior
10
- include Hydra::RepositoryController
11
- include MediaShelf::ActiveFedoraHelper
12
- include Blacklight::SolrHelper
13
- before_filter :require_solr, :only=>[:index, :create, :show, :destroy]
14
- before_filter :load_resources, :only=>[:index]
15
- prepend_before_filter :sanitize_update_params
16
- end
17
- module InstanceMethods
4
+ module Aggregates
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ include Hydra::AssetsControllerHelper
8
+ include Cul::Scv::Hydra::Controllers::AggregatorControllerHelper
9
+ include Cul::Scv::Hydra::Controllers::Helpers::ResourcesHelperBehavior
10
+ include Hydra::RepositoryController
11
+ include MediaShelf::ActiveFedoraHelper
12
+ include Blacklight::SolrHelper
13
+ before_filter :require_solr, :only=>[:index, :create, :show, :destroy]
14
+ before_filter :load_resources, :only=>[:index]
15
+ prepend_before_filter :sanitize_update_params
16
+ end
17
+
18
18
  def index
19
19
 
20
20
  if params[:layout] == "false"
@@ -92,4 +92,3 @@ module Aggregates
92
92
  end
93
93
  end
94
94
  end
95
- end
@@ -1,4 +1,3 @@
1
- require 'hydra'
2
1
  require 'cul_scv_hydra/controllers/helpers/resources_helper_behavior'
3
2
  module Cul::Scv::Hydra::Controllers
4
3
  module ContentAggregators
@@ -2,7 +2,7 @@ module Cul::Scv::Hydra::Controllers::Helpers
2
2
  module ActiveFedoraHelperBehavior
3
3
  def load_dc_document_from_solr(doc)
4
4
  pid = doc[:id] ? doc[:id] : doc[:id.to_s]
5
- result = pid ? Cul::Scv::Hydra::ActiveFedora::Model::DcDocument.load_instance_from_solr(pid,doc) : nil
5
+ result = pid ? DcDocument.load_instance_from_solr(pid,doc) : nil
6
6
  result
7
7
  end
8
8
  end
@@ -1,10 +1,9 @@
1
- require 'cul_scv_hydra/active_fedora/model/dcdocument'
2
1
  # Methods added to this helper will be available to all templates in the application.
3
2
  module Cul::Scv::Hydra::Controllers::Helpers
4
3
  module ApplicationHelperBehavior
5
4
  def load_dc_document_from_solr(doc)
6
5
  pid = doc[:id] ? doc[:id] : doc[:id.to_s]
7
- result = pid ? Cul::Scv::Hydra::ActiveFedora::Model::DcDocument.load_instance_from_solr(pid,doc) : nil
6
+ result = pid ? DcDocument.load_instance_from_solr(pid,doc) : nil
8
7
  result
9
8
  end
10
9
  def get_aggregate_count(doc)
@@ -1,4 +1,3 @@
1
- require 'hydra'
2
1
  require 'net/http'
3
2
  require 'open-uri'
4
3
  require 'tempfile'
@@ -1,7 +1,7 @@
1
1
  module Cul
2
2
  module Scv
3
3
  module Hydra
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.2'
5
5
  def self.version
6
6
  VERSION
7
7
  end
data/lib/cul_scv_hydra.rb CHANGED
@@ -5,6 +5,14 @@ module Cul
5
5
  end
6
6
  end
7
7
  end
8
+ # this is a hack to make requiring hydra possible
9
+ module Hydra
10
+ module Datastream
11
+ module CommonModsIndexMethods
12
+ end
13
+ end
14
+ end
15
+ require 'hydra'
8
16
  require "cul_scv_hydra/access_controls_enforcement"
9
17
  require "cul_scv_hydra/active_fedora"
10
18
  require "cul_scv_hydra/controllers"
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: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
9
+ - 2
10
+ version: 0.4.2
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-05-09 00:00:00 Z
18
+ date: 2012-06-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: cul_image_props
@@ -93,9 +93,25 @@ dependencies:
93
93
  type: :runtime
94
94
  version_requirements: *id005
95
95
  - !ruby/object:Gem::Dependency
96
- name: hydra-head
96
+ name: hydra-mods
97
97
  prerelease: false
98
98
  requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 23
104
+ segments:
105
+ - 0
106
+ - 0
107
+ - 4
108
+ version: 0.0.4
109
+ type: :runtime
110
+ version_requirements: *id006
111
+ - !ruby/object:Gem::Dependency
112
+ name: hydra-head
113
+ prerelease: false
114
+ requirement: &id007 !ruby/object:Gem::Requirement
99
115
  none: false
100
116
  requirements:
101
117
  - - ~>
@@ -106,11 +122,11 @@ dependencies:
106
122
  - 0
107
123
  version: "4.0"
108
124
  type: :runtime
109
- version_requirements: *id006
125
+ version_requirements: *id007
110
126
  - !ruby/object:Gem::Dependency
111
127
  name: nokogiri
112
128
  prerelease: false
113
- requirement: &id007 !ruby/object:Gem::Requirement
129
+ requirement: &id008 !ruby/object:Gem::Requirement
114
130
  none: false
115
131
  requirements:
116
132
  - - ">="
@@ -122,11 +138,11 @@ dependencies:
122
138
  - 2
123
139
  version: 1.4.2
124
140
  type: :runtime
125
- version_requirements: *id007
141
+ version_requirements: *id008
126
142
  - !ruby/object:Gem::Dependency
127
143
  name: om
128
144
  prerelease: false
129
- requirement: &id008 !ruby/object:Gem::Requirement
145
+ requirement: &id009 !ruby/object:Gem::Requirement
130
146
  none: false
131
147
  requirements:
132
148
  - - ~>
@@ -138,11 +154,11 @@ dependencies:
138
154
  - 0
139
155
  version: 1.6.0
140
156
  type: :runtime
141
- version_requirements: *id008
157
+ version_requirements: *id009
142
158
  - !ruby/object:Gem::Dependency
143
159
  name: solrizer
144
160
  prerelease: false
145
- requirement: &id009 !ruby/object:Gem::Requirement
161
+ requirement: &id010 !ruby/object:Gem::Requirement
146
162
  none: false
147
163
  requirements:
148
164
  - - ~>
@@ -154,11 +170,11 @@ dependencies:
154
170
  - 0
155
171
  version: 1.2.0
156
172
  type: :runtime
157
- version_requirements: *id009
173
+ version_requirements: *id010
158
174
  - !ruby/object:Gem::Dependency
159
175
  name: rspec
160
176
  prerelease: false
161
- requirement: &id010 !ruby/object:Gem::Requirement
177
+ requirement: &id011 !ruby/object:Gem::Requirement
162
178
  none: false
163
179
  requirements:
164
180
  - - ~>
@@ -170,11 +186,11 @@ dependencies:
170
186
  - 0
171
187
  version: 2.10.0
172
188
  type: :development
173
- version_requirements: *id010
189
+ version_requirements: *id011
174
190
  - !ruby/object:Gem::Dependency
175
191
  name: rspec-rails
176
192
  prerelease: false
177
- requirement: &id011 !ruby/object:Gem::Requirement
193
+ requirement: &id012 !ruby/object:Gem::Requirement
178
194
  none: false
179
195
  requirements:
180
196
  - - ~>
@@ -186,11 +202,11 @@ dependencies:
186
202
  - 0
187
203
  version: 2.10.0
188
204
  type: :development
189
- version_requirements: *id011
205
+ version_requirements: *id012
190
206
  - !ruby/object:Gem::Dependency
191
207
  name: mocha
192
208
  prerelease: false
193
- requirement: &id012 !ruby/object:Gem::Requirement
209
+ requirement: &id013 !ruby/object:Gem::Requirement
194
210
  none: false
195
211
  requirements:
196
212
  - - ">="
@@ -202,11 +218,11 @@ dependencies:
202
218
  - 8
203
219
  version: 0.9.8
204
220
  type: :development
205
- version_requirements: *id012
221
+ version_requirements: *id013
206
222
  - !ruby/object:Gem::Dependency
207
223
  name: equivalent-xml
208
224
  prerelease: false
209
- requirement: &id013 !ruby/object:Gem::Requirement
225
+ requirement: &id014 !ruby/object:Gem::Requirement
210
226
  none: false
211
227
  requirements:
212
228
  - - ">="
@@ -218,11 +234,11 @@ dependencies:
218
234
  - 4
219
235
  version: 0.2.4
220
236
  type: :development
221
- version_requirements: *id013
237
+ version_requirements: *id014
222
238
  - !ruby/object:Gem::Dependency
223
239
  name: rbx-require-relative
224
240
  prerelease: false
225
- requirement: &id014 !ruby/object:Gem::Requirement
241
+ requirement: &id015 !ruby/object:Gem::Requirement
226
242
  none: false
227
243
  requirements:
228
244
  - - "="
@@ -234,7 +250,7 @@ dependencies:
234
250
  - 5
235
251
  version: 0.0.5
236
252
  type: :development
237
- version_requirements: *id014
253
+ version_requirements: *id015
238
254
  description: ActiveFedora, OM, and Solrizer implementations for CUL Staff Collection Viewer
239
255
  email: armintor@gmail.com
240
256
  executables: []
@@ -247,7 +263,6 @@ files:
247
263
  - lib/cul_scv_hydra/access_controls_enforcement.rb
248
264
  - lib/cul_scv_hydra/active_fedora/model/aggregator.rb
249
265
  - lib/cul_scv_hydra/active_fedora/model/common.rb
250
- - lib/cul_scv_hydra/active_fedora/model/dcdocument.rb
251
266
  - lib/cul_scv_hydra/active_fedora/model/resource.rb
252
267
  - lib/cul_scv_hydra/active_fedora/model.rb
253
268
  - lib/cul_scv_hydra/active_fedora.rb
@@ -1,43 +0,0 @@
1
- require "active-fedora"
2
- require "cul_scv_hydra/active_fedora"
3
- require "hydra"
4
- module Cul::Scv::Hydra::ActiveFedora::Model
5
- class DcDocument < ::ActiveFedora::Base
6
- include ::ActiveFedora::Relationships
7
- include ::Hydra::ModelMethods
8
- include Cul::Scv::Hydra::ActiveFedora::Model::Common
9
- alias :file_objects :resources
10
-
11
- # relationships #
12
- has_relationship "containers", :cul_member_of
13
- has_relationship "parts", :cul_member_of, :inbound => true
14
-
15
- def self.load_instance_from_solr(pid,solr_doc=nil)
16
- if solr_doc.nil?
17
- result = find_by_solr(pid)
18
- raise "Object #{pid} not found in solr" if result.nil?
19
- solr_doc = result.hits.first
20
- #double check pid and id in record match
21
- raise "Object #{pid} not found in Solr" unless !result.nil? && !solr_doc.nil? && pid == solr_doc[SOLR_DOCUMENT_ID]
22
- else
23
- raise "Solr document record id and pid do not match" unless pid == solr_doc[SOLR_DOCUMENT_ID]
24
- end
25
-
26
- 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)]
27
- 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)]
28
- obj = DcDocument.new({:pid=>solr_doc[SOLR_DOCUMENT_ID],:create_date=>create_date,:modified_date=>modified_date})
29
- obj.new_object = false
30
- #set by default to load any dependent relationship objects from solr as well
31
- obj.load_from_solr = true
32
- #need to call rels_ext once so it exists when iterating over datastreams
33
- obj.rels_ext
34
- obj.datastreams.each_value do |ds|
35
- if ds.respond_to?(:from_solr)
36
- ds.from_solr(solr_doc) if ds.kind_of?(::ActiveFedora::MetadataDatastream) || ds.kind_of?(::ActiveFedora::NokogiriDatastream) || ( ds.kind_of?(::ActiveFedora::RelsExtDatastream))
37
- end
38
- end
39
- obj
40
- end
41
-
42
- end
43
- end