go_import 3.0.26 → 3.0.27

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjBiMjk3NmIxNjgwZDNhYjI2M2M2MWEwYjUxMzgyODQ2MmNmNmE4NQ==
4
+ NGUwNDcxNGFmZDlkZjExNTJkZDY3MjBiMjI2NGNhNTZmNGM5Y2I0ZQ==
5
5
  data.tar.gz: !binary |-
6
- NTRkOGI4YTZiYjY5YzI5OTk0ZThlOWY4ZWY3NzM3YTBlNzMwMDk1MQ==
6
+ M2I0YmRkOWY2NmY0NmVkN2UwYmZjMDg2NmJlNjQ1ODJmNGNlYzU5NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2JjMjNhNTc4ZTI0ODc2YTRjODU5YzFmODA2NDEzM2ZjZDI2YjE2ZTgwNGM5
10
- Yjk3NjBhN2IxN2NhMzFhNzEzOGY0NTUxZWUzNjMxMmIxMzc3YWZiMDAwOTI3
11
- M2E0Y2U3MzI0OGUxMWExNGI0ZTg2YTRkNDdiOGQzMzUwNjRkNGE=
9
+ Y2I1NzUxOGIxZDAyZTE4MWJkYjQ4YjBhZmViYTJmODVjNjhmMzFkMmQwMWE2
10
+ NWFmMDllMjJjZTk1ZTA4MDBkM2Y0NWU1NzI2NjU4OWIzNGQ3OGNmZTM1M2My
11
+ MWU4MWEzYTk4MjE4MWFiZWIyZTBiMTMzZmNhZDgyMmM3NWYxYWI=
12
12
  data.tar.gz: !binary |-
13
- MDE0MmJmNjliY2Y4MjBkNDk3MTNhNGNjMjljZTMyNmE5YTNiOGNjMzEyMjNk
14
- NzdiZWFkZjhiZjQ0ZTYzODRhNmIzM2YwZTYwOWRhM2ZhNzA3NGMxMmI0OTgw
15
- MDViZGJhODNiYjJkYTdmMmRmOTVkY2YyYzE0OWYyNzQzZGZiZDQ=
13
+ NGI5NjdmOWZmYTA0ODM2Njk5MDkwM2NiZTQ3ZmNiNjRjNzIxYjA0ZjhiNGNh
14
+ MjM1OGMxYWRmNWJmMGQ5Yjk5NTY4MTIyOGI3NzQ4ZThhMzg0ODdhN2Q2NmU1
15
+ MmNjYzcwZTY2OWY2MDFmYzJjZjEwOTY0ODJhZjkxMDU3NzlmZGY=
data/bin/go-import CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "thor"
4
4
  require "go_import"
5
+ require 'progress'
5
6
 
6
7
  RUNNER_DIR = ".go_import"
7
8
 
@@ -58,17 +59,26 @@ class GoImportCommandLine < Thor
58
59
  :desc => "Console output will be redirected to file",
59
60
  :type => :string,
60
61
  :required => false)
62
+ option(:max_file_size,
63
+ :desc => "Maximum size in bytes of documents included in zip",
64
+ :type => :numeric,
65
+ :required => false)
66
+ option(:output_documents,
67
+ :desc => "Name of the file to put imported documents in (default in same as --output)",
68
+ :type => :string,
69
+ :required => false)
61
70
  def run_import()
62
71
  if !options.log_to_file.nil?
63
72
  $stdout = File.new(options.log_to_file == "log_to_file" ? "go-import.log" : options.log_to_file, 'w')
64
73
  $stdout.sync = true
65
74
  end
75
+ max_file_size = options.max_file_size.nil? ? GoImport::File::DEFAULT_MAX_FILE_SIZE : options.max_file_size
66
76
 
67
77
  if !is_valid_goimport_project?
68
78
  return
69
79
  end
70
80
 
