embulk-output-kintone 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
  SHA256:
3
- metadata.gz: 9130ed9cf20ce6daef71d584cc04efa8fb85383a9abae667df654d127306e8c6
4
- data.tar.gz: d1fe2f819d6c8c6a70d740467751cda39a1b57babb8b65fdb94ad0f5d59ea606
3
+ metadata.gz: 256bcb9a1f785c4811ab072062b8bca8cf7d55cfc6dd01a883313ac341abf971
4
+ data.tar.gz: bec48d54a62afbee336ef60c271e5795d6567d19b93a3029857403572a8418dd
5
5
  SHA512:
6
- metadata.gz: 8cc744ff5db444005e44b1100f8d1247455bb37f4c3a096d30791fc7451e67ef8c471225cc40f670c62accda1a88ea4938afb9a4e3cc97f0df690a25033d00c6
7
- data.tar.gz: 701036ca929cc0dfb074101751a2fcbf5e6393a51f2dea2fd2f2c6fb68ca5752c8b557828d8b973822112a8d21448877cbf63dd7f0d8d8f472e137d478e50531
6
+ metadata.gz: 4fc949cbe0b4f631005b7de223902cee34c23099484d412e89bd5fad58ec099ca4e8ed536121348043cfa2b813630efc34f6274858d93ddb066b85c7b53b980a
7
+ data.tar.gz: 2216fee31203a3f34dfa422b488d87d966848500c43db5045fb056780f082375d434d4b3ce82645ae6ee1b39973112714608f8dfa9eaf6bc2f6edc325fb7994e
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.1.0"
16
+ version = "0.1.1"
17
17
 
18
18
  sourceCompatibility = 1.8
19
19
  targetCompatibility = 1.8
@@ -31,78 +31,105 @@ public class KintoneColumnVisitor
31
31
  this.record = record;
32
32
  }
33
33
 
34
- private void setValue(Column column, Object value)
34
+ private void setValue(String fieldCode, Object value, FieldType type)
35
35
  {
36
36
  if (value == null) {
37
37
  return;
38
38
  }
39
+ FieldValue fieldValue = new FieldValue();
40
+ fieldValue.setType(type);
41
+ record.put(fieldCode, fieldValue);
42
+ fieldValue.setValue(String.valueOf(value));
43
+ }
44
+
45
+ private FieldType getType(Column column, FieldType defaultType)
46
+ {
39
47
  KintoneColumnOption option = columnOptions.get(column.getName());
40
48
  if (option == null) {
41
- return;
49
+ return defaultType;
50
+ }
51
+ else {
52
+ return FieldType.valueOf(option.getType());
42
53
  }
43
- FieldValue fieldValue = new FieldValue();
44
- fieldValue.setType(FieldType.valueOf(option.getType()));
45
- fieldValue.setValue(String.valueOf(value));
46
- record.put(option.getFieldCode(), fieldValue);
54
+ }
55
+
56
+ private String getFieldCode(Column column)
57
+ {
58
+ KintoneColumnOption option = columnOptions.get(column.getName());
59
+ if (option == null) {
60
+ return column.getName();
61
+ }
62
+ else {
63
+ return option.getFieldCode();
64
+ }
65
+ }
66
+
67
+ private DateTimeZone getTimezone(Column column)
68
+ {
69
+ KintoneColumnOption option = columnOptions.get(column.getName());
70
+ return DateTimeZone.forID(option.getTimezone().get());
47
71
  }
48
72
 
49
73
  @Override
50
74
  public void booleanColumn(Column column)
51
75
  {
52
- setValue(column, pageReader.getBoolean(column));
76
+ String fieldCode = getFieldCode(column);
77
+ FieldType type = getType(column, FieldType.NUMBER);
78
+ setValue(fieldCode, pageReader.getBoolean(column), type);
53
79
  }
54
80
 
55
81
  @Override
56
82
  public void longColumn(Column column)
57
83
  {
58
- setValue(column, pageReader.getLong(column));
84
+ String fieldCode = getFieldCode(column);
85
+ FieldType type = getType(column, FieldType.NUMBER);
86
+ setValue(fieldCode, pageReader.getLong(column), type);
59
87
  }
60
88
 
61
89
  @Override
62
90
  public void doubleColumn(Column column)
63
91
  {
64
- setValue(column, pageReader.getDouble(column));
92
+ String fieldCode = getFieldCode(column);
93
+ FieldType type = getType(column, FieldType.NUMBER);
94
+ setValue(fieldCode, pageReader.getDouble(column), type);
65
95
  }
66
96
 
67
97
  @Override
68
98
  public void stringColumn(Column column)
69
99
  {
70
- setValue(column, pageReader.getString(column));
100
+ String fieldCode = getFieldCode(column);
101
+ FieldType type = getType(column, FieldType.MULTI_LINE_TEXT);
102
+ setValue(fieldCode, pageReader.getString(column), type);
71
103
  }
72
104
 
73
105
  @Override
74
106
  public void timestampColumn(Column column)
75
107
  {
108
+ String fieldCode = getFieldCode(column);
109
+ FieldType type = getType(column, FieldType.DATETIME);
76
110
  Timestamp value = pageReader.getTimestamp(column);
77
111
  if (value == null) {
78
112
  return;
79
113
  }
80
- KintoneColumnOption option = columnOptions.get(column.getName());
81
- if (option == null) {
82
- return;
83
- }
84
- FieldType fieldType = FieldType.valueOf(option.getType());
85
-
86
- switch (fieldType) {
114
+ switch (type) {
87
115
  case DATE: {
88
116
  String format = "%Y-%m-%d";
89
- DateTimeZone timezone = DateTimeZone.forID(option.getTimezone().get());
117
+ DateTimeZone timezone = getTimezone(column);
90
118
  TimestampFormatter formatter = new TimestampFormatter(format, timezone);
91
119
  String date = formatter.format(value);
92
- setValue(column, date);
120
+ setValue(fieldCode, date, type);
93
121
  break;
94
122
  }
95
123
  case DATETIME: {
96
124
  String format = "%Y-%m-%dT%H:%M:%S%z";
97
125
  DateTimeZone timezone = DateTimeZone.forID("UTC");
98
126
  TimestampFormatter formatter = new TimestampFormatter(format, timezone);
99
- String date = formatter.format(value);
100
- setValue(column, date);
127
+ String dateTime = formatter.format(value);
128
+ setValue(fieldCode, dateTime, type);
101
129
  break;
102
130
  }
103
131
  default: {
104
- setValue(column, value);
105
- break;
132
+ setValue(fieldCode, value, type);
106
133
  }
107
134
  }
108
135
  }
@@ -110,6 +137,8 @@ public class KintoneColumnVisitor
110
137
  @Override
111
138
  public void jsonColumn(Column column)
112
139
  {
113
- setValue(column, pageReader.getJson(column));
140
+ String fieldCode = getFieldCode(column);
141
+ FieldType type = getType(column, FieldType.MULTI_LINE_TEXT);
142
+ setValue(fieldCode, pageReader.getJson(column), type);
114
143
  }
115
144
  }
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.1.0
4
+ version: 0.1.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: 2019-12-16 00:00:00.000000000 Z
11
+ date: 2019-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler