ddr-models 2.4.7 → 2.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6f4046f421e1eff0e98a72a91752fcefdc2d58b
4
- data.tar.gz: 19170b14ef451f3f41f5dc265462e54e86da74a8
3
+ metadata.gz: 529d7cf0ef14124eeff5d9aca162a22d99f9f882
4
+ data.tar.gz: 309f4bdb1800c6f94ab8e92d2fbbace193031a54
5
5
  SHA512:
6
- metadata.gz: 087dc599aead9cb898234e9b20e16e44fe8cd61f74914cf77573ad92a32f6043d0543401c1631e350d12bacdd68970edc474a9f9589deb1e90ec95a10848bcba
7
- data.tar.gz: cc83cf6ed16414010004621c928da3768dc06c3669cabb37f8d28198549650101b31034965830c8ba9f8b1514813cc659894177b7acdc058ddda17b488acb03a
6
+ metadata.gz: f67fae61c9e4eb4802095b3761df7d77f65ae13bedfc44b042c82f4a245b046f814023bd395a638c9a9316650f1231ac1e440c78bb4119baf38d014d3e8f36f9
7
+ data.tar.gz: f92dc9427534c10ebee195eaaa629e2371ef61b35eda6550acd1dd73b6cddc85b9f9b230b1b570c1356596cd650277dff1e2719df09b45e4d9204bad4ad281de
@@ -12,6 +12,8 @@ class Component < Ddr::Models::Base
12
12
  belongs_to :parent, :property => :is_part_of, :class_name => 'Item'
13
13
  belongs_to :target, :property => :has_external_target, :class_name => 'Target'
14
14
 
15
+ after_save :index_parent, if: :has_extracted_text?, unless: "parent.nil?"
16
+
15
17
  alias_method :item, :parent
16
18
  alias_method :item=, :parent=
17
19
 
@@ -23,4 +25,8 @@ class Component < Ddr::Models::Base
23
25
  self.collection.internal_uri rescue nil
24
26
  end
25
27
 
28
+ def index_parent
29
+ Resque.enqueue(Ddr::Jobs::UpdateIndex, parent_id)
30
+ end
31
+
26
32
  end
@@ -21,4 +21,17 @@ class Item < Ddr::Models::Base
21
21
  alias_method :collection_id, :parent_id
22
22
  alias_method :collection=, :parent=
23
23
 
24
+ def children_having_extracted_text
25
+ item = self
26
+ Ddr::Index::Query.new do
27
+ is_part_of item
28
+ where attached_files_having_content: "extractedText"
29
+ fields :id, :extracted_text
30
+ end
31
+ end
32
+
33
+ def all_text
34
+ children_having_extracted_text.docs.map(&:extracted_text).flatten
35
+ end
36
+
24
37
  end
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.add_dependency "devise", "~> 3.4"
27
27
  s.add_dependency "omniauth-shibboleth", "~> 1.2.0"
28
28
  s.add_dependency "grouper-rest-client"
29
- s.add_dependency "ezid-client", "~> 1.1", ">= 1.1.1"
29
+ s.add_dependency "ezid-client", "~> 1.4.2"
30
30
  s.add_dependency "resque", "~> 1.25"
31
31
  s.add_dependency "rdf-vocab", "~> 0.8"
32
32
  s.add_dependency "net-ldap", "~> 0.11"
@@ -8,7 +8,10 @@ module Ddr::Index
8
8
  ACTIVE_FEDORA_MODEL = Field.new :active_fedora_model, :stored_sortable
9
9
  ADMIN_SET = Field.new :admin_set, :stored_sortable
10
10
  ADMIN_SET_FACET = Field.new :admin_set_facet, :facetable
11
+ ALL_TEXT = Field.new :all_text, solr_name: "all_text_timv"
11
12
  ASPACE_ID = Field.new :aspace_id, :stored_sortable
13
+ ATTACHED_FILES_HAVING_CONTENT =
14
+ Field.new :attached_files_having_content, :symbol
12
15
  BOX_NUMBER_FACET = Field.new :box_number_facet, :facetable
13
16
  COLLECTION_FACET = Field.new :collection_facet, :facetable
14
17
  COLLECTION_URI = Field.new :collection_uri, :symbol
@@ -24,7 +27,7 @@ module Ddr::Index
24
27
  DISPLAY_FORMAT = Field.new :display_format, :stored_sortable
25
28
  DOI = Field.new :doi, :symbol
26
29
  EAD_ID = Field.new :ead_id, :stored_sortable
27
- EXTRACTED_TEXT = Field.new :extracted_text, :searchable, type: :text
30
+ EXTRACTED_TEXT = Field.new :extracted_text, solr_name: "extracted_text_tsm"
28
31
  HAS_MODEL = Field.new :has_model, :symbol
