go_import 3.0.13 → 3.0.14

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.
data/bin/go-import CHANGED
@@ -46,7 +46,16 @@ class GoImportCommandLine < Thor
46
46
  :desc => "Output will be created even if the import contains missing files",
47
47
  :type => :boolean,
48
48
  :required => false)
49
+ option(:log_to_file,
50
+ :desc => "Console output will be redirected to file",
51
+ :type => :string,
52
+ :required => false)
49
53
  def run_import()
54
+ if !options.log_to_file.nil?
55
+ $stdout = File.new(options.log_to_file == "log_to_file" ? "go-import.log" : options.log_to_file, 'w')
56
+ $stdout.sync = true
57
+ end
58
+
50
59
  if !is_valid_goimport_project?
51
60
  return
52
61
  end
@@ -91,13 +100,18 @@ class GoImportCommandLine < Thor
91
100
  puts "Trying to log files that can't be found..."
92
101
  file_log_header = "name;integration_id;path;organization.integrationid;organization.name;deal.integrationid;deal.name"
93
102
  file_log = ""
103
+ files_to_remove = []
94
104
  model.documents.files.each do |file|
95
105
  if !::File.exists?(file.path_for_project)
96
106
  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}\n"
97
- model.documents.files.delete file
107
+ files_to_remove.push file
98
108
  end
99
109
  end
100
110
 
111
+ files_to_remove.each do |file|
112
+ model.documents.files.delete file
113
+ end
114
+
101
115
  if file_log.length > 0
102
116
  log_filename = 'go-import-missing-files.csv'
103
117
  ::File.open(log_filename, 'w') { |f|
@@ -80,16 +80,17 @@ def convert_source
80
80
  rootmodel.add_note(to_deal_note(row, rootmodel))
81
81
  end
82
82
 
83
- # company documents
83
+ # documents
84
84
  if defined?(IMPORT_DOCUMENTS) && !IMPORT_DOCUMENTS.nil? && IMPORT_DOCUMENTS
85
85
  process_rows ORGANIZATION_DOCUMENT_FILE do |row|
86
86
  rootmodel.add_file(to_organization_document(row, rootmodel))
87
87
  end
88
88
 
89
89
  process_rows PROJECT_DOCUMENT_FILE do |row|
90
- rootmodel.add_file(from_project_document_to_organization_document(row, includes, rootmodel))
90
+ rootmodel.add_file(to_deal_document(row, includes, rootmodel))
91
91
  end
92
92
  end
93
+
93
94
  return rootmodel
94
95
  end
95
96
 
@@ -187,7 +188,7 @@ def to_organization_document(row, rootmodel)
187
188
  return file
188
189
  end
189
190
 
190
- def from_project_document_to_organization_document(row, includes, rootmodel)
191
+ def to_deal_document(row, includes, rootmodel)
191
192
  file = GoImport::File.new()
192
193
 
193
194
  file.integration_id = "d-#{row['idDocument']}"
@@ -199,13 +200,13 @@ def from_project_document_to_organization_document(row, includes, rootmodel)
199
200
  file.created_by = rootmodel.import_coworker
200
201
  end
201
202
 
202
- organization_id = includes[row['idProject']]
203
- org = rootmodel.find_organization_by_integration_id(organization_id)
204
- if org.nil?
203
+ deal_id = includes[row['idProject']]
204
+ deal = rootmodel.find_deal_by_integration_id(deal_id)
205
+ if deal.nil?
205
206
  return nil
206
207
  end
207
208
 
208
- file.organization = org
209
+ file.deal = deal
209
210
 
210
211
  return file
211
212
  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.13
4
+ version: 3.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: