embulk-input-kintone 0.1.3 → 0.1.4

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: 69c23aa1d03cb2ccfd39918eda208847ed5dcf11
4
- data.tar.gz: 1c24d9b3210d4e30d2c23b48ddb08e2b8f515e2d
3
+ metadata.gz: 44d845eef9835bf7dd89a4c032773241f6f8370f
4
+ data.tar.gz: ff2e8346c67187d39f57b97cb1bec10f62d06e7c
5
5
  SHA512:
6
- metadata.gz: 632505db9038c63988f56c8ec4bc961cc11ba28f8e2320a1f22228add31be29ca0df913337ccc786fdfa86cb93e4f4a386cd85aeee53e7352ba2abc86de3b468
7
- data.tar.gz: c858872b535a14af20adb30023388c7d3acb03159b3c4d7d4db547d45e15f17eca76eb68bb853b0742e13de0b63eb93e2595fca279610d46aa91be37b2949766
6
+ metadata.gz: 5651b726a4e02595d003e869c10ca822cc52f1410bf82169b832df585bd32a379dd2a6c80bacbb4679a26c5c93c5dc6767b16fd6962c99bca21b43d303a1db18
7
+ data.tar.gz: 112b1976784706fc3ed75b982bf6f9461bcce05337fedfe08570db24fa61aa5964d5ca2a8fe8d393b5784bdc6a2be7b081e56481eb4aca8b0bad95bbc8923f23
data/README.md CHANGED
@@ -15,7 +15,6 @@ e.g. limit, offset are not supported.
15
15
 
16
16
  ## Road Map
17
17
  - [ ] Guess
18
- - [ ] Subtable data type support
19
18
  - [ ] field name mapping
20
19
  - [ ] handle certification fot authentication
21
20
 
@@ -32,7 +31,7 @@ e.g. limit, offset are not supported.
32
31
  - **guest_space_id**: Kintone app belongs to guest space, guest space id is required. (integer, optional)
33
32
  - **fields** (required)
34
33
  - **name** the field code of Kintone app record will be retrieved.
35
- - **type** Column values are converted to this embulk type. Available values options are: boolean, long, double, string, json, timestamp)
34
+ - **type** Column values are converted to this embulk type. Available values options are: boolean, long, double, string, json, timestamp) Kintone `SUBTABLE` type is loaded as json text.
36
35
  - **format** Format of the timestamp if type is timestamp. The format for kintone DATETIME is `%Y-%m-%dT%H:%M:%S%z`.
37
36
 
