embulk-input-marketo_extended 0.6.20 → 0.6.25
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/build.gradle +3 -1
- data/src/main/java/org/embulk/input/marketo/CsvTokenizer.java +3 -3
- data/src/main/java/org/embulk/input/marketo/MarketoService.java +1 -1
- data/src/main/java/org/embulk/input/marketo/MarketoServiceImpl.java +75 -11
- data/src/main/java/org/embulk/input/marketo/delegate/ActivityBulkExtractInputPlugin.java +5 -1
- data/src/main/java/org/embulk/input/marketo/delegate/MarketoBaseBulkExtractInputPlugin.java +8 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32159ad8f9fad3a8131bb16fd62735b23cfe8e42
|
4
|
+
data.tar.gz: adfe704d4f79971110e3d83aebb801ea52fa35ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d24bcd0780d4c3081cc7b8592fc8c854f0f33ddc6ec786ee33a31b5fe3d2e91a35e1514583892bc1348d4da51177564854bdf176413559ba4e61e00530a8b29
|
7
|
+
data.tar.gz: fc11f862364a6915c6266a464559afc5362e56a05e171175e73783b1fe7fed848f1794e7f5552257ed275d9e220d80a595a65fa4d3665cc63adb5db015d79ef6
|
data/build.gradle
CHANGED
@@ -16,11 +16,13 @@ repositories {
|
|
16
16
|
configurations {
|
17
17
|
provided
|
18
18
|
}
|
19
|
-
version = "0.6.
|
19
|
+
version = "0.6.25"
|
20
20
|
sourceCompatibility = 1.7
|
21
21
|
targetCompatibility = 1.7
|
22
22
|
|
23
|
+
|
23
24
|
dependencies {
|
25
|
+
|
24
26
|
compile "org.embulk:embulk-core:0.8.+"
|
25
27
|
provided "org.embulk:embulk-core:0.8.+"
|
26
28
|
compile "org.embulk.base.restclient:embulk-base-restclient:0.5.3"
|
@@ -380,7 +380,7 @@ public class CsvTokenizer
|
|
380
380
|
else if (isQuote(c)) {
|
381
381
|
char next = peekNextChar();
|
382
382
|
final char nextNext = peekNextNextChar();
|
383
|
-
|
383
|
+
Exec.getLogger(CsvTokenizer.class).info("Character is {}. Next: {}, NextNext:{}", c,next,nextNext);
|
384
384
|
if (isQuote(next)
|
385
385
|
&& (quotesInQuotedFields != "ACCEPT_STRAY_QUOTES_ASSUMING_NO_DELIMITERS_IN_FIELDS"
|
386
386
|
|| (!isDelimiter(nextNext) && !isEndOfLine(nextNext)))) {
|
@@ -399,14 +399,14 @@ public class CsvTokenizer
|
|
399
399
|
}
|
400
400
|
} else {
|
401
401
|
quotedValue.append(line.substring(valueStartPos, linePos - 1));
|
402
|
-
|
402
|
+
Exec.getLogger(CsvTokenizer.class).info("Current column state is {}. Quoted Value : {}", columnState, quotedValue);
|
403
403
|
columnState = ColumnState.AFTER_QUOTED_VALUE;
|
404
404
|
}
|
405
405
|
}
|
406
406
|
else if (isEscape(c)) { // isQuote must be checked first in case of quote == escape
|
407
407
|
// In RFC 4180, CSV's escape char is '\"'. But '\\' is often used.
|
408
408
|
char next = peekNextChar();
|
409
|
-
|
409
|
+
Exec.getLogger(CsvTokenizer.class).info("Esc Character is {}. Next: {}, column state{}", c,next, columnState);
|
410
410
|
if (isEndOfLine(c)) {
|
411
411
|
// escape end of line. TODO assuming multi-line quoted value without newline?
|
412
412
|
quotedValue.append(line.substring(valueStartPos, linePos));
|
@@ -16,7 +16,7 @@ public interface MarketoService
|
|
16
16
|
|
17
17
|
File extractLead(Date startTime, Date endTime, List<String> extractedFields, String filterField, int pollingTimeIntervalSecond, int bulkJobTimeoutSecond);
|
18
18
|
|
19
|
-
File extractAllActivity(List<Integer> activityTypeIds, Date startTime, Date endTime, int pollingTimeIntervalSecond, int bulkJobTimeoutSecond);
|
19
|
+
File extractAllActivity(List<Integer> activityTypeIds, Date startTime, Date endTime, int pollingTimeIntervalSecond, int bulkJobTimeoutSecond, String landingZone);
|
20
20
|
|
21
21
|
Iterable<ObjectNode> getAllListLead(List<String> extractFields);
|
22
22
|
|
@@ -21,6 +21,11 @@ import java.io.OutputStream;
|
|
21
21
|
import org.apache.commons.io.FileUtils;
|
22
22
|
import java.util.Date;
|
23
23
|
import java.util.List;
|
24
|
+
import java.time.format.DateTimeFormatter;
|
25
|
+
import java.text.DateFormat;
|
26
|
+
import java.text.SimpleDateFormat;
|
27
|
+
|
28
|
+
//import com.amazonaws.services.s3.AmazonS3;
|
24
29
|
|
25
30
|
/**
|
26
31
|
* Created by tai.khuu on 9/6/17.
|
@@ -37,6 +42,12 @@ public class MarketoServiceImpl implements MarketoService
|
|
37
42
|
|
38
43
|
private MarketoRestClient marketoRestClient;
|
39
44
|
|
45
|
+
private static Date startTime;
|
46
|
+
|
47
|
+
private DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
|
48
|
+
|
49
|
+
// private AmazonS3 s3;
|
50
|
+
|
40
51
|
public MarketoServiceImpl(MarketoRestClient marketoRestClient)
|
41
52
|
{
|
42
53
|
this.marketoRestClient = marketoRestClient;
|
@@ -45,6 +56,7 @@ public class MarketoServiceImpl implements MarketoService
|
|
45
56
|
@Override
|
46
57
|
public File extractLead(final Date startTime, Date endTime, List<String> extractedFields, String filterField, int pollingTimeIntervalSecond, final int bulkJobTimeoutSecond)
|
47
58
|
{
|
59
|
+
|
48
60
|
final String exportID = marketoRestClient.createLeadBulkExtract(startTime, endTime, extractedFields, filterField);
|
49
61
|
marketoRestClient.startLeadBulkExtract(exportID);
|
50
62
|
try {
|
@@ -85,9 +97,59 @@ public class MarketoServiceImpl implements MarketoService
|
|
85
97
|
return total;
|
86
98
|
}
|
87
99
|
|
100
|
+
// public boolean exists(String bucketName, String key) {
|
101
|
+
// try {
|
102
|
+
// fullObject = s3Client.getObject(new GetObjectRequest(bucketName, key));
|
103
|
+
// System.out.println("s3 object Content-Type: " + fullObject.getObjectMetadata().getContentType());
|
104
|
+
// return fullObject;
|
105
|
+
// } catch(AmazonServiceException e) {
|
106
|
+
// return false;
|
107
|
+
// }
|
108
|
+
// return true;
|
109
|
+
// }
|
110
|
+
// public String getBucket(String s3_key){
|
111
|
+
// if(s3_key.lenght()) {
|
112
|
+
// return s3_key.split('/')[0];
|
113
|
+
// }
|
114
|
+
// }
|
115
|
+
//
|
116
|
+
// public String getKey(String s3_key){
|
117
|
+
// if(s3_key.lenght()) {
|
118
|
+
// String [] key_parts = s3_key.split('/');
|
119
|
+
// String key = "";
|
120
|
+
// for (String k: key_parts){
|
121
|
+
// key = key + "/" + k ;
|
122
|
+
// }
|
123
|
+
// return s3_key.split('/')[0];
|
124
|
+
// }
|
125
|
+
// }
|
126
|
+
|
88
127
|
@Override
|
89
|
-
public File extractAllActivity(List<Integer> activityTypeIds, Date startTime, Date endTime, int pollingTimeIntervalSecond, int bulkJobTimeoutSecond)
|
128
|
+
public File extractAllActivity(List<Integer> activityTypeIds, Date startTime, Date endTime, int pollingTimeIntervalSecond, int bulkJobTimeoutSecond, String landingZoneFile)
|
90
129
|
{
|
130
|
+
String tempFile = "/tmp/marketo_" + this.dateFormat.format(startTime) +".csv";
|
131
|
+
this.startTime = startTime;
|
132
|
+
|
133
|
+
try{
|
134
|
+
if (landingZoneFile.length()>0){
|
135
|
+
LOGGER.info("Let's check for temp File = {}", tempFile);
|
136
|
+
File f = new File(tempFile);
|
137
|
+
if (f.exists() && f.isFile() && f.canRead()){
|
138
|
+
return f;
|
139
|
+
}
|
140
|
+
// // Lets read and return csv file from s3
|
141
|
+
// s3_object = get_s3_object(getBucket(landingZoneFile), getKey(landingZoneFile));
|
142
|
+
// if(s3_object){
|
143
|
+
// return s3_object.getObjectContent();
|
144
|
+
// }
|
145
|
+
|
146
|
+
}
|
147
|
+
}
|
148
|
+
catch (Exception e){
|
149
|
+
System.out.println("Exception on retrieving from landing zone");
|
150
|
+
System.out.println("Let's continue normal execution.");
|
151
|
+
}
|
152
|
+
|
91
153
|
final String exportID = marketoRestClient.createActivityExtract(activityTypeIds, startTime, endTime);
|
92
154
|
marketoRestClient.startActitvityBulkExtract(exportID);
|
93
155
|
try {
|
@@ -110,10 +172,8 @@ public class MarketoServiceImpl implements MarketoService
|
|
110
172
|
|
111
173
|
private File downloadBulkExtract(Function<BulkExtractRangeHeader, InputStream> getBulkExtractfunction)
|
112
174
|
{
|
113
|
-
final File tempFile = Exec.getTempFileSpace().createTempFile(DEFAULT_FILE_FORMAT);
|
114
|
-
LOGGER.info("Temp File = {}", tempFile.getPath());
|
115
|
-
// File destination = new File("/tmp/example_test.csv");
|
116
175
|
|
176
|
+
final File tempFile = Exec.getTempFileSpace().createTempFile(DEFAULT_FILE_FORMAT);
|
117
177
|
|
118
178
|
long startByte = 0;
|
119
179
|
int resumeTime = 0;
|
@@ -122,13 +182,17 @@ public class MarketoServiceImpl implements MarketoService
|
|
122
182
|
InputStream bulkExtractResult = getBulkExtractfunction.apply(bulkExtractRangeHeader);
|
123
183
|
try {
|
124
184
|
saveExtractedFile(bulkExtractResult, tempFile);
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
185
|
+
if (this.startTime != null){
|
186
|
+
String destinationFileName = "/tmp/marketo_" + this.dateFormat.format(this.startTime) +".csv";
|
187
|
+
final File destination = new File(destinationFileName);
|
188
|
+
try{
|
189
|
+
FileUtils.copyFile(tempFile, destination);
|
190
|
+
LOGGER.info("Save activities in file: "+destinationFileName);
|
191
|
+
}
|
192
|
+
catch (IOException e){
|
193
|
+
LOGGER.error("Exception when copying to file destination {}\nException:{}",destination.getPath(),e );
|
194
|
+
}
|
195
|
+
}
|
132
196
|
return tempFile;
|
133
197
|
}
|
134
198
|
catch (DownloadBulkExtractException e) {
|
@@ -143,7 +143,11 @@ public class ActivityBulkExtractInputPlugin extends MarketoBaseBulkExtractInputP
|
|
143
143
|
protected InputStream getExtractedStream(MarketoService service, PluginTask task, DateTime fromDate, DateTime toDate)
|
144
144
|
{
|
145
145
|
try {
|
146
|
-
|
146
|
+
String landing_path = "";
|
147
|
+
if (task.getLandingPath().isPresent()) {
|
148
|
+
landing_path = task.getLandingPath().get();
|
149
|
+
}
|
150
|
+
return new FileInputStream(service.extractAllActivity(task.getActTypeIds(), fromDate.toDate(), toDate.toDate(), task.getPollingIntervalSecond(), task.getBulkJobTimeoutSecond(), landing_path));
|
147
151
|
}
|
148
152
|
catch (FileNotFoundException e) {
|
149
153
|
throw new RuntimeException("Exception when trying to extract activity", e);
|
@@ -65,6 +65,10 @@ public abstract class MarketoBaseBulkExtractInputPlugin<T extends MarketoBaseBul
|
|
65
65
|
@ConfigDefault("1")
|
66
66
|
Integer getFetchDays();
|
67
67
|
|
68
|
+
@Config("landing_zone")
|
69
|
+
@ConfigDefault("null")
|
70
|
+
Optional<String> getLandingPath();
|
71
|
+
|
68
72
|
@Config("latest_fetch_time")
|
69
73
|
@ConfigDefault("null")
|
70
74
|
Optional<Long> getLatestFetchTime();
|
@@ -170,9 +174,9 @@ public abstract class MarketoBaseBulkExtractInputPlugin<T extends MarketoBaseBul
|
|
170
174
|
int imported = 0;
|
171
175
|
while (csvRecords.hasNext()) {
|
172
176
|
Map<String, String> csvRecord = csvRecords.next();
|
173
|
-
|
174
|
-
|
175
|
-
|
177
|
+
if(csvRecord.containsKey("attributes")) {
|
178
|
+
System.out.println("Attributes Before");
|
179
|
+
System.out.println(csvRecord.get("attributes"));
|
176
180
|
//
|
177
181
|
// csvRecord.put("attributes", csvRecord.get("attributes").replace("\\\"\"","\\\""));
|
178
182
|
// System.out.println("Attributes After");
|
@@ -181,7 +185,7 @@ public abstract class MarketoBaseBulkExtractInputPlugin<T extends MarketoBaseBul
|
|
181
185
|
|
182
186
|
// for (Map.Entry<String, String> entry : csvRecord.entrySet()) {
|
183
187
|
// System.out.println(entry.getKey() + ":" + entry.getValue().toString());
|
184
|
-
|
188
|
+
}
|
185
189
|
ObjectNode objectNode = MarketoUtils.OBJECT_MAPPER.valueToTree(csvRecord);
|
186
190
|
recordImporter.importRecord(new AllStringJacksonServiceRecord(objectNode), pageBuilder);
|
187
191
|
imported = imported + 1;
|
@@ -409,9 +413,7 @@ public abstract class MarketoBaseBulkExtractInputPlugin<T extends MarketoBaseBul
|
|
409
413
|
public boolean hasNext()
|
410
414
|
{
|
411
415
|
if (currentCsvRecord == null) {
|
412
|
-
LOGGER.info("Current csv record: {}", currentCsvRecord);
|
413
416
|
currentCsvRecord = getNextCSVRecord();
|
414
|
-
LOGGER.info("Next csv record: {}", currentCsvRecord);
|
415
417
|
|
416
418
|
}
|
417
419
|
return currentCsvRecord != null;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-marketo_extended
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uu59
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2020-11-
|
14
|
+
date: 2020-11-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,7 +140,7 @@ files:
|
|
140
140
|
- classpath/jetty-io-9.2.14.v20151106.jar
|
141
141
|
- classpath/commons-io-2.8.0.jar
|
142
142
|
- classpath/jetty-util-9.2.14.v20151106.jar
|
143
|
-
- classpath/embulk-input-marketo_extended-0.6.
|
143
|
+
- classpath/embulk-input-marketo_extended-0.6.25.jar
|
144
144
|
- classpath/jetty-http-9.2.14.v20151106.jar
|
145
145
|
- classpath/jetty-client-9.2.14.v20151106.jar
|
146
146
|
- classpath/embulk-base-restclient-0.5.3.jar
|