Module: RTM::Revision

Defined in:
lib/rtm/revision.rb

Overview

Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. License: Apache License, Version 2.0

Constant Summary collapse

Type =
Java::DeTopicmapslabMajortomModelEvent::TopicMapEventType

Class Method Summary collapse

Class Method Details

.specify_event(type) ⇒ Object



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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rtm/revision.rb', line 7

def self.specify_event(type)
  return (
    case type
    when Type::ASSOCIATION_ADDED
      :creation
    when Type::ASSOCIATION_REMOVED
      :deletion
    when Type::DATATYPE_SET
      :update
    when Type::ID_MODIFIED
      :update
    when Type::ITEM_IDENTIFIER_ADDED
      :update
    when Type::ITEM_IDENTIFIER_REMOVED
      :update
    when Type::MERGE
      :update
    when Type::NAME_ADDED
      :update
    when Type::NAME_REMOVED
      :update
    when Type::OCCURRENCE_ADDED
      :update
    when Type::OCCURRENCE_REMOVED
      :update
    when Type::PLAYER_MODIFIED
      :update
    when Type::REIFIER_SET
      :update
    when Type::REMOVE_DUPLICATES
      :update
    when Type::ROLE_ADDED
      :update
    when Type::ROLE_REMOVED
      :update
    when Type::SCOPE_MODIFIED
      :update
    when Type::SUBJECT_IDENTIFIER_ADDED
      :update
    when Type::SUBJECT_IDENTIFIER_REMOVED
      :update
    when Type::SUBJECT_LOCATOR_ADDED
      :update
    when Type::SUBJECT_LOCATOR_REMOVED
      :update
    when Type::TOPIC_ADDED
      :creation
    when Type::TOPIC_REMOVED
      :deletion
    when Type::TYPE_ADDED
      :update
    when Type::TYPE_REMOVED
      :update
    when Type::TYPE_SET
      :update
    when Type::VALUE_MODIFIED
      :update
    when Type::VARIANT_ADDED
      :update
    when Type::VARIANT_REMOVED
      :update
    else
      nil
    end )
end

.topic_or_association_context(revision) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/rtm/revision.rb', line 73

def self.topic_or_association_context(revision)
  # TODO not finished yet, test it also in the history_spec
  type = revision.changeset_type
  changeset = revision.changeset
  
  case type
  when Type::ASSOCIATION_ADDED
    context = changeset.first.new_value # association
  when Type::ASSOCIATION_REMOVED
    context = changeset.last.old_value # association
  when Type::DATATYPE_SET
    datatype_aware = changeset.first.context
    if datatype_aware.is_a?(RTM::Occurrence)
      context = datatype_aware.parent # topic
    else
      context = datatype_aware.parent.parent # topic
    end
  when Type::ID_MODIFIED
    return nil
  when Type::ITEM_IDENTIFIER_ADDED
    context = changeset.first.context # topic
  when Type::ITEM_IDENTIFIER_REMOVED
    context = changeset.first.context # topic
  when Type::MERGE
    return nil
  when Type::NAME_ADDED
    context = changeset.first.context # topic
  when Type::NAME_REMOVED
    context = changeset.last.context # topic
  when Type::OCCURRENCE_ADDED
    context = changeset.first.context # topic
  when Type::OCCURRENCE_REMOVED
    context = changeset.last.context # topic
  when Type::PLAYER_MODIFIED
    context = changeset.first.context.parent # association
  when Type::REIFIER_SET
    return nil
  when Type::REMOVE_DUPLICATES
    return nil
  when Type::ROLE_ADDED
    context = changeset.first.context # association
  when Type::ROLE_REMOVED
    context = changeset.last.context # association
  when Type::SCOPE_MODIFIED
    typed = changeset.first.context
    if typed.is_a?(RTM::Variant)
      context = typed.parent.parent # topic
    elsif typed.is_a?(RTM::Occurrence)
      context = typed.parent # topic
    elsif typed.is_a?(RTM::Name)
      context = typed.parent # topic
    else
      context = typed # association
    end
  when Type::SUBJECT_IDENTIFIER_ADDED
    context = changeset.first.context # topic
  when Type::SUBJECT_IDENTIFIER_REMOVED
    context = changeset.first.context # topic
  when Type::SUBJECT_LOCATOR_ADDED
    context = changeset.first.context # topic
  when Type::SUBJECT_LOCATOR_REMOVED
    context = changeset.first.context # topic
  when Type::TOPIC_ADDED
    context = changeset.first.new_value # topic
  when Type::TOPIC_REMOVED
    context = changeset.last.old_value # topic
  when Type::TYPE_ADDED
    context = changeset.first.context # topic
  when Type::TYPE_REMOVED
    context = changeset.first.context # topic
  when Type::TYPE_SET
    typed = changeset.first.context
    if typed.is_a?(RTM::Role)
      context = typed.parent # association
    elsif typed.is_a?(RTM::Association)
      context = typed # association
    else
      context = typed.parent # topic
    end
  when Type::VALUE_MODIFIED
    valued = changeset.first.context
    if valued.is_a?(RTM::Variant)
      context = valued.parent.parent #topic
    else
      context = valued.parent # topic
    end
  when Type::VARIANT_ADDED
    context = changeset.first.context.parent # topic
  when Type::VARIANT_REMOVED
    context = changeset.last.context.parent # topic
  else
    return nil
  end
  return context
end