embulk-input-kintone 0.1.4 → 0.1.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 646c14f2c41e56b23174e35fcbc2147072d49ba5
|
4
|
+
data.tar.gz: 90477839161c398082fb0cceae2c2cb14e1a2bc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0abfe7044ab966a6ad27158bdb56941b6857be9c1bd97714a5c9be87faff45e5c0c88e0f21746965cf7fcfeaad1e63542729ecb5b1ab1655c28c8d7c6946ca4
|
7
|
+
data.tar.gz: da7f3422eccc3a7cd49a3ded84c37fabb02c90489623ec553443ac6c36b9891be2317456b1e1b1a8bf5724efea75d4e08ba755e68fa2e159fd3076b6194befb9
|
data/build.gradle
CHANGED
@@ -4,6 +4,7 @@ import com.cybozu.kintone.client.authentication.Auth;
|
|
4
4
|
import com.cybozu.kintone.client.connection.Connection;
|
5
5
|
import com.cybozu.kintone.client.exception.KintoneAPIException;
|
6
6
|
import com.cybozu.kintone.client.model.cursor.CreateRecordCursorResponse;
|
7
|
+
import com.cybozu.kintone.client.model.cursor.GetRecordCursorResponse;
|
7
8
|
import com.cybozu.kintone.client.model.record.GetRecordsResponse;
|
8
9
|
import com.cybozu.kintone.client.module.recordCursor.RecordCursor;
|
9
10
|
import org.embulk.config.ConfigException;
|
@@ -19,7 +20,6 @@ public class KintoneClient {
|
|
19
20
|
private Auth kintoneAuth;
|
20
21
|
private RecordCursor kintoneRecordManager;
|
21
22
|
private Connection con;
|
22
|
-
private CreateRecordCursorResponse cursor;
|
23
23
|
|
24
24
|
public KintoneClient(){
|
25
25
|
this.kintoneAuth = new Auth();
|
@@ -57,26 +57,41 @@ public class KintoneClient {
|
|
57
57
|
|
58
58
|
|
59
59
|
public GetRecordsResponse getResponse(final PluginTask task) {
|
60
|
+
CreateRecordCursorResponse cursor = this.createCursor(task);
|
61
|
+
try {
|
62
|
+
return this.kintoneRecordManager.getAllRecords(cursor.getId());
|
63
|
+
}catch (KintoneAPIException e){
|
64
|
+
this.deleteCursor(cursor);
|
65
|
+
throw new RuntimeException(e);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
public GetRecordCursorResponse getRecordsByCursor(CreateRecordCursorResponse cursor){
|
70
|
+
try {
|
71
|
+
return this.kintoneRecordManager.getRecords(cursor.getId());
|
72
|
+
}catch (KintoneAPIException e){
|
73
|
+
this.deleteCursor(cursor);
|
74
|
+
throw new RuntimeException(e);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
public CreateRecordCursorResponse createCursor(final PluginTask task){
|
60
79
|
ArrayList<String> fields = new ArrayList<>();
|
61
80
|
for (ColumnConfig c : task.getFields().getColumns()
|
62
81
|
) {
|
63
82
|
fields.add(c.getName());
|
64
83
|
}
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}catch (KintoneAPIException e){
|
70
|
-
if (this.cursor != null) {
|
71
|
-
this.deleteCursor();
|
72
|
-
}
|
84
|
+
|
85
|
+
try{
|
86
|
+
return this.kintoneRecordManager.createCursor(task.getAppId(), fields, task.getQuery().or(""), FETCH_SIZE);
|
87
|
+
}catch (KintoneAPIException e) {
|
73
88
|
throw new RuntimeException(e);
|
74
89
|
}
|
75
90
|
}
|
76
91
|
|
77
|
-
public void deleteCursor() {
|
92
|
+
public void deleteCursor(CreateRecordCursorResponse cursor) {
|
78
93
|
try {
|
79
|
-
this.kintoneRecordManager.deleteCursor(
|
94
|
+
this.kintoneRecordManager.deleteCursor(cursor.getId());
|
80
95
|
}catch (KintoneAPIException e){
|
81
96
|
this.logger.error(e.toString());
|
82
97
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
package org.embulk.input.kintone;
|
2
2
|
|
3
|
-
import com.cybozu.kintone.client.model.
|
3
|
+
import com.cybozu.kintone.client.model.cursor.CreateRecordCursorResponse;
|
4
|
+
import com.cybozu.kintone.client.model.cursor.GetRecordCursorResponse;
|
4
5
|
import com.cybozu.kintone.client.model.record.field.FieldValue;
|
5
6
|
import com.google.common.annotations.VisibleForTesting;
|
6
7
|
import org.embulk.config.ConfigDiff;
|
@@ -54,11 +55,20 @@ public class KintoneInputPlugin
|
|
54
55
|
KintoneClient client = getKintoneClient();
|
55
56
|
client.validateAuth(task);
|
56
57
|
client.connect(task);
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
|
59
|
+
CreateRecordCursorResponse cursor = client.createCursor(task);
|
60
|
+
GetRecordCursorResponse cursorResponse = new GetRecordCursorResponse();
|
61
|
+
cursorResponse.setNext(true);
|
62
|
+
|
63
|
+
while (cursorResponse.getNext()) {
|
64
|
+
cursorResponse = client.getRecordsByCursor(cursor);
|
65
|
+
for (HashMap<String, FieldValue> record : cursorResponse.getRecords()) {
|
66
|
+
schema.visitColumns(new KintoneInputColumnVisitor(new KintoneAccessor(record), pageBuilder, task));
|
67
|
+
pageBuilder.addRecord();
|
68
|
+
}
|
69
|
+
pageBuilder.flush();
|
61
70
|
}
|
71
|
+
|
62
72
|
pageBuilder.finish();
|
63
73
|
}
|
64
74
|
} catch (Exception e) {
|
@@ -57,7 +57,8 @@ public class TestKintoneInputPlugin {
|
|
57
57
|
.registerPlugin(InputPlugin.class, "kintone", KintoneInputPlugin.class)
|
58
58
|
.build();
|
59
59
|
|
60
|
-
|
60
|
+
// Comment out for now
|
61
|
+
// @Test
|
61
62
|
public void simpleTest(){
|
62
63
|
config = loadYamlResource(embulk, "base.yml");
|
63
64
|
PluginTask task = config.loadConfig(PluginTask.class);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-kintone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- giwa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ files:
|
|
50
50
|
- LICENSE.txt
|
51
51
|
- README.md
|
52
52
|
- build.gradle
|
53
|
-
- classpath/embulk-input-kintone-0.1.
|
53
|
+
- classpath/embulk-input-kintone-0.1.5.jar
|
54
54
|
- classpath/gson-2.8.2.jar
|
55
55
|
- classpath/kintone-sdk-0.4.0.jar
|
56
56
|
- config/checkstyle/checkstyle.xml
|