From 24215e21c9f2ea388c32a03b26c9bbc6262e7e9d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 12 Jun 2024 14:15:19 -0400 Subject: [PATCH] Sanity check for deleted vendors --- src/engine/db/handlers/dbWarehouseHandler.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index bf067c5c..9137f07c 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -192,6 +192,7 @@ public class dbWarehouseHandler extends dbHandlerBase { // via the client interface. ArrayList submitList = new ArrayList<>(); + ArrayList orphanList = new ArrayList<>(); try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_workorders`;"); @@ -200,10 +201,6 @@ public class dbWarehouseHandler extends dbHandlerBase { while (rs.next()) { JSONObject jsonObject = new JSONObject(rs.getString("workorder")); WorkOrder workOrder = new WorkOrder(jsonObject); - - if (workOrder.vendor == null) - continue; - submitList.add(workOrder); } } catch (Exception e) { @@ -213,7 +210,14 @@ public class dbWarehouseHandler extends dbHandlerBase { // Submit new workOrders to the ForgeManager for (WorkOrder workOrder : submitList) { + DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); + + // Delete but do not reconstitute orphan workOrders + + if (workOrder.vendor == null) + continue; + workOrder.workOrderID = ForgeManager.workOrderCounter.incrementAndGet(); DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder);