From 3f16f4c0c38fd3f7b854f769f06e2be65610f19d Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Mon, 29 Apr 2024 12:13:58 -0500 Subject: [PATCH] CE-1068 - Pass transaction throughout --- .../customizers/ScheduledJobTableCustomizer.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/scheduledjobs/customizers/ScheduledJobTableCustomizer.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/scheduledjobs/customizers/ScheduledJobTableCustomizer.java index 7203f500..13cfc0ec 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/scheduledjobs/customizers/ScheduledJobTableCustomizer.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/scheduledjobs/customizers/ScheduledJobTableCustomizer.java @@ -32,6 +32,7 @@ import java.util.Optional; import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; +import com.kingsrook.qqq.backend.core.actions.QBackendTransaction; import com.kingsrook.qqq.backend.core.actions.customizers.TableCustomizerInterface; import com.kingsrook.qqq.backend.core.actions.tables.QueryAction; import com.kingsrook.qqq.backend.core.exceptions.QException; @@ -58,6 +59,7 @@ import static com.kingsrook.qqq.backend.core.logging.LogUtils.logPair; *******************************************************************************/ public class ScheduledJobTableCustomizer implements TableCustomizerInterface { + private QBackendTransaction transaction = null; /******************************************************************************* ** @@ -65,6 +67,7 @@ public class ScheduledJobTableCustomizer implements TableCustomizerInterface @Override public List preInsert(InsertInput insertInput, List records, boolean isPreview) throws QException { + transaction = insertInput.getTransaction(); validateConditionalFields(records, Collections.emptyMap()); return (records); } @@ -77,6 +80,7 @@ public class ScheduledJobTableCustomizer implements TableCustomizerInterface @Override public List postInsert(InsertInput insertInput, List records) throws QException { + transaction = insertInput.getTransaction(); scheduleJobsForRecordList(records); return (records); } @@ -89,6 +93,7 @@ public class ScheduledJobTableCustomizer implements TableCustomizerInterface @Override public List preUpdate(UpdateInput updateInput, List records, boolean isPreview, Optional> oldRecordList) throws QException { + transaction = updateInput.getTransaction(); Map freshOldRecordsWithAssociationsMap = CollectionUtils.recordsToMap(freshlyQueryForRecordsWithAssociations(oldRecordList.get()), "id", Integer.class); validateConditionalFields(records, freshOldRecordsWithAssociationsMap); @@ -169,6 +174,7 @@ public class ScheduledJobTableCustomizer implements TableCustomizerInterface @Override public List postUpdate(UpdateInput updateInput, List records, Optional> oldRecordList) throws QException { + transaction = updateInput.getTransaction(); if(oldRecordList.isPresent()) { Set idsWithErrors = getRecordIdsWithErrors(records); @@ -201,6 +207,7 @@ public class ScheduledJobTableCustomizer implements TableCustomizerInterface @Override public List postDelete(DeleteInput deleteInput, List records) throws QException { + transaction = deleteInput.getTransaction(); Set idsWithErrors = getRecordIdsWithErrors(records); unscheduleJobsForRecordList(records, idsWithErrors); return (records); @@ -262,12 +269,13 @@ public class ScheduledJobTableCustomizer implements TableCustomizerInterface /******************************************************************************* ** *******************************************************************************/ - private static List freshlyQueryForRecordsWithAssociations(List records) throws QException + private List freshlyQueryForRecordsWithAssociations(List records) throws QException { List idList = records.stream().map(r -> r.getValueInteger("id")).toList(); return new QueryAction().execute(new QueryInput(ScheduledJob.TABLE_NAME) .withIncludeAssociations(true) + .withTransaction(transaction) .withFilter(new QQueryFilter(new QFilterCriteria("id", QCriteriaOperator.IN, idList)))) .getRecords(); }