CTLE-433: checkpoint commit of backend variants, updated process utils to no longer take in input object since now comes from qContext, put instruction coverage back to 80%

This commit is contained in:
Tim Chamberlain
2023-05-10 15:50:03 -05:00
parent 1e1a33c250
commit e06a5ab4b3
19 changed files with 592 additions and 102 deletions

View File

@ -53,7 +53,7 @@
<maven.compiler.showDeprecation>true</maven.compiler.showDeprecation> <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
<maven.compiler.showWarnings>true</maven.compiler.showWarnings> <maven.compiler.showWarnings>true</maven.compiler.showWarnings>
<coverage.haltOnFailure>true</coverage.haltOnFailure> <coverage.haltOnFailure>true</coverage.haltOnFailure>
<coverage.instructionCoveredRatioMinimum>0.75</coverage.instructionCoveredRatioMinimum> <coverage.instructionCoveredRatioMinimum>0.80</coverage.instructionCoveredRatioMinimum>
<coverage.classCoveredRatioMinimum>0.95</coverage.classCoveredRatioMinimum> <coverage.classCoveredRatioMinimum>0.95</coverage.classCoveredRatioMinimum>
<plugin.shade.phase>none</plugin.shade.phase> <plugin.shade.phase>none</plugin.shade.phase>
</properties> </properties>

View File

@ -35,6 +35,7 @@ import com.kingsrook.qqq.backend.core.actions.dashboard.widgets.NoCodeWidgetRend
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction; import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
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.tables.UpdateAction; import com.kingsrook.qqq.backend.core.actions.tables.UpdateAction;
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.processes.ProcessState; import com.kingsrook.qqq.backend.core.model.actions.processes.ProcessState;
@ -65,6 +66,7 @@ import com.kingsrook.qqq.backend.core.state.UUIDAndTypeStateKey;
import com.kingsrook.qqq.backend.core.utils.CollectionUtils; import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
import com.kingsrook.qqq.backend.core.utils.StringUtils; import com.kingsrook.qqq.backend.core.utils.StringUtils;
import com.kingsrook.qqq.backend.core.utils.ValueUtils; import com.kingsrook.qqq.backend.core.utils.ValueUtils;
import com.kingsrook.qqq.backend.core.utils.collections.MapBuilder;
import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.BooleanUtils;
@ -112,6 +114,17 @@ public class RunProcessAction
} }
runProcessOutput.setProcessUUID(runProcessInput.getProcessUUID()); runProcessOutput.setProcessUUID(runProcessInput.getProcessUUID());
/////////////////////////////////////////////////////////////////////////////////
// if this process has defined backend variant data, put that into the session //
/////////////////////////////////////////////////////////////////////////////////
if(runProcessInput.getProcessMetaData() != null && runProcessInput.getProcessMetaData().getBackendVariant() != null)
{
String backendVariant = runProcessInput.getProcessMetaData().getBackendVariant();
Serializable backendVariantValue = runProcessInput.getProcessMetaData().getBackendVariantValue();
LOG.trace("Found Backend Variant [" + backendVariant + "] with a value of [" + backendVariantValue + "], putting into QSession.");
QContext.getQSession().setBackendVariants(MapBuilder.of(backendVariant, backendVariantValue));
}
UUIDAndTypeStateKey stateKey = new UUIDAndTypeStateKey(UUID.fromString(runProcessInput.getProcessUUID()), StateType.PROCESS_STATUS); UUIDAndTypeStateKey stateKey = new UUIDAndTypeStateKey(UUID.fromString(runProcessInput.getProcessUUID()), StateType.PROCESS_STATUS);
ProcessState processState = primeProcessState(runProcessInput, stateKey, process); ProcessState processState = primeProcessState(runProcessInput, stateKey, process);

View File

@ -52,6 +52,7 @@ import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateInput; import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateOutput; import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateOutput;
import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.fields.AdornmentType;
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData; import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData; import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.tables.cache.CacheUseCase; import com.kingsrook.qqq.backend.core.model.metadata.tables.cache.CacheUseCase;
@ -386,7 +387,7 @@ public class GetAction
{ {
returnRecord.removeValue(fieldName); returnRecord.removeValue(fieldName);
} }
else if(field.getType() != null && field.getType().needsMasked()) else if(getInput.getShouldMaskPasswords() && field.getType() != null && field.getType().needsMasked() && !field.hasAdornmentType(AdornmentType.REVEAL))
{ {
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// empty out the value completely first (which will remove from // // empty out the value completely first (which will remove from //

View File

@ -47,6 +47,7 @@ import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput; import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput; import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
import com.kingsrook.qqq.backend.core.model.data.QRecord; import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.fields.AdornmentType;
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData; import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.joins.JoinOn; import com.kingsrook.qqq.backend.core.model.metadata.joins.JoinOn;
import com.kingsrook.qqq.backend.core.model.metadata.joins.QJoinMetaData; import com.kingsrook.qqq.backend.core.model.metadata.joins.QJoinMetaData;
@ -272,7 +273,7 @@ public class QueryAction
{ {
hiddenFields.add(fieldName); hiddenFields.add(fieldName);
} }
else if(field.getType() != null && field.getType().needsMasked()) else if(queryInput.getShouldMaskPasswords() && field.getType() != null && field.getType().needsMasked() && !field.hasAdornmentType(AdornmentType.REVEAL))
{ {
maskedFields.add(fieldName); maskedFields.add(fieldName);
} }

View File

@ -66,6 +66,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.queues.SQSQueueProviderMeta
import com.kingsrook.qqq.backend.core.model.metadata.reporting.QReportDataSource; import com.kingsrook.qqq.backend.core.model.metadata.reporting.QReportDataSource;
import com.kingsrook.qqq.backend.core.model.metadata.reporting.QReportField; import com.kingsrook.qqq.backend.core.model.metadata.reporting.QReportField;
import com.kingsrook.qqq.backend.core.model.metadata.reporting.QReportView; import com.kingsrook.qqq.backend.core.model.metadata.reporting.QReportView;
import com.kingsrook.qqq.backend.core.model.metadata.scheduleing.QScheduleMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.security.FieldSecurityLock; import com.kingsrook.qqq.backend.core.model.metadata.security.FieldSecurityLock;
import com.kingsrook.qqq.backend.core.model.metadata.security.RecordSecurityLock; import com.kingsrook.qqq.backend.core.model.metadata.security.RecordSecurityLock;
import com.kingsrook.qqq.backend.core.model.metadata.tables.AssociatedScript; import com.kingsrook.qqq.backend.core.model.metadata.tables.AssociatedScript;
@ -1177,6 +1178,23 @@ public class QInstanceValidator
} }
} }
} }
///////////////////////////////////////////////////////////////////////////////
// if the process has a schedule, make sure required schedule data populated //
///////////////////////////////////////////////////////////////////////////////
if(process.getSchedule() != null)
{
QScheduleMetaData schedule = process.getSchedule();
assertCondition(schedule.getRepeatMillis() != null || schedule.getRepeatSeconds() != null, "Either repeat millis or repeat seconds must be set on schedule in process " + processName);
if(schedule.getBackendVariant() != null)
{
assertCondition(schedule.getVariantRunStrategy() != null, "A variant strategy was not set for " + schedule.getBackendVariant() + " on schedule in process " + processName);
assertCondition(schedule.getVariantTableName() != null, "A variant table name was not set for " + schedule.getBackendVariant() + " on schedule in process " + processName);
assertCondition(schedule.getVariantFieldName() != null, "A variant field name was not set for " + schedule.getBackendVariant() + " on schedule in process " + processName);
}
}
}); });
} }
} }

View File

@ -43,6 +43,9 @@ public class QBackendMetaData
private String name; private String name;
private String backendType; private String backendType;
private boolean usesVariants = false;
private String variantsOptionTableName;
private Set<Capability> enabledCapabilities = new HashSet<>(); private Set<Capability> enabledCapabilities = new HashSet<>();
private Set<Capability> disabledCapabilities = new HashSet<>(); private Set<Capability> disabledCapabilities = new HashSet<>();
@ -343,4 +346,67 @@ public class QBackendMetaData
// noop in base class // // noop in base class //
//////////////////////// ////////////////////////
} }
/*******************************************************************************
** Getter for usesVariants
*******************************************************************************/
public boolean getUsesVariants()
{
return (this.usesVariants);
}
/*******************************************************************************
** Setter for usesVariants
*******************************************************************************/
public void setUsesVariants(boolean usesVariants)
{
this.usesVariants = usesVariants;
}
/*******************************************************************************
** Fluent setter for usesVariants
*******************************************************************************/
public QBackendMetaData withUsesVariants(boolean usesVariants)
{
this.usesVariants = usesVariants;
return (this);
}
/*******************************************************************************
** Getter for variantsOptionTableName
*******************************************************************************/
public String getVariantsOptionTableName()
{
return (this.variantsOptionTableName);
}
/*******************************************************************************
** Setter for variantsOptionTableName
*******************************************************************************/
public void setVariantsOptionTableName(String variantsOptionTableName)
{
this.variantsOptionTableName = variantsOptionTableName;
}
/*******************************************************************************
** Fluent setter for variantsOptionTableName
*******************************************************************************/
public QBackendMetaData withVariantsOptionTableName(String variantsOptionTableName)
{
this.variantsOptionTableName = variantsOptionTableName;
return (this);
}
} }

View File

