move-to-go 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/move-to-go/model/meeting.rb +219 -0
- data/lib/move-to-go/model/organization.rb +9 -1
- data/lib/move-to-go/model/person.rb +4 -0
- data/lib/move-to-go/model/rootmodel.rb +145 -3
- data/lib/move-to-go/model/todo.rb +172 -0
- data/lib/move-to-go/roo_helper.rb +4 -1
- data/lib/move-to-go/serialize_helper.rb +18 -0
- data/lib/move-to-go/shard_helper.rb +16 -0
- data/lib/move-to-go/source.rb +2 -0
- data/sources/excel/.move-to-go/runner.rb +34 -0
- data/sources/excel/converter.rb +45 -2
- data/sources/excel/sample-data.xlsx +0 -0
- data/sources/lime-easy/.move-to-go/runner.rb +148 -32
- data/sources/lime-easy/converter.rb +23 -7
- data/spec/meeting_spec.rb +152 -0
- data/spec/todo_spec.rb +149 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 369dc09edf8f83c6e21d833aaceccfdc5517d577
|
4
|
+
data.tar.gz: 50a934212ed3607d5e2fd24ab0578f3dcd3cb8fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a87a18293122ab47b4e3d5e13c924deb92bbc1bb4ed40995bf4e6913ab169cf6c12a4ab50b97fc99d39c47518438d19a53d99619a22ea9283292b2649c4195bd
|
7
|
+
data.tar.gz: c12a6eecd94e064a64938c090284f3526f27b1698dc7f9ebf9f15d7c9804c8903be59972c4a9b5dfce21d6fa93b8a5477f575e97b4752298782e5e942332a390
|
@@ -0,0 +1,219 @@
|
|
1
|
+
module MoveToGo
|
2
|
+
class Meeting < CanBecomeImmutable
|
3
|
+
include SerializeHelper
|
4
|
+
##
|
5
|
+
# :attr_accessor: id
|
6
|
+
immutable_accessor :id
|
7
|
+
##
|
8
|
+
# :attr_accessor: integration_id
|
9
|
+
immutable_accessor :integration_id
|
10
|
+
|
11
|
+
attr_reader :text, :heading, :date_stop, :location
|
12
|
+
attr_reader :date_start, :date_start_has_time, :datechecked
|
13
|
+
attr_reader :organization, :created_by, :assigned_coworker, :person, :deal
|
14
|
+
|
15
|
+
def initialize(opt = nil)
|
16
|
+
if !opt.nil?
|
17
|
+
serialize_variables.each do |myattr|
|
18
|
+
val = opt[myattr[:id]]
|
19
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def serialize_variables
|
25
|
+
[ :id, :text, :heading, :location, :integration_id ].map {
|
26
|
+
|p| {
|
27
|
+
:id => p,
|
28
|
+
:type => :string
|
29
|
+
}
|
30
|
+
} +
|
31
|
+
[
|
32
|
+
{ :id => :date_start, :type => :datetime },
|
33
|
+
{ :id => :date_stop, :type => :datetime },
|
34
|
+
{ :id => :date_start_has_time, :type => :bool },
|
35
|
+
{ :id => :created_by_reference, :type => :coworker_reference, :element_name => :created_by },
|
36
|
+
{ :id => :assigned_coworker_reference, :type => :coworker_reference, :element_name => :assigned_coworker },
|
37
|
+
{ :id => :organization_reference, :type => :organization_reference, :element_name => :organization },
|
38
|
+
{ :id => :deal_reference, :type => :deal_reference, :element_name => :deal },
|
39
|
+
{ :id => :person_reference, :type => :person_reference, :element_name => :person }
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_import_rows
|
44
|
+
(serialize_variables + [
|
45
|
+
{ :id => :organization, :type => :organization_reference},
|
46
|
+
{ :id => :person, :type => :person_reference}
|
47
|
+
]).map do |p|
|
48
|
+
map_to_row p
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def serialize_name
|
53
|
+
"Meeting"
|
54
|
+
end
|
55
|
+
|
56
|
+
def organization=(org)
|
57
|
+
raise_if_immutable
|
58
|
+
@organization_reference = OrganizationReference.from_organization(org)
|
59
|
+
|
60
|
+
if org.is_a?(Organization)
|
61
|
+
@organization = org
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def created_by=(coworker)
|
66
|
+
raise_if_immutable
|
67
|
+
@created_by_reference = CoworkerReference.from_coworker(coworker)
|
68
|
+
|
69
|
+
if coworker.is_a?(Coworker)
|
70
|
+
@created_by = coworker
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def assigned_coworker=(coworker)
|
75
|
+
raise_if_immutable
|
76
|
+
@assigned_coworker_reference = CoworkerReference.from_coworker(coworker)
|
77
|
+
|
78
|
+
if coworker.is_a?(Coworker)
|
79
|
+
@assigned_coworker = coworker
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def person=(person)
|
84
|
+
raise_if_immutable
|
85
|
+
@person_reference = PersonReference.from_person(person)
|
86
|
+
|
87
|
+
if person.is_a?(Person)
|
88
|
+
@person = person
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def deal=(deal)
|
93
|
+
raise_if_immutable
|
94
|
+
@deal_reference = DealReference.from_deal(deal)
|
95
|
+
|
96
|
+
if deal.is_a?(Deal)
|
97
|
+
@deal = deal
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def text=(text)
|
102
|
+
raise_if_immutable
|
103
|
+
@text = text
|
104
|
+
|
105
|
+
if @text.nil?
|
106
|
+
return
|
107
|
+
end
|
108
|
+
|
109
|
+
if @text.length == 0
|
110
|
+
return
|
111
|
+
end
|
112
|
+
|
113
|
+
@text.strip!
|
114
|
+
|
115
|
+
# remove form feeds
|
116
|
+
@text.gsub!("\f", "")
|
117
|
+
|
118
|
+
# remove vertical spaces
|
119
|
+
@text.gsub!("\v", "")
|
120
|
+
|
121
|
+
# remove backspace
|
122
|
+
@text.gsub!("\b", "")
|
123
|
+
end
|
124
|
+
|
125
|
+
def heading=(heading)
|
126
|
+
raise_if_immutable
|
127
|
+
@heading = heading
|
128
|
+
|
129
|
+
if @heading.nil?
|
130
|
+
return
|
131
|
+
end
|
132
|
+
|
133
|
+
if @heading.length == 0
|
134
|
+
return
|
135
|
+
end
|
136
|
+
|
137
|
+
@heading.strip!
|
138
|
+
|
139
|
+
# remove form feeds
|
140
|
+
@heading.gsub!("\f", "")
|
141
|
+
|
142
|
+
# remove vertical spaces
|
143
|
+
@heading.gsub!("\v", "")
|
144
|
+
|
145
|
+
# remove backspace
|
146
|
+
@heading.gsub!("\b", "")
|
147
|
+
end
|
148
|
+
|
149
|
+
def location=(location)
|
150
|
+
raise_if_immutable
|
151
|
+
@location = location
|
152
|
+
|
153
|
+
if @location.nil?
|
154
|
+
return
|
155
|
+
end
|
156
|
+
|
157
|
+
if @location.length == 0
|
158
|
+
return
|
159
|
+
end
|
160
|
+
|
161
|
+
@location.strip!
|
162
|
+
|
163
|
+
# remove form feeds
|
164
|
+
@location.gsub!("\f", "")
|
165
|
+
|
166
|
+
# remove vertical spaces
|
167
|
+
@location.gsub!("\v", "")
|
168
|
+
|
169
|
+
# remove backspace
|
170
|
+
@location.gsub!("\b", "")
|
171
|
+
end
|
172
|
+
|
173
|
+
def date_start=(datetime)
|
174
|
+
@date_start = DateTime.parse(datetime)
|
175
|
+
end
|
176
|
+
|
177
|
+
def date_stop=(datetime)
|
178
|
+
@date_stop = DateTime.parse(datetime)
|
179
|
+
end
|
180
|
+
|
181
|
+
def date_start_has_time=(bool)
|
182
|
+
@date_start_has_time = bool
|
183
|
+
end
|
184
|
+
|
185
|
+
def datechecked=(datetime)
|
186
|
+
@datechecked = DateTime.parse(datetime)
|
187
|
+
end
|
188
|
+
|
189
|
+
def validate
|
190
|
+
error = String.new
|
191
|
+
|
192
|
+
if (@heading.nil? || @heading.empty?)
|
193
|
+
error = "Heading is required for meeting\n"
|
194
|
+
end
|
195
|
+
|
196
|
+
if @created_by.nil?
|
197
|
+
error = "#{error}Created_by is required for meeting\n"
|
198
|
+
end
|
199
|
+
|
200
|
+
if @date_start.nil?
|
201
|
+
error = "#{error}Date_start is required for meeting\n"
|
202
|
+
end
|
203
|
+
|
204
|
+
if @date_start_has_time.nil?
|
205
|
+
error = "#{error}Date_start_has_time is required for meeting\n"
|
206
|
+
end
|
207
|
+
|
208
|
+
if @date_stop.nil?
|
209
|
+
error = "#{error}Date_stop is required for meeting\n"
|
210
|
+
end
|
211
|
+
|
212
|
+
if @organization.nil?
|
213
|
+
error = "#{error}Organization is required for meeting\n"
|
214
|
+
end
|
215
|
+
|
216
|
+
return error
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
@@ -196,6 +196,14 @@ module MoveToGo
|
|
196
196
|
@rootmodel.select_histories{|history| history.organization == self}
|
197
197
|
end
|
198
198
|
|
199
|
+
def todos
|
200
|
+
@rootmodel.select_todos{|todo| todo.organization == self}
|
201
|
+
end
|
202
|
+
|
203
|
+
def meetings
|
204
|
+
@rootmodel.select_meetings{|meeting| meeting.organization == self}
|
205
|
+
end
|
206
|
+
|
199
207
|
def documents(type)
|
200
208
|
@rootmodel.select_documents(type){|doc| doc.organization == self}
|
201
209
|
end
|
@@ -227,7 +235,7 @@ module MoveToGo
|
|
227
235
|
end
|
228
236
|
|
229
237
|
def find_employee_by_integration_id(integration_id)
|
230
|
-
return nil if @employees.nil?
|
238
|
+
return nil if @employees.nil? || integration_id.nil?
|
231
239
|
return @employees.find do |e|
|
232
240
|
e.integration_id == integration_id
|
233
241
|
end
|
@@ -76,6 +76,9 @@ module MoveToGo
|
|
76
76
|
##
|
77
77
|
# :attr_accessor: currently_employed
|
78
78
|
immutable_accessor :currently_employed
|
79
|
+
##
|
80
|
+
# :attr_accessor: has_mail_consent
|
81
|
+
immutable_accessor :has_mail_consent
|
79
82
|
|
80
83
|
# you add custom values by using {#set_custom_value}
|
81
84
|
attr_reader :custom_values, :organization
|
@@ -147,6 +150,7 @@ module MoveToGo
|
|
147
150
|
{:id => :postal_address, :type => :address},
|
148
151
|
{:id => :custom_values, :type => :custom_values},
|
149
152
|
{:id => :currently_employed, :type => :bool},
|
153
|
+
{:id => :has_mail_consent, :type => :bool},
|
150
154
|
{:id => :organization, :type => :organization_reference},
|
151
155
|
|
152
156
|
]
|
@@ -11,7 +11,7 @@ module MoveToGo
|
|
11
11
|
# responsible for objects that requires a coworker, eg a history.
|
12
12
|
attr_accessor :migrator_coworker
|
13
13
|
|
14
|
-
attr_accessor :settings, :organizations, :coworkers, :deals, :histories
|
14
|
+
attr_accessor :settings, :organizations, :coworkers, :deals, :histories, :todos, :meetings
|
15
15
|
|
16
16
|
# The configuration is used to set run-time properties for
|
17
17
|
# move-to-go. This should not be confused with the model's
|
@@ -31,6 +31,8 @@ module MoveToGo
|
|
31
31
|
{:id => :organizations, :type => :organizations},
|
32
32
|
{:id => :deals, :type => :deals},
|
33
33
|
{:id => :histories, :type => :histories},
|
34
|
+
{:id => :todos, :type => :todos},
|
35
|
+
{:id => :meetings, :type => :meetings},
|
34
36
|
{:id => :documents, :type => :documents}
|
35
37
|
]
|
36
38
|
end
|
@@ -52,6 +54,8 @@ module MoveToGo
|
|
52
54
|
@coworkers[@migrator_coworker.integration_id] = @migrator_coworker
|
53
55
|
@deals = {}
|
54
56
|
@histories = {}
|
57
|
+
@todos = {}
|
58
|
+
@meetings = {}
|
55
59
|
@documents = Documents.new
|
56
60
|
@configuration = {}
|
57
61
|
|
@@ -149,11 +153,17 @@ module MoveToGo
|
|
149
153
|
select_histories{|history| history.organization == organization}
|
150
154
|
.each{|history| @histories.delete(history.integration_id)}
|
151
155
|
|
156
|
+
select_todos{|todo| todo.organization == organization}
|
157
|
+
.each{|todo| @todo.delete(todo.integration_id)}
|
158
|
+
|
159
|
+
select_meetings{|meeting| meeting.organization == organization}
|
160
|
+
.each{|meeting| @meeting.delete(meeting.integration_id)}
|
161
|
+
|
152
162
|
select_documents(:file){|file| file.organization == organization}
|
153
163
|
.each{|file| @documents.files.delete(file.integration_id)}
|
154
164
|
|
155
|
-
select_documents(:link){|
|
156
|
-
.each{|
|
165
|
+
select_documents(:link){|doc| doc.organization == organization}
|
166
|
+
.each{|doc| @documents.links.delete(doc.integration_id)}
|
157
167
|
|
158
168
|
@organizations.delete(organization.integration_id)
|
159
169
|
|
@@ -295,6 +305,60 @@ module MoveToGo
|
|
295
305
|
return history
|
296
306
|
end
|
297
307
|
|
308
|
+
def add_todo(todo)
|
309
|
+
if todo.nil?
|
310
|
+
return nil
|
311
|
+
end
|
312
|
+
|
313
|
+
if !todo.is_a?(Todo)
|
314
|
+
raise ArgumentError.new("Expected an todo")
|
315
|
+
end
|
316
|
+
|
317
|
+
if todo.integration_id.nil? || todo.integration_id.length == 0
|
318
|
+
todo.integration_id = "todo_#{@todos.length}"
|
319
|
+
end
|
320
|
+
|
321
|
+
if find_todo_by_integration_id(todo.integration_id, false) != nil
|
322
|
+
raise AlreadyAddedError, "Already added a todo with integration_id #{todo.integration_id}"
|
323
|
+
end
|
324
|
+
|
325
|
+
if todo.created_by.nil?
|
326
|
+
todo.created_by = @migrator_coworker
|
327
|
+
end
|
328
|
+
|
329
|
+
@todos[todo.integration_id] = todo
|
330
|
+
todo.set_is_immutable
|
331
|
+
|
332
|
+
return todo
|
333
|
+
end
|
334
|
+
|
335
|
+
def add_meeting(meeting)
|
336
|
+
if meeting.nil?
|
337
|
+
return nil
|
338
|
+
end
|
339
|
+
|
340
|
+
if !meeting.is_a?(Meeting)
|
341
|
+
raise ArgumentError.new("Expected an meeting")
|
342
|
+
end
|
343
|
+
|
344
|
+
if meeting.integration_id.nil? || meeting.integration_id.length == 0
|
345
|
+
meeting.integration_id = "meeting_#{@meetings.length}"
|
346
|
+
end
|
347
|
+
|
348
|
+
if find_meeting_by_integration_id(meeting.integration_id, false) != nil
|
349
|
+
raise AlreadyAddedError, "Already added a meeting with integration_id #{meeting.integration_id}"
|
350
|
+
end
|
351
|
+
|
352
|
+
if meeting.created_by.nil?
|
353
|
+
meeting.created_by = @migrator_coworker
|
354
|
+
end
|
355
|
+
|
356
|
+
@meetings[meeting.integration_id] = meeting
|
357
|
+
meeting.set_is_immutable
|
358
|
+
|
359
|
+
return meeting
|
360
|
+
end
|
361
|
+
|
298
362
|
def add_link(link)
|
299
363
|
@documents = Documents.new if @documents == nil
|
300
364
|
|
@@ -345,6 +409,24 @@ module MoveToGo
|
|
345
409
|
end
|
346
410
|
end
|
347
411
|
|
412
|
+
def find_todo_by_integration_id(integration_id, report_result=!!configuration[:report_result])
|
413
|
+
if @todos.has_key?(integration_id)
|
414
|
+
return @todos[integration_id]
|
415
|
+
else
|
416
|
+
report_failed_to_find_object("todo", ":#{integration_id}") if report_result
|
417
|
+
return nil
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
def find_meeting_by_integration_id(integration_id, report_result=!!configuration[:report_result])
|
422
|
+
if @meetings.has_key?(integration_id)
|
423
|
+
return @meetings[integration_id]
|
424
|
+
else
|
425
|
+
report_failed_to_find_object("meeting", ":#{integration_id}") if report_result
|
426
|
+
return nil
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
348
430
|
# find deals for organization using {Organization#integration_id}
|
349
431
|
def find_deals_for_organization(organization)
|
350
432
|
deals = []
|
@@ -467,6 +549,46 @@ module MoveToGo
|
|
467
549
|
return result
|
468
550
|
end
|
469
551
|
|
552
|
+
# Finds a todo based on one of its property.
|
553
|
+
# Returns the first found matching todo
|
554
|
+
# @example Finds a todo on its name
|
555
|
+
# rm.find_todo {|todo| todo.text == "hello!" }
|
556
|
+
def find_todo(report_result=!!configuration[:report_result], &block)
|
557
|
+
result = find(@todos.values.flatten, &block)
|
558
|
+
report_failed_to_find_object("todo") if result.nil? and report_result
|
559
|
+
return result
|
560
|
+
end
|
561
|
+
|
562
|
+
# Finds a todo based on one of its property.
|
563
|
+
# Returns all found matching todo
|
564
|
+
# @example Finds a todo on its name
|
565
|
+
# rm.select_todo {|todo| todo.text == "hello!" }
|
566
|
+
def select_todos(report_result=!!configuration[:report_result], &block)
|
567
|
+
result = select(@todos.values.flatten, &block)
|
568
|
+
report_failed_to_find_object("todo") if result.nil? and report_result
|
569
|
+
return result
|
570
|
+
end
|
571
|
+
|
572
|
+
# Finds a meeting based on one of its property.
|
573
|
+
# Returns the first found matching meeting
|
574
|
+
# @example Finds a meeting on its name
|
575
|
+
# rm.find_meeting {|meeting| meeting.text == "hello!" }
|
576
|
+
def find_meeting(report_result=!!configuration[:report_result], &block)
|
577
|
+
result = find(@meetings.values.flatten, &block)
|
578
|
+
report_failed_to_find_object("meeting") if result.nil? and report_result
|
579
|
+
return result
|
580
|
+
end
|
581
|
+
|
582
|
+
# Finds a meeting based on one of its property.
|
583
|
+
# Returns all found matching meeting
|
584
|
+
# @example Finds a meeting on its name
|
585
|
+
# rm.select_meeting {|meeting| meeting.text == "hello!" }
|
586
|
+
def select_meetings(report_result=!!configuration[:report_result], &block)
|
587
|
+
result = select(@meetings.values.flatten, &block)
|
588
|
+
report_failed_to_find_object("meeting") if result.nil? and report_result
|
589
|
+
return result
|
590
|
+
end
|
591
|
+
|
470
592
|
# Finds a document based on one of its property.
|
471
593
|
# Returns the first found matching document
|
472
594
|
# @example Finds a document on its name
|
@@ -568,6 +690,22 @@ module MoveToGo
|
|
568
690
|
end
|
569
691
|
end
|
570
692
|
|
693
|
+
@todos.each do |key, todo|
|
694
|
+
validation_message = todo.validate
|
695
|
+
|
696
|
+
if !validation_message.empty?
|
697
|
+
errors = "#{errors}\n#{validation_message}"
|
698
|
+
end
|
699
|
+
end
|
700
|
+
|
701
|
+
@meetings.each do |key, meeting|
|
702
|
+
validation_message = meeting.validate
|
703
|
+
|
704
|
+
if !validation_message.empty?
|
705
|
+
errors = "#{errors}\n#{validation_message}"
|
706
|
+
end
|
707
|
+
end
|
708
|
+
|
571
709
|
@documents.links.each do |link|
|
572
710
|
validation_message = link.validate
|
573
711
|
if !validation_message.empty?
|
@@ -619,6 +757,8 @@ module MoveToGo
|
|
619
757
|
@coworkers = []
|
620
758
|
@deals = []
|
621
759
|
@histories = []
|
760
|
+
@todos = []
|
761
|
+
@meetings = []
|
622
762
|
@documents = saved_documents
|
623
763
|
serialize_to_file(go_files_file)
|
624
764
|
|
@@ -678,6 +818,8 @@ module MoveToGo
|
|
678
818
|
" Persons: #{persons.length}\n" \
|
679
819
|
" Deals: #{@deals.length}\n" \
|
680
820
|
" History logs: #{@histories.length}\n" \
|
821
|
+
" Todos: #{@todos.length}\n" \
|
822
|
+
" Meetings: #{@meetings.length}\n" \
|
681
823
|
" Documents: #{nbr_of_documents}"
|
682
824
|
end
|
683
825
|
|