mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
CTLE-419: added ability to tell table sync step to either not do inserts or updates, another instant parse format, typo
This commit is contained in:
@ -72,6 +72,18 @@ 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)
|
||||||
|
.withMessageSuffix("because of this process' configuration.")
|
||||||
|
.withSingularFutureMessage("will not be inserted ")
|
||||||
|
.withPluralFutureMessage("will not be inserted ")
|
||||||
|
.withSingularPastMessage("was not inserted ")
|
||||||
|
.withPluralPastMessage("were not inserted ");
|
||||||
|
private ProcessSummaryLine willNotUpdate = new ProcessSummaryLine(Status.INFO)
|
||||||
|
.withMessageSuffix("because of this process' configuration.")
|
||||||
|
.withSingularFutureMessage("will not be updated ")
|
||||||
|
.withPluralFutureMessage("will not be updated ")
|
||||||
|
.withSingularPastMessage("was 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 ")
|
||||||
@ -92,7 +104,16 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
@Override
|
@Override
|
||||||
public ArrayList<ProcessSummaryLineInterface> getProcessSummary(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen)
|
public ArrayList<ProcessSummaryLineInterface> getProcessSummary(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen)
|
||||||
{
|
{
|
||||||
return (StandardProcessSummaryLineProducer.toArrayList(okToInsert, okToUpdate, errorMissingKeyField));
|
ArrayList<ProcessSummaryLineInterface> processSummaryLineList = StandardProcessSummaryLineProducer.toArrayList(okToInsert, okToUpdate, errorMissingKeyField);
|
||||||
|
if(willNotInsert.getCount() > 0)
|
||||||
|
{
|
||||||
|
processSummaryLineList.add(willNotInsert);
|
||||||
|
}
|
||||||
|
if(willNotUpdate.getCount() > 0)
|
||||||
|
{
|
||||||
|
processSummaryLineList.add(willNotUpdate);
|
||||||
|
}
|
||||||
|
return (processSummaryLineList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -145,6 +166,11 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public record SyncProcessConfig(String sourceTable, String sourceTableKeyField, String destinationTable, String destinationTableForeignKey)
|
public record SyncProcessConfig(String sourceTable, String sourceTableKeyField, String destinationTable, String destinationTableForeignKey)
|
||||||
{
|
{
|
||||||
|
public static boolean performUpdates = true;
|
||||||
|
public static boolean performInserts = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** artificial method, here to make jacoco see that this class is indeed
|
** artificial method, here to make jacoco see that this class is indeed
|
||||||
** included in test coverage...
|
** included in test coverage...
|
||||||
@ -153,6 +179,75 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
{
|
{
|
||||||
System.out.println("noop");
|
System.out.println("noop");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Getter for performUpdates
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public boolean getPerformUpdates()
|
||||||
|
{
|
||||||
|
return performUpdates;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Setter for performUpdates
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public void setPerformUpdates(boolean performUpdates)
|
||||||
|
{
|
||||||
|
SyncProcessConfig.performUpdates = performUpdates;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Fluent setter for performUpdates
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public SyncProcessConfig withPerformUpdates(boolean performUpdates)
|
||||||
|
{
|
||||||
|
SyncProcessConfig.performUpdates = performUpdates;
|
||||||
|
return (this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Getter for performInserts
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public boolean getPerformInserts()
|
||||||
|
{
|
||||||
|
return performInserts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Setter for performInserts
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public void setPerformInserts(boolean performInserts)
|
||||||
|
{
|
||||||
|
SyncProcessConfig.performInserts = performInserts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Fluent setter for performInserts
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public SyncProcessConfig withPerformInserts(boolean performInserts)
|
||||||
|
{
|
||||||
|
SyncProcessConfig.performInserts = performInserts;
|
||||||
|
return (this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -271,16 +366,30 @@ public abstract class AbstractTableSyncTransformStep extends AbstractTransformSt
|
|||||||
QRecord existingRecord = existingRecordsByForeignKey.get(sourceKeyValueInTargetFieldType);
|
QRecord existingRecord = existingRecordsByForeignKey.get(sourceKeyValueInTargetFieldType);
|
||||||
|
|
||||||
QRecord recordToStore;
|
QRecord recordToStore;
|
||||||
if(existingRecord != null)
|
if(existingRecord != null && config.getPerformUpdates())
|
||||||
{
|
{
|
||||||
recordToStore = existingRecord;
|
recordToStore = existingRecord;
|
||||||
okToUpdate.incrementCount();
|
okToUpdate.incrementCount();
|
||||||
}
|
}
|
||||||
else
|
else if(existingRecord == null && config.getPerformInserts())
|
||||||
{
|
{
|
||||||
recordToStore = new QRecord();
|
recordToStore = new QRecord();
|
||||||
okToInsert.incrementCount();
|
okToInsert.incrementCount();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(existingRecord != null)
|
||||||
|
{
|
||||||
|
LOG.info("Skipping storing existing record because this sync process is set to not perform updates");
|
||||||
|
willNotInsert.incrementCount();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG.info("Skipping storing new record because this sync process is set to not perform inserts");
|
||||||
|
willNotUpdate.incrementCount();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
recordToStore = populateRecordToStore(runBackendStepInput, recordToStore, sourceRecord);
|
recordToStore = populateRecordToStore(runBackendStepInput, recordToStore, sourceRecord);
|
||||||
runBackendStepOutput.addRecord(recordToStore);
|
runBackendStepOutput.addRecord(recordToStore);
|
||||||
|
@ -503,6 +503,11 @@ public class ValueUtils
|
|||||||
//////////////////////////
|
//////////////////////////
|
||||||
return Instant.parse(s + ":00Z");
|
return Instant.parse(s + ":00Z");
|
||||||
}
|
}
|
||||||
|
else if(s.matches("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.0$"))
|
||||||
|
{
|
||||||
|
s = s.replaceAll(" ", "T").replaceAll("\\..*$", "Z");
|
||||||
|
return Instant.parse(s);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -646,16 +651,16 @@ public class ValueUtils
|
|||||||
public static Serializable getValueAsFieldType(QFieldType type, Serializable value)
|
public static Serializable getValueAsFieldType(QFieldType type, Serializable value)
|
||||||
{
|
{
|
||||||
return switch(type)
|
return switch(type)
|
||||||
{
|
{
|
||||||
case STRING, TEXT, HTML, PASSWORD -> getValueAsString(value);
|
case STRING, TEXT, HTML, PASSWORD -> getValueAsString(value);
|
||||||
case INTEGER -> getValueAsInteger(value);
|
case INTEGER -> getValueAsInteger(value);
|
||||||
case DECIMAL -> getValueAsBigDecimal(value);
|
case DECIMAL -> getValueAsBigDecimal(value);
|
||||||
case BOOLEAN -> getValueAsBoolean(value);
|
case BOOLEAN -> getValueAsBoolean(value);
|
||||||
case DATE -> getValueAsLocalDate(value);
|
case DATE -> getValueAsLocalDate(value);
|
||||||
case TIME -> getValueAsLocalTime(value);
|
case TIME -> getValueAsLocalTime(value);
|
||||||
case DATE_TIME -> getValueAsInstant(value);
|
case DATE_TIME -> getValueAsInstant(value);
|
||||||
case BLOB -> getValueAsByteArray(value);
|
case BLOB -> getValueAsByteArray(value);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ gumBanner "Running mvn gitflow:release-start"
|
|||||||
mvn gitflow:release-start
|
mvn gitflow:release-start
|
||||||
gumConfirmProceed "Can we Proceed, or were there errors from the gitflow:release-start?" "Proceed" "There were errors..."
|
gumConfirmProceed "Can we Proceed, or were there errors from the gitflow:release-start?" "Proceed" "There were errors..."
|
||||||
|
|
||||||
gumBanner "Pushining release branch to origin"
|
gumBanner "Pushing release branch to origin"
|
||||||
git push --set-upstream origin "$(git rev-parse --abbrev-ref HEAD)"
|
git push --set-upstream origin "$(git rev-parse --abbrev-ref HEAD)"
|
||||||
|
|
||||||
gumBanner "Please wait for a green run in CI on the release branch..."
|
gumBanner "Please wait for a green run in CI on the release branch..."
|
||||||
|
Reference in New Issue
Block a user