embulk-output-salesforce 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29d21f4cf7365b79ed58cbd012c48bf59b31d7ae
|
4
|
+
data.tar.gz: 77f464e7f1dbfb7aa3d5b9cfc7b27904e3d73688
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06b13aea4bdcc54b1e654788814db4178766b7b7e169b109095acd8ec91c7778827b75fd105fa507993498b6b113f91bb62e3c71a8d51741036e6810e3da8d10
|
7
|
+
data.tar.gz: 661a287aa359c72769d9a8bf5820db0ef19b50bc3f405fcd999dc9c1f34561d7873cc41ef5f2cf56d585ce2b92aec59fd30fd0489029fbc0460eec23b3a53de7
|
data/README.md
CHANGED
@@ -17,8 +17,8 @@ Embulk output plugin to load into Salesforce.com.
|
|
17
17
|
- **login_endpoint**: login endpoint (string, default: https://login.salesforce.com)
|
18
18
|
- **sobject**: salesforce object API name (string, required)
|
19
19
|
- **upsert_key**: upsert API field name (string, default: null)
|
20
|
-
- **action**: output action that is "insert", "update", "upsert" or "delete" (string,
|
21
|
-
- **result_dir**: directory for resulting csv(success and error file) (string, default:
|
20
|
+
- **action**: output action that is "insert", "update", "upsert" or "delete" (string, default: insert)
|
21
|
+
- **result_dir**: directory for resulting csv(success and error file). If the directory is not exist, the plugin show error. If not specified, resulting csv is not created. (string, default: null)
|
22
22
|
- **version**: API version (string, default: "34.0")
|
23
23
|
|
24
24
|
## Example
|
@@ -28,6 +28,7 @@ out:
|
|
28
28
|
type: salesforce
|
29
29
|
username: hoge@example.com
|
30
30
|
password: fuga
|
31
|
+
sobject: Account
|
31
32
|
action: insert
|
32
33
|
```
|
33
34
|
|
data/build.gradle
CHANGED
Binary file
|
@@ -10,6 +10,7 @@ import com.sforce.soap.partner.UpsertResult;
|
|
10
10
|
import com.sforce.soap.partner.sobject.SObject;
|
11
11
|
import com.sforce.ws.ConnectionException;
|
12
12
|
import com.sforce.ws.ConnectorConfig;
|
13
|
+
import java.io.File;
|
13
14
|
import java.io.FileWriter;
|
14
15
|
import java.io.IOException;
|
15
16
|
import java.text.SimpleDateFormat;
|
@@ -55,7 +56,7 @@ public class SalesforceOutputPlugin
|
|
55
56
|
public String getPassword();
|
56
57
|
|
57
58
|
@Config("login_endpoint")
|
58
|
-
@ConfigDefault("https://login.salesforce.com")
|
59
|
+
@ConfigDefault("\"https://login.salesforce.com\"")
|
59
60
|
public Optional<String> getLoginEndpoint();
|
60
61
|
|
61
62
|
@Config("sobject")
|
@@ -78,7 +79,7 @@ public class SalesforceOutputPlugin
|
|
78
79
|
public Optional<String> getVersion();
|
79
80
|
|
80
81
|
@Config("result_dir")
|
81
|
-
@ConfigDefault("
|
82
|
+
@ConfigDefault("null")
|
82
83
|
public Optional<String> getResultDir();
|
83
84
|
}
|
84
85
|
|
@@ -89,6 +90,15 @@ public class SalesforceOutputPlugin
|
|
89
90
|
{
|
90
91
|
PluginTask task = config.loadConfig(PluginTask.class);
|
91
92
|
logger = Exec.getLogger(getClass());
|
93
|
+
|
94
|
+
if (task.getResultDir().isPresent() && task.getResultDir().get() != null) {
|
95
|
+
File resultDir = new File(task.getResultDir().get());
|
96
|
+
if (!resultDir.exists() || !resultDir.isDirectory()) {
|
97
|
+
logger.error("{} is not exist or is not directory.", task.getResultDir().get());
|
98
|
+
throw new RuntimeException(task.getResultDir().get() + " is not exist or is not directory.");
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
92
102
|
final String username = task.getUsername();
|
93
103
|
final String password = task.getPassword();
|
94
104
|
final String loginEndpoint = task.getLoginEndpoint().get();
|
@@ -145,7 +155,7 @@ public class SalesforceOutputPlugin
|
|
145
155
|
public class SalesforcePageOutput
|
146
156
|
implements TransactionalPageOutput
|
147
157
|
{
|
148
|
-
private final String
|
158
|
+
private final String dateSuffix = new SimpleDateFormat("yyyyMMddhhmmssSSS").format(new Date());
|
149
159
|
|
150
160
|
private final PageReader pageReader;
|
151
161
|
private final PartnerConnection client;
|
@@ -348,16 +358,22 @@ public class SalesforceOutputPlugin
|
|
348
358
|
ICsvListWriter successListWriter = null;
|
349
359
|
ICsvListWriter errorListWriter = null;
|
350
360
|
try {
|
351
|
-
String successFileName = this.resultDir + "/success_" +
|
361
|
+
String successFileName = this.resultDir + "/success_" + dateSuffix + ".csv";
|
362
|
+
Boolean isExistSuccessFile = new File(successFileName).exists();
|
352
363
|
successListWriter = new CsvListWriter(new FileWriter(successFileName, true),
|
353
364
|
CsvPreference.STANDARD_PREFERENCE);
|
354
|
-
|
365
|
+
if (!isExistSuccessFile) {
|
366
|
+
successListWriter.write(createSuccessHeader());
|
367
|
+
}
|
355
368
|
|
356
|
-
String errorFileName = this.resultDir + "/error_" +
|
369
|
+
String errorFileName = this.resultDir + "/error_" + dateSuffix + ".csv";
|
370
|
+
Boolean isExistErrorFile = new File(errorFileName).exists();
|
357
371
|
errorListWriter = new CsvListWriter(new FileWriter(errorFileName, true),
|
358
372
|
CsvPreference.STANDARD_PREFERENCE);
|
359
|
-
|
360
|
-
|
373
|
+
if (!isExistErrorFile) {
|
374
|
+
errorListWriter.write(createErrorHeader());
|
375
|
+
}
|
376
|
+
|
361
377
|
CellProcessor[] processors = new CellProcessor[pageReader.getSchema().getColumns().size() + 1];
|
362
378
|
ArrayList<ArrayList<String>> errorValues = new ArrayList<>();
|
363
379
|
for (Integer i = 0, imax = records.size(); i < imax; i++) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-salesforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Makoto Tajitsu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,7 +58,7 @@ files:
|
|
58
58
|
- lib/partner.jar
|
59
59
|
- src/main/java/org/embulk/output/SalesforceOutputPlugin.java
|
60
60
|
- src/test/java/org/embulk/output/TestSalesforceOutputPlugin.java
|
61
|
-
- classpath/embulk-output-salesforce-0.1.
|
61
|
+
- classpath/embulk-output-salesforce-0.1.1.jar
|
62
62
|
- classpath/force-wsc-34.0.jar
|
63
63
|
- classpath/partner.jar
|
64
64
|
- classpath/super-csv-2.3.1.jar
|
Binary file
|