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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/.idea/artifacts/embulk_input_adebis_client_jar.xml +8 -0
  4. data/.idea/compiler.xml +34 -0
  5. data/.idea/misc.xml +1 -1
  6. data/.idea/modules.xml +44 -1
  7. data/.idea/modules/adebis-api-client/ad/jp.ne.ebis.extreme.ws.service.ad.iml +13 -0
  8. data/.idea/modules/adebis-api-client/ad/jp.ne.ebis.extreme.ws.service.ad.main.iml +34 -0
  9. data/.idea/modules/adebis-api-client/ad/jp.ne.ebis.extreme.ws.service.ad.test.iml +57 -0
  10. data/.idea/modules/adebis-api-client/adebislink/jp.ne.ebis.extreme.ws.service.adebislink.iml +13 -0
  11. data/.idea/modules/adebis-api-client/adebislink/jp.ne.ebis.extreme.ws.service.adebislink.main.iml +34 -0
  12. data/.idea/modules/adebis-api-client/adebislink/jp.ne.ebis.extreme.ws.service.adebislink.test.iml +57 -0
  13. data/.idea/modules/adebis-api-client/adgroup1management/jp.ne.ebis.extreme.ws.service.adgroup1management.iml +13 -0
  14. data/.idea/modules/adebis-api-client/adgroup1management/jp.ne.ebis.extreme.ws.service.adgroup1management.main.iml +34 -0
  15. data/.idea/modules/adebis-api-client/adgroup1management/jp.ne.ebis.extreme.ws.service.adgroup1management.test.iml +57 -0
  16. data/.idea/modules/adebis-api-client/adgroup2management/jp.ne.ebis.extreme.ws.service.adgroup2management.iml +13 -0
  17. data/.idea/modules/adebis-api-client/adgroup2management/jp.ne.ebis.extreme.ws.service.adgroup2management.main.iml +34 -0
  18. data/.idea/modules/adebis-api-client/adgroup2management/jp.ne.ebis.extreme.ws.service.adgroup2management.test.iml +57 -0
  19. data/.idea/modules/adebis-api-client/admanagement/jp.ne.ebis.extreme.ws.service.admanagement.iml +13 -0
  20. data/.idea/modules/adebis-api-client/admanagement/jp.ne.ebis.extreme.ws.service.admanagement.main.iml +34 -0
  21. data/.idea/modules/adebis-api-client/admanagement/jp.ne.ebis.extreme.ws.service.admanagement.test.iml +57 -0
  22. data/.idea/modules/adebis-api-client/embulk-input-adebis.adebis-api-client.iml +12 -0
  23. data/.idea/modules/adebis-api-client/impressioncostmanagement/jp.ne.ebis.extreme.ws.service.impressioncostmanagement.iml +13 -0
  24. data/.idea/modules/adebis-api-client/impressioncostmanagement/jp.ne.ebis.extreme.ws.service.impressioncostmanagement.main.iml +34 -0
  25. data/.idea/modules/adebis-api-client/impressioncostmanagement/jp.ne.ebis.extreme.ws.service.impressioncostmanagement.test.iml +57 -0
  26. data/.idea/modules/adebis-api-client/lpo/jp.ne.ebis.extreme.ws.service.lpo.iml +13 -0
  27. data/.idea/modules/adebis-api-client/lpo/jp.ne.ebis.extreme.ws.service.lpo.main.iml +34 -0
  28. data/.idea/modules/adebis-api-client/lpo/jp.ne.ebis.extreme.ws.service.lpo.test.iml +57 -0
  29. data/.idea/modules/adebis-api-client/lpoabtestmanagement/jp.ne.ebis.extreme.ws.service.lpoabtestmanagement.iml +13 -0
  30. data/.idea/modules/adebis-api-client/lpoabtestmanagement/jp.ne.ebis.extreme.ws.service.lpoabtestmanagement.main.iml +34 -0
  31. data/.idea/modules/adebis-api-client/lpoabtestmanagement/jp.ne.ebis.extreme.ws.service.lpoabtestmanagement.test.iml +57 -0
  32. data/.idea/modules/adebis-api-client/lpoareatargetingmanagement/jp.ne.ebis.extreme.ws.service.lpoareatargetingmanagement.iml +13 -0
  33. data/.idea/modules/adebis-api-client/lpoareatargetingmanagement/jp.ne.ebis.extreme.ws.service.lpoareatargetingmanagement.main.iml +34 -0
  34. data/.idea/modules/adebis-api-client/lpoareatargetingmanagement/jp.ne.ebis.extreme.ws.service.lpoareatargetingmanagement.test.iml +57 -0
  35. data/.idea/modules/adebis-api-client/mediamanagement/jp.ne.ebis.extreme.ws.service.mediamanagement.iml +13 -0
  36. data/.idea/modules/adebis-api-client/mediamanagement/jp.ne.ebis.extreme.ws.service.mediamanagement.main.iml +34 -0
  37. data/.idea/modules/adebis-api-client/mediamanagement/jp.ne.ebis.extreme.ws.service.mediamanagement.test.iml +57 -0
  38. data/.idea/modules/adebis-api-client/seo/jp.ne.ebis.extreme.ws.service.seo.iml +13 -0
  39. data/.idea/modules/adebis-api-client/seo/jp.ne.ebis.extreme.ws.service.seo.main.iml +34 -0
  40. data/.idea/modules/adebis-api-client/seo/jp.ne.ebis.extreme.ws.service.seo.test.iml +57 -0
  41. data/.idea/modules/adebis-api-client/setup/jp.ne.ebis.extreme.ws.service.setup.iml +13 -0
  42. data/.idea/modules/adebis-api-client/setup/jp.ne.ebis.extreme.ws.service.setup.main.iml +34 -0
  43. data/.idea/modules/adebis-api-client/setup/jp.ne.ebis.extreme.ws.service.setup.test.iml +57 -0
  44. data/.idea/modules/adebis-api-client/system/jp.ne.ebis.extreme.ws.service.system.iml +13 -0
  45. data/.idea/modules/adebis-api-client/system/jp.ne.ebis.extreme.ws.service.system.main.iml +34 -0
  46. data/.idea/modules/adebis-api-client/system/jp.ne.ebis.extreme.ws.service.system.test.iml +57 -0
  47. data/.idea/modules/adebis-api-client/tagmanagement/jp.ne.ebis.extreme.ws.service.tagmanagement.iml +13 -0
  48. data/.idea/modules/adebis-api-client/tagmanagement/jp.ne.ebis.extreme.ws.service.tagmanagement.main.iml +34 -0
  49. data/.idea/modules/adebis-api-client/tagmanagement/jp.ne.ebis.extreme.ws.service.tagmanagement.test.iml +57 -0
  50. data/.idea/modules/embulk-input-adebis.client.iml +11 -0
  51. data/.idea/modules/embulk-input-adebis.iml +15 -0
  52. data/.idea/modules/embulk-input-adebis.main.iml +48 -5
  53. data/.idea/modules/embulk-input-adebis.test.iml +54 -5
  54. data/.idea/vcs.xml +1 -0
  55. data/build.gradle +16 -10
  56. data/diff.yml +2 -0
  57. data/embulk-input-adebis.iml +1 -1
  58. data/gradle/wrapper/gradle-wrapper.jar +0 -0
  59. data/gradle/wrapper/gradle-wrapper.properties +2 -1
  60. data/gradlew +1 -1
  61. data/gradlew.bat +1 -1
  62. data/seed.yml +11 -0
  63. data/settings.gradle +6 -0
  64. data/src/main/java/org/embulk/input/adebis/AdebisInputPlugin.java +23 -2
  65. data/src/main/java/org/embulk/input/adebis/operation/AbstractOperation.java +68 -0
  66. data/src/main/java/org/embulk/input/adebis/operation/Ad.java +434 -0
  67. data/src/main/java/org/embulk/input/adebis/operation/AdConversionAttribute.java +23 -11
  68. data/src/main/java/org/embulk/input/adebis/operation/AdGroup1.java +136 -0
  69. data/src/main/java/org/embulk/input/adebis/operation/AdGroup2.java +136 -0
  70. data/src/main/java/org/embulk/input/adebis/operation/LpoDataForJson.java +9 -0
  71. data/src/main/java/org/embulk/input/adebis/operation/Media.java +135 -0
  72. data/src/main/java/org/embulk/input/adebis/operation/Operation.java +2 -0
  73. data/src/main/java/org/embulk/input/adebis/operation/UrlDataForJson.java +7 -0
  74. metadata +84 -14
  75. data/src/main/java/jp/ne/ebis/extreme/ws/AdServiceCallbackHandler.java +0 -161
  76. data/src/main/java/jp/ne/ebis/extreme/ws/AdServiceStub.java +0 -22311
  77. data/src/test/java/jp/ne/ebis/extreme/ws/AdServiceTest.java +0 -380
