Skip to content

Commit 294c4aa

Browse files
committed
feat: use OrderRepository lookup for active order number tool
1 parent bdf96de commit 294c4aa

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/main/java/org/soujava/samples/ai/patterns/planning/OrderService.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
import jakarta.enterprise.context.ApplicationScoped;
55
import jakarta.inject.Inject;
66

7+
import java.util.Optional;
8+
import java.util.UUID;
9+
import java.util.logging.Logger;
10+
711
@ApplicationScoped
812
public class OrderService {
913

14+
private static final Logger LOGGER = Logger.getLogger(OrderService.class.getName());
15+
1016
private final OrderRepository repository;
1117

1218
@Inject
@@ -17,11 +23,9 @@ public OrderService(OrderRepository repository) {
1723
// Tool B (Requires the output of Tool A)
1824
@Tool("Finds the active Order Number for a given internal Customer ID.")
1925
public String getActiveOrderNumber(String customerId) {
20-
System.out.println("[TOOL EXECUTION] Looking up order for ID: " + customerId);
21-
if (customerId.equals("CUST-9988")) {
22-
return "ORD-12345";
23-
}
24-
return "NO_ACTIVE_ORDERS";
26+
LOGGER.info("[TOOL EXECUTION] Looking up order for ID: " + customerId);
27+
Optional<Order> order = repository.findByCustomerId(UUID.fromString(customerId));
28+
return order.map(Order::id).map(UUID::toString).orElse("NO_ACTIVE_ORDERS");
2529
}
2630

2731
// Tool C (Requires the output of Tool B)

0 commit comments

Comments
 (0)