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: e3d02cc5822121c62af4ba8512b32674eb5b045f
4
- data.tar.gz: d6fb63e23ab436d9fc844934e3b4dc6634f4915c
3
+ metadata.gz: 29d21f4cf7365b79ed58cbd012c48bf59b31d7ae
4
+ data.tar.gz: 77f464e7f1dbfb7aa3d5b9cfc7b27904e3d73688
5
5
  SHA512:
6
- metadata.gz: 448501ddd1046cf41372854c03cc4fc07919f4c9969cdfa9cbcd2ddf8df436a5eb0573eb8fb6339c32e7f519a3e5769d95e6aea944e98cc482f80db094a4dd43
7
- data.tar.gz: 667291613516bc25a989d4740d3d99a3b7a585a4ee140399208ef767f0457181ef68ad2751d64f42228b2f5c8a9735d6c0264d8c6770c6e9baf86b32bf124aa3
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, required)
21
- - **result_dir**: directory for resulting csv(success and error file) (string, default: "./target")
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
@@ -12,7 +12,7 @@ configurations {
12
12
  provided
13
13
  }
14
14
 
15
- version = "0.1.0"
15
+ version = "0.1.1"
16
16
 
17
17
  dependencies {
18
18
  compile "org.embulk:embulk-core:0.6.11"
@@ -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("\"./target\"")
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 datePostFix = new SimpleDateFormat("yyyyMMddhhmmssSSS").format(new Date());
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_" + datePostFix + ".csv";
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
- //successListWriter.write(createSuccessHeader());
365
+ if (!isExistSuccessFile) {
366
+ successListWriter.write(createSuccessHeader());
367
+ }
355
368
 
356
- String errorFileName = this.resultDir + "/error_" + datePostFix + ".csv";
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
- //errorListWriter.write(createErrorHeader());
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.0
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-21 00:00:00.000000000 Z
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.0.jar
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