From 4247ec44969453ecda7018fefde4348e1d8e5f2e Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Sun, 21 Jul 2024 23:15:43 -0700 Subject: [PATCH 1/3] updates --- build.gradle | 4 +- docs/workflow/README.md | 2 +- .../workflow/WorkflowInput.java | 18 ------ .../HelloWorld/workers/ConductorWorkers.java | 11 ---- .../HelloWorld/workflow/WorkflowInput.java | 14 ----- .../sdk/TaskWorkers/pojo/OrderInfo.java | 23 ------- .../io/orkes/conductor/sdk/WorkflowTest.java | 61 ------------------- .../{ => examples}/AbstractWorkflowTests.java | 26 ++++---- .../conductor/sdk/{ => examples}/ApiUtil.java | 2 +- .../AuthorizationManagement.java | 8 +-- .../sdk/{ => examples}/KitchenSink.java | 23 +++++-- .../{ => examples}/MetadataManagement.java | 2 +- .../OrkesClientExceptionExample.java | 2 +- .../{ => examples}/SchedulerManagement.java | 2 +- .../sdk/{ => examples}/TaskConfigure.java | 26 +++++--- .../sdk/{ => examples}/TaskDomainWorker.java | 2 +- .../sdk/{ => examples}/TaskRunner.java | 7 ++- .../{ => examples}/WorkflowManagement.java | 4 +- .../sdk/{ => examples}/WorkflowOps.java | 35 +++++++---- .../dynamicworkflow}/Main.java | 25 +++++--- .../workers/ConductorWorkers.java | 14 ++++- .../dynamicworkflow}/workers/UserInfo.java | 15 ++++- .../workflow/CreateWorkflow.java | 14 ++++- .../workflow/WorkflowInput.java | 28 +++++++++ .../helloworld}/Main.java | 23 +++++-- .../helloworld/workers/ConductorWorkers.java | 23 +++++++ .../helloworld}/workflow/CreateWorkflow.java | 15 ++++- .../helloworld/workflow/WorkflowInput.java | 26 ++++++++ .../taskworkers}/ConductorWorkers.java | 25 +++++--- .../examples/taskworkers/pojo/OrderInfo.java | 35 +++++++++++ .../taskworkers}/pojo/UserInfo.java | 14 ++++- .../conductor/client/WorkflowClient.java | 35 ++++++++++- .../client/http/OrkesWorkflowClient.java | 10 +++ 33 files changed, 361 insertions(+), 213 deletions(-) delete mode 100644 examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workflow/WorkflowInput.java delete mode 100644 examples/java/io/orkes/conductor/sdk/HelloWorld/workers/ConductorWorkers.java delete mode 100644 examples/java/io/orkes/conductor/sdk/HelloWorld/workflow/WorkflowInput.java delete mode 100644 examples/java/io/orkes/conductor/sdk/TaskWorkers/pojo/OrderInfo.java delete mode 100644 examples/java/io/orkes/conductor/sdk/WorkflowTest.java rename examples/java/io/orkes/conductor/sdk/{ => examples}/AbstractWorkflowTests.java (98%) rename examples/java/io/orkes/conductor/sdk/{ => examples}/ApiUtil.java (97%) rename examples/java/io/orkes/conductor/sdk/{ => examples}/AuthorizationManagement.java (94%) rename examples/java/io/orkes/conductor/sdk/{ => examples}/KitchenSink.java (78%) rename examples/java/io/orkes/conductor/sdk/{ => examples}/MetadataManagement.java (99%) rename examples/java/io/orkes/conductor/sdk/{ => examples}/OrkesClientExceptionExample.java (96%) rename examples/java/io/orkes/conductor/sdk/{ => examples}/SchedulerManagement.java (99%) rename examples/java/io/orkes/conductor/sdk/{ => examples}/TaskConfigure.java (77%) rename examples/java/io/orkes/conductor/sdk/{ => examples}/TaskDomainWorker.java (99%) rename examples/java/io/orkes/conductor/sdk/{ => examples}/TaskRunner.java (97%) rename examples/java/io/orkes/conductor/sdk/{ => examples}/WorkflowManagement.java (96%) rename examples/java/io/orkes/conductor/sdk/{ => examples}/WorkflowOps.java (83%) rename examples/java/io/orkes/conductor/sdk/{DynamicWorkflow => examples/dynamicworkflow}/Main.java (74%) rename examples/java/io/orkes/conductor/sdk/{DynamicWorkflow => examples/dynamicworkflow}/workers/ConductorWorkers.java (52%) rename examples/java/io/orkes/conductor/sdk/{DynamicWorkflow => examples/dynamicworkflow}/workers/UserInfo.java (55%) rename examples/java/io/orkes/conductor/sdk/{DynamicWorkflow => examples/dynamicworkflow}/workflow/CreateWorkflow.java (62%) create mode 100644 examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workflow/WorkflowInput.java rename examples/java/io/orkes/conductor/sdk/{HelloWorld => examples/helloworld}/Main.java (74%) create mode 100644 examples/java/io/orkes/conductor/sdk/examples/helloworld/workers/ConductorWorkers.java rename examples/java/io/orkes/conductor/sdk/{HelloWorld => examples/helloworld}/workflow/CreateWorkflow.java (55%) create mode 100644 examples/java/io/orkes/conductor/sdk/examples/helloworld/workflow/WorkflowInput.java rename examples/java/io/orkes/conductor/sdk/{TaskWorkers => examples/taskworkers}/ConductorWorkers.java (71%) create mode 100644 examples/java/io/orkes/conductor/sdk/examples/taskworkers/pojo/OrderInfo.java rename examples/java/io/orkes/conductor/sdk/{TaskWorkers => examples/taskworkers}/pojo/UserInfo.java (56%) diff --git a/build.gradle b/build.gradle index 574621fe..0936997a 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ ext { spectator : '1.3.7', awsSsm : '1.12.300', azureSsm : '4.2.3', - azureIdentity : '1.3.7', + azureIdentity : '1.12.2', eureka : '1.10.17', wiremock : '2.33.2', ioGRPC : '1.63.1', @@ -251,5 +251,5 @@ signing { tasks.withType(Test) { maxParallelForks = 1 } -sourceSets.main.java.srcDirs += ['example/java', 'example/resources'] +sourceSets.main.java.srcDirs += ['examples/java', 'examples/resources'] diff --git a/docs/workflow/README.md b/docs/workflow/README.md index 6cf80dff..824e4c19 100644 --- a/docs/workflow/README.md +++ b/docs/workflow/README.md @@ -110,7 +110,7 @@ public class ConductorWorkers { } ``` -See [DynamicWorkflow](../../examples/java/io/orkes/conductor/sdk/DynamicWorkflow) for a fully functional example. +See [DynamicWorkflow](../../examples/java/io/orkes/conductor/sdk/dynamicworkflow) for a fully functional example. ### Kitchen-Sink Workflow diff --git a/examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workflow/WorkflowInput.java b/examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workflow/WorkflowInput.java deleted file mode 100644 index 711f798b..00000000 --- a/examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workflow/WorkflowInput.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.orkes.conductor.sdk.DynamicWorkflow.workflow; - -public class WorkflowInput { - private String userId; - public WorkflowInput(String userId) { - this.userId = userId; - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } -} - - diff --git a/examples/java/io/orkes/conductor/sdk/HelloWorld/workers/ConductorWorkers.java b/examples/java/io/orkes/conductor/sdk/HelloWorld/workers/ConductorWorkers.java deleted file mode 100644 index 17c44b7b..00000000 --- a/examples/java/io/orkes/conductor/sdk/HelloWorld/workers/ConductorWorkers.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.orkes.conductor.sdk.HelloWorld.workers; - -import com.netflix.conductor.sdk.workflow.task.InputParam; -import com.netflix.conductor.sdk.workflow.task.WorkerTask; - -public class ConductorWorkers { - @WorkerTask("greet") - public String greeting(@InputParam("name") String name) { - return ("Hello " + name); - } -} diff --git a/examples/java/io/orkes/conductor/sdk/HelloWorld/workflow/WorkflowInput.java b/examples/java/io/orkes/conductor/sdk/HelloWorld/workflow/WorkflowInput.java deleted file mode 100644 index 58e433cc..00000000 --- a/examples/java/io/orkes/conductor/sdk/HelloWorld/workflow/WorkflowInput.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.orkes.conductor.sdk.HelloWorld.workflow; - -public class WorkflowInput { - private String name; - public WorkflowInput(String name) { - this.name = name; - } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/examples/java/io/orkes/conductor/sdk/TaskWorkers/pojo/OrderInfo.java b/examples/java/io/orkes/conductor/sdk/TaskWorkers/pojo/OrderInfo.java deleted file mode 100644 index 96515a9c..00000000 --- a/examples/java/io/orkes/conductor/sdk/TaskWorkers/pojo/OrderInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.orkes.conductor.sdk.TaskWorkers.pojo; - -public class OrderInfo { - private int quantity; - private int skuPrice; - - - public int getSkuPrice() { - return skuPrice; - } - - public void setSkuPrice(int skuPrice) { - this.skuPrice = skuPrice; - } - - public int getQuantity() { - return quantity; - } - - public void setQuantity(int quantity) { - this.quantity = quantity; - } -} diff --git a/examples/java/io/orkes/conductor/sdk/WorkflowTest.java b/examples/java/io/orkes/conductor/sdk/WorkflowTest.java deleted file mode 100644 index 18d4cef1..00000000 --- a/examples/java/io/orkes/conductor/sdk/WorkflowTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2022 Orkes, Inc. - *

- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package io.orkes.conductor.sdk; - -public class WorkflowTest extends AbstractWorkflowTests { - public void testWF(){ - WorkflowDef def = null; - Map> testInputs=null; - try { - def = getWorkflowDef("/workflows/calculate_loan_workflow.json"); - assertNotNull(def); - } catch (Exception e) { - throw new RuntimeException(e); - } - try{ - testInputs = getTestInputs("input.json"); - assertNotNull(testInputs); - }catch(Exception e){ - throw new RuntimeException(e); - } - WorkflowTestRequest testRequest = new WorkflowTestRequest(); - testRequest.setWorkflowDef(def); - WorkflowInput workflowInput = new WorkflowInput("Orkes"); - testRequest.setInput(objectMapper.convertValue(workflowInput, Map.class)); - - testRequest.setTaskRefToMockOutput(testInputs); - testRequest.setName(def.getName()); - testRequest.setVersion(def.getVersion()); - - Workflow execution = workflowClient.testWorkflow(testRequest); - assertNotNull(execution); - - //Assert that the workflow completed successfully - assertEquals(Workflow.WorkflowStatus.COMPLETED, execution.getStatus()); - - //Ensure the inputs were captured correctly - assertEquals(workflowInput.getName(), String.valueOf(execution.getInput().get("name"))); - - //Assert that 1 task has been completed - assertEquals(1, execution.getTasks().size()); - - //fetch the correct input from the workflow - assertEquals(workflowInput.getName(), execution.getTasks().get(0).getInputData().get("name")); - - //And that the task produced the right output - String result = "Hello Orkes"; - assertEquals(result, execution.getTasks().get(0).getOutputData().get("result")); - - - } -} diff --git a/examples/java/io/orkes/conductor/sdk/AbstractWorkflowTests.java b/examples/java/io/orkes/conductor/sdk/examples/AbstractWorkflowTests.java similarity index 98% rename from examples/java/io/orkes/conductor/sdk/AbstractWorkflowTests.java rename to examples/java/io/orkes/conductor/sdk/examples/AbstractWorkflowTests.java index 86d4b0b2..b4f37c19 100644 --- a/examples/java/io/orkes/conductor/sdk/AbstractWorkflowTests.java +++ b/examples/java/io/orkes/conductor/sdk/examples/AbstractWorkflowTests.java @@ -10,30 +10,31 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package io.orkes.conductor.sdk; +package io.orkes.conductor.sdk.examples; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.conductor.common.config.ObjectMapperProvider; import com.netflix.conductor.common.metadata.tasks.TaskResult; import com.netflix.conductor.common.metadata.tasks.TaskType; import com.netflix.conductor.common.metadata.workflow.WorkflowDef; import com.netflix.conductor.common.metadata.workflow.WorkflowTask; import com.netflix.conductor.common.run.Workflow; +import com.netflix.conductor.common.run.WorkflowTestRequest; + import io.orkes.conductor.client.ApiClient; import io.orkes.conductor.client.MetadataClient; import io.orkes.conductor.client.OrkesClients; import io.orkes.conductor.client.WorkflowClient; -import io.orkes.conductor.client.model.WorkflowTestRequest; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; @@ -135,4 +136,3 @@ protected Map> getTestInputs(String p } - diff --git a/examples/java/io/orkes/conductor/sdk/ApiUtil.java b/examples/java/io/orkes/conductor/sdk/examples/ApiUtil.java similarity index 97% rename from examples/java/io/orkes/conductor/sdk/ApiUtil.java rename to examples/java/io/orkes/conductor/sdk/examples/ApiUtil.java index b596fab4..f4143ccd 100644 --- a/examples/java/io/orkes/conductor/sdk/ApiUtil.java +++ b/examples/java/io/orkes/conductor/sdk/examples/ApiUtil.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package io.orkes.conductor.sdk; +package io.orkes.conductor.sdk.examples; import io.orkes.conductor.client.ApiClient; import io.orkes.conductor.client.OrkesClients; diff --git a/examples/java/io/orkes/conductor/sdk/AuthorizationManagement.java b/examples/java/io/orkes/conductor/sdk/examples/AuthorizationManagement.java similarity index 94% rename from examples/java/io/orkes/conductor/sdk/AuthorizationManagement.java rename to examples/java/io/orkes/conductor/sdk/examples/AuthorizationManagement.java index f18f9051..80f83092 100644 --- a/examples/java/io/orkes/conductor/sdk/AuthorizationManagement.java +++ b/examples/java/io/orkes/conductor/sdk/examples/AuthorizationManagement.java @@ -10,18 +10,14 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package io.orkes.conductor.sdk; +package io.orkes.conductor.sdk.examples; import java.util.Arrays; import java.util.UUID; import io.orkes.conductor.client.AuthorizationClient; import io.orkes.conductor.client.OrkesClients; -import io.orkes.conductor.client.model.AuthorizationRequest; -import io.orkes.conductor.client.model.SubjectRef; -import io.orkes.conductor.client.model.TargetRef; -import io.orkes.conductor.client.model.UpsertGroupRequest; -import io.orkes.conductor.client.model.UpsertUserRequest; +import io.orkes.conductor.client.model.*; /** * Examples for managing user authorization in Orkes Conductor diff --git a/examples/java/io/orkes/conductor/sdk/KitchenSink.java b/examples/java/io/orkes/conductor/sdk/examples/KitchenSink.java similarity index 78% rename from examples/java/io/orkes/conductor/sdk/KitchenSink.java rename to examples/java/io/orkes/conductor/sdk/examples/KitchenSink.java index 39e36a8f..2e7cb2b2 100644 --- a/examples/java/io/orkes/conductor/sdk/KitchenSink.java +++ b/examples/java/io/orkes/conductor/sdk/examples/KitchenSink.java @@ -1,17 +1,28 @@ -package io.orkes.conductor.sdk; +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples; + +import java.time.Duration; import com.netflix.conductor.sdk.workflow.def.ConductorWorkflow; import com.netflix.conductor.sdk.workflow.def.tasks.*; import com.netflix.conductor.sdk.workflow.executor.WorkflowExecutor; -import com.netflix.conductor.sdk.workflow.def.tasks.JQ; - - -import java.time.Duration; +import io.orkes.conductor.sdk.examples.helloworld.workflow.WorkflowInput; public class KitchenSink { private final WorkflowExecutor executor; - public GreetingsWorkflow(WorkflowExecutor executor) { + public KitchenSink(WorkflowExecutor executor) { this.executor = executor; } public ConductorWorkflow createWorkflow() { diff --git a/examples/java/io/orkes/conductor/sdk/MetadataManagement.java b/examples/java/io/orkes/conductor/sdk/examples/MetadataManagement.java similarity index 99% rename from examples/java/io/orkes/conductor/sdk/MetadataManagement.java rename to examples/java/io/orkes/conductor/sdk/examples/MetadataManagement.java index 0b3310a2..5e6396d0 100644 --- a/examples/java/io/orkes/conductor/sdk/MetadataManagement.java +++ b/examples/java/io/orkes/conductor/sdk/examples/MetadataManagement.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package io.orkes.conductor.sdk; +package io.orkes.conductor.sdk.examples; import java.util.Arrays; import java.util.Map; diff --git a/examples/java/io/orkes/conductor/sdk/OrkesClientExceptionExample.java b/examples/java/io/orkes/conductor/sdk/examples/OrkesClientExceptionExample.java similarity index 96% rename from examples/java/io/orkes/conductor/sdk/OrkesClientExceptionExample.java rename to examples/java/io/orkes/conductor/sdk/examples/OrkesClientExceptionExample.java index 7b159a0c..dc94cadb 100644 --- a/examples/java/io/orkes/conductor/sdk/OrkesClientExceptionExample.java +++ b/examples/java/io/orkes/conductor/sdk/examples/OrkesClientExceptionExample.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package io.orkes.conductor.sdk; +package io.orkes.conductor.sdk.examples; import io.orkes.conductor.client.MetadataClient; import io.orkes.conductor.client.OrkesClientException; diff --git a/examples/java/io/orkes/conductor/sdk/SchedulerManagement.java b/examples/java/io/orkes/conductor/sdk/examples/SchedulerManagement.java similarity index 99% rename from examples/java/io/orkes/conductor/sdk/SchedulerManagement.java rename to examples/java/io/orkes/conductor/sdk/examples/SchedulerManagement.java index 4be2612c..f2ed9164 100644 --- a/examples/java/io/orkes/conductor/sdk/SchedulerManagement.java +++ b/examples/java/io/orkes/conductor/sdk/examples/SchedulerManagement.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package io.orkes.conductor.sdk; +package io.orkes.conductor.sdk.examples; import java.util.List; diff --git a/examples/java/io/orkes/conductor/sdk/TaskConfigure.java b/examples/java/io/orkes/conductor/sdk/examples/TaskConfigure.java similarity index 77% rename from examples/java/io/orkes/conductor/sdk/TaskConfigure.java rename to examples/java/io/orkes/conductor/sdk/examples/TaskConfigure.java index 4ea7f845..d4313466 100644 --- a/examples/java/io/orkes/conductor/sdk/TaskConfigure.java +++ b/examples/java/io/orkes/conductor/sdk/examples/TaskConfigure.java @@ -1,17 +1,30 @@ -package io.orkes.conductor.sdk; +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; import com.netflix.conductor.common.metadata.tasks.TaskDef; import com.netflix.conductor.sdk.workflow.executor.WorkflowExecutor; + import io.orkes.conductor.client.MetadataClient; import io.orkes.conductor.client.OrkesClients; import io.orkes.conductor.client.TaskClient; import io.orkes.conductor.client.WorkflowClient; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; - public class TaskConfigure { @@ -49,4 +62,3 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc } } - diff --git a/examples/java/io/orkes/conductor/sdk/TaskDomainWorker.java b/examples/java/io/orkes/conductor/sdk/examples/TaskDomainWorker.java similarity index 99% rename from examples/java/io/orkes/conductor/sdk/TaskDomainWorker.java rename to examples/java/io/orkes/conductor/sdk/examples/TaskDomainWorker.java index d227436a..db9c92de 100644 --- a/examples/java/io/orkes/conductor/sdk/TaskDomainWorker.java +++ b/examples/java/io/orkes/conductor/sdk/examples/TaskDomainWorker.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package io.orkes.conductor.sdk; +package io.orkes.conductor.sdk.examples; import java.io.IOException; import java.util.Arrays; diff --git a/examples/java/io/orkes/conductor/sdk/TaskRunner.java b/examples/java/io/orkes/conductor/sdk/examples/TaskRunner.java similarity index 97% rename from examples/java/io/orkes/conductor/sdk/TaskRunner.java rename to examples/java/io/orkes/conductor/sdk/examples/TaskRunner.java index fed9e647..e7abee05 100644 --- a/examples/java/io/orkes/conductor/sdk/TaskRunner.java +++ b/examples/java/io/orkes/conductor/sdk/examples/TaskRunner.java @@ -10,9 +10,12 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package io.orkes.conductor.sdk; +package io.orkes.conductor.sdk.examples; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import com.netflix.conductor.client.worker.Worker; import com.netflix.conductor.common.metadata.tasks.Task; diff --git a/examples/java/io/orkes/conductor/sdk/WorkflowManagement.java b/examples/java/io/orkes/conductor/sdk/examples/WorkflowManagement.java similarity index 96% rename from examples/java/io/orkes/conductor/sdk/WorkflowManagement.java rename to examples/java/io/orkes/conductor/sdk/examples/WorkflowManagement.java index 11cb9821..12ad5974 100644 --- a/examples/java/io/orkes/conductor/sdk/WorkflowManagement.java +++ b/examples/java/io/orkes/conductor/sdk/examples/WorkflowManagement.java @@ -10,7 +10,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package io.orkes.conductor.sdk; +package io.orkes.conductor.sdk.examples; import java.util.Arrays; @@ -19,7 +19,7 @@ import io.orkes.conductor.client.OrkesClients; import io.orkes.conductor.client.WorkflowClient; -import static io.orkes.conductor.sdk.MetadataManagement.workflowDef; +import static io.orkes.conductor.sdk.examples.MetadataManagement.workflowDef; /** * Examples for managing Workflow operations in Conductor diff --git a/examples/java/io/orkes/conductor/sdk/WorkflowOps.java b/examples/java/io/orkes/conductor/sdk/examples/WorkflowOps.java similarity index 83% rename from examples/java/io/orkes/conductor/sdk/WorkflowOps.java rename to examples/java/io/orkes/conductor/sdk/examples/WorkflowOps.java index beb8d760..345965d9 100644 --- a/examples/java/io/orkes/conductor/sdk/WorkflowOps.java +++ b/examples/java/io/orkes/conductor/sdk/examples/WorkflowOps.java @@ -10,22 +10,23 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package examples.java.io.orkes.conductor.sdk; +package io.orkes.conductor.sdk.examples; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import com.netflix.conductor.common.metadata.tasks.Task; -import com.netflix.conductor.common.metadata.tasks.TaskResult; import com.netflix.conductor.common.run.Workflow; import com.netflix.conductor.sdk.workflow.def.ConductorWorkflow; +import com.netflix.conductor.sdk.workflow.def.tasks.SimpleTask; import com.netflix.conductor.sdk.workflow.executor.WorkflowExecutor; -import io.orkes.conductor.client.*; -import io.orkes.conductor.sdk.examples.HelloWorld.workflow.GreetingsWorkflow; -import io.orkes.conductor.sdk.examples.HelloWorld.workflow.WorkflowInput; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; +import io.orkes.conductor.client.*; +import io.orkes.conductor.sdk.examples.helloworld.workflow.WorkflowInput; public class WorkflowOps { @@ -35,6 +36,15 @@ public class WorkflowOps { private static final String UI_URL = "http://localhost:5000/execution/"; + public static ConductorWorkflow createGreetingsWorkflow(WorkflowExecutor executor) { + ConductorWorkflow workflow = new ConductorWorkflow<>(executor); + workflow.setName("greetings"); + workflow.setVersion(1); + SimpleTask greetingsTask = new SimpleTask("greet", "greet_ref"); + greetingsTask.input("name", "${workflow.input.name}"); + workflow.add(greetingsTask); + return workflow; + } public static void main(String[] args) throws ExecutionException, InterruptedException, TimeoutException { //Initialise Conductor Client @@ -48,8 +58,7 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc workflowExecutor.initWorkers("io.orkes.conductor.sdk.examples.HelloWorld.workers"); //Create the workflow with input - GreetingsWorkflow workflowCreator = new GreetingsWorkflow(workflowExecutor); - ConductorWorkflow simpleWorkflow = workflowCreator.createWorkflow(); + ConductorWorkflow simpleWorkflow = createGreetingsWorkflow(workflowExecutor); WorkflowInput input = new WorkflowInput("Orkes"); CompletableFuture workflowExecution = simpleWorkflow.executeDynamic(input); Workflow workflowRun = workflowExecution.get(100, TimeUnit.SECONDS); @@ -93,7 +102,7 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc public static OrkesClients getApiClientWithCredentials() { - ApiClient apiClient = new ApiClient(basePath,keyId,keySecret); + ApiClient apiClient = new ApiClient(BASE_PATH,"replace","replace"); apiClient.setWriteTimeout(30_000); apiClient.setReadTimeout(30_000); apiClient.setConnectTimeout(30_000); diff --git a/examples/java/io/orkes/conductor/sdk/DynamicWorkflow/Main.java b/examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/Main.java similarity index 74% rename from examples/java/io/orkes/conductor/sdk/DynamicWorkflow/Main.java rename to examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/Main.java index ed518451..e0ec33e5 100644 --- a/examples/java/io/orkes/conductor/sdk/DynamicWorkflow/Main.java +++ b/examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/Main.java @@ -1,4 +1,16 @@ -package io.orkes.conductor.sdk.DynamicWorkflow; +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.dynamicworkflow; import java.util.Arrays; import java.util.HashMap; @@ -11,16 +23,16 @@ import com.netflix.conductor.client.worker.Worker; import com.netflix.conductor.common.run.Workflow; import com.netflix.conductor.sdk.workflow.def.ConductorWorkflow; - import com.netflix.conductor.sdk.workflow.executor.WorkflowExecutor; + import io.orkes.conductor.client.MetadataClient; import io.orkes.conductor.client.OrkesClients; import io.orkes.conductor.client.TaskClient; import io.orkes.conductor.client.WorkflowClient; import io.orkes.conductor.client.automator.TaskRunnerConfigurer; -import io.orkes.conductor.sdk.DynamicWorkflow.workflow.CreateWorkflow; -import io.orkes.conductor.sdk.DynamicWorkflow.workflow.WorkflowInput; -import io.orkes.conductor.sdk.ApiUtil; +import io.orkes.conductor.sdk.examples.ApiUtil; +import io.orkes.conductor.sdk.examples.dynamicworkflow.workflow.CreateWorkflow; +import io.orkes.conductor.sdk.examples.dynamicworkflow.workflow.WorkflowInput; public class Main { @@ -61,6 +73,3 @@ private static TaskRunnerConfigurer initWorkers(List workers, TaskClient return taskRunner; } } - - - diff --git a/examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workers/ConductorWorkers.java b/examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workers/ConductorWorkers.java similarity index 52% rename from examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workers/ConductorWorkers.java rename to examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workers/ConductorWorkers.java index 035ecc12..d8dbb3fd 100644 --- a/examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workers/ConductorWorkers.java +++ b/examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workers/ConductorWorkers.java @@ -1,4 +1,16 @@ -package io.orkes.conductor.sdk.DynamicWorkflow.workers; +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.dynamicworkflow.workers; import com.netflix.conductor.sdk.workflow.task.InputParam; import com.netflix.conductor.sdk.workflow.task.WorkerTask; diff --git a/examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workers/UserInfo.java b/examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workers/UserInfo.java similarity index 55% rename from examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workers/UserInfo.java rename to examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workers/UserInfo.java index 84d5b2e1..20385936 100644 --- a/examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workers/UserInfo.java +++ b/examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workers/UserInfo.java @@ -1,4 +1,16 @@ -package io.orkes.conductor.sdk.DynamicWorkflow.workers; +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.dynamicworkflow.workers; public class UserInfo { @@ -49,4 +61,3 @@ public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } } - diff --git a/examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workflow/CreateWorkflow.java b/examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workflow/CreateWorkflow.java similarity index 62% rename from examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workflow/CreateWorkflow.java rename to examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workflow/CreateWorkflow.java index 86ac556d..82a69bb5 100644 --- a/examples/java/io/orkes/conductor/sdk/DynamicWorkflow/workflow/CreateWorkflow.java +++ b/examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workflow/CreateWorkflow.java @@ -1,4 +1,16 @@ -package io.orkes.conductor.sdk.DynamicWorkflow.workflow; +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.dynamicworkflow.workflow; import com.netflix.conductor.sdk.workflow.def.ConductorWorkflow; import com.netflix.conductor.sdk.workflow.def.tasks.SimpleTask; diff --git a/examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workflow/WorkflowInput.java b/examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workflow/WorkflowInput.java new file mode 100644 index 00000000..883e53a7 --- /dev/null +++ b/examples/java/io/orkes/conductor/sdk/examples/dynamicworkflow/workflow/WorkflowInput.java @@ -0,0 +1,28 @@ +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.dynamicworkflow.workflow; + +public class WorkflowInput { + private String userId; + public WorkflowInput(String userId) { + this.userId = userId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } +} diff --git a/examples/java/io/orkes/conductor/sdk/HelloWorld/Main.java b/examples/java/io/orkes/conductor/sdk/examples/helloworld/Main.java similarity index 74% rename from examples/java/io/orkes/conductor/sdk/HelloWorld/Main.java rename to examples/java/io/orkes/conductor/sdk/examples/helloworld/Main.java index 20043b99..710e479a 100644 --- a/examples/java/io/orkes/conductor/sdk/HelloWorld/Main.java +++ b/examples/java/io/orkes/conductor/sdk/examples/helloworld/Main.java @@ -1,4 +1,16 @@ -package io.orkes.conductor.sdk.HelloWorld; +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.helloworld; import java.util.Arrays; import java.util.HashMap; @@ -8,20 +20,19 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - import com.netflix.conductor.client.worker.Worker; import com.netflix.conductor.common.run.Workflow; import com.netflix.conductor.sdk.workflow.def.ConductorWorkflow; - import com.netflix.conductor.sdk.workflow.executor.WorkflowExecutor; + import io.orkes.conductor.client.MetadataClient; import io.orkes.conductor.client.OrkesClients; import io.orkes.conductor.client.TaskClient; import io.orkes.conductor.client.WorkflowClient; import io.orkes.conductor.client.automator.TaskRunnerConfigurer; -import io.orkes.conductor.sdk.ApiUtil; -import io.orkes.conductor.sdk.HelloWorld.workflow.CreateWorkflow; -import io.orkes.conductor.sdk.HelloWorld.workflow.WorkflowInput; +import io.orkes.conductor.sdk.examples.ApiUtil; +import io.orkes.conductor.sdk.examples.helloworld.workflow.CreateWorkflow; +import io.orkes.conductor.sdk.examples.helloworld.workflow.WorkflowInput; public class Main { diff --git a/examples/java/io/orkes/conductor/sdk/examples/helloworld/workers/ConductorWorkers.java b/examples/java/io/orkes/conductor/sdk/examples/helloworld/workers/ConductorWorkers.java new file mode 100644 index 00000000..17be6763 --- /dev/null +++ b/examples/java/io/orkes/conductor/sdk/examples/helloworld/workers/ConductorWorkers.java @@ -0,0 +1,23 @@ +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.helloworld.workers; + +import com.netflix.conductor.sdk.workflow.task.InputParam; +import com.netflix.conductor.sdk.workflow.task.WorkerTask; + +public class ConductorWorkers { + @WorkerTask("greet") + public String greeting(@InputParam("name") String name) { + return ("Hello " + name); + } +} diff --git a/examples/java/io/orkes/conductor/sdk/HelloWorld/workflow/CreateWorkflow.java b/examples/java/io/orkes/conductor/sdk/examples/helloworld/workflow/CreateWorkflow.java similarity index 55% rename from examples/java/io/orkes/conductor/sdk/HelloWorld/workflow/CreateWorkflow.java rename to examples/java/io/orkes/conductor/sdk/examples/helloworld/workflow/CreateWorkflow.java index ee453996..9c147008 100644 --- a/examples/java/io/orkes/conductor/sdk/HelloWorld/workflow/CreateWorkflow.java +++ b/examples/java/io/orkes/conductor/sdk/examples/helloworld/workflow/CreateWorkflow.java @@ -1,4 +1,16 @@ -package io.orkes.conductor.sdk.HelloWorld.workflow; +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.helloworld.workflow; import com.netflix.conductor.sdk.workflow.def.ConductorWorkflow; import com.netflix.conductor.sdk.workflow.def.tasks.SimpleTask; @@ -19,4 +31,3 @@ public ConductorWorkflow createGreetingsWorkflow() { return workflow; } } - diff --git a/examples/java/io/orkes/conductor/sdk/examples/helloworld/workflow/WorkflowInput.java b/examples/java/io/orkes/conductor/sdk/examples/helloworld/workflow/WorkflowInput.java new file mode 100644 index 00000000..0669a32d --- /dev/null +++ b/examples/java/io/orkes/conductor/sdk/examples/helloworld/workflow/WorkflowInput.java @@ -0,0 +1,26 @@ +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.helloworld.workflow; + +public class WorkflowInput { + private String name; + public WorkflowInput(String name) { + this.name = name; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/examples/java/io/orkes/conductor/sdk/TaskWorkers/ConductorWorkers.java b/examples/java/io/orkes/conductor/sdk/examples/taskworkers/ConductorWorkers.java similarity index 71% rename from examples/java/io/orkes/conductor/sdk/TaskWorkers/ConductorWorkers.java rename to examples/java/io/orkes/conductor/sdk/examples/taskworkers/ConductorWorkers.java index 245986fc..5edeede6 100644 --- a/examples/java/io/orkes/conductor/sdk/TaskWorkers/ConductorWorkers.java +++ b/examples/java/io/orkes/conductor/sdk/examples/taskworkers/ConductorWorkers.java @@ -1,15 +1,26 @@ -package io.orkes.conductor.sdk.TaskWorkers; +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.taskworkers; + +import java.util.Date; +import java.util.Random; import com.netflix.conductor.common.metadata.tasks.TaskResult; -import com.netflix.conductor.sdk.workflow.def.tasks.SimpleTask; -import com.netflix.conductor.sdk.workflow.def.tasks.Task; import com.netflix.conductor.sdk.workflow.task.InputParam; import com.netflix.conductor.sdk.workflow.task.WorkerTask; -import io.orkes.conductor.sdk.TaskWorkers.pojo.OrderInfo; -import io.orkes.conductor.sdk.TaskWorkers.pojo.UserInfo; -import java.util.Date; -import java.util.Random; +import io.orkes.conductor.sdk.examples.taskworkers.pojo.OrderInfo; +import io.orkes.conductor.sdk.examples.taskworkers.pojo.UserInfo; import static com.netflix.conductor.common.metadata.tasks.TaskResult.Status.COMPLETED; diff --git a/examples/java/io/orkes/conductor/sdk/examples/taskworkers/pojo/OrderInfo.java b/examples/java/io/orkes/conductor/sdk/examples/taskworkers/pojo/OrderInfo.java new file mode 100644 index 00000000..b61f551b --- /dev/null +++ b/examples/java/io/orkes/conductor/sdk/examples/taskworkers/pojo/OrderInfo.java @@ -0,0 +1,35 @@ +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.taskworkers.pojo; + +public class OrderInfo { + private int quantity; + private int skuPrice; + + + public int getSkuPrice() { + return skuPrice; + } + + public void setSkuPrice(int skuPrice) { + this.skuPrice = skuPrice; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } +} diff --git a/examples/java/io/orkes/conductor/sdk/TaskWorkers/pojo/UserInfo.java b/examples/java/io/orkes/conductor/sdk/examples/taskworkers/pojo/UserInfo.java similarity index 56% rename from examples/java/io/orkes/conductor/sdk/TaskWorkers/pojo/UserInfo.java rename to examples/java/io/orkes/conductor/sdk/examples/taskworkers/pojo/UserInfo.java index 594b30c6..5ef7f46d 100644 --- a/examples/java/io/orkes/conductor/sdk/TaskWorkers/pojo/UserInfo.java +++ b/examples/java/io/orkes/conductor/sdk/examples/taskworkers/pojo/UserInfo.java @@ -1,4 +1,16 @@ -package io.orkes.conductor.sdk.TaskWorkers.pojo; +/* + * Copyright 2024 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.sdk.examples.taskworkers.pojo; public class UserInfo { private String name; diff --git a/src/main/java/io/orkes/conductor/client/WorkflowClient.java b/src/main/java/io/orkes/conductor/client/WorkflowClient.java index b5e08958..eed489b8 100644 --- a/src/main/java/io/orkes/conductor/client/WorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/WorkflowClient.java @@ -35,10 +35,43 @@ public abstract class WorkflowClient extends com.netflix.conductor.client.http.W @Deprecated public abstract CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask); + /** + * Synchronously executes a workflow + * @param request workflow execution request + * @param waitUntilTask waits until workflow has reached this task. + * Useful for executing it synchronously until this task and then continuing asynchronous execution + * @param waitForSeconds maximum amount of time to wait before returning + * @return WorkflowRun + */ public abstract CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds); + /** + * Synchronously executes a workflow + * @param request workflow execution request + * @param waitUntilTasks waits until workflow has reached one of these tasks. + * Useful for executing it synchronously until this task and then continuing asynchronous execution + * Useful when workflow has multiple branches to wait for any of the branches to reach the task + * @param waitForSeconds maximum amount of time to wait before returning + * @return WorkflowRun + */ + public abstract CompletableFuture executeWorkflow(StartWorkflowRequest request, List waitUntilTasks, Integer waitForSeconds); + + /** + * Synchronously executes a workflow + * @param request workflow execution request + * @param waitUntilTask waits until workflow has reached one of these tasks. + * Useful for executing it synchronously until this task and then continuing asynchronous execution + * @param waitTimeout maximum amount of time to wait before returning + * @return WorkflowRun + */ public abstract WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout) throws ExecutionException, InterruptedException, TimeoutException; + /** + * Pause a running workflow - no new tasks are scheduled until resumed + * @param workflowIds ids of the workflow to be paused + * @return + * @throws ApiException + */ public abstract BulkResponse pauseWorkflow(List workflowIds) throws ApiException; public abstract BulkResponse restartWorkflow(List workflowIds, Boolean useLatestDefinitions) @@ -93,7 +126,7 @@ public abstract Map> getWorkflowsByNamesAndCorrelationIds */ public abstract Workflow updateVariables(String workflowId, Map variables); - public abstract void upgradeRunningWorkflow(String workflowId, UpgradeWorkflowRequest body); + public abstract void upgradeRunningWorkflow(String workflowId, UpgradeWorkflowRequest request); /** * diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java index 3eca4225..25a978bc 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java @@ -109,6 +109,16 @@ public CompletableFuture executeWorkflow(StartWorkflowRequest reque } } + @Override + public CompletableFuture executeWorkflow(StartWorkflowRequest request, List waitUntilTasks, Integer waitForSeconds) { + String waitUntilTask = String.join(",", waitUntilTasks); + if(apiClient.isUseGRPC()) { + return grpcWorkflowClient.executeWorkflow(request, waitUntilTask, waitForSeconds); + } else { + return executeWorkflowHttp(request, waitUntilTask, waitForSeconds); + } + } + @Override public WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout) throws ExecutionException, InterruptedException, TimeoutException { CompletableFuture future = executeWorkflow(request, waitUntilTask); From 287d29cfba0ab44c3cd9c80f23454e7c0f35bd28 Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Mon, 22 Jul 2024 13:35:36 -0700 Subject: [PATCH 2/3] Update TaskClientTests.java --- .../java/io/orkes/conductor/client/api/TaskClientTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/orkes/conductor/client/api/TaskClientTests.java b/src/test/java/io/orkes/conductor/client/api/TaskClientTests.java index c42de13c..75191273 100644 --- a/src/test/java/io/orkes/conductor/client/api/TaskClientTests.java +++ b/src/test/java/io/orkes/conductor/client/api/TaskClientTests.java @@ -148,7 +148,7 @@ public void testUpdateByRefNameSync() { assertEquals(Workflow.WorkflowStatus.COMPLETED, workflow.getStatus()); } - @Test + //@Test public void testTaskLog() throws Exception { var workflowName = "random_workflow_name_1hqiuwhjasdsadqqwe"; var taskName1 = "random_task_name_1najsbdha"; From 8d6d78dc2fcb92790e7f2e9d21e3b5b751cb7497 Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Mon, 22 Jul 2024 23:34:08 -0700 Subject: [PATCH 3/3] Update build.gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0936997a..80f67a94 100644 --- a/build.gradle +++ b/build.gradle @@ -251,5 +251,5 @@ signing { tasks.withType(Test) { maxParallelForks = 1 } -sourceSets.main.java.srcDirs += ['examples/java', 'examples/resources'] +//sourceSets.main.java.srcDirs += ['examples/java', 'examples/resources']