embulk-input-adebis 0.0.1.pre1 → 0.0.1.pre3
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/.gitmodules +3 -0
- data/.idea/artifacts/embulk_input_adebis_client_jar.xml +8 -0
- data/.idea/compiler.xml +34 -0
- data/.idea/misc.xml +1 -1
- data/.idea/modules.xml +44 -1
- data/.idea/modules/adebis-api-client/ad/jp.ne.ebis.extreme.ws.service.ad.iml +13 -0
- data/.idea/modules/adebis-api-client/ad/jp.ne.ebis.extreme.ws.service.ad.main.iml +34 -0
- data/.idea/modules/adebis-api-client/ad/jp.ne.ebis.extreme.ws.service.ad.test.iml +57 -0
- data/.idea/modules/adebis-api-client/adebislink/jp.ne.ebis.extreme.ws.service.adebislink.iml +13 -0
- data/.idea/modules/adebis-api-client/adebislink/jp.ne.ebis.extreme.ws.service.adebislink.main.iml +34 -0
- data/.idea/modules/adebis-api-client/adebislink/jp.ne.ebis.extreme.ws.service.adebislink.test.iml +57 -0
- data/.idea/modules/adebis-api-client/adgroup1management/jp.ne.ebis.extreme.ws.service.adgroup1management.iml +13 -0
- data/.idea/modules/adebis-api-client/adgroup1management/jp.ne.ebis.extreme.ws.service.adgroup1management.main.iml +34 -0
- data/.idea/modules/adebis-api-client/adgroup1management/jp.ne.ebis.extreme.ws.service.adgroup1management.test.iml +57 -0
- data/.idea/modules/adebis-api-client/adgroup2management/jp.ne.ebis.extreme.ws.service.adgroup2management.iml +13 -0
- data/.idea/modules/adebis-api-client/adgroup2management/jp.ne.ebis.extreme.ws.service.adgroup2management.main.iml +34 -0
- data/.idea/modules/adebis-api-client/adgroup2management/jp.ne.ebis.extreme.ws.service.adgroup2management.test.iml +57 -0
- data/.idea/modules/adebis-api-client/admanagement/jp.ne.ebis.extreme.ws.service.admanagement.iml +13 -0
- data/.idea/modules/adebis-api-client/admanagement/jp.ne.ebis.extreme.ws.service.admanagement.main.iml +34 -0
- data/.idea/modules/adebis-api-client/admanagement/jp.ne.ebis.extreme.ws.service.admanagement.test.iml +57 -0
- data/.idea/modules/adebis-api-client/embulk-input-adebis.adebis-api-client.iml +12 -0
- data/.idea/modules/adebis-api-client/impressioncostmanagement/jp.ne.ebis.extreme.ws.service.impressioncostmanagement.iml +13 -0
- data/.idea/modules/adebis-api-client/impressioncostmanagement/jp.ne.ebis.extreme.ws.service.impressioncostmanagement.main.iml +34 -0
- data/.idea/modules/adebis-api-client/impressioncostmanagement/jp.ne.ebis.extreme.ws.service.impressioncostmanagement.test.iml +57 -0
- data/.idea/modules/adebis-api-client/lpo/jp.ne.ebis.extreme.ws.service.lpo.iml +13 -0
- data/.idea/modules/adebis-api-client/lpo/jp.ne.ebis.extreme.ws.service.lpo.main.iml +34 -0
- data/.idea/modules/adebis-api-client/lpo/jp.ne.ebis.extreme.ws.service.lpo.test.iml +57 -0
- data/.idea/modules/adebis-api-client/lpoabtestmanagement/jp.ne.ebis.extreme.ws.service.lpoabtestmanagement.iml +13 -0
- data/.idea/modules/adebis-api-client/lpoabtestmanagement/jp.ne.ebis.extreme.ws.service.lpoabtestmanagement.main.iml +34 -0
- data/.idea/modules/adebis-api-client/lpoabtestmanagement/jp.ne.ebis.extreme.ws.service.lpoabtestmanagement.test.iml +57 -0
- data/.idea/modules/adebis-api-client/lpoareatargetingmanagement/jp.ne.ebis.extreme.ws.service.lpoareatargetingmanagement.iml +13 -0
- data/.idea/modules/adebis-api-client/lpoareatargetingmanagement/jp.ne.ebis.extreme.ws.service.lpoareatargetingmanagement.main.iml +34 -0
- data/.idea/modules/adebis-api-client/lpoareatargetingmanagement/jp.ne.ebis.extreme.ws.service.lpoareatargetingmanagement.test.iml +57 -0
- data/.idea/modules/adebis-api-client/mediamanagement/jp.ne.ebis.extreme.ws.service.mediamanagement.iml +13 -0
- data/.idea/modules/adebis-api-client/mediamanagement/jp.ne.ebis.extreme.ws.service.mediamanagement.main.iml +34 -0
- data/.idea/modules/adebis-api-client/mediamanagement/jp.ne.ebis.extreme.ws.service.mediamanagement.test.iml +57 -0
- data/.idea/modules/adebis-api-client/seo/jp.ne.ebis.extreme.ws.service.seo.iml +13 -0
- data/.idea/modules/adebis-api-client/seo/jp.ne.ebis.extreme.ws.service.seo.main.iml +34 -0
- data/.idea/modules/adebis-api-client/seo/jp.ne.ebis.extreme.ws.service.seo.test.iml +57 -0
- data/.idea/modules/adebis-api-client/setup/jp.ne.ebis.extreme.ws.service.setup.iml +13 -0
- data/.idea/modules/adebis-api-client/setup/jp.ne.ebis.extreme.ws.service.setup.main.iml +34 -0
- data/.idea/modules/adebis-api-client/setup/jp.ne.ebis.extreme.ws.service.setup.test.iml +57 -0
- data/.idea/modules/adebis-api-client/system/jp.ne.ebis.extreme.ws.service.system.iml +13 -0
- data/.idea/modules/adebis-api-client/system/jp.ne.ebis.extreme.ws.service.system.main.iml +34 -0
- data/.idea/modules/adebis-api-client/system/jp.ne.ebis.extreme.ws.service.system.test.iml +57 -0
- data/.idea/modules/adebis-api-client/tagmanagement/jp.ne.ebis.extreme.ws.service.tagmanagement.iml +13 -0
- data/.idea/modules/adebis-api-client/tagmanagement/jp.ne.ebis.extreme.ws.service.tagmanagement.main.iml +34 -0
- data/.idea/modules/adebis-api-client/tagmanagement/jp.ne.ebis.extreme.ws.service.tagmanagement.test.iml +57 -0
- data/.idea/modules/embulk-input-adebis.client.iml +11 -0
- data/.idea/modules/embulk-input-adebis.iml +15 -0
- data/.idea/modules/embulk-input-adebis.main.iml +48 -5
- data/.idea/modules/embulk-input-adebis.test.iml +54 -5
- data/.idea/vcs.xml +1 -0
- data/build.gradle +16 -10
- data/diff.yml +2 -0
- data/embulk-input-adebis.iml +1 -1
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +2 -1
- data/gradlew +1 -1
- data/gradlew.bat +1 -1
- data/seed.yml +11 -0
- data/settings.gradle +6 -0
- data/src/main/java/org/embulk/input/adebis/AdebisInputPlugin.java +23 -2
- data/src/main/java/org/embulk/input/adebis/operation/AbstractOperation.java +68 -0
- data/src/main/java/org/embulk/input/adebis/operation/Ad.java +434 -0
- data/src/main/java/org/embulk/input/adebis/operation/AdConversionAttribute.java +23 -11
- data/src/main/java/org/embulk/input/adebis/operation/AdGroup1.java +136 -0
- data/src/main/java/org/embulk/input/adebis/operation/AdGroup2.java +136 -0
- data/src/main/java/org/embulk/input/adebis/operation/LpoDataForJson.java +9 -0
- data/src/main/java/org/embulk/input/adebis/operation/Media.java +135 -0
- data/src/main/java/org/embulk/input/adebis/operation/Operation.java +2 -0
- data/src/main/java/org/embulk/input/adebis/operation/UrlDataForJson.java +7 -0
- metadata +84 -14
- data/src/main/java/jp/ne/ebis/extreme/ws/AdServiceCallbackHandler.java +0 -161
- data/src/main/java/jp/ne/ebis/extreme/ws/AdServiceStub.java +0 -22311
- data/src/test/java/jp/ne/ebis/extreme/ws/AdServiceTest.java +0 -380
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
package org.embulk.input.adebis.operation;
|
|
2
2
|
|
|
3
3
|
import com.google.common.base.Optional;
|
|
4
|
-
import jp.ne.ebis.extreme.ws.
|
|
4
|
+
import jp.ne.ebis.extreme.ws.entity.xsd.AdConversionAttributeCondition;
|
|
5
|
+
import jp.ne.ebis.extreme.ws.entity.xsd.HoteiAuthHeader;
|
|
6
|
+
import jp.ne.ebis.extreme.ws.entity.xsd.HoteiAuthHeaderE;
|
|
7
|
+
import jp.ne.ebis.extreme.ws.service.AdService;
|
|
8
|
+
import jp.ne.ebis.extreme.ws.service.AdServiceStub;
|
|
9
|
+
import jp.ne.ebis.extreme.ws.service.GetAdConversionAttributes;
|
|
10
|
+
import jp.ne.ebis.extreme.ws.service.GetAdConversionAttributesResponse;
|
|
5
11
|
import org.apache.axis2.AxisFault;
|
|
6
12
|
import org.embulk.config.Config;
|
|
7
13
|
import org.embulk.config.ConfigDefault;
|
|
@@ -58,9 +64,9 @@ public class AdConversionAttribute extends AbstractOperation {
|
|
|
58
64
|
|
|
59
65
|
public void run(PageBuilder pageBuilder) {
|
|
60
66
|
Schema schema = pageBuilder.getSchema();
|
|
61
|
-
|
|
67
|
+
AdService adService;
|
|
62
68
|
try {
|
|
63
|
-
|
|
69
|
+
adService = new AdServiceStub();
|
|
64
70
|
} catch (AxisFault axisFault) {
|
|
65
71
|
axisFault.printStackTrace();
|
|
66
72
|
return;
|
|
@@ -79,12 +85,12 @@ public class AdConversionAttribute extends AbstractOperation {
|
|
|
79
85
|
startDate = lastRecordTime.toLocalDate();
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
GetAdConversionAttributes params = new GetAdConversionAttributes();
|
|
89
|
+
AdConversionAttributeCondition cond = new AdConversionAttributeCondition();
|
|
84
90
|
|
|
85
91
|
// Build Header
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
HoteiAuthHeader header = new HoteiAuthHeader();
|
|
93
|
+
HoteiAuthHeaderE headerE = new HoteiAuthHeaderE();
|
|
88
94
|
header.setLogId(getLogId());
|
|
89
95
|
header.setLogArgument(getLogArgument());
|
|
90
96
|
header.setApiKey(getApiKey());
|
|
@@ -99,13 +105,13 @@ public class AdConversionAttribute extends AbstractOperation {
|
|
|
99
105
|
|
|
100
106
|
int offset = 0, limit = FETCH_LIMIT_AT_ONCE;
|
|
101
107
|
params.setLimit(limit);
|
|
102
|
-
|
|
108
|
+
GetAdConversionAttributesResponse response;
|
|
103
109
|
|
|
104
110
|
newestRecordTime = lastRecordTime;
|
|
105
111
|
while(true) {
|
|
106
112
|
params.setOffset(offset);
|
|
107
113
|
try {
|
|
108
|
-
response =
|
|
114
|
+
response = adService.getAdConversionAttributes(params, headerE);
|
|
109
115
|
} catch (RemoteException e) {
|
|
110
116
|
e.printStackTrace();
|
|
111
117
|
return;
|
|
@@ -113,13 +119,18 @@ public class AdConversionAttribute extends AbstractOperation {
|
|
|
113
119
|
return;
|
|
114
120
|
}
|
|
115
121
|
|
|
116
|
-
|
|
122
|
+
jp.ne.ebis.extreme.ws.entity.xsd.AdConversionAttribute[] results = response.get_return();
|
|
117
123
|
if (results != null) offset += limit;
|
|
118
124
|
else break;
|
|
119
|
-
for (
|
|
125
|
+
for (jp.ne.ebis.extreme.ws.entity.xsd.AdConversionAttribute record : results) {
|
|
120
126
|
Boolean isExcluded = false;
|
|
121
127
|
for (Column c : schema.getColumns()) {
|
|
122
128
|
switch (c.getName()) {
|
|
129
|
+
case "createdAt":
|
|
130
|
+
long unixtime = System.currentTimeMillis() / 1000L;
|
|
131
|
+
org.embulk.spi.time.Timestamp timestamp = org.embulk.spi.time.Timestamp.ofEpochSecond(unixtime);
|
|
132
|
+
pageBuilder.setTimestamp(c, timestamp);
|
|
133
|
+
break;
|
|
123
134
|
case "amount":
|
|
124
135
|
if (record.isAmountSpecified()) pageBuilder.setLong(c, record.getAmount());
|
|
125
136
|
else pageBuilder.setNull(c);
|
|
@@ -244,6 +255,7 @@ public class AdConversionAttribute extends AbstractOperation {
|
|
|
244
255
|
|
|
245
256
|
public Schema buildSchema() {
|
|
246
257
|
return Schema.builder()
|
|
258
|
+
.add("createdAt", Types.TIMESTAMP)
|
|
247
259
|
.add("amount", Types.LONG)
|
|
248
260
|
.add("conversionDate", Types.TIMESTAMP)
|
|
249
261
|
.add("conversionId", Types.LONG)
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
package org.embulk.input.adebis.operation;
|
|
2
|
+
|
|
3
|
+
import com.google.common.base.Optional;
|
|
4
|
+
|
|
5
|
+
import jp.ne.ebis.extreme.ws.entity.xsd.HoteiAuthHeader;
|
|
6
|
+
import jp.ne.ebis.extreme.ws.entity.xsd.HoteiAuthHeaderE;
|
|
7
|
+
import jp.ne.ebis.extreme.ws.service.AdGroup1ManagementService;
|
|
8
|
+
import jp.ne.ebis.extreme.ws.service.AdGroup1ManagementServiceStub;
|
|
9
|
+
|
|
10
|
+
import jp.ne.ebis.extreme.ws.service.GetAdGroup1SResponse;
|
|
11
|
+
|
|
12
|
+
import org.apache.axis2.AxisFault;
|
|
13
|
+
import org.embulk.config.Config;
|
|
14
|
+
import org.embulk.config.ConfigDefault;
|
|
15
|
+
import org.embulk.config.Task;
|
|
16
|
+
import org.embulk.input.adebis.AdebisInputPlugin;
|
|
17
|
+
import org.embulk.spi.Column;
|
|
18
|
+
import org.embulk.spi.PageBuilder;
|
|
19
|
+
import org.embulk.spi.Schema;
|
|
20
|
+
import org.embulk.spi.type.Types;
|
|
21
|
+
|
|
22
|
+
import java.rmi.RemoteException;
|
|
23
|
+
import java.time.LocalDate;
|
|
24
|
+
import java.time.LocalDateTime;
|
|
25
|
+
import java.util.Date;
|
|
26
|
+
|
|
27
|
+
public class AdGroup1 extends AbstractOperation {
|
|
28
|
+
public int lastRecordId = 0;
|
|
29
|
+
|
|
30
|
+
public interface Condition extends Task {
|
|
31
|
+
//リクエストパラメータ無し
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public void run(PageBuilder pageBuilder) {
|
|
35
|
+
Schema schema = pageBuilder.getSchema();
|
|
36
|
+
AdGroup1ManagementService adGroup1ManagementService;
|
|
37
|
+
try {
|
|
38
|
+
adGroup1ManagementService = new AdGroup1ManagementServiceStub();
|
|
39
|
+
} catch (AxisFault axisFault) {
|
|
40
|
+
axisFault.printStackTrace();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//LocalDate startDate = LocalDate.parse(condition.getStartDate().get(), adebisDateFormat);
|
|
45
|
+
//LocalDate endDate = LocalDate.parse(condition.getEndDate().get(), adebisDateFormat);
|
|
46
|
+
LocalDateTime lastRecordTime, newestRecordTime;
|
|
47
|
+
//System.out.println(startDate);
|
|
48
|
+
//System.out.println(endDate);
|
|
49
|
+
|
|
50
|
+
if(getLastRecordTime().isPresent()) {
|
|
51
|
+
lastRecordTime = LocalDateTime.parse(getLastRecordTime().get(), embulkDateTimeFormat);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
//lastRecordTime = startDate.atStartOfDay();
|
|
55
|
+
lastRecordTime = LocalDateTime.now();
|
|
56
|
+
//lastRecordTime = Optional.of(lastRecordTime.format(embulkDateTimeFormat));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if(getLastRecordId().isPresent()) {
|
|
60
|
+
lastRecordId = Integer.parseInt(getLastRecordId().get());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//if(lastRecordTime.isAfter(startDate.atStartOfDay())) {
|
|
64
|
+
// startDate = lastRecordTime.toLocalDate();
|
|
65
|
+
//}
|
|
66
|
+
|
|
67
|
+
// Build Header
|
|
68
|
+
HoteiAuthHeader header = new HoteiAuthHeader();
|
|
69
|
+
HoteiAuthHeaderE headerE = new HoteiAuthHeaderE();
|
|
70
|
+
header.setLogId(getLogId());
|
|
71
|
+
header.setLogArgument(getLogArgument());
|
|
72
|
+
header.setApiKey(getApiKey());
|
|
73
|
+
headerE.setHoteiAuthHeader(header);
|
|
74
|
+
|
|
75
|
+
GetAdGroup1SResponse response;
|
|
76
|
+
|
|
77
|
+
newestRecordTime = lastRecordTime;
|
|
78
|
+
try {
|
|
79
|
+
response = adGroup1ManagementService.getAdGroup1S(headerE);
|
|
80
|
+
} catch (RemoteException e) {
|
|
81
|
+
e.printStackTrace();
|
|
82
|
+
return;
|
|
83
|
+
} catch (NullPointerException e) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
jp.ne.ebis.extreme.ws.entity.xsd.AdGroup1[] results = response.get_return();
|
|
88
|
+
for (jp.ne.ebis.extreme.ws.entity.xsd.AdGroup1 record : results) {
|
|
89
|
+
Boolean isExcluded = false;
|
|
90
|
+
int currentRecordId= record.getAdGroup1Id();
|
|
91
|
+
if ( ! record.isAdGroup1IdSpecified()) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (lastRecordId < currentRecordId) {
|
|
95
|
+
lastRecordId = currentRecordId;
|
|
96
|
+
} else {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
for (Column c : schema.getColumns()) {
|
|
100
|
+
switch (c.getName()) {
|
|
101
|
+
case "createdAt":
|
|
102
|
+
long unixtime = System.currentTimeMillis() / 1000L;
|
|
103
|
+
org.embulk.spi.time.Timestamp timestamp = org.embulk.spi.time.Timestamp.ofEpochSecond(unixtime);
|
|
104
|
+
pageBuilder.setTimestamp(c, timestamp);
|
|
105
|
+
break;
|
|
106
|
+
case "adGroup1Id":
|
|
107
|
+
if (record.isAdGroup1IdSpecified()) pageBuilder.setLong(c, record.getAdGroup1Id());
|
|
108
|
+
else pageBuilder.setNull(c);
|
|
109
|
+
break;
|
|
110
|
+
case "adGroup1Name":
|
|
111
|
+
if (record.isAdGroup1NameSpecified()) pageBuilder.setString(c, record.getAdGroup1Name());
|
|
112
|
+
else pageBuilder.setNull(c);
|
|
113
|
+
break;
|
|
114
|
+
default:
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
if (isExcluded) break;
|
|
118
|
+
}
|
|
119
|
+
if (isExcluded)
|
|
120
|
+
pageBuilder.flush();
|
|
121
|
+
else
|
|
122
|
+
pageBuilder.addRecord();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
setLastRecordTime(Optional.of(newestRecordTime.format(embulkDateTimeFormat)));
|
|
126
|
+
setLastRecordId(Optional.of(String.valueOf(lastRecordId)));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public Schema buildSchema() {
|
|
130
|
+
return Schema.builder()
|
|
131
|
+
.add("createdAt" , Types.TIMESTAMP)
|
|
132
|
+
.add("adGroup1Id" , Types.LONG)
|
|
133
|
+
.add("adGroup1Name", Types.STRING)
|
|
134
|
+
.build();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
package org.embulk.input.adebis.operation;
|
|
2
|
+
|
|
3
|
+
import com.google.common.base.Optional;
|
|
4
|
+
|
|
5
|
+
import jp.ne.ebis.extreme.ws.entity.xsd.HoteiAuthHeader;
|
|
6
|
+
import jp.ne.ebis.extreme.ws.entity.xsd.HoteiAuthHeaderE;
|
|
7
|
+
import jp.ne.ebis.extreme.ws.service.AdGroup2ManagementService;
|
|
8
|
+
import jp.ne.ebis.extreme.ws.service.AdGroup2ManagementServiceStub;
|
|
9
|
+
|
|
10
|
+
import jp.ne.ebis.extreme.ws.service.GetAdGroup2SResponse;
|
|
11
|
+
|
|
12
|
+
import org.apache.axis2.AxisFault;
|
|
13
|
+
import org.embulk.config.Config;
|
|
14
|
+
import org.embulk.config.ConfigDefault;
|
|
15
|
+
import org.embulk.config.Task;
|
|
16
|
+
import org.embulk.input.adebis.AdebisInputPlugin;
|
|
17
|
+
import org.embulk.spi.Column;
|
|
18
|
+
import org.embulk.spi.PageBuilder;
|
|
19
|
+
import org.embulk.spi.Schema;
|
|
20
|
+
import org.embulk.spi.type.Types;
|
|
21
|
+
|
|
22
|
+
import java.rmi.RemoteException;
|
|
23
|
+
import java.time.LocalDate;
|
|
24
|
+
import java.time.LocalDateTime;
|
|
25
|
+
import java.util.Date;
|
|
26
|
+
|
|
27
|
+
public class AdGroup2 extends AbstractOperation {
|
|
28
|
+
public int lastRecordId = 0;
|
|
29
|
+
|
|
30
|
+
public interface Condition extends Task {
|
|
31
|
+
//リクエストパラメータ無し
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public void run(PageBuilder pageBuilder) {
|
|
35
|
+
Schema schema = pageBuilder.getSchema();
|
|
36
|
+
AdGroup2ManagementService adGroup2ManagementService;
|
|
37
|
+
try {
|
|
38
|
+
adGroup2ManagementService = new AdGroup2ManagementServiceStub();
|
|
39
|
+
} catch (AxisFault axisFault) {
|
|
40
|
+
axisFault.printStackTrace();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//LocalDate startDate = LocalDate.parse(condition.getStartDate().get(), adebisDateFormat);
|
|
45
|
+
//LocalDate endDate = LocalDate.parse(condition.getEndDate().get(), adebisDateFormat);
|
|
46
|
+
LocalDateTime lastRecordTime, newestRecordTime;
|
|
47
|
+
//System.out.println(startDate);
|
|
48
|
+
//System.out.println(endDate);
|
|
49
|
+
|
|
50
|
+
if(getLastRecordTime().isPresent()) {
|
|
51
|
+
lastRecordTime = LocalDateTime.parse(getLastRecordTime().get(), embulkDateTimeFormat);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
//lastRecordTime = startDate.atStartOfDay();
|
|
55
|
+
lastRecordTime = LocalDateTime.now();
|
|
56
|
+
//lastRecordTime = Optional.of(lastRecordTime.format(embulkDateTimeFormat));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if(getLastRecordId().isPresent()) {
|
|
60
|
+
lastRecordId = Integer.parseInt(getLastRecordId().get());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//if(lastRecordTime.isAfter(startDate.atStartOfDay())) {
|
|
64
|
+
// startDate = lastRecordTime.toLocalDate();
|
|
65
|
+
//}
|
|
66
|
+
|
|
67
|
+
// Build Header
|
|
68
|
+
HoteiAuthHeader header = new HoteiAuthHeader();
|
|
69
|
+
HoteiAuthHeaderE headerE = new HoteiAuthHeaderE();
|
|
70
|
+
header.setLogId(getLogId());
|
|
71
|
+
header.setLogArgument(getLogArgument());
|
|
72
|
+
header.setApiKey(getApiKey());
|
|
73
|
+
headerE.setHoteiAuthHeader(header);
|
|
74
|
+
|
|
75
|
+
GetAdGroup2SResponse response;
|
|
76
|
+
|
|
77
|
+
newestRecordTime = lastRecordTime;
|
|
78
|
+
try {
|
|
79
|
+
response = adGroup2ManagementService.getAdGroup2S(headerE);
|
|
80
|
+
} catch (RemoteException e) {
|
|
81
|
+
e.printStackTrace();
|
|
82
|
+
return;
|
|
83
|
+
} catch (NullPointerException e) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
jp.ne.ebis.extreme.ws.entity.xsd.AdGroup2[] results = response.get_return();
|
|
88
|
+
for (jp.ne.ebis.extreme.ws.entity.xsd.AdGroup2 record : results) {
|
|
89
|
+
Boolean isExcluded = false;
|
|
90
|
+
int currentRecordId= record.getAdGroup2Id();
|
|
91
|
+
if ( ! record.isAdGroup2IdSpecified()) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (lastRecordId < currentRecordId) {
|
|
95
|
+
lastRecordId = currentRecordId;
|
|
96
|
+
} else {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
for (Column c : schema.getColumns()) {
|
|
100
|
+
switch (c.getName()) {
|
|
101
|
+
case "createdAt":
|
|
102
|
+
long unixtime = System.currentTimeMillis() / 1000L;
|
|
103
|
+
org.embulk.spi.time.Timestamp timestamp = org.embulk.spi.time.Timestamp.ofEpochSecond(unixtime);
|
|
104
|
+
pageBuilder.setTimestamp(c, timestamp);
|
|
105
|
+
break;
|
|
106
|
+
case "adGroup2Id":
|
|
107
|
+
if (record.isAdGroup2IdSpecified()) pageBuilder.setLong(c, record.getAdGroup2Id());
|
|
108
|
+
else pageBuilder.setNull(c);
|
|
109
|
+
break;
|
|
110
|
+
case "adGroup2Name":
|
|
111
|
+
if (record.isAdGroup2NameSpecified()) pageBuilder.setString(c, record.getAdGroup2Name());
|
|
112
|
+
else pageBuilder.setNull(c);
|
|
113
|
+
break;
|
|
114
|
+
default:
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
if (isExcluded) break;
|
|
118
|
+
}
|
|
119
|
+
if (isExcluded)
|
|
120
|
+
pageBuilder.flush();
|
|
121
|
+
else
|
|
122
|
+
pageBuilder.addRecord();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
setLastRecordTime(Optional.of(newestRecordTime.format(embulkDateTimeFormat)));
|
|
126
|
+
setLastRecordId(Optional.of(String.valueOf(lastRecordId)));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public Schema buildSchema() {
|
|
130
|
+
return Schema.builder()
|
|
131
|
+
.add("createdAt" , Types.TIMESTAMP)
|
|
132
|
+
.add("adGroup2Id" , Types.LONG)
|
|
133
|
+
.add("adGroup2Name", Types.STRING)
|
|
134
|
+
.build();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
package org.embulk.input.adebis.operation;
|
|
2
|
+
|
|
3
|
+
import com.google.common.base.Optional;
|
|
4
|
+
|
|
5
|
+
import jp.ne.ebis.extreme.ws.entity.xsd.HoteiAuthHeader;
|
|
6
|
+
import jp.ne.ebis.extreme.ws.entity.xsd.HoteiAuthHeaderE;
|
|
7
|
+
import jp.ne.ebis.extreme.ws.service.MediaManagementService;
|
|
8
|
+
import jp.ne.ebis.extreme.ws.service.MediaManagementServiceStub;
|
|
9
|
+
|
|
10
|
+
import jp.ne.ebis.extreme.ws.service.GetMediasResponse;
|
|
11
|
+
|
|
12
|
+
import org.apache.axis2.AxisFault;
|
|
13
|
+
import org.embulk.config.Config;
|
|
14
|
+
import org.embulk.config.ConfigDefault;
|
|
15
|
+
import org.embulk.config.Task;
|
|
16
|
+
import org.embulk.spi.Column;
|
|
17
|
+
import org.embulk.spi.PageBuilder;
|
|
18
|
+
import org.embulk.spi.Schema;
|
|
19
|
+
import org.embulk.spi.type.Types;
|
|
20
|
+
|
|
21
|
+
import java.rmi.RemoteException;
|
|
22
|
+
import java.time.LocalDate;
|
|
23
|
+
import java.time.LocalDateTime;
|
|
24
|
+
import java.util.Date;
|
|
25
|
+
|
|
26
|
+
public class Media extends AbstractOperation {
|
|
27
|
+
public int lastRecordId = 0;
|
|
28
|
+
|
|
29
|
+
public interface Condition extends Task {
|
|
30
|
+
//リクエストパラメータ無し
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public void run(PageBuilder pageBuilder) {
|
|
34
|
+
Schema schema = pageBuilder.getSchema();
|
|
35
|
+
MediaManagementService mediaManagementService;
|
|
36
|
+
try {
|
|
37
|
+
mediaManagementService = new MediaManagementServiceStub();
|
|
38
|
+
} catch (AxisFault axisFault) {
|
|
39
|
+
axisFault.printStackTrace();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//LocalDate startDate = LocalDate.parse(condition.getStartDate().get(), adebisDateFormat);
|
|
44
|
+
//LocalDate endDate = LocalDate.parse(condition.getEndDate().get(), adebisDateFormat);
|
|
45
|
+
LocalDateTime lastRecordTime, newestRecordTime;
|
|
46
|
+
//System.out.println(startDate);
|
|
47
|
+
//System.out.println(endDate);
|
|
48
|
+
|
|
49
|
+
if(getLastRecordTime().isPresent()) {
|
|
50
|
+
lastRecordTime = LocalDateTime.parse(getLastRecordTime().get(), embulkDateTimeFormat);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
//lastRecordTime = startDate.atStartOfDay();
|
|
54
|
+
lastRecordTime = LocalDateTime.now();
|
|
55
|
+
//lastRecordTime = Optional.of(lastRecordTime.format(embulkDateTimeFormat));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if(getLastRecordId().isPresent()) {
|
|
59
|
+
lastRecordId = Integer.parseInt(getLastRecordId().get());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//if(lastRecordTime.isAfter(startDate.atStartOfDay())) {
|
|
63
|
+
// startDate = lastRecordTime.toLocalDate();
|
|
64
|
+
//}
|
|
65
|
+
|
|
66
|
+
// Build Header
|
|
67
|
+
HoteiAuthHeader header = new HoteiAuthHeader();
|
|
68
|
+
HoteiAuthHeaderE headerE = new HoteiAuthHeaderE();
|
|
69
|
+
header.setLogId(getLogId());
|
|
70
|
+
header.setLogArgument(getLogArgument());
|
|
71
|
+
header.setApiKey(getApiKey());
|
|
72
|
+
headerE.setHoteiAuthHeader(header);
|
|
73
|
+
|
|
74
|
+
GetMediasResponse response;
|
|
75
|
+
|
|
76
|
+
newestRecordTime = lastRecordTime;
|
|
77
|
+
try {
|
|
78
|
+
response = mediaManagementService.getMedias(headerE);
|
|
79
|
+
} catch (RemoteException e) {
|
|
80
|
+
e.printStackTrace();
|
|
81
|
+
return;
|
|
82
|
+
} catch (NullPointerException e) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
jp.ne.ebis.extreme.ws.entity.xsd.Media[] results = response.get_return();
|
|
87
|
+
for (jp.ne.ebis.extreme.ws.entity.xsd.Media record : results) {
|
|
88
|
+
Boolean isExcluded = false;
|
|
89
|
+
int currentRecordId= record.getMediaId();
|
|
90
|
+
if ( ! record.isMediaIdSpecified()) {
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
if (lastRecordId < currentRecordId) {
|
|
94
|
+
lastRecordId = currentRecordId;
|
|
95
|
+
} else {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
for (Column c : schema.getColumns()) {
|
|
99
|
+
switch (c.getName()) {
|
|
100
|
+
case "createdAt":
|
|
101
|
+
long unixtime = System.currentTimeMillis() / 1000L;
|
|
102
|
+
org.embulk.spi.time.Timestamp timestamp = org.embulk.spi.time.Timestamp.ofEpochSecond(unixtime);
|
|
103
|
+
pageBuilder.setTimestamp(c, timestamp);
|
|
104
|
+
break;
|
|
105
|
+
case "mediaId":
|
|
106
|
+
if (record.isMediaIdSpecified()) pageBuilder.setLong(c, record.getMediaId());
|
|
107
|
+
else pageBuilder.setNull(c);
|
|
108
|
+
break;
|
|
109
|
+
case "mediaName":
|
|
110
|
+
if (record.isMediaNameSpecified()) pageBuilder.setString(c, record.getMediaName());
|
|
111
|
+
else pageBuilder.setNull(c);
|
|
112
|
+
break;
|
|
113
|
+
default:
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
if (isExcluded) break;
|
|
117
|
+
}
|
|
118
|
+
if (isExcluded)
|
|
119
|
+
pageBuilder.flush();
|
|
120
|
+
else
|
|
121
|
+
pageBuilder.addRecord();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
setLastRecordTime(Optional.of(newestRecordTime.format(embulkDateTimeFormat)));
|
|
125
|
+
setLastRecordId(Optional.of(String.valueOf(lastRecordId)));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public Schema buildSchema() {
|
|
129
|
+
return Schema.builder()
|
|
130
|
+
.add("createdAt", Types.TIMESTAMP)
|
|
131
|
+
.add("mediaId" , Types.LONG)
|
|
132
|
+
.add("mediaName", Types.STRING)
|
|
133
|
+
.build();
|
|
134
|
+
}
|
|
135
|
+
}
|