CE-1955 populate association structures for record preview validation screen based on table structure associations, not actual mapping (e.g., so lines always appear on orders, even if not being used - to make that clear to user that they aren't being used)

This commit is contained in:
2024-12-03 20:39:18 -06:00
parent 1911e27cc0
commit b5eae02fa4

View File

@ -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<String> previewRecordAssociatedTableNames = new ArrayList<>();
ArrayList<String> previewRecordAssociatedWidgetNames = new ArrayList<>();
ArrayList<String> previewRecordAssociationNames = new ArrayList<>();
for(String mappedAssociation : bulkInsertMapping.getMappedAssociations())
////////////////////////////////////////////////////////////
// note - not recursively processing associations here... //
////////////////////////////////////////////////////////////
for(BulkLoadTableStructure associatedStructure : tableStructure.getAssociations())
{
Optional<Association> association = table.getAssociations().stream().filter(a -> a.getName().equals(mappedAssociation)).findFirst();
String associationName = associatedStructure.getAssociationPath();
Optional<Association> association = table.getAssociations().stream().filter(a -> a.getName().equals(associationName)).findFirst();
if(association.isPresent())
{
for(QFieldSection section : table.getSections())