71
- runner_file = File.expand_path("./#{RUNNER_DIR}/runner.rb", Dir.pwd)
81
+ runner_file = ::File.expand_path("./#{RUNNER_DIR}/runner.rb", Dir.pwd)
72
82
  require(runner_file)
73
83
  model = convert_source()
74
84
 
@@ -82,15 +92,18 @@ class GoImportCommandLine < Thor
82
92
  puts "WARNING: This means that files with an absolute path will be imported with their original path. Set this constant if you want to get files from the FILES_FOLDER directory."
83
93
  end
84
94
 
85
- is_ok, error_msg, warnings_msg = can_be_serialized?(model, options.ignore_invalid_files)
95
+ is_ok, error_msg, warnings_msg = can_be_serialized?(model, options.ignore_invalid_files, max_file_size)
86
96
  if is_ok
97
+
87
98
  if options.ignore_invalid_files && model.documents.files.length > 0
88
- log_and_remove_invalid_files model
99
+ log_and_remove_invalid_files model, max_file_size
89
100
  end
90
101
 
91
102
  go_data_zip = options.output.nil? == true ? "go.zip" : options.output
92
- model.save_to_zip(go_data_zip)
103
+ go_files = options.output_documents.nil? == true ? nil : ::File.basename(options.output_documents,File.extname(options.output_documents))
104
+ model.save_to_zip(go_data_zip, go_files)
93
105
  puts "Source has been been converted into '#{go_data_zip}'."
106
+ puts " - and files into '#{go_files}.zip'." if !go_files.nil?
94
107
  if !warnings_msg.empty?
95
108
  puts "WARNINGS: "
96
109
  puts warnings_msg
@@ -107,17 +120,16 @@ class GoImportCommandLine < Thor
107
120
  end
108
121
 
109
122
  private
110
- def log_and_remove_invalid_files(model)
123
+ def log_and_remove_invalid_files(model, max_file_size)
111
124
  if model.documents.files.length > 0
112
- puts "Trying to log files that can't be found..."
113
125
  file_log_header = "name;integration_id;path;organization.integrationid;organization.name;deal.integrationid;deal.name;file.size"
114
126
  file_log = ""
115
127
  files_to_remove = []
116
- model.documents.files.each do |file|
128
+ model.documents.files.with_progress(" - Trying to log files that can't be found...").each do |file|
117
129
  if !::File.exists?(file.path_for_project)
118
130
  file_log = "#{file_log}#{file.name};#{file.integration_id};#{file.path};#{file.organization.nil? ? '' : file.organization.integration_id};#{file.organization.nil? ? '' : file.organization.name};#{file.deal.nil? ? '' : file.deal.integration_id};#{file.deal.nil? ? '' : file.deal.name};0\n"
119
131
  files_to_remove.push file
120
- elsif ::File.size(file.path_for_project) > GoImport::File::MAX_FILE_SIZE
132
+ elsif ::File.size(file.path_for_project) > max_file_size
121
133
  file_log = "#{file_log}#{file.name};#{file.integration_id};#{file.path};#{file.organization.nil? ? '' : file.organization.integration_id};#{file.organization.nil? ? '' : file.organization.name};#{file.deal.nil? ? '' : file.deal.integration_id};#{file.deal.nil? ? '' : file.deal.name};#{::File.size(file.path_for_project)}\n"
122
134
  files_to_remove.push file
123
135
  end
@@ -133,7 +145,7 @@ class GoImportCommandLine < Thor
133
145
  f.puts file_log_header
134
146
  f.puts file_log
135
147
  }
136
- puts "WARNING: go-import has invalid files. Filenames of all ignored files has been written to '#{log_filename}'."
148
+ puts "WARNING: go-import has invalid files (#{files_to_remove.length} of #{model.documents.files.length}). Filenames of all ignored files has been written to '#{log_filename}'."
137
149
  else
138
150
  puts "All files are OK."
139
151
  end
@@ -141,11 +153,11 @@ class GoImportCommandLine < Thor
141
153
  end
