diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/processes/implementations/bulk/insert/BulkInsertTransformStep.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/processes/implementations/bulk/insert/BulkInsertTransformStep.java index ad531967..bd1fb40c 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/processes/implementations/bulk/insert/BulkInsertTransformStep.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/processes/implementations/bulk/insert/BulkInsertTransformStep.java @@ -58,7 +58,8 @@ import com.kingsrook.qqq.backend.core.model.metadata.tables.UniqueKey; import com.kingsrook.qqq.backend.core.model.statusmessages.QErrorMessage; import com.kingsrook.qqq.backend.core.processes.implementations.bulk.insert.mapping.AbstractBulkLoadRollableValueError; import com.kingsrook.qqq.backend.core.processes.implementations.bulk.insert.mapping.BulkLoadRecordUtils; -import com.kingsrook.qqq.backend.core.processes.implementations.bulk.insert.model.BulkInsertMapping; +import com.kingsrook.qqq.backend.core.processes.implementations.bulk.insert.mapping.BulkLoadTableStructureBuilder; +import com.kingsrook.qqq.backend.core.processes.implementations.bulk.insert.model.BulkLoadTableStructure; import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.AbstractTransformStep; import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.LoadViaInsertStep; import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.StreamedETLWithFrontendProcess; @@ -94,6 +95,7 @@ public class BulkInsertTransformStep extends AbstractTransformStep private static final int EXAMPLE_ROW_LIMIT = 10; + /******************************************************************************* ** extension of ProcessSummaryLine for lines where a UniqueKey was violated, ** where we'll collect a sample (or maybe all) of the values that broke the UK. @@ -139,16 +141,20 @@ public class BulkInsertTransformStep extends AbstractTransformStep ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// runBackendStepOutput.addValue("formatPreviewRecordUsingTableLayout", table.getName()); - BulkInsertMapping bulkInsertMapping = (BulkInsertMapping) runBackendStepOutput.getValue("bulkInsertMapping"); - if(bulkInsertMapping != null) + BulkLoadTableStructure tableStructure = BulkLoadTableStructureBuilder.buildTableStructure(table.getName()); + if(CollectionUtils.nullSafeHasContents(tableStructure.getAssociations())) { ArrayList previewRecordAssociatedTableNames = new ArrayList<>(); ArrayList previewRecordAssociatedWidgetNames = new ArrayList<>(); ArrayList previewRecordAssociationNames = new ArrayList<>(); - for(String mappedAssociation : bulkInsertMapping.getMappedAssociations()) + //////////////////////////////////////////////////////////// + // note - not recursively processing associations here... // + //////////////////////////////////////////////////////////// + for(BulkLoadTableStructure associatedStructure : tableStructure.getAssociations()) { - Optional association = table.getAssociations().stream().filter(a -> a.getName().equals(mappedAssociation)).findFirst(); + String associationName = associatedStructure.getAssociationPath(); + Optional association = table.getAssociations().stream().filter(a -> a.getName().equals(associationName)).findFirst(); if(association.isPresent()) { for(QFieldSection section : table.getSections()) @@ -518,17 +524,17 @@ public class BulkInsertTransformStep extends AbstractTransformStep String message = entry.getKey(); if(errorToExampleRowValueMap.containsKey(message)) { - ProcessSummaryLine line = entry.getValue(); - List rowValues = errorToExampleRowValueMap.get(message); - String exampleOrFull = rowValues.size() < line.getCount() ? "Example " : ""; + ProcessSummaryLine line = entry.getValue(); + List rowValues = errorToExampleRowValueMap.get(message); + String exampleOrFull = rowValues.size() < line.getCount() ? "Example " : ""; line.setMessageSuffix(line.getMessageSuffix() + ". " + exampleOrFull + "Values:"); line.setBulletsOfText(new ArrayList<>(rowValues.stream().map(String::valueOf).toList())); } else if(errorToExampleRowsMap.containsKey(message)) { - ProcessSummaryLine line = entry.getValue(); - List rowDescriptions = errorToExampleRowsMap.get(message); - String exampleOrFull = rowDescriptions.size() < line.getCount() ? "Example " : ""; + ProcessSummaryLine line = entry.getValue(); + List rowDescriptions = errorToExampleRowsMap.get(message); + String exampleOrFull = rowDescriptions.size() < line.getCount() ? "Example " : ""; line.setMessageSuffix(line.getMessageSuffix() + ". " + exampleOrFull + "Records:"); line.setBulletsOfText(new ArrayList<>(rowDescriptions.stream().map(String::valueOf).toList())); }