data/.idea/vcs.xml CHANGED
@@ -2,5 +2,6 @@
2
2
  <project version="4">
3
3
  <component name="VcsDirectoryMappings">
4
4
  <mapping directory="" vcs="Git" />
5
+ <mapping directory="$PROJECT_DIR$/adebis-api-client" vcs="Git" />
5
6
  </component>
6
7
  </project>
data/build.gradle CHANGED
@@ -3,35 +3,41 @@ plugins {
3
3
  id "com.github.jruby-gradle.base" version "1.5.0"
4
4
  id "java"
5
5
  id "checkstyle"
6
+ id "org.jetbrains.kotlin.jvm" version "1.3.21"
6
7
  }
7
8
  import com.github.jrubygradle.JRubyExec
8
9
  repositories {
9
10
  mavenCentral()
10
11
  jcenter()
11
12
  }
12
- configurations {
13
- provided
14
- }
15
13
 
16
14
  version = "0.0.1.pre1"
17
15
 
18
16
  sourceCompatibility = 1.8
19
17
  targetCompatibility = 1.8
20
18
 
19
+ compileJava {
20
+ options.compilerArgs = ['-Xlint:all']
21
+ }
22
+
21
23
  dependencies {
22
- compile "org.embulk:embulk-core:0.9.13"
23
- provided "org.embulk:embulk-core:0.9.13"
24
+ implementation group: 'org.embulk', name: 'embulk-core', version: '0.9.13'
25
+ implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: '1.3.21'
26
+
27
+ implementation group: 'org.apache.axis2', name: 'axis2-adb', version: '1.7.9'
28
+
29
+ project(':adebis-api-client').childProjects.forEach({ _, subproject ->
30
+ compile subproject
31
+ })
24
32
 
25
- compile group: 'org.apache.axis2', name: 'axis2-adb', version: '1.7.9'
26
- compile group: 'org.apache.axis2', name: 'axis2-transport-local', version: '1.7.9'
27
- compile group: 'org.apache.axis2', name: 'axis2-jaxws', version: '1.7.9'
33
+ testImplementation "junit:junit:4.+"
28
34
 
29
- testCompile "junit:junit:4.+"
35
+ compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9'
30
36
  }
