From 311f38b6a4794f6d32b36c2559a035be377da5f5 Mon Sep 17 00:00:00 2001 From: Alexis Varsava Date: Tue, 18 Jun 2024 16:01:47 -0400 Subject: [PATCH] Let text searches access the vidarr id --- .../main/java/ca/on/oicr/gsi/shesmu/vidarr/RunState.java | 3 +++ .../ca/on/oicr/gsi/shesmu/vidarr/RunStateAttemptSubmit.java | 6 ++++++ .../ca/on/oicr/gsi/shesmu/vidarr/RunStateConflicted.java | 6 ++++++ .../java/ca/on/oicr/gsi/shesmu/vidarr/RunStateDead.java | 6 ++++++ .../java/ca/on/oicr/gsi/shesmu/vidarr/RunStateMissing.java | 6 ++++++ .../java/ca/on/oicr/gsi/shesmu/vidarr/RunStateMonitor.java | 6 ++++++ .../java/ca/on/oicr/gsi/shesmu/vidarr/SubmitAction.java | 3 ++- 7 files changed, 35 insertions(+), 1 deletion(-) diff --git a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunState.java b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunState.java index 3b41b7fbd..3f42e3eff 100644 --- a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunState.java +++ b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunState.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Optional; import java.util.OptionalInt; +import java.util.regex.Pattern; import java.util.stream.Stream; /** @@ -20,6 +21,8 @@ */ abstract class RunState { + public abstract boolean search(Pattern query); + public static final class PerformResult { private final ActionState actionState; private final List errors; diff --git a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateAttemptSubmit.java b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateAttemptSubmit.java index 3839b9ccb..e97635f76 100644 --- a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateAttemptSubmit.java +++ b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateAttemptSubmit.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Optional; import java.util.OptionalInt; +import java.util.regex.Pattern; import java.util.stream.Stream; /** State when we have no knowledge of what's going on in Vidarr */ @@ -36,6 +37,11 @@ public RunStateAttemptSubmit(int attempt) { this.attempt = attempt; } + @Override + public boolean search(Pattern query) { + return false; + } + @Override public AvailableCommands commands() { return AvailableCommands.RESET_ONLY; diff --git a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateConflicted.java b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateConflicted.java index 9e8b5436c..f519012a9 100644 --- a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateConflicted.java +++ b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateConflicted.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Optional; import java.util.OptionalInt; +import java.util.regex.Pattern; import java.util.stream.Stream; final class RunStateConflicted extends RunState { @@ -26,6 +27,11 @@ public RunStateConflicted(List ids) { + String.join(", ", ids)); } + @Override + public boolean search(Pattern query) { + return ids.stream().anyMatch(id -> query.matcher(id).matches()); + } + @Override public AvailableCommands commands() { return AvailableCommands.RESET_ONLY; diff --git a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateDead.java b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateDead.java index b235d9793..786fbe0bb 100644 --- a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateDead.java +++ b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateDead.java @@ -10,10 +10,16 @@ import java.util.List; import java.util.Optional; import java.util.OptionalInt; +import java.util.regex.Pattern; import java.util.stream.Stream; final class RunStateDead extends RunState { + @Override + public boolean search(Pattern query) { + return false; + } + @Override public AvailableCommands commands() { return AvailableCommands.RESET_ONLY; diff --git a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateMissing.java b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateMissing.java index c8072bdfa..b87d33806 100644 --- a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateMissing.java +++ b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateMissing.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Optional; import java.util.OptionalInt; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -34,6 +35,11 @@ public RunStateMissing(String id, List keys) { .collect(Collectors.toList()); } + @Override + public boolean search(Pattern query) { + return query.matcher(id).matches(); + } + @Override public AvailableCommands commands() { return AvailableCommands.RESET_ONLY; diff --git a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateMonitor.java b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateMonitor.java index 0f3dc3801..426f10e6b 100644 --- a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateMonitor.java +++ b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/RunStateMonitor.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Optional; import java.util.OptionalInt; +import java.util.regex.Pattern; import java.util.stream.Stream; final class RunStateMonitor extends RunState { @@ -93,6 +94,11 @@ public RunStateMonitor(String workflowRunUrl, WorkflowRunStatusResponse status) this.status = status; } + @Override + public boolean search(Pattern query) { + return query.matcher(status.getId()).matches(); + } + @Override public AvailableCommands commands() { // Failed during provision out may be retried diff --git a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/SubmitAction.java b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/SubmitAction.java index a3bc64c64..5c6c76bff 100644 --- a/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/SubmitAction.java +++ b/plugin-vidarr/src/main/java/ca/on/oicr/gsi/shesmu/vidarr/SubmitAction.java @@ -226,7 +226,8 @@ public boolean search(Pattern query) { || query.matcher(v.getValue()).matches())) || checkJson(request.getArguments(), query) || checkJson(request.getMetadata(), query) - || checkJson(request.getEngineParameters(), query); + || checkJson(request.getEngineParameters(), query) + || state.search(query); } @ActionParameter(required = false)