-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathbulk.py
89 lines (70 loc) · 3.17 KB
/
bulk.py
1
2
3
4
5
6
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import sublime
import sublime_plugin
import os
from . import util
from . import processor
from .salesforce.lib.panel import Printer
class CloseJobsCommand(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(CloseJobsCommand, self).__init__(*args, **kwargs)
def run(self):
self.window.show_input_panel("Input JobId (Separated By ','): ", "", self.on_input, None, None)
def on_input(self, input):
if not input:
Printer.get("error").write("Please input job ids that is separated by ','")
return
job_ids = input.split(",")
processor.handle_close_jobs_thread(job_ids)
class BulkExportSingleCommand(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(BulkExportSingleCommand, self).__init__(*args, **kwargs)
def run(self, export_soql=False):
self.export_soql = export_soql
sobjects_describe = util.populate_sobjects_describe()
self.sobjects = sorted(sobjects_describe.keys())
self.window.show_quick_panel(self.sobjects, self.on_done)
def on_done(self, index):
if index == -1: return
self.chosen_sobject = self.sobjects[index]
if not self.export_soql:
processor.handle_backup_sobject_thread(self.chosen_sobject)
else:
self.window.show_input_panel("Input SOQL: ", "", self.on_input, None, None)
def on_input(self, soql):
if not soql or not soql.upper().startswith("SELECT"):
Printer.get("error").write("Invalid SOQL")
return
processor.handle_backup_sobject_thread(self.chosen_sobject, soql)
class BulkExportAllCommand(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(BulkExportAllCommand, self).__init__(*args, **kwargs)
def run(self):
processor.handle_backup_all_sobjects_thread()
class BulkOperationCommand(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(BulkOperationCommand, self).__init__(*args, **kwargs)
def run(self, operation=None):
self.operation = operation
sobjects_describe = util.populate_sobjects_describe()
self.sobjects = sorted(sobjects_describe.keys())
self.window.show_quick_panel(self.sobjects, self.on_done)
def on_done(self, index):
if index == -1: return
self.sobject = self.sobjects[index]
path = sublime.get_clipboard()
if not os.path.isfile(path): path = ""
self.window.show_input_panel("Input CSV Path: ",
path, self.on_input, None, None)
def on_input(self, file_path):
if not file_path.endswith('csv'):
Printer.get("error").write("Input file must be CSV")
return
if not os.path.exists(file_path):
Printer.get("error").write(file_path + " is not valid file")
return
processor.handle_bulk_operation_thread(self.sobject, file_path, self.operation)
class BulkUpsertCommand(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(BulkUpsertCommand, self).__init__(*args, **kwargs)
def run(self):
sublime.message_dialog("This command is ongoing")