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 +4 -4
- data/build.gradle +1 -1
- data/src/main/java/org/embulk/output/kintone/KintoneColumnVisitor.java +53 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 256bcb9a1f785c4811ab072062b8bca8cf7d55cfc6dd01a883313ac341abf971
|
4
|
+
data.tar.gz: bec48d54a62afbee336ef60c271e5795d6567d19b93a3029857403572a8418dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fc949cbe0b4f631005b7de223902cee34c23099484d412e89bd5fad58ec099ca4e8ed536121348043cfa2b813630efc34f6274858d93ddb066b85c7b53b980a
|
7
|
+
data.tar.gz: 2216fee31203a3f34dfa422b488d87d966848500c43db5045fb056780f082375d434d4b3ce82645ae6ee1b39973112714608f8dfa9eaf6bc2f6edc325fb7994e
|
data/build.gradle
CHANGED
@@ -31,78 +31,105 @@ public class KintoneColumnVisitor
|
|
31
31
|
this.record = record;
|
32
32
|
}
|
33
33
|
|
34
|
-
private void setValue(
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
117
|
+
DateTimeZone timezone = getTimezone(column);
|
90
118
|
TimestampFormatter formatter = new TimestampFormatter(format, timezone);
|
91
119
|
String date = formatter.format(value);
|
92
|
-
setValue(
|
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
|
100
|
-
setValue(
|
127
|
+
String dateTime = formatter.format(value);
|
128
|
+
setValue(fieldCode, dateTime, type);
|
101
129
|
break;
|
102
130
|
}
|
103
131
|
default: {
|
104
|
-
setValue(
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2019-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|