bulk_ops 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bulk_ops/operation.rb +1 -1
- data/lib/bulk_ops/relationship.rb +6 -4
- data/lib/bulk_ops/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b118e0e6b4039a3fff3174e553faaa05c447c09b08c3ea5ad013ba8922b09084
|
4
|
+
data.tar.gz: d27b01baf50a45da61d1131f8a84a61bd0b2db6bbfd23742a49b508e55cdecd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b9f53d064c5cdef7044c7b727fe36d2ccd1fcfb50bf522b5c45375fb7c6f548a9fbe1bc88ef4cfe757dac1f44af4d4b2d503246a98b65891883c1e08d1dc75
|
7
|
+
data.tar.gz: 32faf9307eb850f7a306d7e3c9c088b53faf63fd9a25578c04b6facdcb6647eca0fb38c26253c078772d2e49715e559a7b3bc655fa349791dbf33b6070edded1
|
data/lib/bulk_ops/operation.rb
CHANGED
@@ -150,7 +150,7 @@ module BulkOps
|
|
150
150
|
|
151
151
|
work_proxies.each do |proxy|
|
152
152
|
wrk = Work.find(proxy.work_id)
|
153
|
-
wrk.save if wrk.members.any?{|mem| mem.class.to_s
|
153
|
+
wrk.save if wrk.members.any?{|mem| mem.class.to_s != "FileSet"}
|
154
154
|
sd = SolrDocument.find(wrk.id)
|
155
155
|
wrk.save if sd['hasRelatedImage_ssim'].present? && sd['relatedImageId_ss'].blank?
|
156
156
|
end
|
@@ -58,7 +58,7 @@ class BulkOps::Relationship < ActiveRecord::Base
|
|
58
58
|
implement_relationship! relationship_type, subject, object
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
61
|
+
def insert_among_children(object,new_member)
|
62
62
|
return nil unless ["parent"].include?(relationship_type.downcase)
|
63
63
|
prev_sib_id = previous_sibling
|
64
64
|
# This is the id of the WorkProxy associate with the most recent sibling work
|
@@ -68,7 +68,8 @@ class BulkOps::Relationship < ActiveRecord::Base
|
|
68
68
|
prev_sib_proxy = BulkOps::WorkProxy.find(previous_sibling)
|
69
69
|
# Check if the previous sibling is fully ingested
|
70
70
|
# and get its index among its siblings (if it has been successfully attached to the parent)
|
71
|
-
prev_sib_index = object.ordered_member_ids.index(prev_sib_proxy.work_id) if prev_sib_proxy.work_id.present?
|
71
|
+
prev_sib_index = object.ordered_member_ids.index(prev_sib_proxy.work_id) if prev_sib_proxy.work_id.present?
|
72
|
+
# Insert the new member among its siblings if we found the right place
|
72
73
|
return object.ordered_members.to_a.insert(prev_sib_index+1, new_member) if prev_sib_index.present?
|
73
74
|
# Otherwise, pull up the sibling's relationship field to check if it sibling has a sibling before it
|
74
75
|
sib_relationship = prev_sib_proxy.relationships.find_by(relationship_type: relationship_type, object_identifier: object_identifier)
|
@@ -77,14 +78,15 @@ class BulkOps::Relationship < ActiveRecord::Base
|
|
77
78
|
break unless sib_relationship.present?
|
78
79
|
prev_sib_id = sib_relationship.previous_sibling
|
79
80
|
end
|
80
|
-
|
81
|
+
#If we never found an existing previous sibling already attached, put this one at the front
|
82
|
+
return [new_member]+object.ordered_members.to_a
|
81
83
|
end
|
82
84
|
|
83
85
|
def implement_relationship!(type,subject,object)
|
84
86
|
case type.downcase
|
85
87
|
when "parent"
|
86
88
|
unless object.member_ids.include? subject.id
|
87
|
-
object.ordered_members =
|
89
|
+
object.ordered_members = insert_among_children(object, subject)
|
88
90
|
object.save
|
89
91
|
end
|
90
92
|
when "child"
|
data/lib/bulk_ops/version.rb
CHANGED