mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Add 'unspecifiedError' for higher-level exceptions; add primaryKeys in summary lines
This commit is contained in:
@ -35,6 +35,7 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
|
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
|
||||||
import com.kingsrook.qqq.backend.core.actions.values.QPossibleValueTranslator;
|
import com.kingsrook.qqq.backend.core.actions.values.QPossibleValueTranslator;
|
||||||
|
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||||
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
||||||
import com.kingsrook.qqq.backend.core.model.actions.audits.AuditSingleInput;
|
import com.kingsrook.qqq.backend.core.model.actions.audits.AuditSingleInput;
|
||||||
@ -74,18 +75,21 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
|
|
||||||
private ProcessSummaryLine okToInsert = StandardProcessSummaryLineProducer.getOkToInsertLine();
|
private ProcessSummaryLine okToInsert = StandardProcessSummaryLineProducer.getOkToInsertLine();
|
||||||
private ProcessSummaryLine okToUpdate = StandardProcessSummaryLineProducer.getOkToUpdateLine();
|
private ProcessSummaryLine okToUpdate = StandardProcessSummaryLineProducer.getOkToUpdateLine();
|
||||||
|
|
||||||
private ProcessSummaryLine willNotInsert = new ProcessSummaryLine(Status.INFO)
|
private ProcessSummaryLine willNotInsert = new ProcessSummaryLine(Status.INFO)
|
||||||
.withMessageSuffix("because of this process' configuration.")
|
.withMessageSuffix("because of this process' configuration.")
|
||||||
.withSingularFutureMessage("will not be inserted ")
|
.withSingularFutureMessage("will not be inserted ")
|
||||||
.withPluralFutureMessage("will not be inserted ")
|
.withPluralFutureMessage("will not be inserted ")
|
||||||
.withSingularPastMessage("was not inserted ")
|
.withSingularPastMessage("was not inserted ")
|
||||||
.withPluralPastMessage("were not inserted ");
|
.withPluralPastMessage("were not inserted ");
|
||||||
|
|
||||||
private ProcessSummaryLine willNotUpdate = new ProcessSummaryLine(Status.INFO)
|
private ProcessSummaryLine willNotUpdate = new ProcessSummaryLine(Status.INFO)
|
||||||
.withMessageSuffix("because of this process' configuration.")
|
.withMessageSuffix("because of this process' configuration.")
|
||||||
.withSingularFutureMessage("will not be updated ")
|
.withSingularFutureMessage("will not be updated ")
|
||||||
.withPluralFutureMessage("will not be updated ")
|
.withPluralFutureMessage("will not be updated ")
|
||||||
.withSingularPastMessage("was not updated ")
|
.withSingularPastMessage("was not updated ")
|
||||||
.withPluralPastMessage("were not updated ");
|
.withPluralPastMessage("were not updated ");
|
||||||
|
|
||||||
private ProcessSummaryLine errorMissingKeyField = new ProcessSummaryLine(Status.ERROR)
|
private ProcessSummaryLine errorMissingKeyField = new ProcessSummaryLine(Status.ERROR)
|
||||||
.withMessageSuffix("missing a value for the key field.")
|
.withMessageSuffix("missing a value for the key field.")
|
||||||
.withSingularFutureMessage("will not be synced, because it is ")
|
.withSingularFutureMessage("will not be synced, because it is ")
|
||||||
@ -93,6 +97,13 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
.withSingularPastMessage("was not synced, because it is ")
|
.withSingularPastMessage("was not synced, because it is ")
|
||||||
.withPluralPastMessage("were not synced, because they are ");
|
.withPluralPastMessage("were not synced, because they are ");
|
||||||
|
|
||||||
|
private ProcessSummaryLine unspecifiedError = new ProcessSummaryLine(Status.ERROR)
|
||||||
|
.withMessageSuffix("of an unexpected error: ")
|
||||||
|
.withSingularFutureMessage("will not be synced, ")
|
||||||
|
.withPluralFutureMessage("will not be synced, ")
|
||||||
|
.withSingularPastMessage("was not synced, ")
|
||||||
|
.withPluralPastMessage("were not synced, ");
|
||||||
|
|
||||||
protected RunBackendStepInput runBackendStepInput = null;
|
protected RunBackendStepInput runBackendStepInput = null;
|
||||||
protected RunBackendStepOutput runBackendStepOutput = null;
|
protected RunBackendStepOutput runBackendStepOutput = null;
|
||||||
protected RecordLookupHelper recordLookupHelper = null;
|
protected RecordLookupHelper recordLookupHelper = null;
|
||||||
@ -107,8 +118,17 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
@Override
|
@Override
|
||||||
public ArrayList<ProcessSummaryLineInterface> getProcessSummary(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen)
|
public ArrayList<ProcessSummaryLineInterface> getProcessSummary(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen)
|
||||||
{
|
{
|
||||||
ArrayList<ProcessSummaryLineInterface> processSummaryLineList = StandardProcessSummaryLineProducer.toArrayList(okToInsert, okToUpdate, errorMissingKeyField, willNotInsert, willNotUpdate);
|
return StandardProcessSummaryLineProducer.toArrayList(okToInsert, okToUpdate, errorMissingKeyField, unspecifiedError, willNotInsert, willNotUpdate);
|
||||||
return (processSummaryLineList);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
protected ArrayList<ProcessSummaryLineInterface> getErrorProcessSummaryLines(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen)
|
||||||
|
{
|
||||||
|
return StandardProcessSummaryLineProducer.toArrayList(errorMissingKeyField, unspecifiedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -237,6 +257,7 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
Set<Serializable> processedSourceKeys = new HashSet<>();
|
Set<Serializable> processedSourceKeys = new HashSet<>();
|
||||||
for(QRecord sourceRecord : runBackendStepInput.getRecords())
|
for(QRecord sourceRecord : runBackendStepInput.getRecords())
|
||||||
{
|
{
|
||||||
|
Serializable sourcePrimaryKey = sourceRecord.getValue(QContext.getQInstance().getTable(config.sourceTable).getPrimaryKeyField());
|
||||||
Serializable sourceKeyValue = sourceRecord.getValue(sourceTableKeyField);
|
Serializable sourceKeyValue = sourceRecord.getValue(sourceTableKeyField);
|
||||||
if(processedSourceKeys.contains(sourceKeyValue))
|
if(processedSourceKeys.contains(sourceKeyValue))
|
||||||
{
|
{
|
||||||
@ -247,7 +268,7 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
|
|
||||||
if(sourceKeyValue == null || "".equals(sourceKeyValue))
|
if(sourceKeyValue == null || "".equals(sourceKeyValue))
|
||||||
{
|
{
|
||||||
errorMissingKeyField.incrementCount();
|
errorMissingKeyField.incrementCountAndAddPrimaryKey(sourcePrimaryKey);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -266,6 +287,8 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
// look for the existing record, to determine insert/update //
|
// look for the existing record, to determine insert/update //
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
try
|
||||||
|
{
|
||||||
QRecord existingRecord = getExistingRecord(existingRecordsByForeignKey, destinationForeignKeyField, sourceKeyValue);
|
QRecord existingRecord = getExistingRecord(existingRecordsByForeignKey, destinationForeignKeyField, sourceKeyValue);
|
||||||
|
|
||||||
QRecord recordToStore;
|
QRecord recordToStore;
|
||||||
@ -282,12 +305,12 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
if(existingRecord != null)
|
if(existingRecord != null)
|
||||||
{
|
{
|
||||||
LOG.info("Skipping storing existing record because this sync process is set to not perform updates");
|
LOG.info("Skipping storing existing record because this sync process is set to not perform updates");
|
||||||
willNotInsert.incrementCount();
|
willNotInsert.incrementCountAndAddPrimaryKey(sourcePrimaryKey);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG.info("Skipping storing new record because this sync process is set to not perform inserts");
|
LOG.info("Skipping storing new record because this sync process is set to not perform inserts");
|
||||||
willNotUpdate.incrementCount();
|
willNotUpdate.incrementCountAndAddPrimaryKey(sourcePrimaryKey);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -300,16 +323,22 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
{
|
{
|
||||||
if(existingRecord != null)
|
if(existingRecord != null)
|
||||||
{
|
{
|
||||||
okToUpdate.incrementCount();
|
okToUpdate.incrementCountAndAddPrimaryKey(sourcePrimaryKey);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
okToInsert.incrementCount();
|
okToInsert.incrementCountAndAddPrimaryKey(sourcePrimaryKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
runBackendStepOutput.addRecord(recordToStore);
|
runBackendStepOutput.addRecord(recordToStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
unspecifiedError.incrementCountAndAddPrimaryKey(sourcePrimaryKey);
|
||||||
|
unspecifiedError.setMessageSuffix(unspecifiedError.getMessageSuffix() + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
// populate possible-values for review screen //
|
// populate possible-values for review screen //
|
||||||
|
Reference in New Issue
Block a user