Class: Pacer::Neo4j::TxDataWrapper

Inherits:
Object
  • Object
show all
Includes:
Algo::Wrapping
Defined in:
lib/pacer-neo4j/tx_data_wrapper.rb

Overview

Uses the interface defined here: api.neo4j.org/1.8/org/neo4j/graphdb/Path.html

Note that I have removed methods that I didn’t understand, assuming they are internal.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tx, graph) ⇒ TxDataWrapper

Returns a new instance of TxDataWrapper.



12
13
14
15
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 12

def initialize(tx, graph)
  @tx = tx
  @graph = graph
end

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



10
11
12
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 10

def graph
  @graph
end

#txObject (readonly)

Returns the value of attribute tx.



10
11
12
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 10

def tx
  @tx
end

Instance Method Details

#changed_eObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 70

def changed_e
  tx.assignedRelationshipProperties.map do |p|
    { element_type: :edge,
      id: p.entity.getId,
      key: p.key,
      was: graph.decode_property(p.previouslyCommitedValue),
      is: graph.decode_property(p.value) }
  end +
  tx.removedRelationshipProperties.map do |p|
    { element_type: :edge,
      id: p.entity.getId,
      key: p.key,
      was: graph.decode_property(p.previouslyCommitedValue),
      is: nil }
  end
end

#changed_vObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 53

def changed_v
  tx.assignedNodeProperties.map do |p|
    { element_type: :vertex,
      id: p.entity.getId,
      key: p.key,
      was: graph.decode_property(p.previouslyCommitedValue),
      is: graph.decode_property(p.value) }
  end +
  tx.removedNodeProperties.map do |p|
    { element_type: :vertex,
      id: p.entity.getId,
      key: p.key,
      was: graph.decode_property(p.previouslyCommitedValue),
      is: nil }
  end
end

#changesObject



87
88
89
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 87

def changes
  changed_v + changed_e
end

#created_eObject



25
26
27
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 25

def created_e
  tx.createdRelationships.map { |n| wrap_edge n }
end

#created_e_idsObject



41
42
43
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 41

def created_e_ids
  tx.createdRelationships.map { |n| n.getId }
end

#created_vObject



17
18
19
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 17

def created_v
  tx.createdNodes.map { |n| wrap_vertex n }
end

#created_v_idsObject



33
34
35
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 33

def created_v_ids
  tx.createdNodes.map { |n| n.getId }
end

#deleted?(e) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 49

def deleted?(e)
  tx.is_deleted e.element.rawElement
end

#deleted_eObject



29
30
31
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 29

def deleted_e
  tx.deletedRelationships.map { |n| wrap_edge n }
end

#deleted_e_idsObject



45
46
47
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 45

def deleted_e_ids
  tx.deletedRelationships.map { |n| n.getId }
end

#deleted_vObject



21
22
23
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 21

def deleted_v
  tx.deletedNodes.map { |n| wrap_vertex n }
end

#deleted_v_idsObject



37
38
39
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 37

def deleted_v_ids
  tx.deletedNodes.map { |n| n.getId }
end

#summaryObject



91
92
93
94
95
96
97
98
# File 'lib/pacer-neo4j/tx_data_wrapper.rb', line 91

def summary
  { created_v: created_v_ids,
    deleted_v: deleted_v_ids,
    created_e: created_e_ids,
    deleted_e: deleted_e_ids,
    changed_v: changed_v,
    changed_e: changed_e }
end