go_import 3.0.42 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/go-import +2 -1
- data/lib/go_import/errors.rb +2 -2
- data/lib/go_import/model/deal_status.rb +2 -2
- data/lib/go_import/model/{note.rb → history.rb} +17 -13
- data/lib/go_import/model/{note_classification.rb → history_classification.rb} +8 -8
- data/lib/go_import/model/rootmodel.rb +39 -41
- data/lib/go_import/serialize_helper.rb +4 -4
- data/lib/go_import/shard_helper.rb +3 -3
- data/lib/go_import.rb +13 -13
- data/sources/VISMA/.go_import/readme.txt +1 -1
- data/sources/VISMA/.go_import/runner.rb +8 -8
- data/sources/VISMA/converter.rb +15 -14
- data/sources/base-crm/.go_import/runner.rb +24 -24
- data/sources/base-crm/converter.rb +3 -3
- data/sources/base-crm/data/{notes.csv → histories.csv} +0 -0
- data/sources/csv/converter.rb +6 -6
- data/sources/excel/.go_import/runner.rb +11 -11
- data/sources/excel/converter.rb +15 -15
- data/sources/excel-basic/.go_import/runner.rb +11 -11
- data/sources/excel-basic/converter.rb +9 -9
- data/sources/lime-easy/.go_import/runner.rb +40 -40
- data/sources/lime-easy/converter.rb +22 -22
- data/sources/lime-pro-basic/.go_import/runner.rb +19 -19
- data/sources/lime-pro-basic/converter.rb +22 -22
- data/sources/salesforce/.go_import/runner.rb +10 -10
- data/sources/salesforce/converter.rb +6 -6
- data/spec/helpers/serialize_helper_spec.rb +6 -6
- data/spec/helpers/shard_helper_spec.rb +3 -3
- data/spec/history_spec.rb +150 -0
- data/spec/rootmodel_spec.rb +56 -56
- metadata +7 -7
- data/spec/note_spec.rb +0 -150
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b80d03092ece9f1cc8f8194de2e009fea1ec57f9
|
4
|
+
data.tar.gz: cb272c0880e52b47b935320a45d452c94e5f3df3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b83c3c678daca732107052641e35d2c3bc2b393465b127d281d9513516d1b1135d82bfa6fe14b7930a7e1a0e426e89b3ccfb8d48d0aaf3a9d7e09aa90ffd28b
|
7
|
+
data.tar.gz: 5ed9dfd6b376bdfc28985076afe05240a9631d2a0c9bbabfba66525deab6b82802af1f380448c098c725b7848890e61860c40104799c5a0a330b22e596bfe14e
|
data/bin/go-import
CHANGED
data/lib/go_import/errors.rb
CHANGED
@@ -20,9 +20,9 @@ module GoImport
|
|
20
20
|
class InvalidDealStatusError < StandardError
|
21
21
|
end
|
22
22
|
|
23
|
-
class
|
23
|
+
class InvalidHistoryClassificationError < StandardError
|
24
24
|
def initalize(classification)
|
25
|
-
super("#{classification} is not a valid
|
25
|
+
super("#{classification} is not a valid history classification")
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -2,7 +2,7 @@ module GoImport
|
|
2
2
|
class DealStatus
|
3
3
|
include SerializeHelper
|
4
4
|
|
5
|
-
attr_accessor :id, :date, :status_reference, :
|
5
|
+
attr_accessor :id, :date, :status_reference, :history
|
6
6
|
|
7
7
|
def initialize(opt = nil)
|
8
8
|
if opt != nil
|
@@ -14,7 +14,7 @@ module GoImport
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def serialize_variables
|
17
|
-
[ :id, :label, :
|
17
|
+
[ :id, :label, :history ].map{ |p| { :id => p, :type => :string } } +
|
18
18
|
[ :date ].map { |p| { :id => p, :type => :date } } +
|
19
19
|
[ :status_reference ].map { |p| { :id => p, :type => :deal_status_reference } }
|
20
20
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module GoImport
|
2
|
-
class
|
2
|
+
class History < CanBecomeImmutable
|
3
3
|
include SerializeHelper
|
4
4
|
immutable_accessor :id
|
5
5
|
immutable_accessor :integration_id
|
@@ -8,8 +8,8 @@ module GoImport
|
|
8
8
|
attr_reader :text
|
9
9
|
attr_reader :organization, :created_by, :person, :deal
|
10
10
|
|
11
|
-
# The
|
12
|
-
# {#
|
11
|
+
# The history classification. It should be a value from
|
12
|
+
# {#HistoryClassification}. The default value is Comment.
|
13
13
|
attr_reader :classification
|
14
14
|
|
15
15
|
def initialize(opt = nil)
|
@@ -20,7 +20,7 @@ module GoImport
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
@classification =
|
23
|
+
@classification = HistoryClassification::Comment if @classification.nil?
|
24
24
|
end
|
25
25
|
|
26
26
|
def serialize_variables
|
@@ -49,7 +49,7 @@ module GoImport
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def serialize_name
|
52
|
-
"
|
52
|
+
"History"
|
53
53
|
end
|
54
54
|
|
55
55
|
def organization=(org)
|
@@ -90,12 +90,12 @@ module GoImport
|
|
90
90
|
|
91
91
|
def classification=(classification)
|
92
92
|
raise_if_immutable
|
93
|
-
if classification ==
|
94
|
-
classification ==
|
95
|
-
classification ==
|
93
|
+
if classification == HistoryClassification::Comment || classification == HistoryClassification::SalesCall ||
|
94
|
+
classification == HistoryClassification::TalkedTo || classification == HistoryClassification::TriedToReach ||
|
95
|
+
classification == HistoryClassification::ClientVisit
|
96
96
|
@classification = classification
|
97
97
|
else
|
98
|
-
raise
|
98
|
+
raise InvalidHistoryClassificationError, classification
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -126,16 +126,20 @@ module GoImport
|
|
126
126
|
def validate
|
127
127
|
error = String.new
|
128
128
|
|
129
|
-
if @
|
130
|
-
error = "
|
129
|
+
if (@classification.nil? || @classification.empty?)
|
130
|
+
error = "Classification is required for history\n"
|
131
|
+
end
|
132
|
+
|
133
|
+
if (@text.nil? || @text.empty?) && classification != HistoryClassification::TriedToReach
|
134
|
+
error = "Text is required for history\n"
|
131
135
|
end
|
132
136
|
|
133
137
|
if @created_by.nil?
|
134
|
-
error = "#{error}Created_by is required for
|
138
|
+
error = "#{error}Created_by is required for history\n"
|
135
139
|
end
|
136
140
|
|
137
141
|
if @organization.nil? && @deal.nil? && @person.nil?
|
138
|
-
error = "#{error}Organization, deal or person is required for
|
142
|
+
error = "#{error}Organization, deal or person is required for history\n"
|
139
143
|
end
|
140
144
|
|
141
145
|
return error
|
@@ -1,23 +1,23 @@
|
|
1
1
|
module GoImport
|
2
|
-
# Defines a
|
3
|
-
# action that happened before the
|
4
|
-
module
|
2
|
+
# Defines a history type. This defines what kind of
|
3
|
+
# action that happened before the history was written.
|
4
|
+
module HistoryClassification
|
5
5
|
# We talked to the client about a sale. This might be a phone call
|
6
6
|
# or a talk in person.
|
7
|
-
SalesCall =
|
7
|
+
SalesCall = 'SalesCall'
|
8
8
|
|
9
9
|
# This is a general comment about the organization or deal.
|
10
|
-
Comment =
|
10
|
+
Comment = 'Comment'
|
11
11
|
|
12
12
|
# This is a general comment regarding a talk we had with
|
13
13
|
# someone at the client.
|
14
|
-
TalkedTo =
|
14
|
+
TalkedTo = 'TalkedTo'
|
15
15
|
|
16
16
|
# We tried to reach someone but failed.
|
17
|
-
TriedToReach =
|
17
|
+
TriedToReach = 'TriedToReach'
|
18
18
|
|
19
19
|
# We had a meeting at the client's site.
|
20
|
-
ClientVisit =
|
20
|
+
ClientVisit = 'ClientVisit'
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -8,10 +8,10 @@ module GoImport
|
|
8
8
|
# The root model for Go import. This class is the container for everything else.
|
9
9
|
class RootModel
|
10
10
|
# the import_coworker is a special coworker that is set as
|
11
|
-
# responsible for objects that requires a coworker, eg a
|
11
|
+
# responsible for objects that requires a coworker, eg a history.
|
12
12
|
attr_accessor :import_coworker
|
13
13
|
|
14
|
-
attr_accessor :settings, :organizations, :coworkers, :deals, :
|
14
|
+
attr_accessor :settings, :organizations, :coworkers, :deals, :histories
|
15
15
|
|
16
16
|
# The configuration is used to set run-time properties for
|
17
17
|
# go-import. This should not be confused with the model's
|
@@ -30,7 +30,7 @@ module GoImport
|
|
30
30
|
{:id => :coworkers, :type => :coworkers},
|
31
31
|
{:id => :organizations, :type => :organizations},
|
32
32
|
{:id => :deals, :type => :deals},
|
33
|
-
{:id => :
|
33
|
+
{:id => :histories, :type => :histories},
|
34
34
|
{:id => :documents, :type => :documents},
|
35
35
|
]
|
36
36
|
end
|
@@ -50,7 +50,7 @@ module GoImport
|
|
50
50
|
@import_coworker.first_name = "Import"
|
51
51
|
@coworkers[@import_coworker.integration_id] = @import_coworker
|
52
52
|
@deals = {}
|
53
|
-
@
|
53
|
+
@histories = {}
|
54
54
|
@documents = Documents.new
|
55
55
|
@configuration = {}
|
56
56
|
|
@@ -171,41 +171,41 @@ module GoImport
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
-
# Adds the specifed
|
174
|
+
# Adds the specifed history object to the model.
|
175
175
|
#
|
176
176
|
# If no integration_id has been specifed go-import generate
|
177
177
|
# one.
|
178
178
|
#
|
179
|
-
# @example Add a
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
# rootmodel.
|
184
|
-
def
|
185
|
-
if
|
179
|
+
# @example Add a history from a new history
|
180
|
+
# history = GoImport::History.new
|
181
|
+
# history.integration_id = "123"
|
182
|
+
# history.text = "This is a history"
|
183
|
+
# rootmodel.add_history(history)
|
184
|
+
def add_history(history)
|
185
|
+
if history.nil?
|
186
186
|
return nil
|
187
187
|
end
|
188
188
|
|
189
|
-
if !
|
190
|
-
raise ArgumentError.new("Expected a
|
189
|
+
if !history.is_a?(History)
|
190
|
+
raise ArgumentError.new("Expected a history")
|
191
191
|
end
|
192
192
|
|
193
|
-
if
|
194
|
-
|
193
|
+
if history.integration_id.nil? || history.integration_id.length == 0
|
194
|
+
history.integration_id = @histories.length.to_s
|
195
195
|
end
|
196
196
|
|
197
|
-
if
|
198
|
-
raise AlreadyAddedError, "Already added a
|
197
|
+
if find_history_by_integration_id(history.integration_id, false) != nil
|
198
|
+
raise AlreadyAddedError, "Already added a history with integration_id #{history.integration_id}"
|
199
199
|
end
|
200
200
|
|
201
|
-
if
|
202
|
-
|
201
|
+
if history.created_by.nil?
|
202
|
+
history.created_by = @import_coworker
|
203
203
|
end
|
204
204
|
|
205
|
-
@
|
206
|
-
|
205
|
+
@histories[history.integration_id] = history
|
206
|
+
history.set_is_immutable
|
207
207
|
|
208
|
-
return
|
208
|
+
return history
|
209
209
|
end
|
210
210
|
|
211
211
|
def add_link(link)
|
@@ -249,11 +249,11 @@ module GoImport
|
|
249
249
|
return nil
|
250
250
|
end
|
251
251
|
|
252
|
-
def
|
253
|
-
if @
|
254
|
-
return @
|
252
|
+
def find_history_by_integration_id(integration_id, report_result=!!configuration[:report_result])
|
253
|
+
if @histories.has_key?(integration_id)
|
254
|
+
return @histories[integration_id]
|
255
255
|
else
|
256
|
-
report_failed_to_find_object("
|
256
|
+
report_failed_to_find_object("history", ":#{integration_id}") if report_result
|
257
257
|
return nil
|
258
258
|
end
|
259
259
|
end
|
@@ -360,13 +360,13 @@ module GoImport
|
|
360
360
|
end
|
361
361
|
|
362
362
|
|
363
|
-
# Finds a
|
364
|
-
# Returns the first found matching
|
365
|
-
# @example Finds a
|
366
|
-
# rm.
|
367
|
-
def
|
368
|
-
result = find(@
|
369
|
-
report_failed_to_find_object("
|
363
|
+
# Finds a history based on one of its property.
|
364
|
+
# Returns the first found matching history
|
365
|
+
# @example Finds a history on its name
|
366
|
+
# rm.find_history {|history| history.text == "hello!" }
|
367
|
+
def find_history(report_result=!!configuration[:report_result], &block)
|
368
|
+
result = find(@histories.values.flatten, &block)
|
369
|
+
report_failed_to_find_object("history") if result.nil? and report_result
|
370
370
|
return result
|
371
371
|
end
|
372
372
|
|
@@ -434,7 +434,6 @@ module GoImport
|
|
434
434
|
|
435
435
|
converter_deal_statuses = @settings.deal.statuses.map {|status| status.label} if @settings.deal != nil
|
436
436
|
@deals.each do |key, deal|
|
437
|
-
#@deals.each do |deal|
|
438
437
|
error, warning = deal.validate converter_deal_statuses
|
439
438
|
|
440
439
|
if !error.empty?
|
@@ -445,9 +444,8 @@ module GoImport
|
|
445
444
|
end
|
446
445
|
end
|
447
446
|
|
448
|
-
|
449
|
-
|
450
|
-
validation_message = note.validate
|
447
|
+
@histories.each do |key, history|
|
448
|
+
validation_message = history.validate
|
451
449
|
|
452
450
|
if !validation_message.empty?
|
453
451
|
errors = "#{errors}\n#{validation_message}"
|
@@ -474,7 +472,7 @@ module GoImport
|
|
474
472
|
# @!visibility private
|
475
473
|
def to_rexml(doc)
|
476
474
|
element_name = serialize_name
|
477
|
-
elem = doc.add_element(element_name,{"Version"=>"
|
475
|
+
elem = doc.add_element(element_name,{"Version"=>"v3_0"})
|
478
476
|
SerializeHelper::serialize_variables_rexml(elem, self)
|
479
477
|
end
|
480
478
|
|
@@ -504,7 +502,7 @@ module GoImport
|
|
504
502
|
@organizations = []
|
505
503
|
@coworkers = []
|
506
504
|
@deals = []
|
507
|
-
@
|
505
|
+
@histories = []
|
508
506
|
@documents = saved_documents
|
509
507
|
serialize_to_file(go_files_file)
|
510
508
|
|
@@ -563,7 +561,7 @@ module GoImport
|
|
563
561
|
" Organizations: #{@organizations.length}\n" \
|
564
562
|
" Persons: #{persons.length}\n" \
|
565
563
|
" Deals: #{@deals.length}\n" \
|
566
|
-
"
|
564
|
+
" Histories: #{@histories.length}\n" \
|
567
565
|
" Documents: #{nbr_of_documents}"
|
568
566
|
end
|
569
567
|
|
@@ -112,12 +112,12 @@ module GoImport
|
|
112
112
|
map_symbol_to_row(p[:id],p[:type])
|
113
113
|
when :date then
|
114
114
|
map_symbol_to_row(p[:id],p[:type])
|
115
|
-
when :
|
115
|
+
when :histories then
|
116
116
|
{
|
117
117
|
:id => p[:id].to_s,
|
118
118
|
:name => symbol_to_name(p[:id]),
|
119
119
|
:type => p[:type],
|
120
|
-
:models => SerializeHelper.get_import_rows(:
|
120
|
+
:models => SerializeHelper.get_import_rows(:history)
|
121
121
|
}
|
122
122
|
when :tags then
|
123
123
|
{
|
@@ -171,8 +171,8 @@ module GoImport
|
|
171
171
|
Person.new
|
172
172
|
when :source_ref then
|
173
173
|
ReferenceToSource.new
|
174
|
-
when :
|
175
|
-
|
174
|
+
when :history then
|
175
|
+
History.new
|
176
176
|
when :address then
|
177
177
|
Address.new
|
178
178
|
when :organization then
|
@@ -18,7 +18,7 @@ module GoImport
|
|
18
18
|
}
|
19
19
|
model.organizations.each{|key, org| add_organization(org)}
|
20
20
|
model.deals.each{|key, deal| add_deal(deal)}
|
21
|
-
model.
|
21
|
+
model.histories.each{|key, history| add_history(history)}
|
22
22
|
add_documents(model.documents)
|
23
23
|
|
24
24
|
return_value = @shards
|
@@ -34,9 +34,9 @@ module GoImport
|
|
34
34
|
end
|
35
35
|
|
36
36
|
private
|
37
|
-
def
|
37
|
+
def add_history(history)
|
38
38
|
check_or_create_new_chard()
|
39
|
-
@current_shard.
|
39
|
+
@current_shard.add_history(history)
|
40
40
|
@current_shard_count += 1
|
41
41
|
end
|
42
42
|
|
data/lib/go_import.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
module GoImport
|
2
2
|
private
|
3
3
|
def self.require_all_in(folder)
|
4
|
-
Dir.glob(File.join(
|
4
|
+
Dir.glob(::File.join(::File.dirname(::File.absolute_path(__FILE__)),folder), &method(:require))
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
require_relative 'go_import/errors'
|
8
|
+
require_relative 'go_import/serialize_helper'
|
9
|
+
require_relative 'go_import/model_helpers'
|
10
|
+
require_relative 'go_import/can_become_immutable'
|
11
11
|
GoImport::require_all_in 'go_import/model/*.rb'
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
require_relative 'go_import/csv_helper'
|
13
|
+
require_relative 'go_import/roo_helper'
|
14
|
+
require_relative 'go_import/phone_helper'
|
15
|
+
require_relative 'go_import/email_helper'
|
16
|
+
require_relative 'go_import/excel_helper'
|
17
|
+
require_relative 'go_import/templating'
|
18
|
+
require_relative 'go_import/source'
|
19
|
+
require_relative 'go_import/shard_helper'
|
20
20
|
end
|
@@ -1 +1 @@
|
|
1
|
-
This source converts a VISMA database to LIME Go.
|
1
|
+
This source converts a VISMA Administration 2000 database to LIME Go.
|
@@ -9,7 +9,7 @@ KUND_FILE = './database/KUND.DBF'
|
|
9
9
|
KONTAKT_FILE = './database/KONTAKT.DBF'
|
10
10
|
|
11
11
|
def convert_source
|
12
|
-
puts "Trying to convert VISMA source to LIME Go..."
|
12
|
+
puts "Trying to convert VISMA Administration 2000 source to LIME Go..."
|
13
13
|
|
14
14
|
# Verify that required files exists.
|
15
15
|
if !File.exists?(KUND_FILE)
|
@@ -60,19 +60,19 @@ def convert_source
|
|
60
60
|
end
|
61
61
|
puts "Processed #{imported_person_count} Persons."
|
62
62
|
|
63
|
-
#
|
64
|
-
#
|
65
|
-
puts "Trying to process
|
66
|
-
|
63
|
+
# History must be owned by a coworker and then should reference
|
64
|
+
# organization or deal and might reference a person
|
65
|
+
puts "Trying to process History..."
|
66
|
+
imported_history_count = 0
|
67
67
|
organization_rows.each do |row|
|
68
68
|
if not row.nil?
|
69
69
|
if row['ANTECK_1'].length > 0
|
70
|
-
rootmodel.
|
71
|
-
|
70
|
+
rootmodel.add_history(converter.to_history(row))
|
71
|
+
imported_history_count = imported_history_count + 1
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
|
-
puts "Processed #{
|
75
|
+
puts "Processed #{imported_history_count} History."
|
76
76
|
|
77
77
|
return rootmodel
|
78
78
|
end
|
data/sources/VISMA/converter.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'go_import'
|
2
2
|
require 'dbf'
|
3
3
|
|
4
|
-
# Customize this file to suit your input for a
|
4
|
+
# Customize this file to suit your input for a
|
5
|
+
# VISMA Administration 2000 database.
|
5
6
|
#
|
6
7
|
# You must put KUND.DBS and KONTAKTER.DBS in the database folder.
|
7
8
|
#
|
@@ -84,20 +85,20 @@ class Converter
|
|
84
85
|
return organization
|
85
86
|
end
|
86
87
|
|
87
|
-
def
|
88
|
-
|
88
|
+
def to_history(row, rootmodel)
|
89
|
+
history = GoImport::History.new()
|
89
90
|
|
90
91
|
# *** TODO:
|
91
92
|
#
|
92
|
-
# Set
|
93
|
+
# Set history properties from the row.
|
93
94
|
organization = rootmodel.find_organization_by_integration_id(row['KUNDNR'])
|
94
95
|
unless organization.nil?
|
95
|
-
|
96
|
+
history.organization = organization
|
96
97
|
end
|
97
|
-
|
98
|
-
|
98
|
+
history.created_by = rootmodel.import_coworker
|
99
|
+
history.text = row['ANTECK_1']
|
99
100
|
|
100
|
-
return
|
101
|
+
return history
|
101
102
|
end
|
102
103
|
|
103
104
|
def to_person(row, rootmodel)
|
@@ -120,15 +121,15 @@ class Converter
|
|
120
121
|
# HOOKS
|
121
122
|
#
|
122
123
|
# Sometimes you need to add exra information to the rootmodel, this can be done
|
123
|
-
# with hooks, below is an example of an organization hook that adds a
|
124
|
+
# with hooks, below is an example of an organization hook that adds a history to
|
124
125
|
# an organization if a field has a specific value
|
125
126
|
#def organization_hook(row, organization, rootmodel)
|
126
127
|
# if not row['fieldname'].empty?
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
# rootmodel.
|
128
|
+
# history = GoImport::History.new
|
129
|
+
# history.text = row['fieldname']
|
130
|
+
# history.organization = organization
|
131
|
+
# history.created_by = rootmodel.import_coworker
|
132
|
+
# rootmodel.add_history(history)
|
132
133
|
# end
|
133
134
|
#end
|
134
135
|
|
@@ -7,7 +7,7 @@ ORGANIZATION_FILE = "data/contacts.csv"
|
|
7
7
|
LEADS_FILE = "data/leads.csv"
|
8
8
|
PERSON_FILE = "data/contacts.csv"
|
9
9
|
DEAL_FILE = "data/deals.csv"
|
10
|
-
|
10
|
+
HISTORY_FILE = "data/histories.csv"
|
11
11
|
SOURCE_ENCODING = "utf-8"
|
12
12
|
|
13
13
|
|
@@ -24,7 +24,7 @@ def convert_source
|
|
24
24
|
puts "Trying to convert Base CRM source to LIME Go..."
|
25
25
|
|
26
26
|
converter = Converter.new
|
27
|
-
|
27
|
+
ignored_histories = 0
|
28
28
|
ignored_persons = 0
|
29
29
|
|
30
30
|
# A rootmodel is used to represent all entitite/models that is
|
@@ -166,14 +166,14 @@ def convert_source
|
|
166
166
|
organization.add_employee(person)
|
167
167
|
|
168
168
|
if row['description']
|
169
|
-
|
169
|
+
history = GoImport::History.new()
|
170
170
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
171
|
+
history.text = row['description']
|
172
|
+
history.person = person
|
173
|
+
history.organization = organization
|
174
|
+
history.created_by = coworker
|
175
175
|
|
176
|
-
rootmodel.
|
176
|
+
rootmodel.add_history(history)
|
177
177
|
end
|
178
178
|
rootmodel.add_organization(organization)
|
179
179
|
end
|
@@ -199,37 +199,37 @@ def convert_source
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
-
#
|
203
|
-
if defined?(
|
204
|
-
process_rows(
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
202
|
+
# historys
|
203
|
+
if defined?(HISTORY_FILE) && !HISTORY_FILE.nil? && !HISTORY_FILE.empty?
|
204
|
+
process_rows(HISTORY_FILE, source_encoding) do |row|
|
205
|
+
history = converter.to_history(row, rootmodel)
|
206
|
+
history.integration_id = row['id']
|
207
|
+
history.text = row['content']
|
208
|
+
history.created_by = rootmodel.find_coworker_by_integration_id(row["owner"])
|
209
209
|
notable_id = row['noteable_id']
|
210
210
|
case row["noteable_type"]
|
211
211
|
when "Deal"
|
212
212
|
deal = rootmodel.find_deal_by_integration_id(notable_id)
|
213
|
-
|
213
|
+
history.deal = deal
|
214
214
|
when "Lead"
|
215
|
-
|
216
|
-
|
215
|
+
history.person = rootmodel.find_person_by_integration_id("p#{notable_id}")
|
216
|
+
history.organization = rootmodel.find_organization_by_integration_id("l#{notable_id}")
|
217
217
|
when "Contact"
|
218
|
-
puts "Ignoreing
|
219
|
-
|
218
|
+
puts "Ignoreing history for unbound person: #{row['owner']}"
|
219
|
+
ignored_histories += 1
|
220
220
|
next
|
221
221
|
else
|
222
222
|
org = rootmodel.find_organization_by_integration_id(notable_id)
|
223
223
|
if org.nil?
|
224
224
|
person = rootmodel.find_person_by_integration_id(notable_id)
|
225
225
|
org = person.organization
|
226
|
-
|
226
|
+
history.person = person
|
227
227
|
end
|
228
|
-
|
228
|
+
history.organization = org
|
229
229
|
end
|
230
|
-
rootmodel.
|
230
|
+
rootmodel.add_history(history)
|
231
231
|
end
|
232
232
|
end
|
233
|
-
puts "Ignored #{ignored_persons} persons and #{
|
233
|
+
puts "Ignored #{ignored_persons} persons and #{ignored_histories} histories"
|
234
234
|
return rootmodel
|
235
235
|
end
|
@@ -53,10 +53,10 @@ class Converter
|
|
53
53
|
return deal
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
|
56
|
+
def to_history(row, rootmodel)
|
57
|
+
history = GoImport::History.new()
|
58
58
|
# All built in fields are automagically mapped. Add your custom stuff here...
|
59
|
-
|
59
|
+
return history
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
File without changes
|
data/sources/csv/converter.rb
CHANGED
@@ -203,15 +203,15 @@ class Converter
|
|
203
203
|
# HOOKS
|
204
204
|
#
|
205
205
|
# Sometimes you need to add exra information to the rootmodel, this can be done
|
206
|
-
# with hooks, below is an example of an organization hook that adds a
|
206
|
+
# with hooks, below is an example of an organization hook that adds a history to
|
207
207
|
# an organization if a field has a specific value
|
208
208
|
#def organization_hook(row, organization, rootmodel)
|
209
209
|
# if not row['fieldname'].empty?
|
210
|
-
#
|
211
|
-
#
|
212
|
-
#
|
213
|
-
#
|
214
|
-
# rootmodel.
|
210
|
+
# history = GoImport::History.new
|
211
|
+
# history.text = row['fieldname']
|
212
|
+
# history.organization = organization
|
213
|
+
# history.created_by = rootmodel.import_coworker
|
214
|
+
# rootmodel.add_history(history)
|
215
215
|
# end
|
216
216
|
#end
|
217
217
|
|