29
32
  IDENTIFIER_ALL = Field.new :identifier_all, :symbol
30
33
  INTERNAL_URI = Field.new :internal_uri, :stored_sortable
@@ -76,6 +76,10 @@ module Ddr::Index
76
76
  term is_member_of_collection: internal_uri(object_or_id)
77
77
  end
78
78
 
79
+ def is_part_of(object_or_id)
80
+ term is_part_of: internal_uri(object_or_id)
81
+ end
82
+
79
83
  def model(*models)
80
84
  where active_fedora_model: models
81
85
  end
@@ -5,6 +5,7 @@ module Ddr
5
5
  def datastreams_to_validate
6
6
  datastreams.select { |dsid, ds| ds.has_content? }
7
7
  end
8
+ alias_method :attached_files_having_content, :datastreams_to_validate
8
9
 
9
10
  def fixity_checks
10
11
  Ddr::Events::FixityCheckEvent.for_object(self)
@@ -20,6 +20,7 @@ module Ddr
20
20
  ACCESS_ROLE => roles.to_json,
21
21
  ADMIN_SET => admin_set,
22
22
  ASPACE_ID => aspace_id,
23
+ ATTACHED_FILES_HAVING_CONTENT => attached_files_having_content.keys,
23
24
  BOX_NUMBER_FACET => desc_metadata_values('box_number'),
24
25
  CONTRIBUTOR_FACET => desc_metadata_values('contributor'),
25
26
  CREATOR_FACET => creator,
@@ -90,6 +91,7 @@ module Ddr
90
91
  if is_a? Item
91
92
  fields[ADMIN_SET_FACET] = admin_set_facet
92
93
  fields[COLLECTION_FACET] = collection_facet
94
+ fields[ALL_TEXT] = all_text
93
95
  end
94
96
  fields
95
97
  end
@@ -131,6 +131,10 @@ module Ddr::Models
131
131
  has_datastream?(Ddr::Datastreams::CONTENT)
132
132
  end
133
133
 
134
+ def has_extracted_text?
135
+ has_datastream?(Ddr::Datastreams::EXTRACTED_TEXT)
136
+ end
137
+
134
138
  def content_ds
135
139
  datastreams[Ddr::Datastreams::CONTENT]
136
140
  end
@@ -17,6 +17,10 @@ module Ddr
17
17
  xpath("//xmlns:structMap[@TYPE='#{type}']").first
18
18
  end
19
19
 
20
+ def fptr_nodes(type='default')
21
+ structMap_node(type).xpath('//xmlns:fptr')
22
+ end
23
+
20
24
  def as_xml_document
21
25
  __getobj__
22
26
  end
@@ -49,4 +53,4 @@ module Ddr
49
53
 
50
54
  end
51
55
  end
52
- end
56
+ end
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "2.4.7"
3
+ VERSION = "2.4.8"
4
4
  end
5
5
  end
@@ -0,0 +1 @@
1
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis scelerisque diam in lacus sollicitudin maximus. Duis molestie rutrum hendrerit. Vestibulum lobortis augue a ultrices mollis. Mauris semper eu odio posuere scelerisque. Donec vel condimentum nunc. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Morbi fermentum, sem vel interdum suscipit, lacus risus ultricies sem, in lacinia ligula risus ut est. Integer gravida, orci ac lobortis blandit, eros tortor bibendum turpis, quis semper velit erat in augue.
@@ -0,0 +1 @@
1
+ Proin convallis nibh quis ex iaculis, eget porttitor elit consequat. Duis in tincidunt ipsum. Aenean imperdiet lacinia libero nec egestas. Fusce a metus volutpat, vehicula augue accumsan, mattis lorem. Donec ex tellus, tempus vitae orci sit amet, sollicitudin pharetra velit. Fusce egestas nunc vitae placerat elementum. Nullam pharetra porta eros, quis tempor sem pulvinar a. Ut in neque cursus, hendrerit neque in, congue est. Phasellus neque mauris, eleifend in sem ac, posuere tincidunt odio. Duis lectus nibh, ultricies a elementum a, consectetur vitae turpis.
@@ -0,0 +1,3 @@
1
+ Ut eu consequat turpis. Proin commodo facilisis pretium. Vestibulum tristique volutpat lobortis. Donec efficitur tincidunt porta. Sed dui massa, rutrum iaculis interdum at, scelerisque nec velit. Suspendisse potenti. Aliquam quis mauris sed magna convallis ullamcorper non ut ipsum.
2
+
3
+ Donec dolor urna, malesuada id condimentum ut, feugiat consectetur lectus. Morbi dignissim nibh neque, a bibendum ex semper vel. Nunc pellentesque varius bibendum. Etiam posuere lorem nibh, sit amet iaculis dolor lobortis nec. Nam congue dui non lectus luctus scelerisque. Aliquam turpis orci, porta non dapibus eu, accumsan sed tortor. Phasellus placerat ac mauris sed vehicula. Sed dolor massa, fringilla vitae urna vel, efficitur porta eros. Ut massa nisi, bibendum id mollis quis, aliquet eu purus. Aliquam erat volutpat. Phasellus accumsan felis eget dui vulputate, eget feugiat diam eleifend. Donec facilisis massa odio, ac auctor eros ullamcorper quis. Donec sit amet malesuada lectus. Aenean egestas, leo id lacinia mattis, dui ex tempor tellus, vel mollis velit leo a ante.
@@ -16,4 +16,68 @@ RSpec.describe Component, type: :model, components: true do
16
16
  its(:index_fields) { is_expected.to include(Ddr::Index::Fields::COLLECTION_URI => "info:fedora/test:1") }
