mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
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:
@ -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.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.AbstractBulkLoadRollableValueError;
|
||||||
import com.kingsrook.qqq.backend.core.processes.implementations.bulk.insert.mapping.BulkLoadRecordUtils;
|
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.AbstractTransformStep;
|
||||||
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.LoadViaInsertStep;
|
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.LoadViaInsertStep;
|
||||||
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.StreamedETLWithFrontendProcess;
|
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;
|
private static final int EXAMPLE_ROW_LIMIT = 10;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** extension of ProcessSummaryLine for lines where a UniqueKey was violated,
|
** 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.
|
** 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());
|
runBackendStepOutput.addValue("formatPreviewRecordUsingTableLayout", table.getName());
|
||||||
|
|
||||||
BulkInsertMapping bulkInsertMapping = (BulkInsertMapping) runBackendStepOutput.getValue("bulkInsertMapping");
|
BulkLoadTableStructure tableStructure = BulkLoadTableStructureBuilder.buildTableStructure(table.getName());
|
||||||
if(bulkInsertMapping != null)
|
if(CollectionUtils.nullSafeHasContents(tableStructure.getAssociations()))
|
||||||
{
|
{
|
||||||
ArrayList<String> previewRecordAssociatedTableNames = new ArrayList<>();
|
ArrayList<String> previewRecordAssociatedTableNames = new ArrayList<>();
|
||||||
ArrayList<String> previewRecordAssociatedWidgetNames = new ArrayList<>();
|
ArrayList<String> previewRecordAssociatedWidgetNames = new ArrayList<>();
|
||||||
ArrayList<String> previewRecordAssociationNames = 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())
|
if(association.isPresent())
|
||||||
{
|
{
|
||||||
for(QFieldSection section : table.getSections())
|
for(QFieldSection section : table.getSections())
|
||||||
@ -518,17 +524,17 @@ public class BulkInsertTransformStep extends AbstractTransformStep
|
|||||||
String message = entry.getKey();
|
String message = entry.getKey();
|
||||||
if(errorToExampleRowValueMap.containsKey(message))
|
if(errorToExampleRowValueMap.containsKey(message))
|
||||||
{
|
{
|
||||||
ProcessSummaryLine line = entry.getValue();
|
ProcessSummaryLine line = entry.getValue();
|
||||||
List<RowValue> rowValues = errorToExampleRowValueMap.get(message);
|
List<RowValue> rowValues = errorToExampleRowValueMap.get(message);
|
||||||
String exampleOrFull = rowValues.size() < line.getCount() ? "Example " : "";
|
String exampleOrFull = rowValues.size() < line.getCount() ? "Example " : "";
|
||||||
line.setMessageSuffix(line.getMessageSuffix() + ". " + exampleOrFull + "Values:");
|
line.setMessageSuffix(line.getMessageSuffix() + ". " + exampleOrFull + "Values:");
|
||||||
line.setBulletsOfText(new ArrayList<>(rowValues.stream().map(String::valueOf).toList()));
|
line.setBulletsOfText(new ArrayList<>(rowValues.stream().map(String::valueOf).toList()));
|
||||||
}
|
}
|
||||||
else if(errorToExampleRowsMap.containsKey(message))
|
else if(errorToExampleRowsMap.containsKey(message))
|
||||||
{
|
{
|
||||||
ProcessSummaryLine line = entry.getValue();
|
ProcessSummaryLine line = entry.getValue();
|
||||||
List<String> rowDescriptions = errorToExampleRowsMap.get(message);
|
List<String> rowDescriptions = errorToExampleRowsMap.get(message);
|
||||||
String exampleOrFull = rowDescriptions.size() < line.getCount() ? "Example " : "";
|
String exampleOrFull = rowDescriptions.size() < line.getCount() ? "Example " : "";
|
||||||
line.setMessageSuffix(line.getMessageSuffix() + ". " + exampleOrFull + "Records:");
|
line.setMessageSuffix(line.getMessageSuffix() + ". " + exampleOrFull + "Records:");
|
||||||
line.setBulletsOfText(new ArrayList<>(rowDescriptions.stream().map(String::valueOf).toList()));
|
line.setBulletsOfText(new ArrayList<>(rowDescriptions.stream().map(String::valueOf).toList()));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user