From 86c48835f60a2d55963e4eff82d07ff12efe2486 Mon Sep 17 00:00:00 2001 From: Steve Androulakis Date: Mon, 21 Oct 2024 22:07:34 -0700 Subject: [PATCH] split files, using jackson for transaction object --- .../earlyreturn/EarlyReturnClient.java | 33 +++++++++++++++---- .../earlyreturn/EarlyReturnWorker.java | 19 +++++++++++ .../samples/earlyreturn/Transaction.java | 21 +++++++----- .../earlyreturn/TransactionActivities.java | 19 +++++++++++ .../TransactionActivitiesImpl.java | 19 +++++++++++ .../earlyreturn/TransactionWorkflow.java | 19 +++++++++++ .../earlyreturn/TransactionWorkflowImpl.java | 19 +++++++++++ 7 files changed, 135 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnClient.java b/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnClient.java index ed11f2b6..a43f55b3 100644 --- a/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnClient.java +++ b/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnClient.java @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved + * + * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Modifications copyright (C) 2017 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.temporal.samples.earlyreturn; import io.temporal.client.*; @@ -20,7 +39,8 @@ public static WorkflowClient setupWorkflowClient() { // Run workflow using 'updateWithStart' private static void runWorkflowWithUpdateWithStart(WorkflowClient client) { - Transaction tx = new Transaction("", "Bob", "Alice", -1000); + Transaction tx = new Transaction("", "Bob", "Alice", + 1000); // Change this amount to a negative number to have initTransaction fail WorkflowOptions options = buildWorkflowOptions(); TransactionWorkflow workflow = client.newWorkflowStub(TransactionWorkflow.class, options); @@ -29,18 +49,19 @@ private static void runWorkflowWithUpdateWithStart(WorkflowClient client) { System.out.println("Starting workflow with UpdateWithStart"); UpdateWithStartWorkflowOperation updateOp = - UpdateWithStartWorkflowOperation.newBuilder(workflow::returnInitResult) - .setWaitForStage(WorkflowUpdateStage.COMPLETED) // Wait for update to complete - .build(); + UpdateWithStartWorkflowOperation.newBuilder(workflow::returnInitResult) + .setWaitForStage(WorkflowUpdateStage.COMPLETED) // Wait for update to complete + .build(); WorkflowUpdateHandle updateHandle = - WorkflowClient.updateWithStart(workflow::processTransaction, tx, updateOp); + WorkflowClient.updateWithStart(workflow::processTransaction, tx, updateOp); String transactionId = updateHandle.getResultAsync().get(); System.out.println("Transaction initialized successfully: " + transactionId); - // TODO get the result of the workflow + String result = WorkflowStub.fromTyped(workflow).getResult(String.class); + System.out.println("Workflow completed with result: " + result); } catch (Exception e) { System.err.println("Transaction initialization failed: " + e.getMessage()); diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnWorker.java b/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnWorker.java index 97ef9320..222368ec 100644 --- a/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnWorker.java +++ b/core/src/main/java/io/temporal/samples/earlyreturn/EarlyReturnWorker.java @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved + * + * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Modifications copyright (C) 2017 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.temporal.samples.earlyreturn; import io.temporal.client.WorkflowClient; diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/Transaction.java b/core/src/main/java/io/temporal/samples/earlyreturn/Transaction.java index adb87012..54e1adbf 100644 --- a/core/src/main/java/io/temporal/samples/earlyreturn/Transaction.java +++ b/core/src/main/java/io/temporal/samples/earlyreturn/Transaction.java @@ -1,15 +1,20 @@ /* - * Copyright (c) 2024 Temporal Technologies, Inc. All Rights Reserved. + * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not - * use this file except in compliance with the License. A copy of the License is - * located at + * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Modifications copyright (C) 2017 Uber Technologies, Inc. * - * This file 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. + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.temporal.samples.earlyreturn; diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivities.java b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivities.java index 1c018759..156dece5 100644 --- a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivities.java +++ b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivities.java @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved + * + * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Modifications copyright (C) 2017 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.temporal.samples.earlyreturn; import io.temporal.activity.ActivityInterface; diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivitiesImpl.java b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivitiesImpl.java index 39cbda12..54830c56 100644 --- a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivitiesImpl.java +++ b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionActivitiesImpl.java @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved + * + * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Modifications copyright (C) 2017 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.temporal.samples.earlyreturn; import io.temporal.failure.ApplicationFailure; diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflow.java b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflow.java index 272a5343..47ad69cc 100644 --- a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflow.java +++ b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflow.java @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved + * + * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Modifications copyright (C) 2017 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.temporal.samples.earlyreturn; import io.temporal.workflow.UpdateMethod; diff --git a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflowImpl.java b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflowImpl.java index b3ecf3c6..e33457c7 100644 --- a/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflowImpl.java +++ b/core/src/main/java/io/temporal/samples/earlyreturn/TransactionWorkflowImpl.java @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved + * + * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Modifications copyright (C) 2017 Uber Technologies, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not + * use this file except in compliance with the License. A copy of the License is + * located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file 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.temporal.samples.earlyreturn; import io.temporal.activity.ActivityOptions;