17
17
  end
18
18
 
19
+ describe "extracted text" do
20
+ let(:parent) { FactoryGirl.create(:item) }
21
+ describe "when the child is not already associated with the parent" do
22
+ before {
23
+ subject.extractedText.content = fixture_file_upload('extractedText1.txt')
24
+ subject.save
25
+ subject.reload
26
+ }
27
+ it "updates the parent index when associated" do
28
+ expect(subject).to receive(:index_parent)
29
+ subject.parent = parent
30
+ subject.save
31
+ end
32
+ end
33
+ describe "when the child is already associated with the parent" do
34
+ before {
35
+ subject.parent = parent
36
+ subject.save
37
+ }
38
+ describe "when there is no extracted text" do
39
+ describe "and none is added" do
40
+ it "does not trigger an index update on the parent" do
41
+ expect(subject).not_to receive(:index_parent)
42
+ subject.save
43
+ end
44
+ end
45
+ describe "and extracted text is added" do
46
+ it "triggers an index update on the parent" do
47
+ expect(subject).to receive(:index_parent)
48
+ subject.extractedText.content = fixture_file_upload('extractedText1.txt')
49
+ subject.save
50
+ end
51
+ end
52
+ end
53
+ describe "when extracted text exists" do
54
+ before {
55
+ subject.extractedText.content = fixture_file_upload('extractedText1.txt')
56
+ subject.save
57
+ subject.reload
58
+ }
59
+ describe "and is removed" do
60
+ it "triggers an index update on the parent" do
61
+ pending "Deleting a datastream does not mark the content as changed"
62
+ expect(subject).to receive(:index_parent)
63
+ subject.extractedText.delete
64
+ subject.save
65
+ end
66
+ end
67
+ describe "and doesn't change" do
68
+ it "triggers an index update on the parent" do
69
+ expect(subject).to receive(:index_parent)
70
+ subject.save
71
+ end
72
+ end
73
+ describe "and changes" do
74
+ it "triggers an index update on the parent" do
75
+ expect(subject).to receive(:index_parent)
76
+ subject.extractedText.content = fixture_file_upload('extractedText2.txt')
77
+ subject.save
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
19
83
  end
@@ -48,6 +48,9 @@ module Ddr::Models
48
48
  }
49
49
 
50
50
  its([Indexing::CONTENT_CREATE_DATE]) { is_expected.to eq "2016-01-22T21:50:33Z" }
51
+ its([Indexing::ATTACHED_FILES_HAVING_CONTENT]) {
52
+ is_expected.to contain_exactly("content", "RELS-EXT", "descMetadata", "adminMetadata")
53
+ }
51
54
  end
52
55
 
53
56
  end
@@ -7,4 +7,27 @@ RSpec.describe Item, type: :model do
7
7
  it_behaves_like "it has an association", :has_many, :children, :is_part_of, "Component"
8
8
  it_behaves_like "a non-collection model"
9
9
 
10
+ describe "indexing text" do
11
+ let(:children) { FactoryGirl.build_list(:component, 5) }
12
+
13
+ let(:text1) { fixture_file_upload('extractedText1.txt', 'text/plain') }
14
+ let(:text2) { fixture_file_upload('extractedText2.txt', 'text/plain') }
15
+ let(:text3) { fixture_file_upload('extractedText3.txt', 'text/plain') }
16
+
17
+ before {
18
+ children[0].extractedText.content = text1
19
+ children[0].save
20
+ children[1].extractedText.content = text2
21
+ children[1].save
22
+ children[2].extractedText.content = text3
23
+ children[2].save
24
+ subject.children = children
25
+ subject.save
26
+ }
27
+
28
+ it "indexes the combined text of its children" do
29
+ expect(subject.index_fields[Ddr::Index::Fields::ALL_TEXT]).to contain_exactly(text1.read, text2.read, text3.read)
30
+ end
31
+ end
32
+
10
33
  end
