Skip to content

Commit 25c8c19

Browse files
committed
Merge pull request #267 from martiner/jmi-conTimes
introduce zendesk connector start dates
2 parents 14c842e + 57781c1 commit 25c8c19

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

src/main/java/com/gooddata/connector/Zendesk4ProcessExecution.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,29 @@
44
package com.gooddata.connector;
55

66
import static com.gooddata.connector.ConnectorType.ZENDESK4;
7+
import static com.gooddata.util.Validate.notEmpty;
8+
import static com.gooddata.util.Validate.notNull;
9+
10+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
11+
import org.joda.time.DateTime;
12+
import org.joda.time.DateTimeZone;
13+
import org.joda.time.format.DateTimeFormatter;
14+
import org.joda.time.format.ISODateTimeFormat;
15+
16+
import java.util.Map;
17+
import java.util.TreeMap;
718

819
/**
920
* Zendesk 4 (Insights) connector process execution (i.e. definition for single ETL run). Serialization only.
1021
*/
1122
public class Zendesk4ProcessExecution implements ProcessExecution {
1223

24+
private static final DateTimeFormatter FORMATTER = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
25+
1326
private Boolean incremental;
1427

28+
private Map<String, String> startTimes;
29+
1530
@Override
1631
public ConnectorType getConnectorType() {
1732
return ZENDESK4;
@@ -24,4 +39,19 @@ public Boolean getIncremental() {
2439
public void setIncremental(final Boolean incremental) {
2540
this.incremental = incremental;
2641
}
42+
43+
@JsonAnyGetter
44+
public Map<String, String> getStartTimes() {
45+
return startTimes;
46+
}
47+
48+
49+
public void setStartTime(final String resource, final DateTime startTime) {
50+
notEmpty(resource, "resource can't be empty");
51+
notNull(startTime, "startTime can't be null");
52+
53+
startTimes = startTimes == null ? new TreeMap<String, String>() : startTimes;
54+
55+
startTimes.put(resource + "StartDate", FORMATTER.print(startTime));
56+
}
2757
}

src/test/java/com/gooddata/connector/Zendesk4ProcessExecutionTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package com.gooddata.connector;
55

66
import com.gooddata.JsonMatchers;
7+
import org.joda.time.DateTime;
78
import org.testng.annotations.Test;
89

910
import static org.hamcrest.MatcherAssert.assertThat;
@@ -23,4 +24,13 @@ public void testShouldSerializeIncremental() throws Exception {
2324
assertThat(execution, JsonMatchers.serializesToJson(
2425
"/connector/process-execution-incremental.json"));
2526
}
27+
28+
@Test
29+
public void testShouldSerializeStartTimes() throws Exception {
30+
final Zendesk4ProcessExecution execution = new Zendesk4ProcessExecution();
31+
execution.setIncremental(true);
32+
execution.setStartTime("tickets", new DateTime(0L));
33+
assertThat(execution, JsonMatchers.serializesToJson(
34+
"/connector/process-execution-startDate.json"));
35+
}
2636
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"process": {
3+
"incremental": true,
4+
"ticketsStartDate": "1970-01-01T00:00:00.000Z"
5+
}
6+
}

0 commit comments

Comments
 (0)