embulk-output-kintone 0.3.0 → 0.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2004bfc2e202eeb6c57f3149bc7311f90343a67e
4
- data.tar.gz: 86e036bc863ac7d8ca632488d0eb84c645658c43
3
+ metadata.gz: 29cb270e92a0d79d50c33b6e4e6622d7bab0c6b9
4
+ data.tar.gz: 8ea4ec1c7e157a99aaf364d8adf0e17387e5c363
5
5
  SHA512:
6
- metadata.gz: 723f4b6b9e5341a7e0bef48c6de38528860985d46d9a139c2d3e133c59ab867c9a4507b0c98a431b5b654f332178f90038168bc0143d9d9dcb2916dfe1956e44
7
- data.tar.gz: 84441877b034060e5876ae67d8afd1d01f15a91d1aab8a76065bd4549a85c7de1639b0557a814482edc8312bbc11cbcbdc0565fa87aedfb794493966064201b7
6
+ metadata.gz: 9ee3d4c0d1e8a015064a5c4683bc5ee23c06c4da172315a068c715abca55b865f2481e0a2aca5d094b9a35ed3f07118be7d23064995073b54e33c39b64017afa
7
+ data.tar.gz: 30bc14642e24cadd7af74b7ffb5fe7b03d5be8f93989ea496f9577587f18066342ddf2c9c5e2b93b03f1f0087662fd5554cb268efab5c0bc08ad2cd767d5e3f4
data/build.gradle CHANGED
@@ -14,7 +14,7 @@ configurations {
14
14
  provided
15
15
  }
16
16
 
17
- version = "0.3.0"
17
+ version = "0.3.1"
18
18
 
19
19
  sourceCompatibility = 1.8
20
20
  targetCompatibility = 1.8
@@ -10,16 +10,16 @@ public interface KintoneColumnOption
10
10
  extends Task
11
11
  {
12
12
  @Config("type")
13
- public String getType();
13
+ String getType();
14
14
 
15
15
  @Config("field_code")
16
- public String getFieldCode();
16
+ String getFieldCode();
17
17
 
18
18
  @Config("timezone")
19
19
  @ConfigDefault("\"UTC\"")
20
- public Optional<String> getTimezone();
20
+ Optional<String> getTimezone();
21
21
 
22
22
  @Config("val_sep")
23
23
  @ConfigDefault("\",\"")
24
- public String getValueSeparator();
24
+ String getValueSeparator();
25
25
  }
@@ -27,10 +27,10 @@ import java.util.Objects;
27
27
  public class KintoneColumnVisitor
28
28
  implements ColumnVisitor
