Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions das-jira-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.1</version>
<scope>test</scope>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.rawlabs.das.jira.DASJiraUnexpectedError;
import com.rawlabs.protocol.das.v1.tables.Row;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;

@SuppressWarnings("unchecked")
public abstract class DASJiraIssueTransformationTable extends DASJiraTable {

private final ZoneId localZoneId;
private final ZoneId remoteZoneId;
DateTimeFormatter offsetTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

protected DASJiraIssueTransformationTable(
Map<String, String> options, String table, String description) {
Map<String, String> options, ZoneId localZoneId, ZoneId remoteZoneId, String table, String description) {
super(options, table, description);
this.localZoneId = localZoneId;
this.remoteZoneId = remoteZoneId;
}

protected void processFields(
Expand Down Expand Up @@ -51,11 +61,12 @@ protected void processFields(
assignee.map(a -> a.get("displayName")).orElse(null),
columns);

addToRow(
"created",
rowBuilder,
maybeFields.map(f -> f.get(names.get("Created"))).orElse(null),
columns);
String created =
maybeFields
.map(f -> f.get(names.get("Created")))
.map(c -> toLocal(c.toString()).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
.orElse(null);
addToRow("created", rowBuilder, created, columns);

var creator =
maybeFields.map(f -> f.get(names.get("Creator"))).map(p -> (Map<String, Object>) p);
Expand Down Expand Up @@ -86,11 +97,13 @@ protected void processFields(
throw new DASJiraUnexpectedError(e);
}

addToRow(
"due_date",
rowBuilder,
maybeFields.map(f -> f.get(names.get("Due date"))).orElse(null),
columns);
String due_date =
maybeFields
.flatMap(f -> Optional.ofNullable(f.get(names.get("Due date"))))
.map(Object::toString)
.orElse(null);

addToRow("due_date", rowBuilder, due_date, columns);

var priority =
maybeFields.map(f -> f.get(names.get("Priority"))).map(p -> (Map<String, Object>) p);
Expand All @@ -105,12 +118,20 @@ protected void processFields(
rowBuilder,
reporter.map(r -> r.get("accountId")).orElse(null),
columns);

addToRow(
"reporter_display_name",
rowBuilder,
reporter.map(r -> r.get("displayName")).orElse(null),
columns);

String resolved =
maybeFields
.flatMap(f -> Optional.ofNullable(f.get(names.get("Resolved"))))
.map(c -> toLocal(c.toString()).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
.orElse(null);
addToRow("resolution_date", rowBuilder, resolved, columns);

addToRow(
"summary",
rowBuilder,
Expand All @@ -128,7 +149,10 @@ protected void processFields(
addToRow(
"updated",
rowBuilder,
maybeFields.map(f -> f.get(names.get("Updated"))).orElse(null),
maybeFields
.map(f -> f.get(names.get("Updated")))
.map(c -> toLocal(c.toString()).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
.orElse(null),
columns);

var componentIds =
Expand Down Expand Up @@ -176,4 +200,10 @@ protected void processFields(
throw new DASJiraUnexpectedError(e);
}
}

private OffsetDateTime toLocal(String remoteTime) {
return OffsetDateTime.parse(remoteTime, offsetTimeFormatter)
.atZoneSameInstant(localZoneId)
.toOffsetDateTime();
}
}
Loading