@@ -5,9 +5,8 @@ module Ddr
5
5
  module Models
6
6
  RSpec.describe Structure, type: :model, structural_metadata: true do
7
7
 
8
- let(:structure) { FactoryGirl.build(:multiple_struct_maps_structure) }
9
-
10
8
  describe "#struct_maps" do
9
+ let(:structure) { FactoryGirl.build(:multiple_struct_maps_structure) }
11
10
  let(:struct_maps) { structure.struct_maps }
12
11
  it "should include struct divs for each struct map" do
13
12
  expect(struct_maps.keys).to match_array([ 'default', 'reverse' ])
@@ -16,6 +15,16 @@ module Ddr
16
15
  end
17
16
  end
18
17
 
18
+ describe "#fptr_nodes" do
19
+ let(:structure) { FactoryGirl.build(:nested_structure) }
20
+ it "should return all fptr nodes" do
21
+ results = structure.fptr_nodes
22
+ expect(results.size).to eq(3)
23
+ ids = results.map { |entry| entry['CONTENTIDS'] }
24
+ expect(ids).to match_array([ 'info:fedora/test:5', 'info:fedora/test:6', 'info:fedora/test:7' ])
25
+ end
26
+ end
27
+
19
28
  end
20
29
  end
21
- end
30
+ end
@@ -6,8 +6,8 @@ module Ezid
6
6
 
7
7
  self.defaults = {}
8
8
 
9
- def reload; self; end
10
- def reset; self; end
9
+ def load_metadata; self; end
10
+ def reset_metadata; self; end
11
11
 
12
12
  private
13
13
 
@@ -31,14 +31,12 @@ RSpec.shared_examples "an object that can have content" do
31
31
  describe "extracted text" do
32
32
  describe "when it is not present" do
33
33
  its(:has_extracted_text?) { should be false }
34
- its(:to_solr) { should_not include(Ddr::Index::Fields::EXTRACTED_TEXT) }
34
+ its(:to_solr) { is_expected.not_to include(Ddr::Index::Fields::EXTRACTED_TEXT) }
35
35
  end
36
36
  describe "when it is present" do
37
37
  before { subject.extractedText.content = "This is my text. See Spot run." }
38
38
  its(:has_extracted_text?) { should be true }
39
- it "should be indexed" do
40
- expect(subject.to_solr[Ddr::Index::Fields::EXTRACTED_TEXT]).to eq("This is my text. See Spot run.")
41
- end
39
+ its(:to_solr) { is_expected.to include(Ddr::Index::Fields::EXTRACTED_TEXT) }
42
40
  end
43
41
  end
44
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.7
4
+ version: 2.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-23 00:00:00.000000000 Z
12
+ date: 2016-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -129,20 +129,14 @@ dependencies:
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '1.1'
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- version: 1.1.1
132
+ version: 1.4.2
136
133
  type: :runtime
137
134
  prerelease: false
138
135
  version_requirements: !ruby/object:Gem::Requirement
139
136
  requirements:
140
137
  - - "~>"
141
138
  - !ruby/object:Gem::Version
142
- version: '1.1'
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: 1.1.1
139
+ version: 1.4.2
146
140
  - !ruby/object:Gem::Dependency
147
141
  name: resque
148
142
  requirement: !ruby/object:Gem::Requirement
@@ -639,6 +633,9 @@ files:
639
633
  - spec/fixtures/8bit.tif
640
634
  - spec/fixtures/arrow1rightred_e0.gif
641
635
  - spec/fixtures/bird.jpg
636
+ - spec/fixtures/extractedText1.txt
637
+ - spec/fixtures/extractedText2.txt
638
+ - spec/fixtures/extractedText3.txt
642
639
  - spec/fixtures/fits/document.xml
643
640
  - spec/fixtures/fits/image.xml
644
641
  - spec/fixtures/imageA.tif
@@ -811,6 +808,9 @@ test_files:
811
808
  - spec/fixtures/8bit.tif
812
809
  - spec/fixtures/arrow1rightred_e0.gif
813
810
  - spec/fixtures/bird.jpg
811
+ - spec/fixtures/extractedText1.txt
812
+ - spec/fixtures/extractedText2.txt
813
+ - spec/fixtures/extractedText3.txt
814
814
  - spec/fixtures/fits/document.xml
815
815
  - spec/fixtures/fits/image.xml
816
816
  - spec/fixtures/imageA.tif