29
29
  {
30
- private PageReader pageReader;
30
+ private final PageReader pageReader;
31
31
  private Record record;
32
32
  private UpdateKey updateKey;
33
- private Map<String, KintoneColumnOption> columnOptions;
33
+ private final Map<String, KintoneColumnOption> columnOptions;
34
34
  private String updateKeyName;
35
35
 
36
36
  public KintoneColumnVisitor(PageReader pageReader,
@@ -136,7 +136,10 @@ public class KintoneColumnVisitor
136
136
  private ZoneId getZoneId(Column column)
137
137
  {
138
138
  KintoneColumnOption option = columnOptions.get(column.getName());
139
- return ZoneId.of(option.getTimezone().get());
139
+ if (option == null) {
140
+ return ZoneId.of("UTC");
141
+ }
142
+ return ZoneId.of(option.getTimezone().orElse("UTC"));
140
143
  }
141
144
 
142
145
  private boolean isUpdateKey(Column column)
@@ -10,7 +10,6 @@ import org.embulk.spi.OutputPlugin;
10
10
  import org.embulk.spi.Schema;
11
11
  import org.embulk.spi.TransactionalPageOutput;
12
12
 
13
- import java.util.Collection;
14
13
  import java.util.List;
15
14
 
16
15
  public class KintoneOutputPlugin
@@ -46,7 +45,6 @@ public class KintoneOutputPlugin
46
45
  public TransactionalPageOutput open(TaskSource taskSource, Schema schema, int taskIndex)
47
46
  {
48
47
  PluginTask task = taskSource.loadTask(PluginTask.class);
49
- Collection<KintoneColumnOption> options = task.getColumnOptions().values();
50
48
 
51
49
  KintoneMode mode = KintoneMode.getKintoneModeByValue(task.getMode());
52
50
  switch (mode) {
@@ -16,7 +16,7 @@ import org.embulk.spi.Schema;
16
16
  import org.embulk.spi.TransactionalPageOutput;
17
17
 
18
18
  import java.util.ArrayList;
19
- import java.util.Arrays;
19
+ import java.util.Collections;
20
20
  import java.util.List;
21
21
  import java.util.stream.Collectors;
22
22
 
@@ -25,8 +25,8 @@ public class KintonePageOutput
25
25
  {
26
26
  public static final int UPSERT_BATCH_SIZE = 10000;
27
27
  public static final int CHUNK_SIZE = 100;
28
- private PageReader pageReader;
29
- private PluginTask task;
28
+ private final PageReader pageReader;
29
+ private final PluginTask task;
30
30
  private KintoneClient client;
31
31
 
32
32
  public KintonePageOutput(PluginTask task, Schema schema)
@@ -90,14 +90,14 @@ public class KintonePageOutput
90
90
 
91
91
  public interface Consumer<T>
92
92
  {
93
- public void accept(T t);
93
+ void accept(T t);
94
94
  }
95
95
 
96
96
  public void connect(final PluginTask task)
97
97
  {
98
98
  KintoneClientBuilder builder = KintoneClientBuilder.create("https://" + task.getDomain());
99
99
  if (task.getGuestSpaceId().isPresent()) {
100
- builder.setGuestSpaceId(task.getGuestSpaceId().or(-1));
100
+ builder.setGuestSpaceId(task.getGuestSpaceId().orElse(-1));
101
101
  }
102
102
  if (task.getBasicAuthUsername().isPresent() && task.getBasicAuthPassword().isPresent()) {
103
103
  builder.withBasicAuth(task.getBasicAuthUsername().get(),
@@ -157,16 +157,12 @@ public class KintonePageOutput
157
157
  {
158
158
  execute(client -> {
159
159
  try {
160
- if (!task.getUpdateKeyName().isPresent()) {
161
- // already validated in KintoneOutputPlugin.open()
162
- throw new RuntimeException("unreachable error");
163
- }
164
160
  ArrayList<RecordForUpdate> updateRecords = new ArrayList<>();
165
161
  pageReader.setPage(page);
166
162
 
167
163
  KintoneColumnVisitor visitor = new KintoneColumnVisitor(pageReader,
168
164
  task.getColumnOptions(),
169
- task.getUpdateKeyName().get());
165
+ task.getUpdateKeyName().orElseThrow(() -> new RuntimeException("unreachable"))); // Already validated
170
166
  while (pageReader.nextRecord()) {
171
167
  Record record = new Record();
172
168
  UpdateKey updateKey = new UpdateKey();
@@ -201,17 +197,13 @@ public class KintonePageOutput
201
197
  {
202
198
  execute(client -> {
203
199
  try {
204
- if (!task.getUpdateKeyName().isPresent()) {
205
- // already validated in KintoneOutputPlugin.open()
206
- throw new RuntimeException("unreachable error");
207
- }
208
200
  ArrayList<Record> records = new ArrayList<>();
209
201
  ArrayList<UpdateKey> updateKeys = new ArrayList<>();
210
202
  pageReader.setPage(page);
211
203
 
212
204
  KintoneColumnVisitor visitor = new KintoneColumnVisitor(pageReader,
213
205
  task.getColumnOptions(),
214
- task.getUpdateKeyName().get());
206
+ task.getUpdateKeyName().orElseThrow(() -> new RuntimeException("unreachable"))); // Already validated
215
207
  while (pageReader.nextRecord()) {
216
208
  Record record = new Record();
217
209
  UpdateKey updateKey = new UpdateKey();
@@ -294,7 +286,7 @@ public class KintonePageOutput
294
286
  }
295
287
  String cursorId = client.record().createCursor(
296
288
  task.getAppId(),
297
- Arrays.asList(fieldCode),
289
+ Collections.singletonList(fieldCode),
298
290
  fieldCode + " in (" + String.join(",", queryValues) + ")"
299
291
  );
300
292
  while (true) {
@@ -1,11 +1,11 @@
1
1
  package org.embulk.output.kintone;
2
2
 
3
- import com.google.common.base.Optional;
4
3
  import org.embulk.config.Config;
5
4
  import org.embulk.config.ConfigDefault;
6
5
  import org.embulk.config.Task;
7
6
 
8
7
  import java.util.Map;
8
+ import java.util.Optional;
9
9
 
10
10
  public interface PluginTask
11
11
  extends Task
@@ -42,11 +42,11 @@ public interface PluginTask
42
42
 
43
43
  @Config("column_options")
44
44
  @ConfigDefault("{}")
45
- public Map<String, KintoneColumnOption> getColumnOptions();
45
+ Map<String, KintoneColumnOption> getColumnOptions();
46
46
 
47
47
  @Config("mode")
48
48
  @ConfigDefault("insert")
49
- public String getMode();
49
+ String getMode();
50
50
 
51
51
  @Config("update_key")
52
52
  @ConfigDefault("null")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-kintone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - takeshi fujita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-17 00:00:00.000000000 Z
11
+ date: 2022-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +52,7 @@ files:
52
52
  - README.md
53
53
  - Rakefile
54
54
  - build.gradle
55
- - classpath/embulk-output-kintone-0.3.0.jar
55
+ - classpath/embulk-output-kintone-0.3.1.jar
56
56
  - config/checkstyle/checkstyle.xml
57
57
  - config/checkstyle/default.xml
58
58
  - gradle/wrapper/gradle-wrapper.jar