embulk-output-kintone 0.3.3 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  package org.embulk.output.kintone;
2
2
 
3
+ import java.util.List;
3
4
  import org.embulk.config.ConfigDiff;
4
5
  import org.embulk.config.ConfigException;
5
6
  import org.embulk.config.ConfigSource;
@@ -10,60 +11,46 @@ import org.embulk.spi.OutputPlugin;
10
11
  import org.embulk.spi.Schema;
11
12
  import org.embulk.spi.TransactionalPageOutput;
12
13
 
13
- import java.util.List;
14
-
15
- public class KintoneOutputPlugin
16
- implements OutputPlugin
17
- {
18
- @Override
19
- public ConfigDiff transaction(ConfigSource config,
20
- Schema schema, int taskCount,
21
- OutputPlugin.Control control)
22
- {
23
- PluginTask task = config.loadConfig(PluginTask.class);
24
-
25
- control.run(task.dump());
26
- return Exec.newConfigDiff();
27
- }
28
-
29
- @Override
30
- public ConfigDiff resume(TaskSource taskSource,
31
- Schema schema, int taskCount,
32
- OutputPlugin.Control control)
33
- {
34
- throw new UnsupportedOperationException("kintone output plugin does not support resuming");
35
- }
36
-
37
- @Override
38
- public void cleanup(TaskSource taskSource,
39
- Schema schema, int taskCount,
40
- List<TaskReport> successTaskReports)
41
- {
42
- }
43
-
44
- @Override
45
- public TransactionalPageOutput open(TaskSource taskSource, Schema schema, int taskIndex)
46
- {
47
- PluginTask task = taskSource.loadTask(PluginTask.class);
48
-
49
- KintoneMode mode = KintoneMode.getKintoneModeByValue(task.getMode());
50
- switch (mode) {
51
- case INSERT:
52
- if (task.getUpdateKeyName().isPresent()) {
53
- throw new ConfigException("when mode is insert, require no update_key.");
54
- }
55
- break;
56
- case UPDATE:
57
- case UPSERT:
58
- if (!task.getUpdateKeyName().isPresent()) {
59
- throw new ConfigException("when mode is update or upsert, require update_key.");
60
- }
61
- break;
62
- default:
63
- throw new ConfigException(String.format(
64
- "Unknown mode '%s'",
65
- task.getMode()));
14
+ public class KintoneOutputPlugin implements OutputPlugin {
15
+ @Override
16
+ public ConfigDiff transaction(
17
+ ConfigSource config, Schema schema, int taskCount, OutputPlugin.Control control) {
18
+ PluginTask task = config.loadConfig(PluginTask.class);
19
+
20
+ control.run(task.dump());
21
+ return Exec.newConfigDiff();
22
+ }
23
+
24
+ @Override
25
+ public ConfigDiff resume(
26
+ TaskSource taskSource, Schema schema, int taskCount, OutputPlugin.Control control) {
27
+ throw new UnsupportedOperationException("kintone output plugin does not support resuming");
28
+ }
29
+
30
+ @Override
31
+ public void cleanup(
32
+ TaskSource taskSource, Schema schema, int taskCount, List<TaskReport> successTaskReports) {}
33
+
34
+ @Override
35
+ public TransactionalPageOutput open(TaskSource taskSource, Schema schema, int taskIndex) {
36
+ PluginTask task = taskSource.loadTask(PluginTask.class);
37
+
38
+ KintoneMode mode = KintoneMode.getKintoneModeByValue(task.getMode());
39
+ switch (mode) {
40
+ case INSERT:
41
+ if (task.getUpdateKeyName().isPresent()) {
42
+ throw new ConfigException("when mode is insert, require no update_key.");
43
+ }
44
+ break;
45
+ case UPDATE:
46
+ case UPSERT:
47
+ if (!task.getUpdateKeyName().isPresent()) {
48
+ throw new ConfigException("when mode is update or upsert, require update_key.");
66
49
  }
67
- return new KintonePageOutput(task, schema);
50
+ break;
51
+ default:
52
+ throw new ConfigException(String.format("Unknown mode '%s'", task.getMode()));
68
53
  }
54
+ return new KintonePageOutput(task, schema);
55
+ }
69
56
  }