142
154
 
143
155
  private
144
- def can_be_serialized?(rootmodel, ignore_invalid_files)
156
+ def can_be_serialized?(rootmodel, ignore_invalid_files, max_file_size)
145
157
  is_ok = false
146
158
  error = rootmodel.sanity_check
147
159
  if error.empty?
148
- error, warnings = rootmodel.validate(ignore_invalid_files)
160
+ error, warnings = rootmodel.validate(ignore_invalid_files, max_file_size)
149
161
 
150
162
  if error.empty?
151
163
  is_ok = true
@@ -6,7 +6,7 @@ require_relative '../serialize_helper'
6
6
 
7
7
  module GoImport
8
8
  class File
9
- MAX_FILE_SIZE = 100000000 # 100 Mb
9
+ DEFAULT_MAX_FILE_SIZE = 100000000 # 100 Mb
10
10
 
11
11
  include SerializeHelper
12
12
  attr_accessor :id, :integration_id, :description
@@ -62,6 +62,8 @@ module GoImport
62
62
  if (@name.nil? || @name.empty?) && (!@path.nil? && !@path.empty?)
63
63
  @name = Pathname.new(path).basename.to_s
64
64
  end
65
+ @location_in_zip_file = "files/#{SecureRandom.uuid}#{::File.extname(@path).to_s}"
66
+
65
67
  end
66
68
 
67
69
  def name=(name)
@@ -152,12 +154,10 @@ module GoImport
152
154
  end
153
155
 
154
156
  def add_to_zip_file(zip_file)
155
- @location_in_zip_file = "files/#{SecureRandom.uuid}#{::File.extname(@path).to_s}"
156
-
157
157
  zip_file.add(@location_in_zip_file, path_for_project)
158
158
  end
159
159
 
160
- def validate(ignore_invalid_files = false)
160
+ def validate(ignore_invalid_files = false, max_file_size = DEFAULT_MAX_FILE_SIZE)
161
161
  error = String.new
162
162
  warning = String.new
163
163
 
@@ -167,15 +167,14 @@ module GoImport
167
167
 
168
168
  if @path.nil? || @path.empty?
169
169
  error = "Path is required for file.\n"
170
- elsif !ignore_invalid_files
170
+ elsif !ignore_invalid_files
171
171
  if !::File.exists?(path_for_project())
172
172
  error = "#{error}Can't find file with name '#{@name}' and original path '#{@path}' at '#{path_for_project()}'."
173
- elsif ::File.size(path_for_project()) > MAX_FILE_SIZE
174
- error = "#{error}File '#{@name}' is bigger than #{MAX_FILE_SIZE} bytes."
173
+ elsif ::File.exists?(path_for_project) && ::File.size(path_for_project()) > max_file_size
174
+ error = "#{error}File '#{@name}' is bigger than #{max_file_size} bytes."
175
175
  end
176
176
  end
177
177
 
178
-
179
178
  if @created_by_reference.nil?
180
179
  error = "#{error}Created_by is required for file (#{@name}).\n"
181
180
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'zip'
4
4
  require 'securerandom'
5
+ require "progress"
5
6
 
6
7
  module GoImport
7
8
  # The root model for Go import. This class is the container for everything else.
@@ -310,7 +311,7 @@ module GoImport
310
311
  return error.strip
311
312
  end
312
313
 
313
- def validate(ignore_invalid_files = false)
314
+ def validate(ignore_invalid_files = false, max_file_size)
314
315
  errors = String.new
315
316
  warnings = String.new
316
317
 
@@ -322,8 +323,9 @@ module GoImport
322
323
  end
323
324
  end
324
325
 
326
+ converter_deal_statuses = @settings.deal.statuses.map {|status| status.label} if @settings.deal != nil
325
327
  @deals.each do |deal|
326
- error, warning = deal.validate @settings.deal.statuses.map {|status| status.label}
328
+ error, warning = deal.validate converter_deal_statuses
327
329
 
