Skip to content

Commit

Permalink
Fixed RD-15247: Reimplement JQL generation
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaidioz committed Jan 6, 2025
1 parent 8530102 commit 456d9da
Show file tree
Hide file tree
Showing 15 changed files with 1,846 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.rawlabs.das.sdk.java.exceptions.DASSdkApiException;
import com.rawlabs.protocol.das.Row;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

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 remoteZoneId, String table, String description) {
super(options, table, description);
localZoneId = ZoneId.of(options.get("timezone"));
this.remoteZoneId = remoteZoneId;
}

protected void processFields(
Expand Down Expand Up @@ -52,11 +64,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 @@ -87,11 +100,13 @@ protected void processFields(
throw new DASSdkApiException("error processing 'description'", 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 @@ -106,12 +121,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 @@ -129,7 +152,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 @@ -177,4 +203,10 @@ protected void processFields(
throw new DASSdkApiException(e.getMessage());
}
}

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

0 comments on commit 456d9da

Please sign in to comment.