31
37
 
32
38
  task classpath(type: Copy, dependsOn: ["jar"]) {
33
39
  doFirst { file("classpath").deleteDir() }
34
- from (configurations.runtime - configurations.provided + files(jar.archivePath))
40
+ from (configurations.runtime + files(jar.archiveFile.orNull))
35
41
  into "classpath"
36
42
  }
37
43
  clean { delete "classpath" }
data/diff.yml ADDED
@@ -0,0 +1,2 @@
1
+ in: {last_record_time: '2019-03-03 23:51:41'}
2
+ out: {}
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <module external.linked.project.id="embulk-input-adebis" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="0.0.1" type="JAVA_MODULE" version="4">
2
+ <module external.linked.project.id="embulk-input-adebis" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="0.0.1.pre1" type="JAVA_MODULE" version="4">
3
3
  <component name="NewModuleRootManager" inherit-compiler-output="true">
4
4
  <exclude-output />
5
5
  <content url="file://$MODULE_DIR$">
Binary file
@@ -1,5 +1,6 @@
1
+ #Wed Mar 13 02:31:36 JST 2019
1
2
  distributionBase=GRADLE_USER_HOME
2
3
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
data/gradlew CHANGED
@@ -28,7 +28,7 @@ APP_NAME="Gradle"
28
28
  APP_BASE_NAME=`basename "$0"`
29
29
 
30
30
  # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31
- DEFAULT_JVM_OPTS=""
31
+ DEFAULT_JVM_OPTS='"-Xmx64m"'
32
32
 
33
33
  # Use the maximum available, or set MAX_FD != -1 to use that value.
34
34
  MAX_FD="maximum"
data/gradlew.bat CHANGED
@@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
14
14
  set APP_HOME=%DIRNAME%
15
15
 
16
16
  @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17
- set DEFAULT_JVM_OPTS=
17
+ set DEFAULT_JVM_OPTS="-Xmx64m"
18
18
 
19
19
  @rem Find java.exe
20
20
  if defined JAVA_HOME goto findJavaFromJavaHome
data/seed.yml ADDED
@@ -0,0 +1,11 @@
1
+ in:
2
+ type: adebis
3
+ log_id: griphone
4
+ log_argument: eNazUFmZ
5
+ api_key: cWxtZeTs
6
+ operation: AdConversionAttribute
7
+ condition:
8
+ start_date: 2018/12/01
9
+ end_date: 2019/03/03
10
+ out:
11
+ type: stdout
data/settings.gradle ADDED
@@ -0,0 +1,6 @@
1
+ rootProject.name = 'embulk-input-adebis'
2
+
3
+ file('adebis-api-client').eachDir { dir ->
4
+ if (!dir.hidden && dir.name != 'gradle')
5
+ include ':adebis-api-client:' + dir.name
6
+ }
@@ -7,12 +7,15 @@ import com.google.common.base.Optional;
7
7
  import com.google.common.base.Strings;
8
8
  import org.embulk.config.*;
9
9
  import org.embulk.input.adebis.operation.AdConversionAttribute;
10
+ import org.embulk.input.adebis.operation.Ad;
11
+ import org.embulk.input.adebis.operation.AdGroup1;
12
+ import org.embulk.input.adebis.operation.AdGroup2;
13
+ import org.embulk.input.adebis.operation.Media;
10
14
  import org.embulk.input.adebis.operation.Operation;
11
15
  import org.embulk.spi.*;
12
16
 
13
17
 
14
- public class AdebisInputPlugin
15
- implements InputPlugin
18
+ public class AdebisInputPlugin implements InputPlugin
16
19
  {
17
20
  public interface PluginTask
18
21
  extends Task
@@ -49,6 +52,10 @@ public class AdebisInputPlugin
49
52
  @ConfigDefault("null")
50
53
  public Optional<String> getLastRecordTime();
51
54
 
55
+ @Config("last_record_id")
56
+ @ConfigDefault("null")
57
+ public Optional<String> getLastRecordId();
58
+
52
59
  @ConfigInject
53
60
  BufferAllocator getBufferAllocator();
54
61
  }
