Skip to content

Commit

Permalink
Add optional transition sync to the simple sync
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Dec 3, 2024
1 parent 3de0374 commit 5103661
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,17 @@ public void registerManagementRoutes(@Observes ManagementInterface mi) {
// syncs only assignee/body, without links comments and transitions
String project = rc.pathParam("project");
String query = rc.queryParam("query").getFirst();
String applyTransitionUpdate = rc.queryParam("applyTransitionUpdate").getFirst();

HandlerProjectContext context = contextPerProject.get(project);

if (context == null) {
throw new IllegalArgumentException("Unknown project '%s'".formatted(project));
}

syncByQuery(query, context, jiraIssue -> context
.submitTask(new JiraIssueSimpleUpsertEventHandler(reportingConfig, context, jiraIssue)));
syncByQuery(query, context,
jiraIssue -> context.submitTask(new JiraIssueSimpleUpsertEventHandler(reportingConfig, context,
jiraIssue, "true".equals(applyTransitionUpdate))));
rc.end();
});
mi.router().post("/sync/comments/list").consumes(MediaType.APPLICATION_JSON).blockingHandler(rc -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@

public class JiraIssueSimpleUpsertEventHandler extends JiraIssueInternalAbstractEventHandler {

private final boolean applyTransitionUpdate;

public JiraIssueSimpleUpsertEventHandler(ReportingConfig reportingConfig, HandlerProjectContext context,
JiraIssue issue) {
this(reportingConfig, context, issue, false);
}

public JiraIssueSimpleUpsertEventHandler(ReportingConfig reportingConfig, HandlerProjectContext context,
JiraIssue issue, boolean applyTransitionUpdate) {
super(reportingConfig, context, issue);
this.applyTransitionUpdate = applyTransitionUpdate;
}

@Override
protected void updateAction(String destinationKey, JiraIssue sourceIssue) {
updateIssueBody(sourceIssue, destinationKey);
JiraIssue destIssue = context.destinationJiraClient().getIssue(destinationKey);
updateIssueBody(sourceIssue, destIssue, destinationKey);
if (applyTransitionUpdate) {
applyTransition(sourceIssue, destIssue, destinationKey);
}
}

@Override
Expand Down

0 comments on commit 5103661

Please sign in to comment.