Skip to content

Commit

Permalink
feat(cli): add option to remove execution from sys restore-queue
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Mar 6, 2023
1 parent c8d32f0 commit 2f7caff
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class RestoreQueueCommand extends AbstractCommand {
@CommandLine.Option(names = {"--no-triggers"}, description = "Don't send triggers")
private boolean noTriggers = false;

@CommandLine.Option(names = {"--no-triggers-execution-id"}, description = "Remove executionId from trigger")
private boolean noTriggerExecutionId = false;

@Override
public Integer call() throws Exception {
super.call();
Expand All @@ -50,7 +53,7 @@ public Integer call() throws Exception {

// trigger
if (!this.noTriggers) {
int size = restoreQueueService.triggers(noRecreate);
int size = restoreQueueService.triggers(noRecreate, noTriggerExecutionId);
stdOut("Successfully send {0} triggers", size);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,20 @@ public int templates(boolean noRecreate) {
return this.send(templates, QueueFactoryInterface.TEMPLATE_NAMED, Template.class, noRecreate);
}

public int triggers(boolean noRecreate) {
public int triggers(boolean noRecreate, boolean noTriggerExecutionId) {
TriggerRepositoryInterface triggerRepository = applicationContext.getBean(TriggerRepositoryInterface.class);
List<Trigger> triggers = new ArrayList<>(triggerRepository.findAll());

if (noTriggerExecutionId) {
triggers = triggers
.stream()
.map(trigger -> trigger.toBuilder()
.executionId(null)
.build()
)
.collect(Collectors.toList());
}

return this.send(triggers, QueueFactoryInterface.TRIGGER_NAMED, Trigger.class, noRecreate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.micronaut.core.annotation.Nullable;
import javax.validation.constraints.NotNull;

@SuperBuilder
@SuperBuilder(toBuilder = true)
@ToString
@EqualsAndHashCode
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.Arrays;
import javax.validation.constraints.NotNull;

@SuperBuilder
@SuperBuilder(toBuilder = true)
@ToString
@Getter
@NoArgsConstructor
Expand Down

0 comments on commit 2f7caff

Please sign in to comment.