328
330
  if !error.empty?
329
331
  errors = "#{errors}\n#{error}"
@@ -349,7 +351,7 @@ module GoImport
349
351
  end
350
352
 
351
353
  @documents.files.each do |file|
352
- validation_message = file.validate(ignore_invalid_files)
354
+ validation_message = file.validate(ignore_invalid_files, max_file_size)
353
355
  if !validation_message.empty?
354
356
  errors = "#{errors}\n#{validation_message}"
355
357
  end
@@ -367,8 +369,8 @@ module GoImport
367
369
 
368
370
  # @!visibility private
369
371
  # zip-filename is the name of the zip file to create
370
- def save_to_zip(zip_filename)
371
- puts "Trying to save to '#{zip_filename}'..."
372
+ def save_to_zip(zip_filename, files_filename)
373
+ puts "Trying to save to zip..."
372
374
  # saves the model to a zipfile that contains xml data and
373
375
  # document files.
374
376
 
@@ -376,47 +378,70 @@ module GoImport
376
378
  ::File.delete zip_filename
377
379
  end
378
380
 
379
- Zip::File.open(zip_filename, Zip::File::CREATE) do |zip_file|
380
- puts "Trying to add files to zip..."
381
- # We must add files first to the zip file since we
382
- # will set each file's location_in_zip_file when the
383
- # zip file is created.
384
-
385
- if defined?(FILES_FOLDER) && !FILES_FOLDER.empty?()
386
- puts "Files with relative path are imported from '#{FILES_FOLDER}'."
387
- root_folder = FILES_FOLDER
388
- else
389
- puts "Files with relative path are imported from the current folder (#{Dir.pwd})."
390
- root_folder = Dir.pwd
391
- end
392
-
393
- # If a file's path is absolute, then we probably dont
394
- # have the files in the same location here. For
395
- # example, the customer might have stored their files
396
- # at f:\lime-easy\documents. We must replace this part
397
- # of each file with the root_folder from above.
398
- if defined?(FILES_FOLDER_AT_CUSTOMER) && !FILES_FOLDER_AT_CUSTOMER.empty?()
399
- files_folder_at_customer = FILES_FOLDER_AT_CUSTOMER
400
- puts "Files with absolute paths will have the part '#{files_folder_at_customer}' replaced with '#{root_folder}'."
401
- else
402
- files_folder_at_customer = ""
403
- puts "Files with absolute paths will be imported from their origial location."
381
+ go_data_file = Tempfile.new('go')
382
+ puts "Creating go.xml file with data..."
383
+ if !files_filename.nil?
384
+ saved_documents = @documents
385
+ @documents = Documents.new
386
+ end
387
+ serialize_to_file(go_data_file)
388
+ create_zip(zip_filename, go_data_file, documents.files)
389
+
390
+ if !files_filename.nil?
391
+ go_files_file = Tempfile.new('go-files')
392
+ puts "Creating go.xml file with documents information..."
393
+ @organizations = []
394
+ @coworkers = []
395
+ @deals = []
396
+ @notes = []
397
+ @documents = saved_documents
398
+ serialize_to_file(go_files_file)
399
+
400
+ files_zip_filename = files_filename+".zip"
401
+ if ::File.exists?(files_zip_filename)
402
+ ::File.delete files_zip_filename
404
403
  end
404
+ create_zip(files_zip_filename, go_files_file, documents.files)
405
+ end
406
+ end
405
407
 