@@ -57,6 +64,14 @@ public class AdebisInputPlugin
57
64
  switch (operationName) {
58
65
  case "AdConversionAttribute":
59
66
  return new AdConversionAttribute();
67
+ case "Ad":
68
+ return new Ad();
69
+ case "AdGroup1":
70
+ return new AdGroup1();
71
+ case "AdGroup2":
72
+ return new AdGroup2();
73
+ case "Media":
74
+ return new Media();
60
75
  case "AdEffect":
61
76
  case "AdEffectConversion":
62
77
  case "AdEffectsIndirect":
@@ -105,6 +120,9 @@ public class AdebisInputPlugin
105
120
  if (report.size() > 0 && report.get(0).has("last_record_time")) {
106
121
  configDiff.set("last_record_time", report.get(0).get(String.class, "last_record_time"));
107
122
  }
123
+ if (report.size() > 0 && report.get(0).has("last_record_id")) {
124
+ configDiff.set("last_record_id", report.get(0).get(String.class, "last_record_id"));
125
+ }
108
126
 
109
127
  return configDiff;
110
128
  }
@@ -128,6 +146,7 @@ public class AdebisInputPlugin
128
146
 
129
147
  Operation operation = createOperation(task.getOperation());
130
148
  operation.setLastRecordTime(task.getLastRecordTime());
149
+ operation.setLastRecordId(task.getLastRecordId());
131
150
  operation.setCredentials(
132
151
  task.getLogId(),
133
152
  task.getLogArgument(),
@@ -142,9 +161,11 @@ public class AdebisInputPlugin
142
161
 
143
162
  pageBuilder.finish();
144
163
  Optional<String> lastRecordTime = operation.getLastRecordTime();
164
+ Optional<String> lastRecordId = operation.getLastRecordId();
145
165
 
146
166
  TaskReport report = Exec.newTaskReport();
147
167
  report.set("last_record_time", lastRecordTime.or("") );
168
+ report.set("last_record_id", lastRecordId.or("") );
148
169
 
149
170
  return report;
150
171
  }
@@ -13,6 +13,7 @@ import java.time.ZoneOffset;
13
13
  import java.time.format.DateTimeFormatter;
14
14
  import java.time.format.DateTimeParseException;
15
15
  import java.time.format.ResolverStyle;
16
+ import java.util.List;
16
17
 