@ -523,6 +523,25 @@ public class QFieldMetaData implements Cloneable
/*******************************************************************************
** does this field have the given addornment
**
*******************************************************************************/
public boolean hasAdornmentType(AdornmentType adornmentType)
{
for(FieldAdornment thisAdornment : CollectionUtils.nonNullList(this.adornments))
{
if(AdornmentType.REVEAL.equals(thisAdornment.getType()))
{
return (true);
}
}
return (false);
}
/******************************************************************************* /*******************************************************************************
** Getter for adornments ** Getter for adornments
** **

View File

@ -22,6 +22,7 @@
package com.kingsrook.qqq.backend.core.model.metadata.processes; package com.kingsrook.qqq.backend.core.model.metadata.processes;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -54,6 +55,9 @@ public class QProcessMetaData implements QAppChildMetaData, MetaDataWithPermissi
private BasepullConfiguration basepullConfiguration; private BasepullConfiguration basepullConfiguration;
private QPermissionRules permissionRules; private QPermissionRules permissionRules;
private String backendVariant;
private Serializable backendVariantValue;
private List<QStepMetaData> stepList; // these are the steps that are ran, by-default, in the order they are ran in private List<QStepMetaData> stepList; // these are the steps that are ran, by-default, in the order they are ran in
private Map<String, QStepMetaData> steps; // this is the full map of possible steps private Map<String, QStepMetaData> steps; // this is the full map of possible steps
@ -544,4 +548,66 @@ public class QProcessMetaData implements QAppChildMetaData, MetaDataWithPermissi
qInstance.addProcess(this); qInstance.addProcess(this);
} }
/*******************************************************************************
** Getter for backendVariant
*******************************************************************************/
public String getBackendVariant()
{
return (this.backendVariant);
}
/*******************************************************************************
** Setter for backendVariant
*******************************************************************************/
public void setBackendVariant(String backendVariant)
{
this.backendVariant = backendVariant;
}
/*******************************************************************************
** Fluent setter for backendVariant
*******************************************************************************/
public QProcessMetaData withBackendVariant(String backendVariant)
{
this.backendVariant = backendVariant;
return (this);
}
/*******************************************************************************
** Getter for backendVariantValue
*******************************************************************************/
public Serializable getBackendVariantValue()
{
return (this.backendVariantValue);
}
/*******************************************************************************
** Setter for backendVariantValue
*******************************************************************************/
public void setBackendVariantValue(Serializable backendVariantValue)
{
this.backendVariantValue = backendVariantValue;
}
/*******************************************************************************
** Fluent setter for backendVariantValue
*******************************************************************************/
public QProcessMetaData withBackendVariantValue(Serializable backendVariantValue)
{
this.backendVariantValue = backendVariantValue;
return (this);
}
} }

View File

@ -22,6 +22,9 @@
package com.kingsrook.qqq.backend.core.model.metadata.scheduleing; package com.kingsrook.qqq.backend.core.model.metadata.scheduleing;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
/******************************************************************************* /*******************************************************************************
** Meta-data to define scheduled actions within QQQ. ** Meta-data to define scheduled actions within QQQ.
** **
@ -33,11 +36,22 @@ package com.kingsrook.qqq.backend.core.model.metadata.scheduleing;
*******************************************************************************/ *******************************************************************************/
public class QScheduleMetaData public class QScheduleMetaData
{ {
public enum RunStrategy
{PARALLEL, SERIAL}
private Integer repeatSeconds; private Integer repeatSeconds;
private Integer repeatMillis; private Integer repeatMillis;
private Integer initialDelaySeconds; private Integer initialDelaySeconds;
private Integer initialDelayMillis; private Integer initialDelayMillis;
private RunStrategy variantRunStrategy;
private String backendVariant;
private String variantTableName;
private QQueryFilter variantFilter;
private String variantFieldName;
/******************************************************************************* /*******************************************************************************
@ -174,4 +188,159 @@ public class QScheduleMetaData
return (this); return (this);
} }
/*******************************************************************************
** Getter for backendVariant
*******************************************************************************/
public String getBackendVariant()
{
return (this.backendVariant);
}
/*******************************************************************************
** Setter for backendVariant
*******************************************************************************/
public void setBackendVariant(String backendVariant)
{
this.backendVariant = backendVariant;
}
/*******************************************************************************
** Fluent setter for backendVariant
*******************************************************************************/
public QScheduleMetaData withBackendVariant(String backendVariant)
{
this.backendVariant = backendVariant;
return (this);
}
/*******************************************************************************
** Getter for variantTableName
*******************************************************************************/
public String getVariantTableName()
{
return (this.variantTableName);
}
/*******************************************************************************
** Setter for variantTableName
*******************************************************************************/
public void setVariantTableName(String variantTableName)
{
this.variantTableName = variantTableName;
}
/*******************************************************************************
** Fluent setter for variantTableName
*******************************************************************************/
public QScheduleMetaData withVariantTableName(String variantTableName)
{
this.variantTableName = variantTableName;
return (this);
}
/*******************************************************************************
** Getter for variantFilter
*******************************************************************************/
public QQueryFilter getVariantFilter()
{
return (this.variantFilter);
}
/*******************************************************************************
** Setter for variantFilter
*******************************************************************************/
public void setVariantFilter(QQueryFilter variantFilter)
{
this.variantFilter = variantFilter;
}
/*******************************************************************************
** Fluent setter for variantFilter
*******************************************************************************/
public QScheduleMetaData withVariantFilter(QQueryFilter variantFilter)
{
this.variantFilter = variantFilter;
return (this);
}
/*******************************************************************************
** Getter for variantFieldName
*******************************************************************************/
public String getVariantFieldName()
{
return (this.variantFieldName);
}
/*******************************************************************************
** Setter for variantFieldName
*******************************************************************************/
public void setVariantFieldName(String variantFieldName)
{
this.variantFieldName = variantFieldName;
}
/*******************************************************************************
** Fluent setter for variantFieldName
*******************************************************************************/
public QScheduleMetaData withVariantFieldName(String variantFieldName)
{
this.variantFieldName = variantFieldName;
return (this);
}
/*******************************************************************************
** Getter for variantRunStrategy
*******************************************************************************/
public RunStrategy getVariantRunStrategy()
{
return (this.variantRunStrategy);
}
/*******************************************************************************
** Setter for variantRunStrategy
*******************************************************************************/
public void setVariantRunStrategy(RunStrategy variantRunStrategy)
{
this.variantRunStrategy = variantRunStrategy;
}
/*******************************************************************************
** Fluent setter for variantRunStrategy
*******************************************************************************/
public QScheduleMetaData withVariantRunStrategy(RunStrategy variantRunStrategy)
{
this.variantRunStrategy = variantRunStrategy;
return (this);
}
} }

View File

@ -47,8 +47,9 @@ public class QSession implements Serializable
private QUser user; private QUser user;
private String uuid; private String uuid;
private Map<String, List<Serializable>> securityKeyValues;
private Set<String> permissions; private Set<String> permissions;
private Map<String, List<Serializable>> securityKeyValues;
private Map<String, Serializable> backendVariants;
// implementation-specific custom values // implementation-specific custom values
private Map<String, String> values; private Map<String, String> values;
@ -466,4 +467,35 @@ public class QSession implements Serializable
return (this); return (this);
} }
/*******************************************************************************
** Getter for backendVariants
*******************************************************************************/
public Map<String, Serializable> getBackendVariants()
{
return (this.backendVariants);
}
/*******************************************************************************
** Setter for backendVariants
*******************************************************************************/
public void setBackendVariants(Map<String, Serializable> backendVariants)
{
this.backendVariants = backendVariants;
}
/*******************************************************************************
** Fluent setter for backendVariants
*******************************************************************************/
public QSession withBackendVariants(Map<String, Serializable> backendVariants)
{
this.backendVariants = backendVariants;
return (this);
}
} }

View File