406
- # 1) files/ - a folder with all files referenced from
407
- # the source.
408
- documents.files.each do |file|
409
- # we dont need to check that the file exists since
410
- # we assume that rootmodel.validate has been
411
- # called before save_to_zip.
412
- file.add_to_zip_file(zip_file)
408
+ def create_zip(filename, xml, files)
409
+ Zip::File.open(filename, Zip::File::CREATE) do |zip_file|
410
+ puts "Add go.xml file to zip '#{filename}'..."
411
+ zip_file.add('go.xml', xml)
412
+
413
+ if files.length > 0
414
+ if defined?(FILES_FOLDER) && !FILES_FOLDER.empty?()
415
+ puts "Files with relative path are imported from '#{FILES_FOLDER}'."
416
+ root_folder = FILES_FOLDER
417
+ else
418
+ puts "Files with relative path are imported from the current folder (#{Dir.pwd})."
419
+ root_folder = Dir.pwd
420
+ end
421
+
422
+ # If a file's path is absolute, then we probably dont
423
+ # have the files in the same location here. For
424
+ # example, the customer might have stored their files
425
+ # at f:\lime-easy\documents. We must replace this part
426
+ # of each file with the root_folder from above.
427
+ if defined?(FILES_FOLDER_AT_CUSTOMER) && !FILES_FOLDER_AT_CUSTOMER.empty?()
428
+ files_folder_at_customer = FILES_FOLDER_AT_CUSTOMER
429
+ puts "Files with absolute paths will have the part '#{files_folder_at_customer}' replaced with '#{root_folder}'."
430
+ else
431
+ files_folder_at_customer = ""
432
+ puts "Files with absolute paths will be imported from their origial location."
433
+ end
434
+
435
+ # 1) files/ - a folder with all files referenced from
436
+ # the source.
437
+ files.with_progress(" - Trying to add files to zip...").each do |file|
438
+ # we dont need to check that the file exists since
439
+ # we assume that rootmodel.validate has been
440
+ # called before save_to_zip.
441
+ file.add_to_zip_file(zip_file)
442
+ end
413
443
  end
414
-
415
- # 2) go.xml - with all data from source
416
- puts "Trying to add organizations, persons, etc to zip..."
417
- go_data_file = Tempfile.new('go')
418
- serialize_to_file(go_data_file)
419
- zip_file.add('go.xml', go_data_file)
444
+ puts "Compressing zip file ... "
420
445
  end
421
446
  end
422
447
 
@@ -116,4 +116,20 @@ class Converter
116
116
 
117
117
  return person
118
118
  end
119
+
120
+ # HOOKS
121
+ #
122
+ # 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 note to
124
+ # an organization if a field has a specific value
125
+ #def organization_hook(row, organization, rootmodel)
126
+ # if not row['fieldname'].empty?
127
+ # note = GoImport::Note.new
128
+ # note.text = row['fieldname']
129
+ # note.organization = organization
130
+ # note.created_by = rootmodel.import_coworker
131
+ # rootmodel.add_note(note)
132
+ # end
133
+ #end
134
+
119
135
  end
@@ -192,4 +192,20 @@ class Converter
192
192
 
193
193
  return deal
194
194
  end
195
+
196
+ # HOOKS
197
+ #
198
+ # Sometimes you need to add exra information to the rootmodel, this can be done
199
+ # with hooks, below is an example of an organization hook that adds a note to
200
+ # an organization if a field has a specific value
201
+ #def organization_hook(row, organization, rootmodel)
202
+ # if not row['fieldname'].empty?
203
+ # note = GoImport::Note.new
204
+ # note.text = row['fieldname']
205
+ # note.organization = organization
206
+ # note.created_by = rootmodel.import_coworker
207
+ # rootmodel.add_note(note)
208
+ # end
209
+ #end
210
+
195
211
  end
@@ -158,4 +158,20 @@ class Converter
158
158
 
159
159
  return file
160
160
  end
161
+
162
+ # HOOKS
163
+ #
164
+ # Sometimes you need to add exra information to the rootmodel, this can be done
165
+ # with hooks, below is an example of an organization hook that adds a note to
166
+ # an organization if a field has a specific value
167
+ #def organization_hook(row, organization, rootmodel)
168
+ # if not row['fieldname'].empty?
169
+ # note = GoImport::Note.new
170
+ # note.text = row['fieldname']
171
+ # note.organization = organization
172
+ # note.created_by = rootmodel.import_coworker
173
+ # rootmodel.add_note(note)
174
+ # end
175
+ #end
176
+
161
177
  end