38
37
  kintone API has the limitation, therefore this plugin also faces it. See [official documentation](https://developer.kintone.io/hc/en-us/articles/212495188/)
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.1.3"
16
+ version = "0.1.4"
17
17
 
18
18
  sourceCompatibility = 1.8
19
19
  targetCompatibility = 1.8
@@ -5,12 +5,14 @@ import org.slf4j.Logger;
5
5
  import org.slf4j.LoggerFactory;
6
6
  import com.cybozu.kintone.client.model.record.field.FieldValue;
7
7
  import com.cybozu.kintone.client.model.member.Member;
8
+ import com.google.gson.Gson;
8
9
 
9
10
  import java.util.ArrayList;
10
11
  import java.util.HashMap;
11
12
 
12
13
  public class KintoneAccessor {
13
14
  private final Logger logger = LoggerFactory.getLogger(KintoneAccessor.class);
15
+ private final Gson gson = new Gson();
14
16
 
15
17
  private final HashMap<String, FieldValue> record;
16
18
  private final String delimiter = "\n";
@@ -30,8 +32,8 @@ public class KintoneAccessor {
30
32
  .reduce((accum, value) -> accum + this.delimiter + value)
31
33
  .orElse("");
32
34
  case SUBTABLE:
33
- // TODO: support sub table
34
- return "";
35
+ Object subTableValueItem = this.record.get(name).getValue();
36
+ return gson.toJson(subTableValueItem);
35
37
  case CREATOR:
36
38
  case MODIFIER:
37
39
  Member m = (Member) this.record.get(name).getValue();
@@ -3,6 +3,7 @@ package org.embulk.input.kintone;
3
3
 
4
4
  import com.cybozu.kintone.client.model.app.form.FieldType;
5
5
  import com.cybozu.kintone.client.model.record.field.FieldValue;
6
+ import com.cybozu.kintone.client.model.record.SubTableValueItem;
6
7
  import com.cybozu.kintone.client.model.member.Member;
7
8
  import org.junit.Test;
8
9
 
@@ -24,23 +25,23 @@ public class TestKintoneAccessor {
24
25
  public HashMap<String, FieldValue> createTestRecord() {
25
26
  HashMap<String, FieldValue> testRecord = new HashMap<>();
26
27
 
27
- testRecord = TestHelper.addField(testRecord, "文字列__1行", FieldType.SINGLE_LINE_TEXT, "test single text");
28
- testRecord = TestHelper.addField(testRecord, "数値", FieldType.NUMBER, this.uniqueKey);
28
+ TestHelper.addField(testRecord, "文字列__1行", FieldType.SINGLE_LINE_TEXT, "test single text");
29
+ TestHelper.addField(testRecord, "数値", FieldType.NUMBER, this.uniqueKey);
29
30
  this.uniqueKey += 1;
30
- testRecord = TestHelper.addField(testRecord, "文字列__複数行", FieldType.MULTI_LINE_TEXT, "test multi text");
31
- testRecord = TestHelper.addField(testRecord, "リッチエディター", FieldType.RICH_TEXT, "<div>test rich text<br /></div>");
31
+ TestHelper.addField(testRecord, "文字列__複数行", FieldType.MULTI_LINE_TEXT, "test multi text");
32
+ TestHelper.addField(testRecord, "リッチエディター", FieldType.RICH_TEXT, "<div>test rich text<br /></div>");
32
33
 
33
34
  ArrayList<String> selectedItemList = new ArrayList<>();
34
35
  selectedItemList.add("sample1");
35
36
  selectedItemList.add("sample2");
36
- testRecord = TestHelper.addField(testRecord, "チェックボックス", FieldType.CHECK_BOX, selectedItemList);
37
- testRecord = TestHelper.addField(testRecord, "ラジオボタン", FieldType.RADIO_BUTTON, "sample2");
38
- testRecord = TestHelper.addField(testRecord, "ドロップダウン", FieldType.DROP_DOWN, "sample3");
39
- testRecord = TestHelper.addField(testRecord, "複数選択", FieldType.MULTI_SELECT, selectedItemList);
40
- testRecord = TestHelper.addField(testRecord, "リンク", FieldType.LINK, "http://cybozu.co.jp/");
41
- testRecord = TestHelper.addField(testRecord, "日付", FieldType.DATE, "2018-01-01");
42
- testRecord = TestHelper.addField(testRecord, "時刻", FieldType.TIME, "12:34");
43
- testRecord = TestHelper.addField(testRecord, "日時", FieldType.DATETIME, "2018-01-02T02:30:00Z");
37
+ TestHelper.addField(testRecord, "チェックボックス", FieldType.CHECK_BOX, selectedItemList);
38
+ TestHelper.addField(testRecord, "ラジオボタン", FieldType.RADIO_BUTTON, "sample2");
39
+ TestHelper.addField(testRecord, "ドロップダウン", FieldType.DROP_DOWN, "sample3");
40
+ TestHelper.addField(testRecord, "複数選択", FieldType.MULTI_SELECT, selectedItemList);
41
+ TestHelper.addField(testRecord, "リンク", FieldType.LINK, "http://cybozu.co.jp/");
42
+ TestHelper.addField(testRecord, "日付", FieldType.DATE, "2018-01-01");
43
+ TestHelper.addField(testRecord, "時刻", FieldType.TIME, "12:34");
44
+ TestHelper.addField(testRecord, "日時", FieldType.DATETIME, "2018-01-02T02:30:00Z");
44
45
 
45
46
  ArrayList<Member> userList = new ArrayList<>();
46
47
  userList.add(testman1);
@@ -54,6 +55,19 @@ public class TestKintoneAccessor {
54
55
  orgList.add(testorg1);
55
56
  orgList.add(testorg2);
56
57
  TestHelper.addField(testRecord, "組織選択", FieldType.ORGANIZATION_SELECT, orgList);
58
+
59
+ SubTableValueItem tableItem1 = new SubTableValueItem();
60
+ tableItem1.setID(1);
61
+ HashMap<String, FieldValue> tableItemValue1 = new HashMap<>();
62
+ FieldValue fv1 = new FieldValue();
63
+ fv1.setType(FieldType.SINGLE_LINE_TEXT);
64
+ fv1.setValue("sample_text1");
65
+ tableItemValue1.put("sample field1", fv1);
66
+ tableItem1.setValue(tableItemValue1);
67
+ ArrayList<SubTableValueItem> subTableRecords = new ArrayList<>();
68
+ subTableRecords.add(tableItem1);
69
+ TestHelper.addField(testRecord, "サブテーブル", FieldType.SUBTABLE, subTableRecords);
70
+
57
71
  return testRecord;
58
72
  }
59
73
 
@@ -65,7 +79,7 @@ public class TestKintoneAccessor {
65
79
  String userSelect = "code1\ncode2";
66
80
  String groupSelect = "code3\ncode4";
67
81
  String orgSelect = "code5\ncode6";
68
-
82
+ String subTableValue = "[{\"id\":1,\"value\":{\"sample field1\":{\"type\":\"SINGLE_LINE_TEXT\",\"value\":\"sample_text1\"}}}]";
69
83
  assertEquals(testRecord.get("文字列__1行").getValue(), accessor.get("文字列__1行"));
70
84
  assertEquals("1", accessor.get("数値"));
71
85
  assertEquals(testRecord.get("文字列__複数行").getValue(), accessor.get("文字列__複数行"));
@@ -81,5 +95,6 @@ public class TestKintoneAccessor {
81
95
  assertEquals(userSelect, accessor.get("ユーザー選択"));
82
96
  assertEquals(groupSelect, accessor.get("グループ選択"));
83
97
  assertEquals(orgSelect, accessor.get("組織選択"));
98
+ assertEquals(subTableValue, accessor.get("サブテーブル"));
84
99
  }
85
100
  }
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - giwa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-12 00:00:00.000000000 Z
11
+ date: 2020-12-06 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.3.jar
53
+ - classpath/embulk-input-kintone-0.1.4.jar
54
54
  - classpath/gson-2.8.2.jar
55
55
  - classpath/kintone-sdk-0.4.0.jar
56
56
  - config/checkstyle/checkstyle.xml