Skip to content

Commit 230dd3f

Browse files
committed
chore(query): white space changes made by googleJavaFormat
Signed-off-by: “Kevin” <kevlar_ksb@yahoo.com>
1 parent 390455a commit 230dd3f

6 files changed

Lines changed: 60 additions & 63 deletions

File tree

src/main/java/com/uber/cadence/samples/query/LunchVoteWorkflow.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ private LunchVoteWorkflow() {}
3939

4040
/**
4141
* Signal payload for a lunch vote. Public fields are required so Cadence's JSON data converter
42-
* can deserialize the signal input. Field names must match the JSON keys in the Markdoc
43-
* {@code input=} attribute (e.g. {@code input={"location":"Farmhouse","meal":"Red Thai Curry"}}).
42+
* can deserialize the signal input. Field names must match the JSON keys in the Markdoc {@code
43+
* input=} attribute (e.g. {@code input={"location":"Farmhouse","meal":"Red Thai Curry"}}).
4444
*/
4545
public static class LunchOrder {
4646
public String location;
@@ -64,18 +64,19 @@ public LunchOrder(String location, String meal, String requests) {
6464
public interface WorkflowIface {
6565

6666
@WorkflowMethod(
67-
name = QueryConstants.LUNCH_VOTE_WORKFLOW_TYPE,
68-
executionStartToCloseTimeoutSeconds = 700,
69-
taskList = TASK_LIST)
67+
name = QueryConstants.LUNCH_VOTE_WORKFLOW_TYPE,
68+
executionStartToCloseTimeoutSeconds = 700,
69+
taskList = TASK_LIST
70+
)
7071
void run();
7172

7273
/** Visible as "options" in the Cadence Web Query dropdown. */
7374
@QueryMethod(name = "options")
7475
MarkdownFormattedResponse optionsQuery();
7576

7677
/**
77-
* {@code name} sets the signal type string the worker listens for. It must match the
78-
* {@code signalName} attribute in the Markdoc template so Cadence Web sends the right signal.
78+
* {@code name} sets the signal type string the worker listens for. It must match the {@code
79+
* signalName} attribute in the Markdoc template so Cadence Web sends the right signal.
7980
*/
8081
@SignalMethod(name = "lunch_order")
8182
void lunchOrder(LunchOrder vote);
@@ -136,8 +137,10 @@ public MarkdownFormattedResponse optionsQuery() {
136137
return new MarkdownFormattedResponse(data);
137138
}
138139

139-
/** Builds a Markdoc {@code {%- signal -%}} tag. Every attribute is required for Cadence Web
140-
* to route the signal to the correct workflow execution. */
140+
/**
141+
* Builds a Markdoc {@code {%- signal -%}} tag. Every attribute is required for Cadence Web to
142+
* route the signal to the correct workflow execution.
143+
*/
141144
private static String signalBlock(
142145
String workflowId, String runId, String label, String jsonInput) {
143146
return "{% signal \n"

src/main/java/com/uber/cadence/samples/query/MarkdownQueryWorkflow.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,18 @@ private MarkdownQueryWorkflow() {}
4343
*
4444
* <ul>
4545
* <li>{@code @WorkflowMethod} — the entry point; loops waiting for signals.
46-
* <li>{@code @QueryMethod} — returns a {@link MarkdownFormattedResponse} so Cadence Web
47-
* renders interactive markdown instead of raw JSON.
46+
* <li>{@code @QueryMethod} — returns a {@link MarkdownFormattedResponse} so Cadence Web renders
47+
* interactive markdown instead of raw JSON.
4848
* <li>{@code @SignalMethod} — receives external input (from Markdoc buttons or the CLI).
4949
* </ul>
5050
*/
5151
public interface WorkflowIface {
5252

5353
@WorkflowMethod(
54-
name = QueryConstants.MARKDOWN_QUERY_WORKFLOW_TYPE,
55-
executionStartToCloseTimeoutSeconds = 3600,
56-
taskList = TASK_LIST)
54+
name = QueryConstants.MARKDOWN_QUERY_WORKFLOW_TYPE,
55+
executionStartToCloseTimeoutSeconds = 3600,
56+
taskList = TASK_LIST
57+
)
5758
void run();
5859

5960
/**
@@ -96,7 +97,9 @@ public static final class WorkflowImpl implements WorkflowIface {
9697
private String cachedWorkflowId = "";
9798
private String cachedRunId = "";
9899

99-
/** Set by {@link #refreshSuggestedStartWorkflowId()} in {@code run()} before any query executes. */
100+
/**
101+
* Set by {@link #refreshSuggestedStartWorkflowId()} in {@code run()} before any query executes.
102+
*/
100103
private String suggestedNewWorkflowId = "";
101104

102105
@Override

src/main/java/com/uber/cadence/samples/query/OrderFulfillmentModels.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public static class Order {
5050
public String customerEmail = "alice.johnson@example.com";
5151
public OrderItem[] items =
5252
new OrderItem[] {
53-
new OrderItem("Wireless Headphones", 2, 79.99),
54-
new OrderItem("Phone Case", 1, 19.99),
53+
new OrderItem("Wireless Headphones", 2, 79.99), new OrderItem("Phone Case", 1, 19.99),
5554
};
5655
public double totalAmount = 179.97;
5756
public String status = STATUS_PENDING_PAYMENT;
@@ -86,8 +85,8 @@ public static class ActionLogEntry {
8685
/**
8786
* Signal POJOs below use public fields so the Cadence JSON data converter can deserialize them.
8887
* Field names must match the JSON keys in each Markdoc {@code input=} attribute; for example
89-
* {@code input={"operator":"admin","reason":"Fraud"}} maps to {@link #operator} and
90-
* {@link #reason}.
88+
* {@code input={"operator":"admin","reason":"Fraud"}} maps to {@link #operator} and {@link
89+
* #reason}.
9190
*/
9291
public static class RejectPaymentSignal {
9392
public String reason;

src/main/java/com/uber/cadence/samples/query/OrderFulfillmentWorkflow.java

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,17 @@ private OrderFulfillmentWorkflow() {}
5151

5252
/**
5353
* Dashboard pattern: one query method renders the full markdown UI (tables, status, action
54-
* buttons), and multiple signal methods drive state transitions on the order. The {@code name}
55-
* on each {@code @SignalMethod} must match the {@code signalName} in the Markdoc template;
56-
* without {@code name}, the Java SDK would default to {@code WorkflowIface::methodName}.
54+
* buttons), and multiple signal methods drive state transitions on the order. The {@code name} on
55+
* each {@code @SignalMethod} must match the {@code signalName} in the Markdoc template; without
56+
* {@code name}, the Java SDK would default to {@code WorkflowIface::methodName}.
5757
*/
5858
public interface WorkflowIface {
5959

6060
@WorkflowMethod(
61-
name = QueryConstants.ORDER_FULFILLMENT_WORKFLOW_TYPE,
62-
executionStartToCloseTimeoutSeconds = 3600,
63-
taskList = TASK_LIST)
61+
name = QueryConstants.ORDER_FULFILLMENT_WORKFLOW_TYPE,
62+
executionStartToCloseTimeoutSeconds = 3600,
63+
taskList = TASK_LIST
64+
)
6465
void run();
6566

6667
/** Visible as "dashboard" in the Cadence Web Query dropdown. */
@@ -101,9 +102,8 @@ public static final class WorkflowImpl implements WorkflowIface {
101102

102103
/**
103104
* Inbox for signal-to-main-loop communication. Signal handlers (which execute on the workflow
104-
* thread but outside the main loop) enqueue messages here. The main {@link #run()} loop
105-
* drains the inbox one message at a time, keeping state transitions sequential and
106-
* deterministic.
105+
* thread but outside the main loop) enqueue messages here. The main {@link #run()} loop drains
106+
* the inbox one message at a time, keeping state transitions sequential and deterministic.
107107
*/
108108
private final ArrayDeque<Object> inbox = new ArrayDeque<>();
109109

@@ -136,8 +136,7 @@ public WorkflowImpl() {
136136
created.action = "Order Created";
137137
created.operator = "System";
138138
created.details =
139-
String.format(
140-
Locale.US, "Order %s created for %s", order.orderID, order.customerName);
139+
String.format(Locale.US, "Order %s created for %s", order.orderID, order.customerName);
141140
actionLog.add(created);
142141
}
143142

@@ -214,15 +213,11 @@ private void handleShip(OrderFulfillmentModels.ShipOrderSignal signal) {
214213
"Order Shipped",
215214
getOperator(signal.operator),
216215
String.format(
217-
Locale.US,
218-
"Carrier: %s, Tracking: %s",
219-
signal.carrier,
220-
signal.trackingNumber)));
216+
Locale.US, "Carrier: %s, Tracking: %s", signal.carrier, signal.trackingNumber)));
221217
}
222218

223219
private void handleRefund(OrderFulfillmentModels.RefundSignal signal) {
224-
if (!STATUS_PAYMENT_APPROVED.equals(order.status)
225-
&& !STATUS_SHIPPED.equals(order.status)) {
220+
if (!STATUS_PAYMENT_APPROVED.equals(order.status) && !STATUS_SHIPPED.equals(order.status)) {
226221
return;
227222
}
228223
order.status = STATUS_REFUNDED;
@@ -232,8 +227,7 @@ private void handleRefund(OrderFulfillmentModels.RefundSignal signal) {
232227
entry(
233228
"Refund Issued",
234229
getOperator(signal.operator),
235-
String.format(
236-
Locale.US, "Amount: $%.2f, Reason: %s", signal.amount, signal.reason)));
230+
String.format(Locale.US, "Amount: $%.2f, Reason: %s", signal.amount, signal.reason)));
237231
}
238232

239233
private void handleCancel(OrderFulfillmentModels.CancelOrderSignal signal) {
@@ -260,7 +254,8 @@ private void handleMarkDelivered(OrderFulfillmentModels.SimpleSignal signal) {
260254
"Package confirmed delivered to customer"));
261255
}
262256

