embulk-input-adebis 0.0.1.pre1
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 +7 -0
- data/.gitignore +79 -0
- data/.idea/compiler.xml +9 -0
- data/.idea/encodings.xml +4 -0
- data/.idea/misc.xml +6 -0
- data/.idea/modules/embulk-input-adebis.main.iml +101 -0
- data/.idea/modules/embulk-input-adebis.test.iml +105 -0
- data/.idea/modules.xml +10 -0
- data/.idea/vcs.xml +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/build.gradle +102 -0
- data/classpath/apache-mime4j-core-0.7.2.jar +0 -0
- data/classpath/axiom-api-1.2.21.jar +0 -0
- data/classpath/axiom-dom-1.2.21.jar +0 -0
- data/classpath/axiom-impl-1.2.21.jar +0 -0
- data/classpath/axis2-adb-1.7.9.jar +0 -0
- data/classpath/axis2-jaxws-1.7.9.jar +0 -0
- data/classpath/axis2-kernel-1.7.9.jar +0 -0
- data/classpath/axis2-metadata-1.7.9.jar +0 -0
- data/classpath/axis2-saaj-1.7.9.jar +0 -0
- data/classpath/axis2-transport-http-1.7.9.jar +0 -0
- data/classpath/axis2-transport-local-1.7.9.jar +0 -0
- data/classpath/commons-codec-1.9.jar +0 -0
- data/classpath/commons-fileupload-1.3.3.jar +0 -0
- data/classpath/commons-httpclient-3.1.jar +0 -0
- data/classpath/commons-io-2.2.jar +0 -0
- data/classpath/commons-logging-1.2.jar +0 -0
- data/classpath/embulk-input-adebis-0.0.1.pre1.jar +0 -0
- data/classpath/geronimo-activation_1.1_spec-1.1.jar +0 -0
- data/classpath/geronimo-annotation_1.0_spec-1.1.jar +0 -0
- data/classpath/geronimo-javamail_1.4_spec-1.6.jar +0 -0
- data/classpath/geronimo-jaxws_2.2_spec-1.0.jar +0 -0
- data/classpath/geronimo-jta_1.1_spec-1.1.jar +0 -0
- data/classpath/geronimo-saaj_1.3_spec-1.0.1.jar +0 -0
- data/classpath/geronimo-stax-api_1.0_spec-1.0.1.jar +0 -0
- data/classpath/geronimo-ws-metadata_2.0_spec-1.1.2.jar +0 -0
- data/classpath/httpclient-4.5.3.jar +0 -0
- data/classpath/httpcore-4.4.6.jar +0 -0
- data/classpath/jaxb-api-2.2.6.jar +0 -0
- data/classpath/jaxb-impl-2.2.6.jar +0 -0
- data/classpath/jaxb-xjc-2.2.6.jar +0 -0
- data/classpath/jaxen-1.1.6.jar +0 -0
- data/classpath/jaxws-tools-2.1.3.jar +0 -0
- data/classpath/jsr311-api-1.1.1.jar +0 -0
- data/classpath/neethi-3.0.3.jar +0 -0
- data/classpath/servlet-api-2.3.jar +0 -0
- data/classpath/stax2-api-3.1.1.jar +0 -0
- data/classpath/woden-core-1.0M10.jar +0 -0
- data/classpath/woodstox-core-asl-4.2.0.jar +0 -0
- data/classpath/wsdl4j-1.6.2.jar +0 -0
- data/classpath/xalan-2.7.0.jar +0 -0
- data/classpath/xml-resolver-1.2.jar +0 -0
- data/classpath/xmlschema-core-2.2.1.jar +0 -0
- data/config/checkstyle/checkstyle.xml +128 -0
- data/config/checkstyle/default.xml +108 -0
- data/embulk-input-adebis.iml +13 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +5 -0
- data/gradlew +172 -0
- data/gradlew.bat +84 -0
- data/lib/embulk/input/adebis.rb +3 -0
- data/src/main/java/jp/ne/ebis/extreme/ws/AdServiceCallbackHandler.java +161 -0
- data/src/main/java/jp/ne/ebis/extreme/ws/AdServiceStub.java +22311 -0
- data/src/main/java/org/embulk/input/adebis/AdebisInputPlugin.java +157 -0
- data/src/main/java/org/embulk/input/adebis/operation/AbstractOperation.java +100 -0
- data/src/main/java/org/embulk/input/adebis/operation/AdConversionAttribute.java +273 -0
- data/src/main/java/org/embulk/input/adebis/operation/Operation.java +15 -0
- data/src/test/java/jp/ne/ebis/extreme/ws/AdServiceTest.java +380 -0
- data/src/test/java/org/embulk/input/adebis/TestAdebisInputPlugin.java +5 -0
- metadata +141 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
package org.embulk.input.adebis;
|
|
2
|
+
|
|
3
|
+
import java.util.List;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import com.google.common.base.Optional;
|
|
7
|
+
import com.google.common.base.Strings;
|
|
8
|
+
import org.embulk.config.*;
|
|
9
|
+
import org.embulk.input.adebis.operation.AdConversionAttribute;
|
|
10
|
+
import org.embulk.input.adebis.operation.Operation;
|
|
11
|
+
import org.embulk.spi.*;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
public class AdebisInputPlugin
|
|
15
|
+
implements InputPlugin
|
|
16
|
+
{
|
|
17
|
+
public interface PluginTask
|
|
18
|
+
extends Task
|
|
19
|
+
{
|
|
20
|
+
@Config("log_id")
|
|
21
|
+
public String getLogId();
|
|
22
|
+
|
|
23
|
+
@Config("log_argument")
|
|
24
|
+
public String getLogArgument();
|
|
25
|
+
|
|
26
|
+
@Config("api_key")
|
|
27
|
+
public String getApiKey();
|
|
28
|
+
|
|
29
|
+
@Config("operation")
|
|
30
|
+
public String getOperation();
|
|
31
|
+
|
|
32
|
+
@Config("condition")
|
|
33
|
+
@ConfigDefault("null")
|
|
34
|
+
public Optional<ConfigSource> getCondition();
|
|
35
|
+
|
|
36
|
+
@Config("retry_limit")
|
|
37
|
+
@ConfigDefault("5")
|
|
38
|
+
public Optional<Integer> getRetryLimit();
|
|
39
|
+
|
|
40
|
+
@Config("retry_limit_wait_sec")
|
|
41
|
+
@ConfigDefault("2")
|
|
42
|
+
public Optional<Integer> getRetryLimitWaitSec();
|
|
43
|
+
|
|
44
|
+
@Config("incremental")
|
|
45
|
+
@ConfigDefault("true")
|
|
46
|
+
public Boolean getIncremental();
|
|
47
|
+
|
|
48
|
+
@Config("last_record_time")
|
|
49
|
+
@ConfigDefault("null")
|
|
50
|
+
public Optional<String> getLastRecordTime();
|
|
51
|
+
|
|
52
|
+
@ConfigInject
|
|
53
|
+
BufferAllocator getBufferAllocator();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private Operation createOperation(String operationName) throws ConfigException {
|
|
57
|
+
switch (operationName) {
|
|
58
|
+
case "AdConversionAttribute":
|
|
59
|
+
return new AdConversionAttribute();
|
|
60
|
+
case "AdEffect":
|
|
61
|
+
case "AdEffectConversion":
|
|
62
|
+
case "AdEffectsIndirect":
|
|
63
|
+
default:
|
|
64
|
+
String msg = String.format("AdebisInputPlugin is not supported '%s'.", operationName);
|
|
65
|
+
throw new ConfigException(msg);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private void validateInputConfig(PluginTask task) throws ConfigException {
|
|
70
|
+
if (Strings.isNullOrEmpty(task.getLogId())) {
|
|
71
|
+
throw new ConfigException("log_id is empty.");
|
|
72
|
+
}
|
|
73
|
+
if (Strings.isNullOrEmpty(task.getLogArgument())) {
|
|
74
|
+
throw new ConfigException("log_argument is empty.");
|
|
75
|
+
}
|
|
76
|
+
if (Strings.isNullOrEmpty(task.getApiKey())) {
|
|
77
|
+
throw new ConfigException("api_key is empty.");
|
|
78
|
+
}
|
|
79
|
+
if (Strings.isNullOrEmpty(task.getOperation())) {
|
|
80
|
+
throw new ConfigException("operation is empty.");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Override
|
|
85
|
+
public ConfigDiff transaction(ConfigSource config,
|
|
86
|
+
InputPlugin.Control control)
|
|
87
|
+
{
|
|
88
|
+
PluginTask task = config.loadConfig(PluginTask.class);
|
|
89
|
+
|
|
90
|
+
validateInputConfig(task);
|
|
91
|
+
|
|
92
|
+
Schema schema = createOperation(task.getOperation()).buildSchema();
|
|
93
|
+
|
|
94
|
+
return resume(task.dump(), schema, 1, control);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@Override
|
|
98
|
+
public ConfigDiff resume(TaskSource taskSource,
|
|
99
|
+
Schema schema, int taskCount,
|
|
100
|
+
InputPlugin.Control control)
|
|
101
|
+
{
|
|
102
|
+
List<TaskReport> report = control.run(taskSource, schema, taskCount);
|
|
103
|
+
|
|
104
|
+
ConfigDiff configDiff = Exec.newConfigDiff();
|
|
105
|
+
if (report.size() > 0 && report.get(0).has("last_record_time")) {
|
|
106
|
+
configDiff.set("last_record_time", report.get(0).get(String.class, "last_record_time"));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return configDiff;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@Override
|
|
113
|
+
public void cleanup(TaskSource taskSource,
|
|
114
|
+
Schema schema, int taskCount,
|
|
115
|
+
List<TaskReport> successTaskReports)
|
|
116
|
+
{
|
|
117
|
+
// do nothing
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@Override
|
|
121
|
+
public TaskReport run(TaskSource taskSource,
|
|
122
|
+
Schema schema, int taskIndex,
|
|
123
|
+
PageOutput output)
|
|
124
|
+
{
|
|
125
|
+
PluginTask task = taskSource.loadTask(PluginTask.class);
|
|
126
|
+
BufferAllocator allocator = task.getBufferAllocator();
|
|
127
|
+
PageBuilder pageBuilder = new PageBuilder(allocator, schema, output);
|
|
128
|
+
|
|
129
|
+
Operation operation = createOperation(task.getOperation());
|
|
130
|
+
operation.setLastRecordTime(task.getLastRecordTime());
|
|
131
|
+
operation.setCredentials(
|
|
132
|
+
task.getLogId(),
|
|
133
|
+
task.getLogArgument(),
|
|
134
|
+
task.getApiKey()
|
|
135
|
+
);
|
|
136
|
+
Optional<ConfigSource> condition = task.getCondition();
|
|
137
|
+
if (condition.isPresent()) {
|
|
138
|
+
operation.loadCondition(condition.get());
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
operation.run(pageBuilder);
|
|
142
|
+
|
|
143
|
+
pageBuilder.finish();
|
|
144
|
+
Optional<String> lastRecordTime = operation.getLastRecordTime();
|
|
145
|
+
|
|
146
|
+
TaskReport report = Exec.newTaskReport();
|
|
147
|
+
report.set("last_record_time", lastRecordTime.or("") );
|
|
148
|
+
|
|
149
|
+
return report;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@Override
|
|
153
|
+
public ConfigDiff guess(ConfigSource config)
|
|
154
|
+
{
|
|
155
|
+
return Exec.newConfigDiff();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
package org.embulk.input.adebis.operation;
|
|
2
|
+
|
|
3
|
+
import com.google.common.base.Optional;
|
|
4
|
+
import org.embulk.config.Config;
|
|
5
|
+
import org.embulk.config.ConfigDefault;
|
|
6
|
+
import org.embulk.config.ConfigSource;
|
|
7
|
+
import org.embulk.config.Task;
|
|
8
|
+
import org.embulk.spi.time.Timestamp;
|
|
9
|
+
|
|
10
|
+
import java.time.Instant;
|
|
11
|
+
import java.time.LocalDateTime;
|
|
12
|
+
import java.time.ZoneOffset;
|
|
13
|
+
import java.time.format.DateTimeFormatter;
|
|
14
|
+
import java.time.format.DateTimeParseException;
|
|
15
|
+
import java.time.format.ResolverStyle;
|
|
16
|
+
|
|
17
|
+
public abstract class AbstractOperation implements Operation {
|
|
18
|
+
|
|
19
|
+
static protected int FETCH_LIMIT_AT_ONCE = 1000;
|
|
20
|
+
static protected DateTimeFormatter adebisDateFormat = DateTimeFormatter.ofPattern("uuuu/MM/dd").withResolverStyle(ResolverStyle.STRICT);
|
|
21
|
+
static protected DateTimeFormatter adebisDateTimeFormat = DateTimeFormatter.ofPattern("uuuu/MM/dd HH:mm:ss").withResolverStyle(ResolverStyle.STRICT);
|
|
22
|
+
static protected DateTimeFormatter embulkDateTimeFormat = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss").withResolverStyle(ResolverStyle.STRICT);
|
|
23
|
+
|
|
24
|
+
public interface Condition extends Task {
|
|
25
|
+
@Config("start_date")
|
|
26
|
+
@ConfigDefault("null")
|
|
27
|
+
public Optional<String> getStartDate();
|
|
28
|
+
|
|
29
|
+
@Config("end_date")
|
|
30
|
+
@ConfigDefault("null")
|
|
31
|
+
public Optional<String> getEndDate();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
protected String logId;
|
|
35
|
+
protected String logArgument;
|
|
36
|
+
protected String apiKey;
|
|
37
|
+
|
|
38
|
+
protected Condition condition;
|
|
39
|
+
protected Optional<String> last_record_time;
|
|
40
|
+
|
|
41
|
+
public Timestamp toTimestamp(String t) {
|
|
42
|
+
try {
|
|
43
|
+
Instant instant = LocalDateTime.parse(t, adebisDateTimeFormat).toInstant(ZoneOffset.UTC);
|
|
44
|
+
return Timestamp.ofInstant(instant);
|
|
45
|
+
} catch (DateTimeParseException e) {
|
|
46
|
+
e.printStackTrace();
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void loadCondition(ConfigSource config) {
|
|
52
|
+
setCondition(config.loadConfig(Condition.class));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public void setCredentials(String logId, String logArgument, String apiKey){
|
|
56
|
+
setLogId(logId);
|
|
57
|
+
setLogArgument(logArgument);
|
|
58
|
+
setApiKey(apiKey);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public String getLogId() {
|
|
62
|
+
return logId;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public void setLogId(String logId) {
|
|
66
|
+
this.logId = logId;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public String getLogArgument() {
|
|
70
|
+
return logArgument;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public void setLogArgument(String logArgument) {
|
|
74
|
+
this.logArgument = logArgument;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public String getApiKey() {
|
|
78
|
+
return apiKey;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public void setApiKey(String apiKey) {
|
|
82
|
+
this.apiKey = apiKey;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public Condition getCondition() {
|
|
86
|
+
return condition;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public void setCondition(Condition condition) {
|
|
90
|
+
this.condition = condition;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public Optional<String> getLastRecordTime() {
|
|
94
|
+
return last_record_time;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public void setLastRecordTime(Optional<String> last_record_time) {
|
|
98
|
+
this.last_record_time = last_record_time;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
package org.embulk.input.adebis.operation;
|
|
2
|
+
|
|
3
|
+
import com.google.common.base.Optional;
|
|
4
|
+
import jp.ne.ebis.extreme.ws.AdServiceStub;
|
|
5
|
+
import org.apache.axis2.AxisFault;
|
|
6
|
+
import org.embulk.config.Config;
|
|
7
|
+
import org.embulk.config.ConfigDefault;
|
|
8
|
+
import org.embulk.config.Task;
|
|
9
|
+
import org.embulk.spi.Column;
|
|
10
|
+
import org.embulk.spi.PageBuilder;
|
|
11
|
+
import org.embulk.spi.Schema;
|
|
12
|
+
import org.embulk.spi.type.Types;
|
|
13
|
+
|
|
14
|
+
import java.rmi.RemoteException;
|
|
15
|
+
import java.time.LocalDate;
|
|
16
|
+
import java.time.LocalDateTime;
|
|
17
|
+
import java.util.List;
|
|
18
|
+
|
|
19
|
+
public class AdConversionAttribute extends AbstractOperation {
|
|
20
|
+
public interface Condition extends Task {
|
|
21
|
+
@Config("start_date")
|
|
22
|
+
@ConfigDefault("null")
|
|
23
|
+
public Optional<String> getStartDate();
|
|
24
|
+
|
|
25
|
+
@Config("end_date")
|
|
26
|
+
@ConfigDefault("null")
|
|
27
|
+
public Optional<String> getEndDate();
|
|
28
|
+
|
|
29
|
+
@Config("ad_group1_ids")
|
|
30
|
+
@ConfigDefault("null")
|
|
31
|
+
public Optional<List<Integer>> getAdGroup1Ids();
|
|
32
|
+
|
|
33
|
+
@Config("ad_group2_ids")
|
|
34
|
+
@ConfigDefault("null")
|
|
35
|
+
public Optional<List<Integer>> getAdGroup2Ids();
|
|
36
|
+
|
|
37
|
+
@Config("media_ids")
|
|
38
|
+
@ConfigDefault("null")
|
|
39
|
+
public Optional<List<Integer>> getMediaIds();
|
|
40
|
+
|
|
41
|
+
@Config("ad_ids")
|
|
42
|
+
@ConfigDefault("null")
|
|
43
|
+
public Optional<List<String>> getAdIds();
|
|
44
|
+
|
|
45
|
+
@Config("terminal_types")
|
|
46
|
+
@ConfigDefault("null")
|
|
47
|
+
public Optional<List<Integer>> getTerminalTypes();
|
|
48
|
+
|
|
49
|
+
@Config("keyword")
|
|
50
|
+
@ConfigDefault("null")
|
|
51
|
+
public Optional<String> getKeyword();
|
|
52
|
+
|
|
53
|
+
@Config("conversion_ids")
|
|
54
|
+
@ConfigDefault("null")
|
|
55
|
+
public Optional<List<Integer>> getConversionIds();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
public void run(PageBuilder pageBuilder) {
|
|
60
|
+
Schema schema = pageBuilder.getSchema();
|
|
61
|
+
AdServiceStub stub;
|
|
62
|
+
try {
|
|
63
|
+
stub = new AdServiceStub();
|
|
64
|
+
} catch (AxisFault axisFault) {
|
|
65
|
+
axisFault.printStackTrace();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
LocalDate startDate = LocalDate.parse(condition.getStartDate().get(), adebisDateFormat);
|
|
70
|
+
LocalDate endDate = LocalDate.parse(condition.getEndDate().get(), adebisDateFormat);
|
|
71
|
+
LocalDateTime lastRecordTime, newestRecordTime;
|
|
72
|
+
|
|
73
|
+
if(getLastRecordTime().isPresent())
|
|
74
|
+
lastRecordTime = LocalDateTime.parse(getLastRecordTime().get(), embulkDateTimeFormat);
|
|
75
|
+
else
|
|
76
|
+
lastRecordTime = startDate.atStartOfDay();
|
|
77
|
+
|
|
78
|
+
if(lastRecordTime.isAfter(startDate.atStartOfDay())){
|
|
79
|
+
startDate = lastRecordTime.toLocalDate();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
AdServiceStub.GetAdConversionAttributes params = new AdServiceStub.GetAdConversionAttributes();
|
|
83
|
+
AdServiceStub.AdConversionAttributeCondition cond = new AdServiceStub.AdConversionAttributeCondition();
|
|
84
|
+
|
|
85
|
+
// Build Header
|
|
86
|
+
AdServiceStub.HoteiAuthHeader header = new AdServiceStub.HoteiAuthHeader();
|
|
87
|
+
AdServiceStub.HoteiAuthHeaderE headerE = new AdServiceStub.HoteiAuthHeaderE();
|
|
88
|
+
header.setLogId(getLogId());
|
|
89
|
+
header.setLogArgument(getLogArgument());
|
|
90
|
+
header.setApiKey(getApiKey());
|
|
91
|
+
headerE.setHoteiAuthHeader(header);
|
|
92
|
+
|
|
93
|
+
// Build condition
|
|
94
|
+
cond.setStartDate(startDate.format(adebisDateFormat));
|
|
95
|
+
cond.setEndDate(endDate.format(adebisDateFormat));
|
|
96
|
+
|
|
97
|
+
// Build parameter
|
|
98
|
+
params.setAdConversionAttributeCondition(cond);
|
|
99
|
+
|
|
100
|
+
int offset = 0, limit = FETCH_LIMIT_AT_ONCE;
|
|
101
|
+
params.setLimit(limit);
|
|
102
|
+
AdServiceStub.GetAdConversionAttributesResponse response;
|
|
103
|
+
|
|
104
|
+
newestRecordTime = lastRecordTime;
|
|
105
|
+
while(true) {
|
|
106
|
+
params.setOffset(offset);
|
|
107
|
+
try {
|
|
108
|
+
response = stub.getAdConversionAttributes(params, headerE);
|
|
109
|
+
} catch (RemoteException e) {
|
|
110
|
+
e.printStackTrace();
|
|
111
|
+
return;
|
|
112
|
+
} catch (NullPointerException e) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
AdServiceStub.AdConversionAttribute[] results = response.get_return();
|
|
117
|
+
if (results != null) offset += limit;
|
|
118
|
+
else break;
|
|
119
|
+
for (AdServiceStub.AdConversionAttribute record : results) {
|
|
120
|
+
Boolean isExcluded = false;
|
|
121
|
+
for (Column c : schema.getColumns()) {
|
|
122
|
+
switch (c.getName()) {
|
|
123
|
+
case "amount":
|
|
124
|
+
if (record.isAmountSpecified()) pageBuilder.setLong(c, record.getAmount());
|
|
125
|
+
else pageBuilder.setNull(c);
|
|
126
|
+
break;
|
|
127
|
+
case "conversionDate":
|
|
128
|
+
if (record.isConversionDateSpecified()) {
|
|
129
|
+
String conversionDate = record.getConversionDate();
|
|
130
|
+
LocalDateTime recordTime = LocalDateTime.parse(conversionDate, adebisDateTimeFormat);
|
|
131
|
+
if (recordTime.isAfter(lastRecordTime)) {
|
|
132
|
+
pageBuilder.setTimestamp(c, toTimestamp(conversionDate));
|
|
133
|
+
if (recordTime.isAfter(newestRecordTime))
|
|
134
|
+
newestRecordTime = recordTime;
|
|
135
|
+
} else {
|
|
136
|
+
isExcluded = true;
|
|
137
|
+
}
|
|
138
|
+
} else pageBuilder.setNull(c);
|
|
139
|
+
break;
|
|
140
|
+
case "conversionId":
|
|
141
|
+
if (record.isConversionIdSpecified()) pageBuilder.setLong(c, record.getConversionId());
|
|
142
|
+
else pageBuilder.setNull(c);
|
|
143
|
+
break;
|
|
144
|
+
case "directAd":
|
|
145
|
+
if (record.isDirectAdSpecified()) pageBuilder.setString(c, record.getDirectAd());
|
|
146
|
+
else pageBuilder.setNull(c);
|
|
147
|
+
break;
|
|
148
|
+
case "firstAd":
|
|
149
|
+
if (record.isFirstAdSpecified()) pageBuilder.setString(c, record.getFirstAd());
|
|
150
|
+
else pageBuilder.setNull(c);
|
|
151
|
+
break;
|
|
152
|
+
case "firstAdDate":
|
|
153
|
+
if (record.isFirstAdDateSpecified()) {
|
|
154
|
+
String fistAdDateSpecified = record.getFirstAdDate();
|
|
155
|
+
pageBuilder.setTimestamp(c, toTimestamp(fistAdDateSpecified));
|
|
156
|
+
} else pageBuilder.setNull(c);
|
|
157
|
+
break;
|
|
158
|
+
case "indirectAd2":
|
|
159
|
+
if (record.isIndirectAd2Specified()) pageBuilder.setString(c, record.getIndirectAd2());
|
|
160
|
+
else pageBuilder.setNull(c);
|
|
161
|
+
break;
|
|
162
|
+
case "indirectAd3":
|
|
163
|
+
if (record.isIndirectAd3Specified()) pageBuilder.setString(c, record.getIndirectAd3());
|
|
164
|
+
else pageBuilder.setNull(c);
|
|
165
|
+
break;
|
|
166
|
+
case "indirectAd4":
|
|
167
|
+
if (record.isIndirectAd4Specified()) pageBuilder.setString(c, record.getIndirectAd4());
|
|
168
|
+
else pageBuilder.setNull(c);
|
|
169
|
+
break;
|
|
170
|
+
case "indirectAd5":
|
|
171
|
+
if (record.isIndirectAd5Specified()) pageBuilder.setString(c, record.getIndirectAd5());
|
|
172
|
+
else pageBuilder.setNull(c);
|
|
173
|
+
break;
|
|
174
|
+
case "indirectAd6":
|
|
175
|
+
if (record.isIndirectAd6Specified()) pageBuilder.setString(c, record.getIndirectAd6());
|
|
176
|
+
else pageBuilder.setNull(c);
|
|
177
|
+
break;
|
|
178
|
+
case "indirectAd7":
|
|
179
|
+
if (record.isIndirectAd7Specified()) pageBuilder.setString(c, record.getIndirectAd7());
|
|
180
|
+
else pageBuilder.setNull(c);
|
|
181
|
+
break;
|
|
182
|
+
case "indirectAd8":
|
|
183
|
+
if (record.isIndirectAd8Specified()) pageBuilder.setString(c, record.getIndirectAd8());
|
|
184
|
+
else pageBuilder.setNull(c);
|
|
185
|
+
break;
|
|
186
|
+
case "indirectAd9":
|
|
187
|
+
if (record.isIndirectAd9Specified()) pageBuilder.setString(c, record.getIndirectAd9());
|
|
188
|
+
else pageBuilder.setNull(c);
|
|
189
|
+
break;
|
|
190
|
+
case "indirectAd10":
|
|
191
|
+
if (record.isIndirectAd10Specified()) pageBuilder.setString(c, record.getIndirectAd10());
|
|
192
|
+
else pageBuilder.setNull(c);
|
|
193
|
+
break;
|
|
194
|
+
case "latencyTime":
|
|
195
|
+
if (record.isLatencyTimeSpecified()) pageBuilder.setLong(c, record.getLatencyTime());
|
|
196
|
+
else pageBuilder.setNull(c);
|
|
197
|
+
break;
|
|
198
|
+
case "memberName":
|
|
199
|
+
if (record.isMemberNameSpecified()) pageBuilder.setString(c, record.getMemberName());
|
|
200
|
+
else pageBuilder.setNull(c);
|
|
201
|
+
break;
|
|
202
|
+
case "other1":
|
|
203
|
+
if (record.isOther1Specified()) pageBuilder.setString(c, record.getOther1());
|
|
204
|
+
else pageBuilder.setNull(c);
|
|
205
|
+
break;
|
|
206
|
+
case "other2":
|
|
207
|
+
if (record.isOther2Specified()) pageBuilder.setString(c, record.getOther2());
|
|
208
|
+
else pageBuilder.setNull(c);
|
|
209
|
+
break;
|
|
210
|
+
case "other3":
|
|
211
|
+
if (record.isOther3Specified()) pageBuilder.setString(c, record.getOther3());
|
|
212
|
+
else pageBuilder.setNull(c);
|
|
213
|
+
break;
|
|
214
|
+
case "other4":
|
|
215
|
+
if (record.isOther4Specified()) pageBuilder.setString(c, record.getOther4());
|
|
216
|
+
else pageBuilder.setNull(c);
|
|
217
|
+
break;
|
|
218
|
+
case "other5":
|
|
219
|
+
if (record.isOther5Specified()) pageBuilder.setString(c, record.getOther5());
|
|
220
|
+
else pageBuilder.setNull(c);
|
|
221
|
+
break;
|
|
222
|
+
case "terminalType":
|
|
223
|
+
if (record.isTerminalTypeSpecified()) pageBuilder.setLong(c, record.getTerminalType());
|
|
224
|
+
else pageBuilder.setNull(c);
|
|
225
|
+
break;
|
|
226
|
+
case "userId":
|
|
227
|
+
if (record.isUserIdSpecified()) pageBuilder.setString(c, record.getUserId());
|
|
228
|
+
else pageBuilder.setNull(c);
|
|
229
|
+
break;
|
|
230
|
+
default:
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
if (isExcluded) break;
|
|
234
|
+
}
|
|
235
|
+
if (isExcluded)
|
|
236
|
+
pageBuilder.flush();
|
|
237
|
+
else
|
|
238
|
+
pageBuilder.addRecord();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
setLastRecordTime(Optional.of(newestRecordTime.format(embulkDateTimeFormat)));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
public Schema buildSchema() {
|
|
246
|
+
return Schema.builder()
|
|
247
|
+
.add("amount", Types.LONG)
|
|
248
|
+
.add("conversionDate", Types.TIMESTAMP)
|
|
249
|
+
.add("conversionId", Types.LONG)
|
|
250
|
+
.add("directAd", Types.STRING)
|
|
251
|
+
.add("firstAd", Types.STRING)
|
|
252
|
+
.add("firstAdDate", Types.TIMESTAMP)
|
|
253
|
+
.add("indirectAd2", Types.STRING)
|
|
254
|
+
.add("indirectAd3", Types.STRING)
|
|
255
|
+
.add("indirectAd4", Types.STRING)
|
|
256
|
+
.add("indirectAd5", Types.STRING)
|
|
257
|
+
.add("indirectAd6", Types.STRING)
|
|
258
|
+
.add("indirectAd7", Types.STRING)
|
|
259
|
+
.add("indirectAd8", Types.STRING)
|
|
260
|
+
.add("indirectAd9", Types.STRING)
|
|
261
|
+
.add("indirectAd10", Types.STRING)
|
|
262
|
+
.add("latencyTime", Types.LONG)
|
|
263
|
+
.add("memberName", Types.STRING)
|
|
264
|
+
.add("other1", Types.STRING)
|
|
265
|
+
.add("other2", Types.STRING)
|
|
266
|
+
.add("other3", Types.STRING)
|
|
267
|
+
.add("other4", Types.STRING)
|
|
268
|
+
.add("other5", Types.STRING)
|
|
269
|
+
.add("terminalType", Types.LONG)
|
|
270
|
+
.add("userId", Types.STRING)
|
|
271
|
+
.build();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package org.embulk.input.adebis.operation;
|
|
2
|
+
|
|
3
|
+
import com.google.common.base.Optional;
|
|
4
|
+
import org.embulk.config.ConfigSource;
|
|
5
|
+
import org.embulk.spi.PageBuilder;
|
|
6
|
+
import org.embulk.spi.Schema;
|
|
7
|
+
|
|
8
|
+
public interface Operation {
|
|
9
|
+
void setCredentials(String logId, String logArgment, String apiKey);
|
|
10
|
+
Optional<String> getLastRecordTime();
|
|
11
|
+
void setLastRecordTime(Optional<String> lastRecordTime);
|
|
12
|
+
void loadCondition(ConfigSource config);
|
|
13
|
+
Schema buildSchema();
|
|
14
|
+
void run(PageBuilder pageBuilder);
|
|
15
|
+
}
|