embulk-output-kintone 0.4.0 → 1.0.0
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 +4 -4
- data/.github/workflows/ci.yml +1 -0
- data/.gitignore +0 -1
- data/README.md +8 -6
- data/build.gradle +18 -19
- data/classpath/embulk-output-kintone-1.0.0.jar +0 -0
- data/classpath/shadow-kintone-java-client-1.0.0-all.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +1 -1
- data/settings.gradle +2 -0
- data/shadow-kintone-java-client/build.gradle +35 -0
- data/src/main/java/org/embulk/output/kintone/KintoneColumnOption.java +1 -2
- data/src/main/java/org/embulk/output/kintone/KintoneColumnType.java +368 -0
- data/src/main/java/org/embulk/output/kintone/KintoneColumnVisitor.java +195 -135
- data/src/main/java/org/embulk/output/kintone/KintoneMode.java +0 -1
- data/src/main/java/org/embulk/output/kintone/KintoneOutputPlugin.java +0 -2
- data/src/main/java/org/embulk/output/kintone/KintonePageOutput.java +249 -192
- data/src/main/java/org/embulk/output/kintone/KintoneRetryOption.java +19 -0
- data/src/main/java/org/embulk/output/kintone/PluginTask.java +11 -3
- data/src/test/java/com/kintone/client/Json.java +16 -0
- data/src/test/java/org/embulk/output/kintone/KintoneColumnOptionBuilder.java +62 -0
- data/src/test/java/org/embulk/output/kintone/KintoneColumnVisitorTest.java +820 -0
- data/src/test/java/org/embulk/output/kintone/KintoneColumnVisitorVerifier.java +73 -0
- data/src/test/java/org/embulk/output/kintone/KintonePageOutputVerifier.java +221 -0
- data/src/test/java/org/embulk/output/kintone/OutputPageBuilder.java +92 -0
- data/src/test/java/org/embulk/output/kintone/TestKintoneOutputPlugin.java +176 -1
- data/src/test/java/org/embulk/output/kintone/TestTask.java +40 -0
- data/src/test/java/org/embulk/output/kintone/TestTaskMode.java +43 -0
- data/src/test/resources/logback-test.xml +14 -0
- data/src/test/resources/org/embulk/output/kintone/config.yml +4 -0
- data/src/test/resources/org/embulk/output/kintone/task/config.yml +1 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/config.yml +158 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/input.csv +7 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/insert_add_ignore_nulls_records.jsonl +6 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/insert_add_prefer_nulls_records.jsonl +6 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/insert_add_records.jsonl +6 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/update_update_ignore_nulls_records.jsonl +3 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/update_update_prefer_nulls_records.jsonl +3 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/update_update_records.jsonl +6 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/upsert_add_ignore_nulls_records.jsonl +3 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/upsert_add_prefer_nulls_records.jsonl +3 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/upsert_add_records.jsonl +2 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/upsert_update_ignore_nulls_records.jsonl +3 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/upsert_update_prefer_nulls_records.jsonl +3 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/upsert_update_records.jsonl +4 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/values.json +1 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/values_ignore_nulls.json +1 -0
- data/src/test/resources/org/embulk/output/kintone/task/mode/values_prefer_nulls.json +1 -0
- metadata +36 -3
- data/classpath/embulk-output-kintone-0.4.0.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11c7f1cbe588863b206b1581bf2ec89adeafeea4
|
4
|
+
data.tar.gz: c17ae7651f3409a6e51999e65233a96da2d87bf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e1bc2fe10bc224c643d88c06a37a19bfe4849fb46318fede913ef3a3923e1315ce48b78aea8bbdcc5ea9a5b4760058776c569e8acedf8f02691b80b330c5657
|
7
|
+
data.tar.gz: 9261603e49b45d2c8b72bf013d2995057293dd7f98ae0588f4dfa2f7e962b0ba2eac70990cdd7658eedf72a5caabd9cbb8f3135bc80cb91a7d250706c06081b4
|
data/.github/workflows/ci.yml
CHANGED
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -8,19 +8,22 @@ kintone output plugin for Embulk stores app records from kintone.
|
|
8
8
|
|
9
9
|
## Configuration
|
10
10
|
|
11
|
-
- **domain**: kintone domain(FQDN) e.g. devfoo.cybozu.com (string, required)
|
11
|
+
- **domain**: kintone domain (FQDN) e.g. devfoo.cybozu.com (string, required)
|
12
12
|
- **username**: kintone username (string, optional)
|
13
13
|
- **password**: kintone password (string, optional)
|
14
14
|
- **token**: kintone app token. Username and password or token must be configured. If all of them are provided, this plugin uses username and password (string, optional)
|
15
15
|
- **app_id**: kintone app id (integer, required)
|
16
|
-
- **basic_auth_username**:
|
17
|
-
- **basic_auth_password**:
|
16
|
+
- **basic_auth_username**: kintone basic auth username Please see kintone basic auth [here](https://jp.cybozu.help/general/en/admin/list_security/list_ip_basic/basic_auth.html) (string, optional)
|
17
|
+
- **basic_auth_password**: kintone basic auth password (string, optional)
|
18
18
|
- **guest_space_id**: kintone app belongs to guest space, guest space id is required. (integer, optional)
|
19
19
|
- **mode**: kintone mode (string, required)
|
20
|
-
- **update_key**:
|
20
|
+
- **update_key**: Column name to set update key (string, required if mode is update or upsert)
|
21
|
+
- **prefer_nulls**: Whether to set fields to null instead of default value of type when column is null (boolean, default is `false`)
|
22
|
+
- **ignore_nulls**: Whether to completely ignore fields when column is null (boolean, default is `false`)
|
21
23
|
- **column_options** advanced: a key-value pairs where key is a column name and value is options for the column.
|
22
24
|
- **field_code**: field code (string, required)
|
23
|
-
- **type**: field type (string, required)
|
25
|
+
- **type**: field type (string, required). See [this page](https://cybozu.dev/ja/kintone/docs/overview/field-types/#field-type-update) for list of available types. However, following types are not yet supported
|
26
|
+
- `USER_SELECT`, `ORGANIZATION_SELECT`, `GROUP_SELECT`, `FILE`, `SUBTABLE`
|
24
27
|
- **timezone**: timezone to convert into `date` (string, default is `UTC`)
|
25
28
|
- **val_sep**: Used to specify multiple checkbox values (string, default is `,`)
|
26
29
|
|
@@ -43,7 +46,6 @@ out:
|
|
43
46
|
date_time: {field_code: "datetime", type: "DATETIME"}
|
44
47
|
```
|
45
48
|
|
46
|
-
|
47
49
|
## Build
|
48
50
|
|
49
51
|
```
|
data/build.gradle
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
plugins {
|
2
2
|
id "com.jfrog.bintray" version "1.1"
|
3
3
|
id "com.github.jruby-gradle.base" version "1.5.0"
|
4
|
-
id "com.github.johnrengelman.shadow" version "
|
4
|
+
id "com.github.johnrengelman.shadow" version "6.1.0" apply false
|
5
5
|
id "java"
|
6
6
|
id "checkstyle"
|
7
7
|
id "com.palantir.git-version" version "0.12.3"
|
@@ -12,9 +12,6 @@ repositories {
|
|
12
12
|
mavenCentral()
|
13
13
|
jcenter()
|
14
14
|
}
|
15
|
-
configurations {
|
16
|
-
provided
|
17
|
-
}
|
18
15
|
|
19
16
|
version = {
|
20
17
|
def vd = versionDetails()
|
@@ -29,26 +26,23 @@ version = {
|
|
29
26
|
sourceCompatibility = 1.8
|
30
27
|
targetCompatibility = 1.8
|
31
28
|
|
32
|
-
shadowJar {
|
33
|
-
exclude "org/embulk/plugin/**"
|
34
|
-
relocate "com.fasterxml.jackson", "embulk.kintone.com.fasterxml.jackson"
|
35
|
-
}
|
36
|
-
|
37
29
|
dependencies {
|
38
|
-
|
39
|
-
|
40
|
-
compile "com.kintone:kintone-java-client:1.0.2"
|
30
|
+
compileOnly "org.embulk:embulk-core:0.9.23"
|
31
|
+
implementation project(path: ":shadow-kintone-java-client", configuration: "shadow")
|
41
32
|
|
42
|
-
|
43
|
-
|
33
|
+
testImplementation "junit:junit:4.+"
|
34
|
+
testImplementation "org.embulk:embulk-test:0.9.23"
|
35
|
+
testImplementation "org.embulk:embulk-standards:0.9.23"
|
36
|
+
testImplementation "org.embulk:embulk-deps-buffer:0.9.23"
|
37
|
+
testImplementation "org.embulk:embulk-deps-config:0.9.23"
|
38
|
+
testImplementation "org.mockito:mockito-inline:4.11.0"
|
39
|
+
testImplementation "ch.qos.logback:logback-classic:1.3.8"
|
40
|
+
testImplementation "net.jcip:jcip-annotations:1.0"
|
44
41
|
}
|
45
42
|
|
46
|
-
task classpath(type: Copy, dependsOn: ["jar"
|
43
|
+
task classpath(type: Copy, dependsOn: ["jar"]) {
|
47
44
|
doFirst { file("classpath").deleteDir() }
|
48
|
-
from (configurations.
|
49
|
-
+ configurations.shadow
|
50
|
-
- files(shadowJar.getIncludedDependencies())
|
51
|
-
+ files(shadowJar.archivePath))
|
45
|
+
from (configurations.runtimeClasspath + files(jar.archivePath))
|
52
46
|
into "classpath"
|
53
47
|
}
|
54
48
|
clean { delete "classpath" }
|
@@ -127,3 +121,8 @@ spotless {
|
|
127
121
|
toggleOffOn()
|
128
122
|
}
|
129
123
|
}
|
124
|
+
|
125
|
+
test {
|
126
|
+
forkEvery = 1
|
127
|
+
maxHeapSize = "1g"
|
128
|
+
}
|
Binary file
|
Binary file
|
@@ -1,5 +1,5 @@
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
2
2
|
distributionPath=wrapper/dists
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-bin.zip
|
4
4
|
zipStoreBase=GRADLE_USER_HOME
|
5
5
|
zipStorePath=wrapper/dists
|
data/settings.gradle
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
plugins {
|
2
|
+
id "java"
|
3
|
+
id "maven-publish"
|
4
|
+
id "com.github.johnrengelman.shadow"
|
5
|
+
}
|
6
|
+
|
7
|
+
repositories {
|
8
|
+
mavenCentral()
|
9
|
+
}
|
10
|
+
|
11
|
+
group = "${rootProject.group}"
|
12
|
+
version = "${rootProject.version}"
|
13
|
+
|
14
|
+
sourceCompatibility = 1.8
|
15
|
+
targetCompatibility = 1.8
|
16
|
+
|
17
|
+
configurations {
|
18
|
+
runtimeClasspath {
|
19
|
+
resolutionStrategy.activateDependencyLocking()
|
20
|
+
}
|
21
|
+
shadow {
|
22
|
+
resolutionStrategy.activateDependencyLocking()
|
23
|
+
transitive = false
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
dependencies {
|
28
|
+
implementation("com.kintone:kintone-java-client:1.4.0") {
|
29
|
+
exclude group: "org.slf4j", module: "slf4j-api"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
shadowJar {
|
34
|
+
relocate "com.fasterxml.jackson", "embulk.kintone.com.fasterxml.jackson"
|
35
|
+
}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
package org.embulk.output.kintone;
|
2
2
|
|
3
|
-
import java.util.Optional;
|
4
3
|
import org.embulk.config.Config;
|
5
4
|
import org.embulk.config.ConfigDefault;
|
6
5
|
import org.embulk.config.Task;
|
@@ -14,7 +13,7 @@ public interface KintoneColumnOption extends Task {
|
|
14
13
|
|
15
14
|
@Config("timezone")
|
16
15
|
@ConfigDefault("\"UTC\"")
|
17
|
-
|
16
|
+
String getTimezone();
|
18
17
|
|
19
18
|
@Config("val_sep")
|
20
19
|
@ConfigDefault("\",\"")
|
@@ -0,0 +1,368 @@
|
|
1
|
+
package org.embulk.output.kintone;
|
2
|
+
|
3
|
+
import com.kintone.client.model.record.CheckBoxFieldValue;
|
4
|
+
import com.kintone.client.model.record.DateFieldValue;
|
5
|
+
import com.kintone.client.model.record.DateTimeFieldValue;
|
6
|
+
import com.kintone.client.model.record.DropDownFieldValue;
|
7
|
+
import com.kintone.client.model.record.FieldValue;
|
8
|
+
import com.kintone.client.model.record.FileFieldValue;
|
9
|
+
import com.kintone.client.model.record.GroupSelectFieldValue;
|
10
|
+
import com.kintone.client.model.record.LinkFieldValue;
|
11
|
+
import com.kintone.client.model.record.MultiLineTextFieldValue;
|
12
|
+
import com.kintone.client.model.record.MultiSelectFieldValue;
|
13
|
+
import com.kintone.client.model.record.NumberFieldValue;
|
14
|
+
import com.kintone.client.model.record.OrganizationSelectFieldValue;
|
15
|
+
import com.kintone.client.model.record.RadioButtonFieldValue;
|
16
|
+
import com.kintone.client.model.record.RichTextFieldValue;
|
17
|
+
import com.kintone.client.model.record.SingleLineTextFieldValue;
|
18
|
+
import com.kintone.client.model.record.SubtableFieldValue;
|
19
|
+
import com.kintone.client.model.record.TimeFieldValue;
|
20
|
+
import com.kintone.client.model.record.UpdateKey;
|
21
|
+
import com.kintone.client.model.record.UserSelectFieldValue;
|
22
|
+
import java.math.BigDecimal;
|
23
|
+
import java.time.Instant;
|
24
|
+
import java.time.LocalDate;
|
25
|
+
import java.time.LocalTime;
|
26
|
+
import java.time.ZoneId;
|
27
|
+
import java.time.ZoneOffset;
|
28
|
+
import java.time.ZonedDateTime;
|
29
|
+
import java.util.Arrays;
|
30
|
+
import java.util.Collections;
|
31
|
+
import java.util.List;
|
32
|
+
import org.embulk.spi.time.Timestamp;
|
33
|
+
import org.msgpack.value.Value;
|
34
|
+
|
35
|
+
public enum KintoneColumnType {
|
36
|
+
SINGLE_LINE_TEXT {
|
37
|
+
@Override
|
38
|
+
public SingleLineTextFieldValue getFieldValue() {
|
39
|
+
return new SingleLineTextFieldValue(null);
|
40
|
+
}
|
41
|
+
|
42
|
+
@Override
|
43
|
+
public SingleLineTextFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
44
|
+
return new SingleLineTextFieldValue(value);
|
45
|
+
}
|
46
|
+
|
47
|
+
@Override
|
48
|
+
public void setUpdateKey(UpdateKey updateKey, String field) {
|
49
|
+
updateKey.setField(field);
|
50
|
+
}
|
51
|
+
|
52
|
+
@Override
|
53
|
+
public void setUpdateKey(UpdateKey updateKey, String field, FieldValue value) {
|
54
|
+
updateKey.setField(field).setValue(((SingleLineTextFieldValue) value).getValue());
|
55
|
+
}
|
56
|
+
},
|
57
|
+
MULTI_LINE_TEXT {
|
58
|
+
@Override
|
59
|
+
public MultiLineTextFieldValue getFieldValue() {
|
60
|
+
return new MultiLineTextFieldValue(null);
|
61
|
+
}
|
62
|
+
|
63
|
+
@Override
|
64
|
+
public MultiLineTextFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
65
|
+
return new MultiLineTextFieldValue(value);
|
66
|
+
}
|
67
|
+
},
|
68
|
+
RICH_TEXT {
|
69
|
+
@Override
|
70
|
+
public RichTextFieldValue getFieldValue() {
|
71
|
+
return new RichTextFieldValue(null);
|
72
|
+
}
|
73
|
+
|
74
|
+
@Override
|
75
|
+
public RichTextFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
76
|
+
return new RichTextFieldValue(value);
|
77
|
+
}
|
78
|
+
},
|
79
|
+
NUMBER {
|
80
|
+
@Override
|
81
|
+
public NumberFieldValue getFieldValue() {
|
82
|
+
return new NumberFieldValue(null);
|
83
|
+
}
|
84
|
+
|
85
|
+
@Override
|
86
|
+
public NumberFieldValue getFieldValue(boolean value, KintoneColumnOption option) {
|
87
|
+
return getFieldValue(value ? "1" : "0", option);
|
88
|
+
}
|
89
|
+
|
90
|
+
@Override
|
91
|
+
public NumberFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
92
|
+
return new NumberFieldValue(new BigDecimal(value.isEmpty() ? "0" : value));
|
93
|
+
}
|
94
|
+
|
95
|
+
@Override
|
96
|
+
public NumberFieldValue getFieldValue(Timestamp value, KintoneColumnOption option) {
|
97
|
+
return (NumberFieldValue) getFieldValue(value.getEpochSecond(), option);
|
98
|
+
}
|
99
|
+
|
100
|
+
@Override
|
101
|
+
public void setUpdateKey(UpdateKey updateKey, String field) {
|
102
|
+
updateKey.setField(field);
|
103
|
+
}
|
104
|
+
|
105
|
+
@Override
|
106
|
+
public void setUpdateKey(UpdateKey updateKey, String field, FieldValue value) {
|
107
|
+
updateKey.setField(field).setValue(((NumberFieldValue) value).getValue());
|
108
|
+
}
|
109
|
+
},
|
110
|
+
CHECK_BOX {
|
111
|
+
@Override
|
112
|
+
public CheckBoxFieldValue getFieldValue() {
|
113
|
+
return new CheckBoxFieldValue();
|
114
|
+
}
|
115
|
+
|
116
|
+
@Override
|
117
|
+
public CheckBoxFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
118
|
+
return new CheckBoxFieldValue(asList(value, option));
|
119
|
+
}
|
120
|
+
},
|
121
|
+
RADIO_BUTTON {
|
122
|
+
@Override
|
123
|
+
public RadioButtonFieldValue getFieldValue() {
|
124
|
+
return new RadioButtonFieldValue(null);
|
125
|
+
}
|
126
|
+
|
127
|
+
@Override
|
128
|
+
public RadioButtonFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
129
|
+
return new RadioButtonFieldValue(value);
|
130
|
+
}
|
131
|
+
},
|
132
|
+
MULTI_SELECT {
|
133
|
+
@Override
|
134
|
+
public MultiSelectFieldValue getFieldValue() {
|
135
|
+
return new MultiSelectFieldValue();
|
136
|
+
}
|
137
|
+
|
138
|
+
@Override
|
139
|
+
public MultiSelectFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
140
|
+
return new MultiSelectFieldValue(asList(value, option));
|
141
|
+
}
|
142
|
+
},
|
143
|
+
DROP_DOWN {
|
144
|
+
@Override
|
145
|
+
public DropDownFieldValue getFieldValue() {
|
146
|
+
return new DropDownFieldValue(null);
|
147
|
+
}
|
148
|
+
|
149
|
+
@Override
|
150
|
+
public DropDownFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
151
|
+
return new DropDownFieldValue(value);
|
152
|
+
}
|
153
|
+
},
|
154
|
+
USER_SELECT {
|
155
|
+
@Override
|
156
|
+
public UserSelectFieldValue getFieldValue() {
|
157
|
+
return new UserSelectFieldValue();
|
158
|
+
}
|
159
|
+
|
160
|
+
@Override
|
161
|
+
public UserSelectFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
162
|
+
throw new UnsupportedOperationException();
|
163
|
+
}
|
164
|
+
},
|
165
|
+
ORGANIZATION_SELECT {
|
166
|
+
@Override
|
167
|
+
public OrganizationSelectFieldValue getFieldValue() {
|
168
|
+
return new OrganizationSelectFieldValue();
|
169
|
+
}
|
170
|
+
|
171
|
+
@Override
|
172
|
+
public OrganizationSelectFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
173
|
+
throw new UnsupportedOperationException();
|
174
|
+
}
|
175
|
+
},
|
176
|
+
GROUP_SELECT {
|
177
|
+
@Override
|
178
|
+
public GroupSelectFieldValue getFieldValue() {
|
179
|
+
return new GroupSelectFieldValue();
|
180
|
+
}
|
181
|
+
|
182
|
+
@Override
|
183
|
+
public GroupSelectFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
184
|
+
throw new UnsupportedOperationException();
|
185
|
+
}
|
186
|
+
},
|
187
|
+
DATE {
|
188
|
+
@Override
|
189
|
+
public DateFieldValue getFieldValue() {
|
190
|
+
return new DateFieldValue(null);
|
191
|
+
}
|
192
|
+
|
193
|
+
@Override
|
194
|
+
public DateFieldValue getFieldValue(long value, KintoneColumnOption option) {
|
195
|
+
return getFieldValue(Timestamp.ofEpochSecond(value), option);
|
196
|
+
}
|
197
|
+
|
198
|
+
@Override
|
199
|
+
public DateFieldValue getFieldValue(double value, KintoneColumnOption option) {
|
200
|
+
return getFieldValue(Double.valueOf(value).longValue(), option);
|
201
|
+
}
|
202
|
+
|
203
|
+
@Override
|
204
|
+
public DateFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
205
|
+
return value.isEmpty()
|
206
|
+
? getFieldValue(EPOCH, option)
|
207
|
+
: new DateFieldValue(
|
208
|
+
LocalDate.parse(value)
|
209
|
+
.atStartOfDay(ZoneOffset.UTC)
|
210
|
+
.withZoneSameInstant(getZoneId(option))
|
211
|
+
.toLocalDate());
|
212
|
+
}
|
213
|
+
|
214
|
+
@Override
|
215
|
+
public DateFieldValue getFieldValue(Timestamp value, KintoneColumnOption option) {
|
216
|
+
return new DateFieldValue(value.getInstant().atZone(getZoneId(option)).toLocalDate());
|
217
|
+
}
|
218
|
+
},
|
219
|
+
TIME {
|
220
|
+
@Override
|
221
|
+
public TimeFieldValue getFieldValue() {
|
222
|
+
return new TimeFieldValue(null);
|
223
|
+
}
|
224
|
+
|
225
|
+
@Override
|
226
|
+
public TimeFieldValue getFieldValue(long value, KintoneColumnOption option) {
|
227
|
+
return getFieldValue(Timestamp.ofEpochSecond(value), option);
|
228
|
+
}
|
229
|
+
|
230
|
+
@Override
|
231
|
+
public TimeFieldValue getFieldValue(double value, KintoneColumnOption option) {
|
232
|
+
return getFieldValue(Double.valueOf(value).longValue(), option);
|
233
|
+
}
|
234
|
+
|
235
|
+
@Override
|
236
|
+
public TimeFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
237
|
+
return value.isEmpty()
|
238
|
+
? getFieldValue(EPOCH, option)
|
239
|
+
: new TimeFieldValue(
|
240
|
+
LocalTime.parse(value)
|
241
|
+
.atOffset(ZoneOffset.UTC)
|
242
|
+
.withOffsetSameInstant(getZoneOffset(option))
|
243
|
+
.toLocalTime());
|
244
|
+
}
|
245
|
+
|
246
|
+
@Override
|
247
|
+
public TimeFieldValue getFieldValue(Timestamp value, KintoneColumnOption option) {
|
248
|
+
return new TimeFieldValue(value.getInstant().atZone(getZoneId(option)).toLocalTime());
|
249
|
+
}
|
250
|
+
},
|
251
|
+
DATETIME {
|
252
|
+
@Override
|
253
|
+
public DateTimeFieldValue getFieldValue() {
|
254
|
+
return new DateTimeFieldValue(null);
|
255
|
+
}
|
256
|
+
|
257
|
+
@Override
|
258
|
+
public DateTimeFieldValue getFieldValue(long value, KintoneColumnOption option) {
|
259
|
+
return getFieldValue(Timestamp.ofEpochSecond(value), option);
|
260
|
+
}
|
261
|
+
|
262
|
+
@Override
|
263
|
+
public DateTimeFieldValue getFieldValue(double value, KintoneColumnOption option) {
|
264
|
+
return getFieldValue(Double.valueOf(value).longValue(), option);
|
265
|
+
}
|
266
|
+
|
267
|
+
@Override
|
268
|
+
public DateTimeFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
269
|
+
return value.isEmpty()
|
270
|
+
? getFieldValue(EPOCH, option)
|
271
|
+
: new DateTimeFieldValue(ZonedDateTime.parse(value));
|
272
|
+
}
|
273
|
+
|
274
|
+
@Override
|
275
|
+
public DateTimeFieldValue getFieldValue(Timestamp value, KintoneColumnOption option) {
|
276
|
+
return new DateTimeFieldValue(value.getInstant().atZone(ZoneOffset.UTC));
|
277
|
+
}
|
278
|
+
},
|
279
|
+
LINK {
|
280
|
+
@Override
|
281
|
+
public LinkFieldValue getFieldValue() {
|
282
|
+
return new LinkFieldValue(null);
|
283
|
+
}
|
284
|
+
|
285
|
+
@Override
|
286
|
+
public LinkFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
287
|
+
return new LinkFieldValue(value);
|
288
|
+
}
|
289
|
+
},
|
290
|
+
FILE {
|
291
|
+
@Override
|
292
|
+
public FileFieldValue getFieldValue() {
|
293
|
+
return new FileFieldValue();
|
294
|
+
}
|
295
|
+
|
296
|
+
@Override
|
297
|
+
public FileFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
298
|
+
throw new UnsupportedOperationException();
|
299
|
+
}
|
300
|
+
},
|
301
|
+
SUBTABLE {
|
302
|
+
@Override
|
303
|
+
public SubtableFieldValue getFieldValue() {
|
304
|
+
return new SubtableFieldValue();
|
305
|
+
}
|
306
|
+
|
307
|
+
@Override
|
308
|
+
public SubtableFieldValue getFieldValue(String value, KintoneColumnOption option) {
|
309
|
+
throw new UnsupportedOperationException();
|
310
|
+
}
|
311
|
+
};
|
312
|
+
private static final Timestamp EPOCH = Timestamp.ofInstant(Instant.EPOCH);
|
313
|
+
|
314
|
+
public static KintoneColumnType getType(
|
315
|
+
KintoneColumnOption option, KintoneColumnType defaultType) {
|
316
|
+
return option != null ? valueOf(option.getType()) : defaultType;
|
317
|
+
}
|
318
|
+
|
319
|
+
public abstract FieldValue getFieldValue();
|
320
|
+
|
321
|
+
public FieldValue getFieldValue(boolean value, KintoneColumnOption option) {
|
322
|
+
return getFieldValue(String.valueOf(value), option);
|
323
|
+
}
|
324
|
+
|
325
|
+
public FieldValue getFieldValue(long value, KintoneColumnOption option) {
|
326
|
+
return getFieldValue(String.valueOf(value), option);
|
327
|
+
}
|
328
|
+
|
329
|
+
public FieldValue getFieldValue(double value, KintoneColumnOption option) {
|
330
|
+
return getFieldValue(String.valueOf(value), option);
|
331
|
+
}
|
332
|
+
|
333
|
+
public abstract FieldValue getFieldValue(String value, KintoneColumnOption option);
|
334
|
+
|
335
|
+
public FieldValue getFieldValue(Timestamp value, KintoneColumnOption option) {
|
336
|
+
return getFieldValue(value.getInstant().toString(), option);
|
337
|
+
}
|
338
|
+
|
339
|
+
public FieldValue getFieldValue(Value value, KintoneColumnOption option) {
|
340
|
+
return getFieldValue(value.toJson(), option);
|
341
|
+
}
|
342
|
+
|
343
|
+
public void setUpdateKey(UpdateKey updateKey, String field) {
|
344
|
+
throw new UnsupportedOperationException();
|
345
|
+
}
|
346
|
+
|
347
|
+
public void setUpdateKey(UpdateKey updateKey, String field, FieldValue value) {
|
348
|
+
throw new UnsupportedOperationException();
|
349
|
+
}
|
350
|
+
|
351
|
+
private static List<String> asList(String value, KintoneColumnOption option) {
|
352
|
+
return value.isEmpty()
|
353
|
+
? Collections.emptyList()
|
354
|
+
: Arrays.asList(value.split(getValueSeparator(option), 0));
|
355
|
+
}
|
356
|
+
|
357
|
+
private static ZoneOffset getZoneOffset(KintoneColumnOption option) {
|
358
|
+
return getZoneId(option).getRules().getOffset(Instant.EPOCH);
|
359
|
+
}
|
360
|
+
|
361
|
+
private static ZoneId getZoneId(KintoneColumnOption option) {
|
362
|
+
return ZoneId.of(option != null ? option.getTimezone() : "UTC");
|
363
|
+
}
|
364
|
+
|
365
|
+
private static String getValueSeparator(KintoneColumnOption option) {
|
366
|
+
return option != null ? option.getValueSeparator() : ",";
|
367
|
+
}
|
368
|
+
}
|