@ -33,7 +33,6 @@ import com.kingsrook.qqq.backend.core.actions.tables.GetAction;
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction; import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
import com.kingsrook.qqq.backend.core.exceptions.QException; import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.exceptions.QUserFacingException; import com.kingsrook.qqq.backend.core.exceptions.QUserFacingException;
import com.kingsrook.qqq.backend.core.model.actions.AbstractActionInput;
import com.kingsrook.qqq.backend.core.model.actions.processes.RunBackendStepInput; import com.kingsrook.qqq.backend.core.model.actions.processes.RunBackendStepInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountInput; import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountOutput; import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountOutput;
@ -66,9 +65,9 @@ public class GeneralProcessUtils
** e.g., for a list of orders (with a clientId field), build a map of client.id => client record ** e.g., for a list of orders (with a clientId field), build a map of client.id => client record
** via getForeignRecordMap(input, orderList, "clientId", "client", "id") ** via getForeignRecordMap(input, orderList, "clientId", "client", "id")
*******************************************************************************/ *******************************************************************************/
public static Map<Serializable, QRecord> getForeignRecordMap(AbstractActionInput parentActionInput, List<QRecord> sourceRecords, String sourceTableForeignKeyFieldName, String foreignTableName, String foreignTablePrimaryKeyName) throws QException public static Map<Serializable, QRecord> getForeignRecordMap(List<QRecord> sourceRecords, String sourceTableForeignKeyFieldName, String foreignTableName, String foreignTablePrimaryKeyName) throws QException
{ {
return getForeignRecordMap(parentActionInput, sourceRecords, sourceTableForeignKeyFieldName, foreignTableName, foreignTablePrimaryKeyName, new QQueryFilter()); return getForeignRecordMap(sourceRecords, sourceTableForeignKeyFieldName, foreignTableName, foreignTablePrimaryKeyName, new QQueryFilter());
} }
// todo not commit - clean up all method sigs // todo not commit - clean up all method sigs
@ -83,7 +82,7 @@ public class GeneralProcessUtils
** e.g., for a list of orders (with a clientId field), build a map of client.id => client record ** e.g., for a list of orders (with a clientId field), build a map of client.id => client record
** via getForeignRecordMap(input, orderList, "clientId", "client", "id") ** via getForeignRecordMap(input, orderList, "clientId", "client", "id")
*******************************************************************************/ *******************************************************************************/
public static Map<Serializable, QRecord> getForeignRecordMap(AbstractActionInput parentActionInput, List<QRecord> sourceRecords, String sourceTableForeignKeyFieldName, String foreignTableName, String foreignTablePrimaryKeyName, QQueryFilter additionalFilter) throws QException public static Map<Serializable, QRecord> getForeignRecordMap(List<QRecord> sourceRecords, String sourceTableForeignKeyFieldName, String foreignTableName, String foreignTablePrimaryKeyName, QQueryFilter additionalFilter) throws QException
{ {
Map<Serializable, QRecord> foreignRecordMap = new HashMap<>(); Map<Serializable, QRecord> foreignRecordMap = new HashMap<>();
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
@ -111,7 +110,7 @@ public class GeneralProcessUtils
** e.g., for a list of orders, build a ListingHash of order.id => List(OrderLine records) ** e.g., for a list of orders, build a ListingHash of order.id => List(OrderLine records)
** via getForeignRecordListingHashMap(input, orderList, "id", "orderLine", "orderId") ** via getForeignRecordListingHashMap(input, orderList, "id", "orderLine", "orderId")
*******************************************************************************/ *******************************************************************************/
public static ListingHash<Serializable, QRecord> getForeignRecordListingHashMap(AbstractActionInput parentActionInput, List<QRecord> sourceRecords, String sourceTableForeignKeyFieldName, String foreignTableName, String foreignTableForeignKeyName) throws QException public static ListingHash<Serializable, QRecord> getForeignRecordListingHashMap(List<QRecord> sourceRecords, String sourceTableForeignKeyFieldName, String foreignTableName, String foreignTableForeignKeyName) throws QException
{ {
ListingHash<Serializable, QRecord> foreignRecordMap = new ListingHash<>(); ListingHash<Serializable, QRecord> foreignRecordMap = new ListingHash<>();
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
@ -138,9 +137,9 @@ public class GeneralProcessUtils
** e.g., for a list of orders (with a clientId field), setValue("client", QRecord(client)); ** e.g., for a list of orders (with a clientId field), setValue("client", QRecord(client));
** via addForeignRecordsToRecordList(input, orderList, "clientId", "client", "id") ** via addForeignRecordsToRecordList(input, orderList, "clientId", "client", "id")
*******************************************************************************/ *******************************************************************************/
public static void addForeignRecordsToRecordList(AbstractActionInput parentActionInput, List<QRecord> sourceRecords, String sourceTableForeignKeyFieldName, String foreignTableName, String foreignTablePrimaryKeyName) throws QException public static void addForeignRecordsToRecordList(List<QRecord> sourceRecords, String sourceTableForeignKeyFieldName, String foreignTableName, String foreignTablePrimaryKeyName) throws QException
{ {
Map<Serializable, QRecord> foreignRecordMap = getForeignRecordMap(parentActionInput, sourceRecords, sourceTableForeignKeyFieldName, foreignTableName, foreignTablePrimaryKeyName); Map<Serializable, QRecord> foreignRecordMap = getForeignRecordMap(sourceRecords, sourceTableForeignKeyFieldName, foreignTableName, foreignTablePrimaryKeyName);
for(QRecord sourceRecord : sourceRecords) for(QRecord sourceRecord : sourceRecords)
{ {
QRecord foreignRecord = foreignRecordMap.get(sourceRecord.getValue(sourceTableForeignKeyFieldName)); QRecord foreignRecord = foreignRecordMap.get(sourceRecord.getValue(sourceTableForeignKeyFieldName));
@ -158,9 +157,9 @@ public class GeneralProcessUtils
** e.g., for a list of orders, setValue("orderLine", List(QRecord(orderLine))) ** e.g., for a list of orders, setValue("orderLine", List(QRecord(orderLine)))
** via addForeignRecordsListToRecordList(input, orderList, "id", "orderLine", "orderId") ** via addForeignRecordsListToRecordList(input, orderList, "id", "orderLine", "orderId")
*******************************************************************************/ *******************************************************************************/
public static void addForeignRecordsListToRecordList(AbstractActionInput parentActionInput, List<QRecord> sourceRecords, String sourceTableForeignKeyFieldName, String foreignTableName, String foreignTableForeignKeyName) throws QException public static void addForeignRecordsListToRecordList(List<QRecord> sourceRecords, String sourceTableForeignKeyFieldName, String foreignTableName, String foreignTableForeignKeyName) throws QException
{ {
ListingHash<Serializable, QRecord> foreignRecordMap = getForeignRecordListingHashMap(parentActionInput, sourceRecords, sourceTableForeignKeyFieldName, foreignTableName, foreignTableForeignKeyName); ListingHash<Serializable, QRecord> foreignRecordMap = getForeignRecordListingHashMap(sourceRecords, sourceTableForeignKeyFieldName, foreignTableName, foreignTableForeignKeyName);
for(QRecord sourceRecord : sourceRecords) for(QRecord sourceRecord : sourceRecords)
{ {
List<QRecord> foreignRecordList = foreignRecordMap.get(sourceRecord.getValue(sourceTableForeignKeyFieldName)); List<QRecord> foreignRecordList = foreignRecordMap.get(sourceRecord.getValue(sourceTableForeignKeyFieldName));
@ -184,7 +183,7 @@ public class GeneralProcessUtils
** Run a query on tableName, for where fieldName equals fieldValue, and return ** Run a query on tableName, for where fieldName equals fieldValue, and return
** the list of QRecords. ** the list of QRecords.
*******************************************************************************/ *******************************************************************************/
public static List<QRecord> getRecordListByField(AbstractActionInput parentActionInput, String tableName, String fieldName, Serializable fieldValue) throws QException public static List<QRecord> getRecordListByField(String tableName, String fieldName, Serializable fieldValue) throws QException
{ {
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
queryInput.setTableName(tableName); queryInput.setTableName(tableName);
@ -200,7 +199,7 @@ public class GeneralProcessUtils
** key, or any other field on the table. Note, if multiple rows do match the value, ** key, or any other field on the table. Note, if multiple rows do match the value,
** only 1 (determined in an unspecified way) is returned. ** only 1 (determined in an unspecified way) is returned.
*******************************************************************************/ *******************************************************************************/
public static Optional<QRecord> getRecordByField(AbstractActionInput parentActionInput, String tableName, String fieldName, Serializable fieldValue) throws QException public static Optional<QRecord> getRecordByField(String tableName, String fieldName, Serializable fieldValue) throws QException
{ {
if(fieldValue == null) if(fieldValue == null)
{ {
@ -221,9 +220,9 @@ public class GeneralProcessUtils
** key, or any other field on the table. Note, if multiple rows do match the value, ** key, or any other field on the table. Note, if multiple rows do match the value,
** only 1 (determined in an unspecified way) is returned. ** only 1 (determined in an unspecified way) is returned.
*******************************************************************************/ *******************************************************************************/
public static <T extends QRecordEntity> Optional<T> getEntityByField(AbstractActionInput parentActionInput, String tableName, String fieldName, Serializable fieldValue, Class<T> entityClass) throws QException public static <T extends QRecordEntity> Optional<T> getEntityByField(String tableName, String fieldName, Serializable fieldValue, Class<T> entityClass) throws QException
{ {
Optional<QRecord> optionalQRecord = getRecordByField(parentActionInput, tableName, fieldName, fieldValue); Optional<QRecord> optionalQRecord = getRecordByField(tableName, fieldName, fieldValue);
if(optionalQRecord.isPresent()) if(optionalQRecord.isPresent())
{ {
return (Optional.of(QRecordEntity.fromQRecord(entityClass, optionalQRecord.get()))); return (Optional.of(QRecordEntity.fromQRecord(entityClass, optionalQRecord.get())));
@ -236,9 +235,9 @@ public class GeneralProcessUtils
/******************************************************************************* /*******************************************************************************
** Query to get one record by a unique key value. ** Query to get one record by a unique key value.
*******************************************************************************/ *******************************************************************************/
public static QRecord getRecordByFieldOrElseThrow(AbstractActionInput parentActionInput, String tableName, String fieldName, Serializable fieldValue) throws QException public static QRecord getRecordByFieldOrElseThrow(String tableName, String fieldName, Serializable fieldValue) throws QException
{ {
return getRecordByField(parentActionInput, tableName, fieldName, fieldValue) return getRecordByField(tableName, fieldName, fieldValue)
.orElseThrow(() -> new QException(tableName + " with " + fieldName + " of " + fieldValue + " was not found.")); .orElseThrow(() -> new QException(tableName + " with " + fieldName + " of " + fieldValue + " was not found."));
} }
@ -247,7 +246,7 @@ public class GeneralProcessUtils
/******************************************************************************* /*******************************************************************************
** Query to get one record by its primary key value. ** Query to get one record by its primary key value.
*******************************************************************************/ *******************************************************************************/
public static Optional<QRecord> getRecordByPrimaryKey(AbstractActionInput parentActionInput, String tableName, Serializable value) throws QException public static Optional<QRecord> getRecordByPrimaryKey(String tableName, Serializable value) throws QException
{ {
GetInput getInput = new GetInput(); GetInput getInput = new GetInput();
getInput.setTableName(tableName); getInput.setTableName(tableName);
@ -261,9 +260,9 @@ public class GeneralProcessUtils
/******************************************************************************* /*******************************************************************************
** Query to get one record by its primary key value. ** Query to get one record by its primary key value.
*******************************************************************************/ *******************************************************************************/
public static QRecord getRecordByPrimaryKeyOrElseThrow(AbstractActionInput parentActionInput, String tableName, Serializable value) throws QException public static QRecord getRecordByPrimaryKeyOrElseThrow(String tableName, Serializable value) throws QException
{ {
return getRecordByPrimaryKey(parentActionInput, tableName, value) return getRecordByPrimaryKey(tableName, value)
.orElseThrow(() -> new QException(tableName + " with primary key of " + value + " was not found.")); .orElseThrow(() -> new QException(tableName + " with primary key of " + value + " was not found."));
} }
@ -275,7 +274,7 @@ public class GeneralProcessUtils
** Note, this is inherently unsafe, if you were to call it on a table with ** Note, this is inherently unsafe, if you were to call it on a table with
** too many rows... Caveat emptor. ** too many rows... Caveat emptor.
*******************************************************************************/ *******************************************************************************/
public static List<QRecord> loadTable(AbstractActionInput parentActionInput, String tableName) throws QException public static List<QRecord> loadTable(String tableName) throws QException
{ {
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
queryInput.setTableName(tableName); queryInput.setTableName(tableName);
@ -291,7 +290,7 @@ public class GeneralProcessUtils
** Note, this is inherently unsafe, if you were to call it on a table with ** Note, this is inherently unsafe, if you were to call it on a table with
** too many rows... Caveat emptor. ** too many rows... Caveat emptor.
*******************************************************************************/ *******************************************************************************/
public static <T extends QRecordEntity> List<T> loadTable(AbstractActionInput parentActionInput, String tableName, Class<T> entityClass) throws QException public static <T extends QRecordEntity> List<T> loadTable(String tableName, Class<T> entityClass) throws QException
{ {
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
queryInput.setTableName(tableName); queryInput.setTableName(tableName);
@ -319,9 +318,9 @@ public class GeneralProcessUtils
** Also, note, this is inherently unsafe, if you were to call it on a table with ** Also, note, this is inherently unsafe, if you were to call it on a table with
** too many rows... Caveat emptor. ** too many rows... Caveat emptor.
*******************************************************************************/ *******************************************************************************/
public static Map<Serializable, QRecord> loadTableToMap(AbstractActionInput parentActionInput, String tableName, String keyFieldName) throws QException public static Map<Serializable, QRecord> loadTableToMap(String tableName, String keyFieldName) throws QException
{ {
return (loadTableToMap(parentActionInput, tableName, keyFieldName, (QQueryFilter) null)); return (loadTableToMap(tableName, keyFieldName, (QQueryFilter) null));
} }
@ -334,7 +333,7 @@ public class GeneralProcessUtils
** If multiple values are found for the key, they'll squash each other, and only ** If multiple values are found for the key, they'll squash each other, and only
** one (random) value will appear. ** one (random) value will appear.
*******************************************************************************/ *******************************************************************************/
public static Map<Serializable, QRecord> loadTableToMap(AbstractActionInput parentActionInput, String tableName, String keyFieldName, QQueryFilter filter) throws QException public static Map<Serializable, QRecord> loadTableToMap(String tableName, String keyFieldName, QQueryFilter filter) throws QException
{ {
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
queryInput.setTableName(tableName); queryInput.setTableName(tableName);
@ -368,7 +367,7 @@ public class GeneralProcessUtils
** Also, note, this is inherently unsafe, if you were to call it on a table with ** Also, note, this is inherently unsafe, if you were to call it on a table with
** too many rows... Caveat emptor. ** too many rows... Caveat emptor.
*******************************************************************************/ *******************************************************************************/
public static <T extends Serializable> Map<T, QRecord> loadTableToMap(AbstractActionInput parentActionInput, String tableName, Class<T> keyType, String keyFieldName) throws QException public static <T extends Serializable> Map<T, QRecord> loadTableToMap(String tableName, Class<T> keyType, String keyFieldName) throws QException
{ {
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
queryInput.setTableName(tableName); queryInput.setTableName(tableName);
@ -393,7 +392,7 @@ public class GeneralProcessUtils
/******************************************************************************* /*******************************************************************************
** Note - null values from the key field are NOT put in the map. ** Note - null values from the key field are NOT put in the map.
*******************************************************************************/ *******************************************************************************/
public static <T extends QRecordEntity> Map<Serializable, T> loadTableToMap(AbstractActionInput parentActionInput, String tableName, String keyFieldName, Class<T> entityClass) throws QException public static <T extends QRecordEntity> Map<Serializable, T> loadTableToMap(String tableName, String keyFieldName, Class<T> entityClass) throws QException
{ {
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
queryInput.setTableName(tableName); queryInput.setTableName(tableName);
@ -424,7 +423,7 @@ public class GeneralProcessUtils
** Also, note, this is inherently unsafe, if you were to call it on a table with ** Also, note, this is inherently unsafe, if you were to call it on a table with
** too many rows... Caveat emptor. ** too many rows... Caveat emptor.
*******************************************************************************/ *******************************************************************************/
public static ListingHash<Serializable, QRecord> loadTableToListingHash(AbstractActionInput parentActionInput, String tableName, String keyFieldName) throws QException public static ListingHash<Serializable, QRecord> loadTableToListingHash(String tableName, String keyFieldName) throws QException
{ {
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
queryInput.setTableName(tableName); queryInput.setTableName(tableName);
@ -497,7 +496,7 @@ public class GeneralProcessUtils
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/
public static Integer count(AbstractActionInput input, String tableName, QQueryFilter filter) throws QException public static Integer count(String tableName, QQueryFilter filter) throws QException
{ {
CountInput countInput = new CountInput(); CountInput countInput = new CountInput();
countInput.setTableName(tableName); countInput.setTableName(tableName);

View File

@ -83,7 +83,7 @@ public class RecordLookupHelper
{ {
if(disallowedOneOffLookups.isEmpty() || !disallowedOneOffLookups.contains(Pair.of(tableName, keyFieldName))) if(disallowedOneOffLookups.isEmpty() || !disallowedOneOffLookups.contains(Pair.of(tableName, keyFieldName)))
{ {
Optional<QRecord> optRecord = GeneralProcessUtils.getRecordByField(null, tableName, keyFieldName, key); Optional<QRecord> optRecord = GeneralProcessUtils.getRecordByField(tableName, keyFieldName, key);
recordMap.put(key, optRecord.orElse(null)); recordMap.put(key, optRecord.orElse(null));
} }
} }
@ -106,7 +106,7 @@ public class RecordLookupHelper
String mapKey = tableName + "." + keyFieldName; String mapKey = tableName + "." + keyFieldName;
if(!preloadedKeys.contains(mapKey)) if(!preloadedKeys.contains(mapKey))
{ {
Map<Serializable, QRecord> recordMap = GeneralProcessUtils.loadTableToMap(null, tableName, keyFieldName); Map<Serializable, QRecord> recordMap = GeneralProcessUtils.loadTableToMap(tableName, keyFieldName);
recordMaps.put(mapKey, recordMap); recordMaps.put(mapKey, recordMap);
preloadedKeys.add(mapKey); preloadedKeys.add(mapKey);
} }
@ -126,7 +126,7 @@ public class RecordLookupHelper
{ {
String mapKey = tableName + "." + keyFieldName; String mapKey = tableName + "." + keyFieldName;
Map<Serializable, QRecord> tableMap = recordMaps.computeIfAbsent(mapKey, s -> new HashMap<>()); Map<Serializable, QRecord> tableMap = recordMaps.computeIfAbsent(mapKey, s -> new HashMap<>());
tableMap.putAll(GeneralProcessUtils.loadTableToMap(null, tableName, keyFieldName, filter)); tableMap.putAll(GeneralProcessUtils.loadTableToMap(tableName, keyFieldName, filter));
} }
@ -148,7 +148,7 @@ public class RecordLookupHelper
Map<Serializable, QRecord> tableMap = recordMaps.computeIfAbsent(mapKey, s -> new HashMap<>()); Map<Serializable, QRecord> tableMap = recordMaps.computeIfAbsent(mapKey, s -> new HashMap<>());
QQueryFilter filter = new QQueryFilter(new QFilterCriteria(keyFieldName, QCriteriaOperator.IN, inList)); QQueryFilter filter = new QQueryFilter(new QFilterCriteria(keyFieldName, QCriteriaOperator.IN, inList));
tableMap.putAll(GeneralProcessUtils.loadTableToMap(null, tableName, keyFieldName, filter)); tableMap.putAll(GeneralProcessUtils.loadTableToMap(tableName, keyFieldName, filter));
QFieldType type = QContext.getQInstance().getTable(tableName).getField(keyFieldName).getType(); QFieldType type = QContext.getQInstance().getTable(tableName).getField(keyFieldName).getType();
for(Serializable keyValue : inList) for(Serializable keyValue : inList)

View File

@ -22,17 +22,25 @@
package com.kingsrook.qqq.backend.core.scheduler; package com.kingsrook.qqq.backend.core.scheduler;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Supplier; import java.util.function.Supplier;
import com.kingsrook.qqq.backend.core.actions.automation.polling.PollingAutomationPerTableRunner; import com.kingsrook.qqq.backend.core.actions.automation.polling.PollingAutomationPerTableRunner;
import com.kingsrook.qqq.backend.core.actions.processes.RunProcessAction; import com.kingsrook.qqq.backend.core.actions.processes.RunProcessAction;
import com.kingsrook.qqq.backend.core.actions.queues.SQSQueuePoller; import com.kingsrook.qqq.backend.core.actions.queues.SQSQueuePoller;
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
import com.kingsrook.qqq.backend.core.context.QContext; import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.instances.QMetaDataVariableInterpreter; import com.kingsrook.qqq.backend.core.instances.QMetaDataVariableInterpreter;
import com.kingsrook.qqq.backend.core.logging.LogPair;
import com.kingsrook.qqq.backend.core.logging.QLogger; import com.kingsrook.qqq.backend.core.logging.QLogger;
import com.kingsrook.qqq.backend.core.model.actions.processes.RunProcessInput; import com.kingsrook.qqq.backend.core.model.actions.processes.RunProcessInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance; import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.automation.QAutomationProviderMetaData; import com.kingsrook.qqq.backend.core.model.metadata.automation.QAutomationProviderMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData; import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
@ -41,6 +49,8 @@ import com.kingsrook.qqq.backend.core.model.metadata.queues.QQueueProviderMetaDa
import com.kingsrook.qqq.backend.core.model.metadata.queues.SQSQueueProviderMetaData; import com.kingsrook.qqq.backend.core.model.metadata.queues.SQSQueueProviderMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.scheduleing.QScheduleMetaData; import com.kingsrook.qqq.backend.core.model.metadata.scheduleing.QScheduleMetaData;
import com.kingsrook.qqq.backend.core.model.session.QSession; import com.kingsrook.qqq.backend.core.model.session.QSession;
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
import com.kingsrook.qqq.backend.core.utils.collections.MapBuilder;
/******************************************************************************* /*******************************************************************************
@ -131,13 +141,71 @@ public class ScheduleManager
{ {
if(process.getSchedule() != null && allowedToStart(process.getName())) if(process.getSchedule() != null && allowedToStart(process.getName()))
{ {
startProcess(process); QScheduleMetaData scheduleMetaData = process.getSchedule();
if(process.getSchedule().getBackendVariant() == null || QScheduleMetaData.RunStrategy.SERIAL.equals(process.getSchedule().getVariantRunStrategy()))
{
///////////////////////////////////////////////
// if no variants, or variant is serial mode //
///////////////////////////////////////////////
startProcess(process, null);
}
else if(QScheduleMetaData.RunStrategy.PARALLEL.equals(process.getSchedule().getVariantRunStrategy()))
{
/////////////////////////////////////////////////////////////////////////////////////////////////////
// if this a "parallel", which for example means we want to have a thread for each backend variant //
// running at the same time, get the variant records and schedule each separately //
/////////////////////////////////////////////////////////////////////////////////////////////////////
QContext.init(qInstance, sessionSupplier.get());
for(QRecord qRecord : CollectionUtils.nonNullList(getBackendVariantFilteredRecords(process)))
{
try
{
startProcess(process, MapBuilder.of(scheduleMetaData.getBackendVariant(), qRecord.getValue(scheduleMetaData.getVariantFieldName())));
}
catch(Exception e)
{
LOG.error("An error starting process [" + process.getLabel() + "], with backend variant data.", e, new LogPair("variantQRecord", qRecord));
}
}
}
else
{
LOG.error("Unsupported Schedule Run Strategy [" + process.getSchedule().getVariantFilter() + "] was provided.");
}
} }
} }
} }
/*******************************************************************************
**
*******************************************************************************/
private List<QRecord> getBackendVariantFilteredRecords(QProcessMetaData processMetaData)
{
List<QRecord> records = null;
try
{
QScheduleMetaData scheduleMetaData = processMetaData.getSchedule();
QueryInput queryInput = new QueryInput();
queryInput.setTableName(scheduleMetaData.getVariantTableName());
queryInput.setFilter(scheduleMetaData.getVariantFilter());
QContext.init(qInstance, sessionSupplier.get());
QueryOutput queryOutput = new QueryAction().execute(queryInput);
records = queryOutput.getRecords();
}
catch(Exception e)
{
LOG.error("An error fetching variant data for process [" + processMetaData.getLabel() + "]", e);
}
return (records);
}
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/
@ -249,7 +317,7 @@ public class ScheduleManager
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/
private void startProcess(QProcessMetaData process) private void startProcess(QProcessMetaData process, Map<String, Serializable> backendVariantData)
{ {
Runnable runProcess = () -> Runnable runProcess = () ->
{ {
@ -257,18 +325,31 @@ public class ScheduleManager
try try
{ {
QContext.init(qInstance, sessionSupplier.get()); if(process.getSchedule().getBackendVariant() == null || QScheduleMetaData.RunStrategy.PARALLEL.equals(process.getSchedule().getVariantRunStrategy()))
Thread.currentThread().setName("ScheduledProcess>" + process.getName()); {
LOG.debug("Running Scheduled Process [" + process.getName() + "]"); QContext.init(qInstance, sessionSupplier.get());
executeSingleProcess(process, backendVariantData);
RunProcessInput runProcessInput = new RunProcessInput(); }
runProcessInput.setProcessName(process.getName()); else if(QScheduleMetaData.RunStrategy.SERIAL.equals(process.getSchedule().getVariantRunStrategy()))
runProcessInput.setFrontendStepBehavior(RunProcessInput.FrontendStepBehavior.SKIP); {
///////////////////////////////////////////////////////////////////////////////////////////////////
QContext.pushAction(runProcessInput); // if this is "serial", which for example means we want to run each backend variant one after //
// the other in the same thread so loop over these here so that they run in same lambda function //
RunProcessAction runProcessAction = new RunProcessAction(); ///////////////////////////////////////////////////////////////////////////////////////////////////
runProcessAction.execute(runProcessInput); for(QRecord qRecord : getBackendVariantFilteredRecords(process))
{
try
{
QContext.init(qInstance, sessionSupplier.get());
QScheduleMetaData scheduleMetaData = process.getSchedule();
executeSingleProcess(process, MapBuilder.of(scheduleMetaData.getBackendVariant(), qRecord.getValue(scheduleMetaData.getVariantFieldName())));
}
catch(Exception e)
{
LOG.error("An error starting process [" + process.getLabel() + "], with backend variant data.", e, new LogPair("variantQRecord", qRecord));
}
}
}
} }
catch(Exception e) catch(Exception e)
{ {
@ -294,6 +375,31 @@ public class ScheduleManager
/*******************************************************************************
**
*******************************************************************************/
private static void executeSingleProcess(QProcessMetaData process, Map<String, Serializable> backendVariantData) throws QException
{
if(backendVariantData != null)
{
QContext.getQSession().setBackendVariants(backendVariantData);
}
Thread.currentThread().setName("ScheduledProcess>" + process.getName());
LOG.debug("Running Scheduled Process [" + process.getName() + "]");
RunProcessInput runProcessInput = new RunProcessInput();
runProcessInput.setProcessName(process.getName());
runProcessInput.setFrontendStepBehavior(RunProcessInput.FrontendStepBehavior.SKIP);
QContext.pushAction(runProcessInput);
RunProcessAction runProcessAction = new RunProcessAction();
runProcessAction.execute(runProcessInput);
}
/******************************************************************************* /*******************************************************************************
** **
*******************************************************************************/ *******************************************************************************/

View File

@ -69,9 +69,9 @@ class AuditActionTest extends BaseTest
///////////////////////////////////// /////////////////////////////////////
// make sure things can be fetched // // make sure things can be fetched //
///////////////////////////////////// /////////////////////////////////////
GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "auditTable", "name", TestUtils.TABLE_NAME_PERSON_MEMORY); GeneralProcessUtils.getRecordByFieldOrElseThrow("auditTable", "name", TestUtils.TABLE_NAME_PERSON_MEMORY);
GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "auditUser", "name", userName); GeneralProcessUtils.getRecordByFieldOrElseThrow("auditUser", "name", userName);
QRecord auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "audit", "recordId", recordId); QRecord auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow("audit", "recordId", recordId);
assertEquals("Test Audit", auditRecord.getValueString("message")); assertEquals("Test Audit", auditRecord.getValueString("message"));
} }
@ -95,7 +95,7 @@ class AuditActionTest extends BaseTest
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
// it should not throw, but it should also not insert the audit. // // it should not throw, but it should also not insert the audit. //
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
Optional<QRecord> auditRecord = GeneralProcessUtils.getRecordByField(null, "audit", "recordId", recordId); Optional<QRecord> auditRecord = GeneralProcessUtils.getRecordByField("audit", "recordId", recordId);
assertFalse(auditRecord.isPresent()); assertFalse(auditRecord.isPresent());
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
@ -109,7 +109,7 @@ class AuditActionTest extends BaseTest
///////////////////////////////////// /////////////////////////////////////
// now the audit should be stored. // // now the audit should be stored. //
///////////////////////////////////// /////////////////////////////////////
auditRecord = GeneralProcessUtils.getRecordByField(null, "audit", "recordId", recordId); auditRecord = GeneralProcessUtils.getRecordByField("audit", "recordId", recordId);
assertTrue(auditRecord.isPresent()); assertTrue(auditRecord.isPresent());
} }
@ -137,12 +137,12 @@ class AuditActionTest extends BaseTest
///////////////////////////////////// /////////////////////////////////////
// make sure things can be fetched // // make sure things can be fetched //
///////////////////////////////////// /////////////////////////////////////
GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "auditTable", "name", TestUtils.TABLE_NAME_PERSON_MEMORY); GeneralProcessUtils.getRecordByFieldOrElseThrow("auditTable", "name", TestUtils.TABLE_NAME_PERSON_MEMORY);
GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "auditUser", "name", userName); GeneralProcessUtils.getRecordByFieldOrElseThrow("auditUser", "name", userName);
QRecord auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "audit", "recordId", recordId1); QRecord auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow("audit", "recordId", recordId1);
assertEquals("Test Audit", auditRecord.getValueString("message")); assertEquals("Test Audit", auditRecord.getValueString("message"));
auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "audit", "recordId", recordId2); auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow("audit", "recordId", recordId2);
assertEquals("Test Another Audit", auditRecord.getValueString("message")); assertEquals("Test Another Audit", auditRecord.getValueString("message"));
assertEquals(47, auditRecord.getValueInteger(TestUtils.SECURITY_KEY_TYPE_STORE)); assertEquals(47, auditRecord.getValueInteger(TestUtils.SECURITY_KEY_TYPE_STORE));
} }
@ -173,26 +173,26 @@ class AuditActionTest extends BaseTest
///////////////////////////////////// /////////////////////////////////////
// make sure things can be fetched // // make sure things can be fetched //
///////////////////////////////////// /////////////////////////////////////
GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "auditTable", "name", TestUtils.TABLE_NAME_PERSON_MEMORY); GeneralProcessUtils.getRecordByFieldOrElseThrow("auditTable", "name", TestUtils.TABLE_NAME_PERSON_MEMORY);
GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "auditUser", "name", userName); GeneralProcessUtils.getRecordByFieldOrElseThrow("auditUser", "name", userName);
QRecord auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "audit", "recordId", recordId1); QRecord auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow("audit", "recordId", recordId1);
assertEquals("Test Audit", auditRecord.getValueString("message")); assertEquals("Test Audit", auditRecord.getValueString("message"));
List<QRecord> auditDetails = GeneralProcessUtils.getRecordListByField(null, "auditDetail", "auditId", auditRecord.getValue("id")); List<QRecord> auditDetails = GeneralProcessUtils.getRecordListByField("auditDetail", "auditId", auditRecord.getValue("id"));
assertEquals(2, auditDetails.size()); assertEquals(2, auditDetails.size());
assertThat(auditDetails).anyMatch(r -> r.getValueString("message").equals("Detail1")); assertThat(auditDetails).anyMatch(r -> r.getValueString("message").equals("Detail1"));
assertThat(auditDetails).anyMatch(r -> r.getValueString("message").equals("Detail2")); assertThat(auditDetails).anyMatch(r -> r.getValueString("message").equals("Detail2"));
auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "audit", "recordId", recordId2); auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow("audit", "recordId", recordId2);
assertEquals("Test Another Audit", auditRecord.getValueString("message")); assertEquals("Test Another Audit", auditRecord.getValueString("message"));
assertEquals(47, auditRecord.getValueInteger(TestUtils.SECURITY_KEY_TYPE_STORE)); assertEquals(47, auditRecord.getValueInteger(TestUtils.SECURITY_KEY_TYPE_STORE));
auditDetails = GeneralProcessUtils.getRecordListByField(null, "auditDetail", "auditId", auditRecord.getValue("id")); auditDetails = GeneralProcessUtils.getRecordListByField("auditDetail", "auditId", auditRecord.getValue("id"));
assertEquals(0, auditDetails.size()); assertEquals(0, auditDetails.size());
auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow(null, "audit", "recordId", recordId3); auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow("audit", "recordId", recordId3);
assertEquals("Audit 3", auditRecord.getValueString("message")); assertEquals("Audit 3", auditRecord.getValueString("message"));
assertEquals(42, auditRecord.getValueInteger(TestUtils.SECURITY_KEY_TYPE_STORE)); assertEquals(42, auditRecord.getValueInteger(TestUtils.SECURITY_KEY_TYPE_STORE));
auditDetails = GeneralProcessUtils.getRecordListByField(null, "auditDetail", "auditId", auditRecord.getValue("id")); auditDetails = GeneralProcessUtils.getRecordListByField("auditDetail", "auditId", auditRecord.getValue("id"));
assertEquals(1, auditDetails.size()); assertEquals(1, auditDetails.size());
assertThat(auditDetails).anyMatch(r -> r.getValueString("message").equals("Detail3")); assertThat(auditDetails).anyMatch(r -> r.getValueString("message").equals("Detail3"));
} }

View File

@ -111,7 +111,7 @@ class MergeDuplicatesProcessTest extends BaseTest
///////////////////////////////////////////////// /////////////////////////////////////////////////
// make sure records 4 and 5 have been deleted // // make sure records 4 and 5 have been deleted //
///////////////////////////////////////////////// /////////////////////////////////////////////////
Map<Serializable, QRecord> personMap = GeneralProcessUtils.loadTableToMap(runProcessInput, TestUtils.TABLE_NAME_PERSON_MEMORY, "id"); Map<Serializable, QRecord> personMap = GeneralProcessUtils.loadTableToMap(TestUtils.TABLE_NAME_PERSON_MEMORY, "id");
assertEquals(5, personMap.size()); assertEquals(5, personMap.size());
assertNull(personMap.get(4)); assertNull(personMap.get(4));
assertNull(personMap.get(5)); assertNull(personMap.get(5));
@ -124,7 +124,7 @@ class MergeDuplicatesProcessTest extends BaseTest
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// make sure the shapes corresponding to records 4 and 5 have been deleted // // make sure the shapes corresponding to records 4 and 5 have been deleted //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
Map<Serializable, QRecord> shapesMap = GeneralProcessUtils.loadTableToMap(runProcessInput, TestUtils.TABLE_NAME_SHAPE, "id"); Map<Serializable, QRecord> shapesMap = GeneralProcessUtils.loadTableToMap(TestUtils.TABLE_NAME_SHAPE, "id");
assertEquals(5, shapesMap.size()); assertEquals(5, shapesMap.size());
assertNull(shapesMap.get(4)); assertNull(shapesMap.get(4));
assertNull(shapesMap.get(5)); assertNull(shapesMap.get(5));

View File

@ -94,7 +94,7 @@ class TableSyncProcessTest extends BaseTest
// make sure the record referencing 3 has had its name updated // // make sure the record referencing 3 has had its name updated //
// and the one referencing 5 stayed the same // // and the one referencing 5 stayed the same //
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
Map<Serializable, QRecord> syncPersonsBySourceId = GeneralProcessUtils.loadTableToMap(runProcessInput, TABLE_NAME_PEOPLE_SYNC, "sourcePersonId"); Map<Serializable, QRecord> syncPersonsBySourceId = GeneralProcessUtils.loadTableToMap(TABLE_NAME_PEOPLE_SYNC, "sourcePersonId");
assertEquals("Tyler", syncPersonsBySourceId.get(3).getValueString("firstName")); assertEquals("Tyler", syncPersonsBySourceId.get(3).getValueString("firstName"));
assertEquals("Homer", syncPersonsBySourceId.get(5).getValueString("firstName")); assertEquals("Homer", syncPersonsBySourceId.get(5).getValueString("firstName"));
} }
@ -177,7 +177,7 @@ class TableSyncProcessTest extends BaseTest
// make sure the record referencing 3 has had its name updated // // make sure the record referencing 3 has had its name updated //
// and the one referencing 5 stayed the same // // and the one referencing 5 stayed the same //
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
Map<Serializable, QRecord> syncPersonsBySourceId = GeneralProcessUtils.loadTableToMap(runProcessInput, TABLE_NAME_PEOPLE_SYNC, "sourcePersonId"); Map<Serializable, QRecord> syncPersonsBySourceId = GeneralProcessUtils.loadTableToMap(TABLE_NAME_PEOPLE_SYNC, "sourcePersonId");
assertEquals("Tyler", syncPersonsBySourceId.get(3).getValueString("firstName")); assertEquals("Tyler", syncPersonsBySourceId.get(3).getValueString("firstName"));
assertEquals("Homer", syncPersonsBySourceId.get(5).getValueString("firstName")); assertEquals("Homer", syncPersonsBySourceId.get(5).getValueString("firstName"));
} }

View File

@ -90,7 +90,7 @@ class GeneralProcessUtilsTest extends BaseTest
queryInput.setTableName(TestUtils.TABLE_NAME_PERSON_MEMORY); queryInput.setTableName(TestUtils.TABLE_NAME_PERSON_MEMORY);
QueryOutput queryOutput = new QueryAction().execute(queryInput); QueryOutput queryOutput = new QueryAction().execute(queryInput);
Map<Serializable, QRecord> foreignRecordMap = GeneralProcessUtils.getForeignRecordMap(queryInput, queryOutput.getRecords(), "favoriteShapeId", TestUtils.TABLE_NAME_SHAPE, "id"); Map<Serializable, QRecord> foreignRecordMap = GeneralProcessUtils.getForeignRecordMap(queryOutput.getRecords(), "favoriteShapeId", TestUtils.TABLE_NAME_SHAPE, "id");
assertEquals(2, foreignRecordMap.size()); assertEquals(2, foreignRecordMap.size());
assertEquals(1, foreignRecordMap.get(1).getValueInteger("id")); assertEquals(1, foreignRecordMap.get(1).getValueInteger("id"));
@ -118,7 +118,7 @@ class GeneralProcessUtilsTest extends BaseTest
QueryOutput queryOutput = new QueryAction().execute(queryInput); QueryOutput queryOutput = new QueryAction().execute(queryInput);
QQueryFilter additionalFilter = new QQueryFilter(new QFilterCriteria("name", QCriteriaOperator.EQUALS, "Circle")); QQueryFilter additionalFilter = new QQueryFilter(new QFilterCriteria("name", QCriteriaOperator.EQUALS, "Circle"));
Map<Serializable, QRecord> foreignRecordMap = GeneralProcessUtils.getForeignRecordMap(queryInput, queryOutput.getRecords(), "favoriteShapeId", TestUtils.TABLE_NAME_SHAPE, "id", additionalFilter); Map<Serializable, QRecord> foreignRecordMap = GeneralProcessUtils.getForeignRecordMap(queryOutput.getRecords(), "favoriteShapeId", TestUtils.TABLE_NAME_SHAPE, "id", additionalFilter);
assertEquals(1, foreignRecordMap.size()); assertEquals(1, foreignRecordMap.size());
assertEquals(3, foreignRecordMap.get(3).getValueInteger("id")); assertEquals(3, foreignRecordMap.get(3).getValueInteger("id"));
@ -145,7 +145,7 @@ class GeneralProcessUtilsTest extends BaseTest
queryInput.setTableName(TestUtils.TABLE_NAME_SHAPE); queryInput.setTableName(TestUtils.TABLE_NAME_SHAPE);
QueryOutput queryOutput = new QueryAction().execute(queryInput); QueryOutput queryOutput = new QueryAction().execute(queryInput);
ListingHash<Serializable, QRecord> foreignRecordListingHashMap = GeneralProcessUtils.getForeignRecordListingHashMap(queryInput, queryOutput.getRecords(), "id", TestUtils.TABLE_NAME_PERSON_MEMORY, "favoriteShapeId"); ListingHash<Serializable, QRecord> foreignRecordListingHashMap = GeneralProcessUtils.getForeignRecordListingHashMap(queryOutput.getRecords(), "id", TestUtils.TABLE_NAME_PERSON_MEMORY, "favoriteShapeId");
assertEquals(2, foreignRecordListingHashMap.size()); assertEquals(2, foreignRecordListingHashMap.size());
@ -176,7 +176,7 @@ class GeneralProcessUtilsTest extends BaseTest
queryInput.setTableName(TestUtils.TABLE_NAME_PERSON_MEMORY); queryInput.setTableName(TestUtils.TABLE_NAME_PERSON_MEMORY);
QueryOutput queryOutput = new QueryAction().execute(queryInput); QueryOutput queryOutput = new QueryAction().execute(queryInput);
GeneralProcessUtils.addForeignRecordsToRecordList(queryInput, queryOutput.getRecords(), "favoriteShapeId", TestUtils.TABLE_NAME_SHAPE, "id"); GeneralProcessUtils.addForeignRecordsToRecordList(queryOutput.getRecords(), "favoriteShapeId", TestUtils.TABLE_NAME_SHAPE, "id");
for(QRecord record : queryOutput.getRecords()) for(QRecord record : queryOutput.getRecords())
{ {
@ -205,7 +205,7 @@ class GeneralProcessUtilsTest extends BaseTest
queryInput.setTableName(TestUtils.TABLE_NAME_SHAPE); queryInput.setTableName(TestUtils.TABLE_NAME_SHAPE);
QueryOutput queryOutput = new QueryAction().execute(queryInput); QueryOutput queryOutput = new QueryAction().execute(queryInput);
GeneralProcessUtils.addForeignRecordsListToRecordList(queryInput, queryOutput.getRecords(), "id", TestUtils.TABLE_NAME_PERSON_MEMORY, "favoriteShapeId"); GeneralProcessUtils.addForeignRecordsListToRecordList(queryOutput.getRecords(), "id", TestUtils.TABLE_NAME_PERSON_MEMORY, "favoriteShapeId");
for(QRecord record : queryOutput.getRecords()) for(QRecord record : queryOutput.getRecords())
{ {
@ -246,7 +246,7 @@ class GeneralProcessUtilsTest extends BaseTest
)); ));
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
List<QRecord> records = GeneralProcessUtils.getRecordListByField(queryInput, TestUtils.TABLE_NAME_PERSON_MEMORY, "favoriteShapeId", 3); List<QRecord> records = GeneralProcessUtils.getRecordListByField(TestUtils.TABLE_NAME_PERSON_MEMORY, "favoriteShapeId", 3);
assertEquals(2, records.size()); assertEquals(2, records.size());
assertTrue(records.stream().anyMatch(r -> r.getValue("id").equals(1))); assertTrue(records.stream().anyMatch(r -> r.getValue("id").equals(1)));
assertTrue(records.stream().anyMatch(r -> r.getValue("id").equals(2))); assertTrue(records.stream().anyMatch(r -> r.getValue("id").equals(2)));
@ -270,11 +270,11 @@ class GeneralProcessUtilsTest extends BaseTest
)); ));
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
Optional<QRecord> record = GeneralProcessUtils.getRecordByField(queryInput, TestUtils.TABLE_NAME_PERSON_MEMORY, "firstName", "James"); Optional<QRecord> record = GeneralProcessUtils.getRecordByField(TestUtils.TABLE_NAME_PERSON_MEMORY, "firstName", "James");
assertTrue(record.isPresent()); assertTrue(record.isPresent());
assertEquals(2, record.get().getValueInteger("id")); assertEquals(2, record.get().getValueInteger("id"));
record = GeneralProcessUtils.getRecordByField(queryInput, TestUtils.TABLE_NAME_PERSON_MEMORY, "firstName", "Bobby"); record = GeneralProcessUtils.getRecordByField(TestUtils.TABLE_NAME_PERSON_MEMORY, "firstName", "Bobby");
assertFalse(record.isPresent()); assertFalse(record.isPresent());
} }
@ -295,7 +295,7 @@ class GeneralProcessUtilsTest extends BaseTest
)); ));
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
List<QRecord> records = GeneralProcessUtils.loadTable(queryInput, TestUtils.TABLE_NAME_PERSON_MEMORY); List<QRecord> records = GeneralProcessUtils.loadTable(TestUtils.TABLE_NAME_PERSON_MEMORY);
assertEquals(3, records.size()); assertEquals(3, records.size());
} }
@ -316,17 +316,17 @@ class GeneralProcessUtilsTest extends BaseTest
)); ));
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
Map<Serializable, QRecord> recordMapById = GeneralProcessUtils.loadTableToMap(queryInput, TestUtils.TABLE_NAME_PERSON_MEMORY, "id"); Map<Serializable, QRecord> recordMapById = GeneralProcessUtils.loadTableToMap(TestUtils.TABLE_NAME_PERSON_MEMORY, "id");
assertEquals(3, recordMapById.size()); assertEquals(3, recordMapById.size());
assertEquals("Darin", recordMapById.get(1).getValueString("firstName")); assertEquals("Darin", recordMapById.get(1).getValueString("firstName"));
assertEquals("James", recordMapById.get(2).getValueString("firstName")); assertEquals("James", recordMapById.get(2).getValueString("firstName"));
Map<Serializable, QRecord> recordMapByFirstName = GeneralProcessUtils.loadTableToMap(queryInput, TestUtils.TABLE_NAME_PERSON_MEMORY, "firstName"); Map<Serializable, QRecord> recordMapByFirstName = GeneralProcessUtils.loadTableToMap(TestUtils.TABLE_NAME_PERSON_MEMORY, "firstName");
assertEquals(3, recordMapByFirstName.size()); assertEquals(3, recordMapByFirstName.size());
assertEquals(1, recordMapByFirstName.get("Darin").getValueInteger("id")); assertEquals(1, recordMapByFirstName.get("Darin").getValueInteger("id"));
assertEquals(3, recordMapByFirstName.get("Tim").getValueInteger("id")); assertEquals(3, recordMapByFirstName.get("Tim").getValueInteger("id"));
Map<String, QRecord> recordMapByFirstNameAsString = GeneralProcessUtils.loadTableToMap(queryInput, TestUtils.TABLE_NAME_PERSON_MEMORY, String.class, "firstName"); Map<String, QRecord> recordMapByFirstNameAsString = GeneralProcessUtils.loadTableToMap(TestUtils.TABLE_NAME_PERSON_MEMORY, String.class, "firstName");
assertEquals(3, recordMapByFirstName.size()); assertEquals(3, recordMapByFirstName.size());
assertEquals(1, recordMapByFirstName.get("Darin").getValueInteger("id")); assertEquals(1, recordMapByFirstName.get("Darin").getValueInteger("id"));
assertEquals(3, recordMapByFirstName.get("Tim").getValueInteger("id")); assertEquals(3, recordMapByFirstName.get("Tim").getValueInteger("id"));
@ -349,7 +349,7 @@ class GeneralProcessUtilsTest extends BaseTest
)); ));
QueryInput queryInput = new QueryInput(); QueryInput queryInput = new QueryInput();
ListingHash<Serializable, QRecord> map = GeneralProcessUtils.loadTableToListingHash(queryInput, TestUtils.TABLE_NAME_PERSON_MEMORY, "firstName"); ListingHash<Serializable, QRecord> map = GeneralProcessUtils.loadTableToListingHash(TestUtils.TABLE_NAME_PERSON_MEMORY, "firstName");
assertEquals(2, map.size()); assertEquals(2, map.size());
assertEquals(1, map.get("Darin").size()); assertEquals(1, map.get("Darin").size());
assertEquals(2, map.get("James").size()); assertEquals(2, map.get("James").size());
@ -366,8 +366,8 @@ class GeneralProcessUtilsTest extends BaseTest
QInstance instance = QContext.getQInstance(); QInstance instance = QContext.getQInstance();
TestUtils.insertDefaultShapes(instance); TestUtils.insertDefaultShapes(instance);
assertNotNull(GeneralProcessUtils.getRecordByFieldOrElseThrow(new AbstractActionInput(), TestUtils.TABLE_NAME_SHAPE, "name", "Triangle")); assertNotNull(GeneralProcessUtils.getRecordByFieldOrElseThrow(TestUtils.TABLE_NAME_SHAPE, "name", "Triangle"));
assertThrows(QException.class, () -> GeneralProcessUtils.getRecordByFieldOrElseThrow(new AbstractActionInput(), TestUtils.TABLE_NAME_SHAPE, "name", "notAShape")); assertThrows(QException.class, () -> GeneralProcessUtils.getRecordByFieldOrElseThrow(TestUtils.TABLE_NAME_SHAPE, "name", "notAShape"));
} }
@ -382,10 +382,10 @@ class GeneralProcessUtilsTest extends BaseTest
TestUtils.insertDefaultShapes(instance); TestUtils.insertDefaultShapes(instance);
AbstractActionInput actionInput = new AbstractActionInput(); AbstractActionInput actionInput = new AbstractActionInput();
assertTrue(GeneralProcessUtils.getRecordByPrimaryKey(actionInput, TestUtils.TABLE_NAME_SHAPE, 1).isPresent()); assertTrue(GeneralProcessUtils.getRecordByPrimaryKey(TestUtils.TABLE_NAME_SHAPE, 1).isPresent());
assertFalse(GeneralProcessUtils.getRecordByPrimaryKey(actionInput, TestUtils.TABLE_NAME_SHAPE, -1).isPresent()); assertFalse(GeneralProcessUtils.getRecordByPrimaryKey(TestUtils.TABLE_NAME_SHAPE, -1).isPresent());
assertNotNull(GeneralProcessUtils.getRecordByPrimaryKeyOrElseThrow(actionInput, TestUtils.TABLE_NAME_SHAPE, 1)); assertNotNull(GeneralProcessUtils.getRecordByPrimaryKeyOrElseThrow(TestUtils.TABLE_NAME_SHAPE, 1));
assertThrows(QException.class, () -> GeneralProcessUtils.getRecordByPrimaryKeyOrElseThrow(actionInput, TestUtils.TABLE_NAME_SHAPE, -1)); assertThrows(QException.class, () -> GeneralProcessUtils.getRecordByPrimaryKeyOrElseThrow(TestUtils.TABLE_NAME_SHAPE, -1));
} }
@ -400,9 +400,9 @@ class GeneralProcessUtilsTest extends BaseTest
TestUtils.insertDefaultShapes(instance); TestUtils.insertDefaultShapes(instance);
AbstractActionInput actionInput = new AbstractActionInput(); AbstractActionInput actionInput = new AbstractActionInput();
assertEquals(3, GeneralProcessUtils.count(actionInput, TestUtils.TABLE_NAME_SHAPE, null)); assertEquals(3, GeneralProcessUtils.count(TestUtils.TABLE_NAME_SHAPE, null));
assertEquals(1, GeneralProcessUtils.count(actionInput, TestUtils.TABLE_NAME_SHAPE, new QQueryFilter(new QFilterCriteria("id", QCriteriaOperator.EQUALS, 2)))); assertEquals(1, GeneralProcessUtils.count(TestUtils.TABLE_NAME_SHAPE, new QQueryFilter(new QFilterCriteria("id", QCriteriaOperator.EQUALS, 2))));
assertEquals(0, GeneralProcessUtils.count(actionInput, TestUtils.TABLE_NAME_SHAPE, new QQueryFilter(new QFilterCriteria("name", QCriteriaOperator.IS_BLANK)))); assertEquals(0, GeneralProcessUtils.count(TestUtils.TABLE_NAME_SHAPE, new QQueryFilter(new QFilterCriteria("name", QCriteriaOperator.IS_BLANK))));
} }
@ -417,8 +417,8 @@ class GeneralProcessUtilsTest extends BaseTest
TestUtils.insertDefaultShapes(instance); TestUtils.insertDefaultShapes(instance);
AbstractActionInput actionInput = new AbstractActionInput(); AbstractActionInput actionInput = new AbstractActionInput();
assertEquals("Triangle", GeneralProcessUtils.getEntityByField(actionInput, TestUtils.TABLE_NAME_SHAPE, "name", "Triangle", Shape.class).get().getName()); assertEquals("Triangle", GeneralProcessUtils.getEntityByField(TestUtils.TABLE_NAME_SHAPE, "name", "Triangle", Shape.class).get().getName());
assertFalse(GeneralProcessUtils.getEntityByField(actionInput, TestUtils.TABLE_NAME_SHAPE, "name", "notAShape", Shape.class).isPresent()); assertFalse(GeneralProcessUtils.getEntityByField(TestUtils.TABLE_NAME_SHAPE, "name", "notAShape", Shape.class).isPresent());
} }
@ -433,7 +433,7 @@ class GeneralProcessUtilsTest extends BaseTest
TestUtils.insertDefaultShapes(instance); TestUtils.insertDefaultShapes(instance);
AbstractActionInput actionInput = new AbstractActionInput(); AbstractActionInput actionInput = new AbstractActionInput();
List<Shape> shapes = GeneralProcessUtils.loadTable(actionInput, TestUtils.TABLE_NAME_SHAPE, Shape.class); List<Shape> shapes = GeneralProcessUtils.loadTable(TestUtils.TABLE_NAME_SHAPE, Shape.class);
assertEquals(3, shapes.size()); assertEquals(3, shapes.size());
assertTrue(shapes.get(0) instanceof Shape); assertTrue(shapes.get(0) instanceof Shape);
} }
@ -450,7 +450,7 @@ class GeneralProcessUtilsTest extends BaseTest
TestUtils.insertDefaultShapes(instance); TestUtils.insertDefaultShapes(instance);
AbstractActionInput actionInput = new AbstractActionInput(); AbstractActionInput actionInput = new AbstractActionInput();
Map<Serializable, Shape> map = GeneralProcessUtils.loadTableToMap(actionInput, TestUtils.TABLE_NAME_SHAPE, "id", Shape.class); Map<Serializable, Shape> map = GeneralProcessUtils.loadTableToMap(TestUtils.TABLE_NAME_SHAPE, "id", Shape.class);
assertEquals(3, map.size()); assertEquals(3, map.size());
assertTrue(map.get(1) instanceof Shape); assertTrue(map.get(1) instanceof Shape);
} }