@@ -1,6 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require 'go_import'
4
+ require 'progress'
4
5
  require_relative("../converter")
5
6
 
6
7
  EXPORT_FOLDER = 'export'
@@ -34,59 +35,61 @@ def convert_source
34
35
  # coworkers
35
36
  # start with these since they are referenced
36
37
  # from everywhere....
37
- process_rows COWORKER_FILE do |row|
38
+
39
+ process_rows(" - Reading Coworkers '#{COWORKER_FILE}'", COWORKER_FILE) do |row|
38
40
  rootmodel.add_coworker(to_coworker(row))
39
41
  end
40
42
 
41
43
  # organizations
42
- process_rows ORGANIZATION_FILE do |row|
44
+ process_rows(" - Reading Organizations '#{ORGANIZATION_FILE}'", ORGANIZATION_FILE) do |row|
43
45
  organization = init_organization(row, rootmodel)
44
46
  rootmodel.add_organization(
45
47
  converter.to_organization(organization, row))
48
+ converter.organization_hook(row, organization, rootmodel) if defined? converter.organization_hook
46
49
  end
47
50
 
48
51
  # persons
49
52
  # depends on organizations
50
- process_rows PERSON_FILE do |row|
53
+ process_rows(" - Reading Persons '#{PERSON_FILE}'", PERSON_FILE) do |row|
51
54
  # init method also adds the person to the employer
52
55
  person = init_person(row, rootmodel)
53
56
  converter.to_person(person, row)
54
57
  end
55
58
 
56
59
  # organization notes
57
- process_rows ORGANIZATION_NOTE_FILE do |row|
60
+ process_rows(" - Reading Organization Notes '#{ORGANIZATION_NOTE_FILE}'", ORGANIZATION_NOTE_FILE) do |row|
58
61
  # adds itself if applicable
59
62
  rootmodel.add_note(to_organization_note(converter, row, rootmodel))
60
63
  end
61
64
 
62
65
  # Organization - Deal connection
63
66
  # Reads the includes.txt and creats a hash
64
- # that connect organizations to deals
65
- process_rows INCLUDE_FILE do |row|
67
+ # that connect organizations to deals
68
+ process_rows(" - Reading Organization Deals '#{INCLUDE_FILE}'", INCLUDE_FILE) do |row|
66
69
  includes[row['idProject']] = row['idCompany']
67
70
  end
68
71
 
69
72
  # deals
70
73
  # deals can reference coworkers (responsible), organizations
71
- # and persons (contact)
72
- process_rows DEAL_FILE do |row|
74
+ # and persons (contact)
75
+ process_rows(" - Reading Deals '#{DEAL_FILE}'", DEAL_FILE) do |row|
73
76
  deal = init_deal(row, rootmodel, includes)
74
77
  rootmodel.add_deal(converter.to_deal(deal, row))
75
78
  end
76
79
 
77
80
  # deal notes
78
- process_rows DEAL_NOTE_FILE do |row|
81
+ process_rows(" - Reading Deal Notess '#{DEAL_NOTE_FILE}'", DEAL_NOTE_FILE) do |row|
79
82
  # adds itself if applicable
80
83
  rootmodel.add_note(to_deal_note(converter, row, rootmodel))
81
84
  end
82
85
 
83
86
  # documents
84
87
  if defined?(IMPORT_DOCUMENTS) && !IMPORT_DOCUMENTS.nil? && IMPORT_DOCUMENTS
85
- process_rows ORGANIZATION_DOCUMENT_FILE do |row|
88
+ process_rows(" - Reading Organization Documents", ORGANIZATION_DOCUMENT_FILE) do |row|
86
89
  rootmodel.add_file(to_organization_document(row, rootmodel))
87
90
  end