263-
private OrderFulfillmentModels.ActionLogEntry entry(String action, String operator, String details) {
257+
private OrderFulfillmentModels.ActionLogEntry entry(
258+
String action, String operator, String details) {
264259
OrderFulfillmentModels.ActionLogEntry e = new OrderFulfillmentModels.ActionLogEntry();
265260
e.timestampMillis = Workflow.currentTimeMillis();
266261
e.action = action;
@@ -320,19 +315,12 @@ private String makeOrderDashboard() {
320315

321316
String trackingRow = "";
322317
if (order.trackingNum != null && !order.trackingNum.isEmpty()) {
323-
trackingRow =
324-
"\n| **Tracking** | "
325-
+ order.carrier
326-
+ " - "
327-
+ order.trackingNum
328-
+ " |";
318+
trackingRow = "\n| **Tracking** | " + order.carrier + " - " + order.trackingNum + " |";
329319
}
330320
String refundRow = "";
331321
if (order.refundAmount > 0) {
332322
refundRow =
333-
"\n| **Refund** | $"
334-
+ String.format(Locale.US, "%.2f", order.refundAmount)
335-
+ " |";
323+
"\n| **Refund** | $" + String.format(Locale.US, "%.2f", order.refundAmount) + " |";
336324
}
337325

338326
return "\n## 🛒 Order Dashboard\n\n"
@@ -420,7 +408,10 @@ private static String makeItemsTable(OrderFulfillmentModels.Order order) {
420408
String.format(
421409
Locale.US,
422410
"| %s | %d | $%.2f | $%.2f |\n",
423-
item.name, item.quantity, item.price, subtotal));
411+
item.name,
412+
item.quantity,
413+
item.price,
414+
subtotal));
424415
}
425416
return table.toString();
426417
}
@@ -445,8 +436,8 @@ private static String makeActionHistory(List<OrderFulfillmentModels.ActionLogEnt
445436

446437
/**
447438
* Key to the "state-driven UI" pattern: the set of rendered Markdoc buttons depends on the
448-
* current order status. For example, shipping options only appear when the order is
449-
* {@code ready_to_ship}, and approval buttons only appear when {@code pending_payment}.
439+
* current order status. For example, shipping options only appear when the order is {@code
440+
* ready_to_ship}, and approval buttons only appear when {@code pending_payment}.
450441
*/
451442
private static String makeActionButtons(
452443
String workflowId, String runId, OrderFulfillmentModels.Order order) {
@@ -490,9 +481,7 @@ private static String makeActionButtons(
490481
+ "\n**Refund Options:**\n\n"
491482
+ sig(
492483
"issue_refund",
493-
"💰 Full Refund ($"
494-
+ String.format(Locale.US, "%.2f", order.totalAmount)
495-
+ ")",
484+
"💰 Full Refund ($" + String.format(Locale.US, "%.2f", order.totalAmount) + ")",
496485
workflowId,
497486
runId,
498487
String.format(
@@ -550,9 +539,7 @@ private static String makeActionButtons(
550539
+ "\n**Refund Options:**\n\n"
551540
+ sig(
552541
"issue_refund",
553-
"💰 Full Refund ($"
554-
+ String.format(Locale.US, "%.2f", order.totalAmount)
555-
+ ")",
542+
"💰 Full Refund ($" + String.format(Locale.US, "%.2f", order.totalAmount) + ")",
556543
workflowId,
557544
runId,
558545
String.format(

src/main/java/com/uber/cadence/samples/query/QuerySampleSupport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ static boolean printHintIfDomainMissing(Throwable t) {
4343
String m = c.getMessage();
4444
if (m != null && m.contains("Domain") && m.contains("does not exist")) {
4545
System.err.println();
46-
System.err.println("Cadence reported that the domain \"" + SampleConstants.DOMAIN + "\" does not exist.");
46+
System.err.println(
47+
"Cadence reported that the domain \"" + SampleConstants.DOMAIN + "\" does not exist.");
4748
System.err.println("Register it once against your cluster, then run this starter again:");
4849
System.err.println();
4950
System.err.println(

src/main/java/com/uber/cadence/samples/query/QueryWorker.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import static com.uber.cadence.samples.query.QueryConstants.TASK_LIST;
2121

2222
import com.uber.cadence.client.WorkflowClient;
23+
import com.uber.cadence.samples.common.SampleConstants;
2324
import com.uber.cadence.worker.Worker;
2425
import com.uber.cadence.worker.WorkerFactory;
25-
import com.uber.cadence.samples.common.SampleConstants;
2626

2727
/**
2828
* Hosts all Custom Workflow Controls sample workflows and {@link
@@ -46,13 +46,17 @@ public static void main(String[] args) {
4646
MarkdownQueryWorkflow.WorkflowImpl.class,
4747
LunchVoteWorkflow.WorkflowImpl.class,
4848
OrderFulfillmentWorkflow.WorkflowImpl.class);
49-
worker.registerActivitiesImplementations(new MarkdownQueryWorkflow.MarkdownQueryActivitiesImpl());
49+
worker.registerActivitiesImplementations(
50+
new MarkdownQueryWorkflow.MarkdownQueryActivitiesImpl());
5051

5152
// Non-blocking: the worker threads poll the task list in the background and this process
5253
// stays alive until killed.
5354
factory.start();
54-
System.out.println("QueryWorker listening on task list \"" + TASK_LIST + "\" (domain \""
55-
+ SampleConstants.DOMAIN
56-
+ "\").");
55+
System.out.println(
56+
"QueryWorker listening on task list \""
57+
+ TASK_LIST
58+
+ "\" (domain \""
59+
+ SampleConstants.DOMAIN
60+
+ "\").");
5761
}
5862
}

0 commit comments

Comments
 (0)