View File

@ -544,7 +544,7 @@ public class BaseAPIActionUtil
protected String buildQueryStringForGet(QQueryFilter filter, Integer limit, Integer skip, Map<String, QFieldMetaData> fields) throws QException protected String buildQueryStringForGet(QQueryFilter filter, Integer limit, Integer skip, Map<String, QFieldMetaData> fields) throws QException
{ {
// todo: reasonable default action // todo: reasonable default action
return (null); return ("");
} }

View File

@ -143,7 +143,7 @@ public class QJavalinScriptsHandler
QTableMetaData scriptTable = QContext.getQInstance().getTable(Script.TABLE_NAME); QTableMetaData scriptTable = QContext.getQInstance().getTable(Script.TABLE_NAME);
if(scriptTypeTable != null && scriptTable != null && scriptRevisionTable != null) if(scriptTypeTable != null && scriptTable != null && scriptRevisionTable != null)
{ {
Map<Serializable, QRecord> scriptTypeMap = GeneralProcessUtils.loadTableToMap(getInput, ScriptType.TABLE_NAME, "id"); Map<Serializable, QRecord> scriptTypeMap = GeneralProcessUtils.loadTableToMap(ScriptType.TABLE_NAME, "id");
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
// process each associated script type for the table // // process each associated script type for the table //
@ -259,7 +259,7 @@ public class QJavalinScriptsHandler
if(CollectionUtils.nullSafeHasContents(queryOutput.getRecords())) if(CollectionUtils.nullSafeHasContents(queryOutput.getRecords()))
{ {
GeneralProcessUtils.addForeignRecordsListToRecordList(queryInput, queryOutput.getRecords(), "id", "scriptLogLine", "scriptLogId"); GeneralProcessUtils.addForeignRecordsListToRecordList(queryOutput.getRecords(), "id", "scriptLogLine", "scriptLogId");
} }
Map<String, Serializable> rs = new HashMap<>(); Map<String, Serializable> rs = new HashMap<>();