88
91
 
89
- process_rows PROJECT_DOCUMENT_FILE do |row|
92
+ process_rows(" - Reading Project Documents", PROJECT_DOCUMENT_FILE) do |row|
90
93
  rootmodel.add_file(to_deal_document(row, rootmodel))
91
94
  end
92
95
  end
@@ -321,13 +324,13 @@ def validate_constants()
321
324
  end
322
325
 
323
326
 
324
- def process_rows(file_name)
327
+ def process_rows(description, file_name)
325
328
  data = File.open(file_name, 'r').read.encode('UTF-8',"ISO-8859-1").strip().gsub('"', '')
326
329
  data = '"' + data.gsub("\t", "\"\t\"") + '"'
327
330
  data = data.gsub("\n", "\"\n\"")
328
331
 
329
332
  rows = GoImport::CsvHelper::text_to_hashes(data, "\t", "\n", '"')
330
- rows.each do |row|
333
+ rows.with_progress(description).each do |row|
331
334
  yield row
332
335
  end
333
336
  end
@@ -314,7 +314,7 @@ class Converter
314
314
 
315
315
  # return classification
316
316
  end
317
-
317
+
318
318
  def configure(rootmodel)
319
319
  #####################################################################
320
320
  ## LIME Go custom fields.
@@ -334,5 +334,22 @@ class Converter
334
334
  # deal.add_status( {:label => '4. Deal lost', :assessment => GoImport::DealState::NegativeEndState })
335
335
  # end
336
336
  end
337
+
338
+ # HOOKS
339
+ #
340
+ # Sometimes you need to add exra information to the rootmodel, this can be done
341
+ # with hooks, below is an example of an organization hook that adds a note to
342
+ # an organization if a field has a specific value
343
+ #def organization_hook(row, organization, rootmodel)
344
+ # if not row['fieldname'].empty?
345
+ # note = GoImport::Note.new
346
+ # note.text = row['fieldname']
347
+ # note.organization = organization
348
+ # note.created_by = rootmodel.import_coworker
349
+ # rootmodel.add_note(note)
350
+ # end
351
+ #end
352
+
353
+
337
354
  end
338
355
 
@@ -376,5 +376,21 @@ class Converter
376
376
  # deal.add_status( {:label => '4. Deal lost', :assessment => GoImport::DealState::NegativeEndState })
377
377
  # end
378
378
  end
379
+
380
+ # HOOKS
381
+ #
382
+ # Sometimes you need to add exra information to the rootmodel, this can be done
383
+ # with hooks, below is an example of an organization hook that adds a note to
384
+ # an organization if a field has a specific value
385
+ #def organization_hook(row, organization, rootmodel)
386
+ # if not row['fieldname'].empty?
387
+ # note = GoImport::Note.new
388
+ # note.text = row['fieldname']
389
+ # note.organization = organization
390
+ # note.created_by = rootmodel.import_coworker
391
+ # rootmodel.add_note(note)
392
+ # end
393
+ #end
394
+
379
395
  end
380
396
 
@@ -94,4 +94,20 @@ class Converter
94
94
 
95
95
  # return nil
96
96
  end
97
+
98
+ # HOOKS
99
+ #
100
+ # Sometimes you need to add exra information to the rootmodel, this can be done
101
+ # with hooks, below is an example of an organization hook that adds a note to
102
+ # an organization if a field has a specific value
103
+ #def organization_hook(row, organization, rootmodel)
104
+ # if not row['fieldname'].empty?
105
+ # note = GoImport::Note.new
106
+ # note.text = row['fieldname']
107
+ # note.organization = organization
108
+ # note.created_by = rootmodel.import_coworker
109
+ # rootmodel.add_note(note)
110
+ # end
111
+ #end
112
+
97
113
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.26
4
+ version: 3.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petter Sandholdt
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-03-06 00:00:00.000000000 Z
15
+ date: 2015-03-16 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: iso_country_codes