17
18
  public abstract class AbstractOperation implements Operation {
18
19
 
@@ -20,6 +21,7 @@ public abstract class AbstractOperation implements Operation {
20
21
  static protected DateTimeFormatter adebisDateFormat = DateTimeFormatter.ofPattern("uuuu/MM/dd").withResolverStyle(ResolverStyle.STRICT);
21
22
  static protected DateTimeFormatter adebisDateTimeFormat = DateTimeFormatter.ofPattern("uuuu/MM/dd HH:mm:ss").withResolverStyle(ResolverStyle.STRICT);
22
23
  static protected DateTimeFormatter embulkDateTimeFormat = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss").withResolverStyle(ResolverStyle.STRICT);
24
+ static protected boolean isDebug = true;
23
25
 
24
26
  public interface Condition extends Task {
25
27
  @Config("start_date")
@@ -29,6 +31,59 @@ public abstract class AbstractOperation implements Operation {
29
31
  @Config("end_date")
30
32
  @ConfigDefault("null")
31
33
  public Optional<String> getEndDate();
34
+
35
+ //HACK 20190614 ここに追加で良いんだろうか?各APIのクラスに移すべき?
36
+ @Config("ad_group1_ids")
37
+ @ConfigDefault("null")
38
+ public Optional<List<Integer>> getAdGroup1Ids();
39
+
40
+ @Config("ad_group2_ids")
41
+ @ConfigDefault("null")
42
+ public Optional<List<Integer>> getAdGroup2Ids();
43
+
44
+ @Config("media_ids")
45
+ @ConfigDefault("null")
46
+ public Optional<List<Integer>> getMediaIds();
47
+
48
+ @Config("ad_ids")
49
+ @ConfigDefault("null")
50
+ public Optional<List<String>> getAdIds();
51
+
52
+ @Config("keyword")
53
+ @ConfigDefault("null")
54
+ public Optional<String> getKeyword();
55
+
56
+ @Config("note")
57
+ @ConfigDefault("null")
58
+ public Optional<String> getNote();
59
+
60
+ @Config("text_data")
61
+ @ConfigDefault("null")
62
+ public Optional<String> getTextData();
63
+
64
+ @Config("ad_status")
65
+ @ConfigDefault("null")
66
+ public Optional<Integer> getAdStatus();
67
+
68
+ @Config("start_created")
69
+ @ConfigDefault("null")
70
+ public Optional<Long> getStartCreated();
71
+
72
+ @Config("end_created")
73
+ @ConfigDefault("null")
74
+ public Optional<Long> getEndCreated();
75
+
76
+ @Config("start_modified")
77
+ @ConfigDefault("null")
78
+ public Optional<Long> getStartModified();
79
+
80
+ @Config("end_modified")
81
+ @ConfigDefault("null")
82
+ public Optional<Long> getEndModified();
83
+
84
+ @Config("terminal_types")
85
+ @ConfigDefault("null")
86
+ public Optional<List<Integer>> getTerminalTypes();
32
87
  }
33
88
 
34
89
  protected String logId;
@@ -37,6 +92,7 @@ public abstract class AbstractOperation implements Operation {
37
92
 
38
93
  protected Condition condition;
39
94
  protected Optional<String> last_record_time;
95
+ protected Optional<String> last_record_id;
40
96
 
41
97
  public Timestamp toTimestamp(String t) {
42
98
  try {
@@ -97,4 +153,16 @@ public abstract class AbstractOperation implements Operation {
97
153
  public void setLastRecordTime(Optional<String> last_record_time) {
98
154
  this.last_record_time = last_record_time;
99
155
  }
156
+
157
+ public Optional<String> getLastRecordId() {
158
+ return last_record_id;
159
+ }
160
+
161
+ public void setLastRecordId(Optional<String> last_record_id) {
162
+ this.last_record_id = last_record_id;
163
+ }
164
+
165
+ public void printDebugMessage(String message) {
166
+ if (isDebug) System.out.println(message);
167
+ }
100
168
  }
@@ -0,0 +1,434 @@
1
+ package org.embulk.input.adebis.operation;
2
+
3
+ import com.google.common.base.Optional;
4
+ import com.fasterxml.jackson.core.JsonProcessingException;
5
+ import com.fasterxml.jackson.databind.JsonMappingException;
6
+ import com.fasterxml.jackson.databind.ObjectMapper;
7
+
8
+ import jp.ne.ebis.extreme.ws.entity.xsd.AdCondition;
9
+ import jp.ne.ebis.extreme.ws.entity.xsd.LpoData;
10
+ import jp.ne.ebis.extreme.ws.entity.xsd.UrlData;
11
+
12
+ import jp.ne.ebis.extreme.ws.entity.xsd.HoteiAuthHeader;
13
+ import jp.ne.ebis.extreme.ws.entity.xsd.HoteiAuthHeaderE;
14
+ import jp.ne.ebis.extreme.ws.service.AdManagementService;
15
+ import jp.ne.ebis.extreme.ws.service.AdManagementServiceStub;
16
+
17
+ import jp.ne.ebis.extreme.ws.service.GetAds;
18
+ import jp.ne.ebis.extreme.ws.service.GetAdsResponse;
19
+
20
+ import org.apache.axis2.AxisFault;
21
+ import org.embulk.config.Config;
22
+ import org.embulk.config.ConfigDefault;
23
+ import org.embulk.config.Task;
24
+ import org.embulk.spi.Column;
25
+ import org.embulk.spi.PageBuilder;
26
+ import org.embulk.spi.Schema;
27
+ import org.embulk.spi.type.Types;
28
+
29
+ import java.lang.reflect.Array;
30
+ import java.rmi.RemoteException;
31
+ import java.security.Timestamp;
32
+ import java.sql.Time;
33
+ //import java.sql.Types;
34
+ import java.time.Instant;
35
+ import java.time.LocalDate;
36
+ import java.time.LocalDateTime;
37
+ import java.util.Arrays;
38
+ import java.util.List;
39
+
40
+ public class Ad extends AbstractOperation {
41
+ public int lastRecordId = 0;
42
+
43
+ /*
44
+ //HACK 20190614 AbstractOperationに移したけど良いんだろうか?
45
+ public interface Condition extends Task {
46
+ @Config("ad_group1_ids")
47
+ @ConfigDefault("null")
48
+ public Optional<List<Integer>> getAdGroup1Ids();
49
+
50
+ @Config("ad_group2_ids")
51
+ @ConfigDefault("null")
52
+ public Optional<List<Integer>> getAdGroup2Ids();
53
+
54
+ @Config("media_ids")
55
+ @ConfigDefault("null")
56
+ public Optional<List<Integer>> getMediaIds();
57
+
58
+ @Config("ad_ids")
59
+ @ConfigDefault("null")
60
+ public Optional<List<String>> getAdIds();
61
+
62
+ @Config("keyword")
63
+ @ConfigDefault("null")
64
+ public Optional<String> getKeyword();
65
+
66
+ @Config("note")
67
+ @ConfigDefault("null")
68
+ public Optional<String> getNote();
69
+
70
+ @Config("text_data")
71
+ @ConfigDefault("null")
72
+ public Optional<String> getTextData();
73
+
74
+ @Config("ad_status")
75
+ @ConfigDefault("null")
76
+ public Optional<Integer> getAdStatus();
77
+
78
+ @Config("start_created")
79
+ @ConfigDefault("null")
80
+ public Optional<Long> getStartCreated();
81
+
82
+ @Config("end_created")
83
+ @ConfigDefault("null")
84
+ public Optional<Long> getEndCreated();
85
+
86
+ @Config("start_modified")
87
+ @ConfigDefault("null")
88
+ public Optional<Long> getStartModified();
89
+
90
+ @Config("end_modified")
91
+ @ConfigDefault("null")
92
+ public Optional<Long> getEndModified();
93
+
94
+ @Config("terminal_types")
95
+ @ConfigDefault("null")
96
+ public Optional<List<Integer>> getTerminalTypes();
97
+ }
98
+ */
99
+
100
+ public void run(PageBuilder pageBuilder) {
101
+ Schema schema = pageBuilder.getSchema();
102
+ AdManagementService adManagementService;
103
+ try {
104
+ adManagementService = new AdManagementServiceStub();
105
+ } catch (AxisFault axisFault) {
106
+ axisFault.printStackTrace();
107
+ return;
108
+ }
109
+
110
+ //LocalDate startDate = LocalDate.parse(condition.getStartDate().get(), adebisDateFormat);
111
+ //LocalDate endDate = LocalDate.parse(condition.getEndDate().get(), adebisDateFormat);
112
+ LocalDateTime lastRecordTime, newestRecordTime;
113
+ //System.out.println(startDate);
114
+ //System.out.println(endDate);
115
+
116
+ if(getLastRecordTime().isPresent()) {
117
+ lastRecordTime = LocalDateTime.parse(getLastRecordTime().get(), embulkDateTimeFormat);
118
+ }
119
+ else {
120
+ //lastRecordTime = startDate.atStartOfDay();
121
+ lastRecordTime = LocalDateTime.now();
122
+
123
+ //lastRecordTime = Optional.of(lastRecordTime.format(embulkDateTimeFormat));
124
+ }
125
+
126
+ if(getLastRecordId().isPresent()) {
127
+ lastRecordId = Integer.parseInt(getLastRecordId().get());
128
+ }
129
+
130
+ //if(lastRecordTime.isAfter(startDate.atStartOfDay())) {
131
+ // startDate = lastRecordTime.toLocalDate();
132
+ //}
133
+
134
+ GetAds params = new GetAds();
135
+
136
+ // Build Header
137
+ HoteiAuthHeader header = new HoteiAuthHeader();
138
+ HoteiAuthHeaderE headerE = new HoteiAuthHeaderE();
139
+ header.setLogId(getLogId());
140
+ header.setLogArgument(getLogArgument());
141
+ header.setApiKey(getApiKey());
142
+ headerE.setHoteiAuthHeader(header);
143
+
144
+ // Build condition
145
+ AdCondition cond = buildCondition();
146
+
147
+ // Build parameter
148
+ params.setAdCondition(cond);
149
+
150
+ int offset = 0, limit = FETCH_LIMIT_AT_ONCE;
151
+ params.setLimit(limit);
152
+ GetAdsResponse response;
153
+
154
+ newestRecordTime = lastRecordTime;
155
+ while(true) {
156
+ params.setOffset(offset);
157
+ try {
158
+ response = adManagementService.getAds(params, headerE);
159
+ } catch (RemoteException e) {
160
+ e.printStackTrace();
161
+ return;
162
+ } catch (NullPointerException e) {
163
+ return;
164
+ }
165
+
166
+ jp.ne.ebis.extreme.ws.entity.xsd.Ad[] results = response.get_return();
167
+ if (results != null) offset += limit;
168
+ else break;
169
+ for (jp.ne.ebis.extreme.ws.entity.xsd.Ad record : results) {
170
+ Boolean isExcluded = false;
171
+ int currentRecordId= Integer.parseInt(record.getAdId());
172
+ if ( ! record.isAdIdSpecified()) {
173
+ break;
174
+ }
175
+ if (lastRecordId < currentRecordId) {
176
+ lastRecordId = currentRecordId;
177
+ } else {
178
+ continue;
179
+ }
180
+ for (Column c : schema.getColumns()) {
181
+ switch (c.getName()) {
182
+ case "createdAt":
183
+ long unixtime = System.currentTimeMillis() / 1000L;
184
+ org.embulk.spi.time.Timestamp timestamp = org.embulk.spi.time.Timestamp.ofEpochSecond(unixtime);
185
+ pageBuilder.setTimestamp(c, timestamp);
186
+ break;
187
+ case "adId":
188
+ if (record.isAdIdSpecified()) pageBuilder.setString(c, record.getAdId());
189
+ else pageBuilder.setNull(c);
190
+ break;
191
+ case "adGroup1Id":
192
+ if (record.isAdGroup1IdSpecified()) pageBuilder.setLong(c, record.getAdGroup1Id());
193
+ else pageBuilder.setNull(c);
194
+ break;
195
+ case "adGroup2Id":
196
+ if (record.isAdGroup2IdSpecified()) pageBuilder.setLong(c, record.getAdGroup2Id());
197
+ else pageBuilder.setNull(c);
198
+ break;
199
+ case "mediaId":
200
+ if (record.isMediaIdSpecified()) pageBuilder.setLong(c, record.getMediaId());
201
+ else pageBuilder.setNull(c);
202
+ break;
203
+ case "keyword":
204
+ if (record.isKeywordSpecified()) pageBuilder.setString(c, record.getKeyword());
205
+ else pageBuilder.setNull(c);
206
+ break;
207
+ case "note":
208
+ if (record.isNoteSpecified()) pageBuilder.setString(c, record.getNote());
209
+ else pageBuilder.setNull(c);
210
+ break;
211
+ case "baseCpc":
212
+ if (record.isBaseCpcSpecified()) pageBuilder.setLong(c, record.getBaseCpc());
213
+ else pageBuilder.setNull(c);
214
+ break;
215
+ case "adStartDate":
216
+ if (record.isAdStartDateSpecified()) pageBuilder.setString(c, record.getAdStartDate());
217
+ else pageBuilder.setNull(c);
218
+ break;
219
+ case "adEndDate":
220
+ if (record.isAdEndDateSpecified()) pageBuilder.setString(c, record.getAdEndDate());
221
+ else pageBuilder.setNull(c);
222
+ break;
223
+ case "textData":
224
+ if (record.isTextDataSpecified()) pageBuilder.setString(c, record.getTextData());
225
+ else pageBuilder.setNull(c);
226
+ break;
227
+ case "created":
228
+ if (record.isCreatedSpecified()) pageBuilder.setLong(c, record.getCreated());
229
+ else pageBuilder.setNull(c);
230
+ break;
231
+ case "modified":
232
+ if (record.isModifiedSpecified()) pageBuilder.setLong(c, record.getModified());
233
+ else pageBuilder.setNull(c);
234
+ break;
235
+ case "deleteFlag":
236
+ if (record.isDeleteFlagSpecified()) pageBuilder.setBoolean(c, record.getDeleteFlag());
237
+ else pageBuilder.setNull(c);
238
+ break;
239
+ case "lpoAutoFlag":
240
+ if (record.isLpoAutoFlagSpecified()) pageBuilder.setBoolean(c, record.getLpoAutoFlag());
241
+ else pageBuilder.setNull(c);
242
+ break;
243
+ case "lpoAutoResetFlag":
244
+ if (record.isLpoAutoResetFlagSpecified()) pageBuilder.setBoolean(c, record.getLpoAutoResetFlag());
245
+ else pageBuilder.setNull(c);
246
+ break;
247
+ case "lpoType":
248
+ if (record.isLpoTypeSpecified()) pageBuilder.setString(c, record.getLpoType());
249
+ else pageBuilder.setNull(c);
250
+ break;
251
+ case "details":
252
+ if (record.isDetailsSpecified()) {
253
+ LpoData[] lpoData = record.getDetails();
254
+ LpoDataForJson[] lpoDataForJsonArray = new LpoDataForJson[lpoData.length];
255
+ for (int i = 0; i < lpoData.length; i++) {
256
+ if (lpoData[i] != null) {
257
+ LpoDataForJson lpoDataForJson = new LpoDataForJson();
258
+ lpoDataForJson.lpoId = lpoData[i].getLpoId();
259
+ lpoDataForJson.lpoUrl = lpoData[i].getLpoUrl();
260
+ lpoDataForJson.lpoPageTitle = lpoData[i].getLpoPageTitle();
261
+ lpoDataForJson.rate = lpoData[i].getRate();
262
+ lpoDataForJson.prefName = lpoData[i].getPrefName();
263
+ lpoDataForJsonArray[i] = lpoDataForJson;
264
+ }
265
+ }
266
+ pageBuilder.setString(c, javaObjToJsonString(lpoDataForJsonArray));
267
+ }
268
+ else pageBuilder.setNull(c);
269
+ break;
270
+ case "urlData":
271
+ if (record.isUrlDataSpecified()) {
272
+ UrlData[] urlData = record.getUrlData();
273
+ UrlDataForJson[] urlDataForJsonArray = new UrlDataForJson[urlData.length];
274
+ for (int i = 0; i < urlData.length; i++) {
275
+ if (urlData[i] != null) {
276
+ UrlDataForJson urlDataForJson = new UrlDataForJson();
277
+ urlDataForJson.terminalType = urlData[i].getTerminalType();
278
+ urlDataForJson.url = urlData[i].getUrl();
279
+ urlDataForJson.title = urlData[i].getTitle();
280
+ urlDataForJsonArray[i] = urlDataForJson;
281
+ }
282
+ }
283
+ pageBuilder.setString(c, javaObjToJsonString(urlDataForJsonArray));
284
+ }
285
+ else pageBuilder.setNull(c);
286
+ break;
287
+ case "parentAdId":
288
+ if (record.isParentAdIdSpecified()) pageBuilder.setString(c, record.getParentAdId());
289
+ else pageBuilder.setNull(c);
290
+ break;
291
+ default:
292
+ break;
293
+ }
294
+ if (isExcluded) break;
295
+ }
296
+ if (isExcluded)
297
+ pageBuilder.flush();
298
+ else
299
+ pageBuilder.addRecord();
300
+ }
301
+ }
302
+
303
+ setLastRecordTime(Optional.of(newestRecordTime.format(embulkDateTimeFormat)));
304
+ setLastRecordId(Optional.of(String.valueOf(lastRecordId)));
305
+ }
306
+
307
+ public Schema buildSchema() {
308
+ return Schema.builder()
309
+ .add("createdAt" , Types.TIMESTAMP)
310
+ .add("adId" , Types.STRING)
311
+ .add("adGroup1Id" , Types.LONG)
312
+ .add("adGroup2Id" , Types.LONG)
313
+ .add("mediaId" , Types.LONG)
314
+ .add("keyword" , Types.STRING)
315
+ .add("note" , Types.STRING)
316
+ .add("baseCpc" , Types.LONG)
317
+ .add("adStartDate" , Types.STRING)
318
+ .add("adEndDate" , Types.STRING)
319
+ .add("textData" , Types.STRING)
320
+ .add("created" , Types.LONG)
321
+ .add("modified" , Types.LONG)
322
+ .add("deleteFlag" , Types.BOOLEAN)
323
+ .add("lpoAutoFlag" , Types.BOOLEAN)
324
+ .add("lpoAutoResetFlag" , Types.BOOLEAN)
325
+ .add("lpoType" , Types.STRING)
326
+ .add("details" , Types.STRING)
327
+ .add("urlData" , Types.STRING)
328
+ .add("parentAdId" , Types.STRING)
329
+ .build();
330
+ }
331
+
332
+ public AdCondition buildCondition() {
333
+ AdCondition cond = new AdCondition();
334
+
335
+ if (condition == null) return cond;
336
+
337
+ if (condition.getAdGroup1Ids().isPresent()) {
338
+ printDebugMessage("広告グループ1IDで絞り込み");
339
+ List<Integer> adGroup1IdsList = condition.getAdGroup1Ids().get();
340
+ int[] adGroup1IdsArray = new int[adGroup1IdsList.size()];
341
+ for (int i = 0; i < adGroup1IdsList.size(); i++) {
342
+ adGroup1IdsArray[i] = adGroup1IdsList.get(i);
343
+ }
344
+ cond.setAdGroup1Ids(adGroup1IdsArray);
345
+ }
346
+ if (condition.getAdGroup2Ids().isPresent()) {
347
+ printDebugMessage("広告グループ2IDで絞り込み");
348
+ List<Integer> adGroup2IdsList = condition.getAdGroup2Ids().get();
349
+ int[] adGroup2IdsArray = new int[adGroup2IdsList.size()];
350
+ for (int i = 0; i < adGroup2IdsList.size(); i++) {
351
+ adGroup2IdsArray[i] = adGroup2IdsList.get(i);
352
+ }
353
+ cond.setAdGroup2Ids(adGroup2IdsArray);
354
+ }
355
+ if (condition.getAdIds().isPresent()) {
356
+ printDebugMessage("広告IDで絞り込み");
357
+ List<String> adIdsList = condition.getAdIds().get();
358
+ String[] adIdsArray = adIdsList.toArray(new String[adIdsList.size()]);
359
+ cond.setAdIds(adIdsArray);
360
+ }
361
+ if (condition.getMediaIds().isPresent()) {
362
+ printDebugMessage("媒体種別IDで絞り込み");
363
+ List<Integer> mediaIdsList = condition.getMediaIds().get();
364
+ int[] mediaIdsArray = new int[mediaIdsList.size()];
365
+ for (int i = 0; i < mediaIdsList.size(); i++) {
366
+ mediaIdsArray[i] = mediaIdsList.get(i);
367
+ }
368
+ cond.setMediaIds(mediaIdsArray);
369
+ }
370
+ if (condition.getKeyword().isPresent()) {
371
+ printDebugMessage("広告名で絞り込み");
372
+ String keyword = condition.getKeyword().get();
373
+ cond.setKeyword(keyword);
374
+ }
375
+ if (condition.getNote().isPresent()) {
376
+ printDebugMessage("備考で絞り込み");
377
+ String note = condition.getNote().get();
378
+ cond.setNote(note);
379
+ }
380
+ if (condition.getTextData().isPresent()) {
381
+ printDebugMessage("テキスト原稿で絞り込み");
382
+ String textData = condition.getTextData().get();
383
+ cond.setNote(textData);
384
+ }
385
+ if (condition.getAdStatus().isPresent()) {
386
+ printDebugMessage("adStatusで絞り込み");
387
+ Integer adStatus = condition.getAdStatus().get();
388
+ cond.setAdStatus(adStatus);
389
+ }
390
+ if (condition.getStartCreated().isPresent()) {
391
+ printDebugMessage("startCreatedで絞り込み");
392
+ Long startCreated = condition.getStartCreated().get();
393
+ cond.setStartCreated(startCreated);
394
+ }
395
+ if (condition.getEndCreated().isPresent()) {
396
+ printDebugMessage("endCreatedで絞り込み");
397
+ Long endCreated = condition.getEndCreated().get();
398
+ cond.setEndCreated(endCreated);
399
+ }
400
+ if (condition.getStartModified().isPresent()) {
401
+ printDebugMessage("startModifiedで絞り込み");
402
+ Long startModified = condition.getStartModified().get();
403
+ cond.setStartModified(startModified);
404
+ }
405
+ if (condition.getEndModified().isPresent()) {
406
+ printDebugMessage("endModifiedで絞り込み");
407
+ Long endModified = condition.getEndModified().get();
408
+ cond.setEndModified(endModified);
409
+ }
410
+ if (condition.getTerminalTypes().isPresent()) {
411
+ printDebugMessage("デバイス種別で絞り込み");
412
+ List<Integer> terminalTypesList = condition.getTerminalTypes().get();
413
+ int[] terminalTypesArray = new int[terminalTypesList.size()];
414
+ for (int i = 0; i < terminalTypesList.size(); i++) {
415
+ terminalTypesArray[i] = terminalTypesList.get(i);
416
+ }
417
+ cond.setTerminalTypes(terminalTypesArray);
418
+ }
419
+
420
+ return cond;
421
+ }
422
+
423
+ public String javaObjToJsonString(Object javaObjForJson) {
424
+ String json = null;
425
+ try {
426
+ ObjectMapper objectMapper = new ObjectMapper();
427
+ json = objectMapper.writeValueAsString(javaObjForJson);
428
+ } catch (JsonProcessingException e) {
429
+ e.printStackTrace();
430
+ }
431
+ return json;
432
+ }
433
+
434
+ }