4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/concerns/interpret_relationships_behavior.rb', line 4
def interpret_relationship_fields
@raw_row.each do |field,value|
next if value.blank? or field.blank? or value == field
id_type = reference_identifier
if (split = field.split(/[:_\-\s]/)).count == 2
id_type = split.last
field = split.first
end
next unless (relationship_type = self.class.normalize_relationship_field_name(field))
case relationship_type
when "order"
@proxy.update(order: value.to_f)
next
when "collection"
col = find_or_create_collection(value)
( @metadata[:member_of_collection_ids] ||= [] ) << col.id if col
next
when "parent"
if (split = value.split(/[:_\\s]/)).count == 2
id_type = split.first
value = split.last
end
parent = find_parent_proxy(value, field, id_type)
proxy_updates = { parent_id: parent.id}
siblings = parent.ordered_children
if siblings.present? && @proxy.previous_sibling_id.nil?
proxy_updates[:previous_sibling_id] = siblings.last.id
end
@proxy.update(proxy_updates)
end
end
end
|