mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-20 06:00:44 +00:00
Compare commits
7 Commits
snapshot-h
...
snapshot-f
Author | SHA1 | Date | |
---|---|---|---|
acb311ee52 | |||
4a53c0d42a | |||
fa5c4f715f | |||
7a56d1ae22 | |||
1d309afbea | |||
02fc031e09 | |||
e57292f10f |
@ -46,6 +46,7 @@ import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.security.RecordSecurityLock;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.session.QUser;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTableAccessor;
|
||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.Pair;
|
||||
|
||||
@ -177,7 +178,6 @@ public class AuditAction extends AbstractQActionFunction<AuditInput, AuditOutput
|
||||
////////////////////////////////////////////////
|
||||
// map names to ids and handle default values //
|
||||
////////////////////////////////////////////////
|
||||
Integer auditTableId = getIdForName("auditTable", auditSingleInput.getAuditTableName());
|
||||
Integer auditUserId = getIdForName("auditUser", Objects.requireNonNullElse(auditSingleInput.getAuditUserName(), getSessionUserName()));
|
||||
Instant timestamp = Objects.requireNonNullElse(auditSingleInput.getTimestamp(), Instant.now());
|
||||
|
||||
@ -185,7 +185,7 @@ public class AuditAction extends AbstractQActionFunction<AuditInput, AuditOutput
|
||||
// build record //
|
||||
//////////////////
|
||||
QRecord record = new QRecord()
|
||||
.withValue("auditTableId", auditTableId)
|
||||
.withValue("tableId", QQQTableAccessor.getTableId(auditSingleInput.getAuditTableName()))
|
||||
.withValue("auditUserId", auditUserId)
|
||||
.withValue("timestamp", timestamp)
|
||||
.withValue("message", auditSingleInput.getMessage())
|
||||
@ -287,15 +287,6 @@ public class AuditAction extends AbstractQActionFunction<AuditInput, AuditOutput
|
||||
insertInput.setTableName(tableName);
|
||||
QRecord record = new QRecord().withValue("name", nameValue);
|
||||
|
||||
if(tableName.equals("auditTable"))
|
||||
{
|
||||
QTableMetaData table = QContext.getQInstance().getTable(nameValue);
|
||||
if(table != null)
|
||||
{
|
||||
record.setValue("label", table.getLabel());
|
||||
}
|
||||
}
|
||||
|
||||
insertInput.setRecords(List.of(record));
|
||||
InsertOutput insertOutput = new InsertAction().execute(insertInput);
|
||||
id = insertOutput.getRecords().get(0).getValueInteger("id");
|
||||
|
@ -45,6 +45,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.tables.automation.QTableAut
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.automation.TableAutomationAction;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.automation.TriggerEvent;
|
||||
import com.kingsrook.qqq.backend.core.model.session.QSession;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTableAccessor;
|
||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
|
||||
@ -171,7 +172,7 @@ public class RecordAutomationStatusUpdater
|
||||
CountInput countInput = new CountInput();
|
||||
countInput.setTableName(TableTrigger.TABLE_NAME);
|
||||
countInput.setFilter(new QQueryFilter(
|
||||
new QFilterCriteria("tableName", QCriteriaOperator.EQUALS, table.getName()),
|
||||
new QFilterCriteria("tableId", QCriteriaOperator.EQUALS, QQQTableAccessor.getTableId(table.getName())),
|
||||
new QFilterCriteria(triggerEvent.equals(TriggerEvent.POST_INSERT) ? "postInsert" : "postUpdate", QCriteriaOperator.EQUALS, true)
|
||||
));
|
||||
CountOutput countOutput = new CountAction().execute(countInput);
|
||||
|
@ -66,6 +66,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.tables.automation.TableAuto
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.automation.TriggerEvent;
|
||||
import com.kingsrook.qqq.backend.core.model.savedfilters.SavedFilter;
|
||||
import com.kingsrook.qqq.backend.core.model.session.QSession;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTableAccessor;
|
||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.JsonUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
@ -270,7 +271,7 @@ public class PollingAutomationPerTableRunner implements Runnable
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(TableTrigger.TABLE_NAME);
|
||||
queryInput.setFilter(new QQueryFilter(
|
||||
new QFilterCriteria("tableName", QCriteriaOperator.EQUALS, table.getName()),
|
||||
new QFilterCriteria("tableId", QCriteriaOperator.EQUALS, QQQTableAccessor.getTableId(table.getName())),
|
||||
new QFilterCriteria(triggerEvent.equals(TriggerEvent.POST_INSERT) ? "postInsert" : "postUpdate", QCriteriaOperator.EQUALS, true)
|
||||
));
|
||||
QueryOutput queryOutput = new QueryAction().execute(queryInput);
|
||||
|
@ -47,6 +47,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldType;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.scripts.Script;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTableAccessor;
|
||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
||||
@ -83,7 +84,7 @@ public class RecordScriptTestInterface implements TestScriptActionInterface
|
||||
//////////////////////////////////////////////
|
||||
// look up the records being tested against //
|
||||
//////////////////////////////////////////////
|
||||
String tableName = script.getValueString("tableName");
|
||||
String tableName = QQQTableAccessor.getTableName(script.getValueInteger("tableId"));
|
||||
QTableMetaData table = QContext.getQInstance().getTable(tableName);
|
||||
if(table == null)
|
||||
{
|
||||
|
@ -31,16 +31,12 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.GetAction;
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
|
||||
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.logging.QLogger;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterCriteria;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterOrderBy;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
|
||||
@ -54,11 +50,9 @@ import com.kingsrook.qqq.backend.core.model.querystats.QueryStatCriteriaField;
|
||||
import com.kingsrook.qqq.backend.core.model.querystats.QueryStatJoinTable;
|
||||
import com.kingsrook.qqq.backend.core.model.querystats.QueryStatOrderByField;
|
||||
import com.kingsrook.qqq.backend.core.model.session.QSession;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTable;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTablesMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTableAccessor;
|
||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.collections.MapBuilder;
|
||||
import static com.kingsrook.qqq.backend.core.logging.LogUtils.logPair;
|
||||
|
||||
|
||||
@ -363,8 +357,8 @@ public class QueryStatManager
|
||||
//////////////////////
|
||||
// set the table id //
|
||||
//////////////////////
|
||||
Integer qqqTableId = getQQQTableId(queryStat.getTableName());
|
||||
queryStat.setQqqTableId(qqqTableId);
|
||||
Integer tableId = QQQTableAccessor.getTableId(queryStat.getTableName());
|
||||
queryStat.setTableId(tableId);
|
||||
|
||||
//////////////////////////////
|
||||
// build join-table records //
|
||||
@ -374,7 +368,7 @@ public class QueryStatManager
|
||||
List<QueryStatJoinTable> queryStatJoinTableList = new ArrayList<>();
|
||||
for(String joinTableName : queryStat.getJoinTableNames())
|
||||
{
|
||||
queryStatJoinTableList.add(new QueryStatJoinTable().withQqqTableId(getQQQTableId(joinTableName)));
|
||||
queryStatJoinTableList.add(new QueryStatJoinTable().withTableId(QQQTableAccessor.getTableId(joinTableName)));
|
||||
}
|
||||
queryStat.setQueryStatJoinTableList(queryStatJoinTableList);
|
||||
}
|
||||
@ -385,14 +379,14 @@ public class QueryStatManager
|
||||
if(queryStat.getQueryFilter() != null && queryStat.getQueryFilter().hasAnyCriteria())
|
||||
{
|
||||
List<QueryStatCriteriaField> queryStatCriteriaFieldList = new ArrayList<>();
|
||||
processCriteriaFromFilter(qqqTableId, queryStatCriteriaFieldList, queryStat.getQueryFilter());
|
||||
processCriteriaFromFilter(tableId, queryStatCriteriaFieldList, queryStat.getQueryFilter());
|
||||
queryStat.setQueryStatCriteriaFieldList(queryStatCriteriaFieldList);
|
||||
}
|
||||
|
||||
if(CollectionUtils.nullSafeHasContents(queryStat.getQueryFilter().getOrderBys()))
|
||||
{
|
||||
List<QueryStatOrderByField> queryStatOrderByFieldList = new ArrayList<>();
|
||||
processOrderByFromFilter(qqqTableId, queryStatOrderByFieldList, queryStat.getQueryFilter());
|
||||
processOrderByFromFilter(tableId, queryStatOrderByFieldList, queryStat.getQueryFilter());
|
||||
queryStat.setQueryStatOrderByFieldList(queryStatOrderByFieldList);
|
||||
}
|
||||
|
||||
@ -434,7 +428,7 @@ public class QueryStatManager
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private static void processCriteriaFromFilter(Integer qqqTableId, List<QueryStatCriteriaField> queryStatCriteriaFieldList, QQueryFilter queryFilter) throws QException
|
||||
private static void processCriteriaFromFilter(Integer tableId, List<QueryStatCriteriaField> queryStatCriteriaFieldList, QQueryFilter queryFilter) throws QException
|
||||
{
|
||||
for(QFilterCriteria criteria : CollectionUtils.nonNullList(queryFilter.getCriteria()))
|
||||
{
|
||||
@ -452,13 +446,13 @@ public class QueryStatManager
|
||||
String[] parts = fieldName.split("\\.");
|
||||
if(parts.length > 1)
|
||||
{
|
||||
queryStatCriteriaField.setQqqTableId(getQQQTableId(parts[0]));
|
||||
queryStatCriteriaField.setTableId(QQQTableAccessor.getTableId(parts[0]));
|
||||
queryStatCriteriaField.setName(parts[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
queryStatCriteriaField.setQqqTableId(qqqTableId);
|
||||
queryStatCriteriaField.setTableId(tableId);
|
||||
queryStatCriteriaField.setName(fieldName);
|
||||
}
|
||||
|
||||
@ -467,7 +461,7 @@ public class QueryStatManager
|
||||
|
||||
for(QQueryFilter subFilter : CollectionUtils.nonNullList(queryFilter.getSubFilters()))
|
||||
{
|
||||
processCriteriaFromFilter(qqqTableId, queryStatCriteriaFieldList, subFilter);
|
||||
processCriteriaFromFilter(tableId, queryStatCriteriaFieldList, subFilter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -476,7 +470,7 @@ public class QueryStatManager
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private static void processOrderByFromFilter(Integer qqqTableId, List<QueryStatOrderByField> queryStatOrderByFieldList, QQueryFilter queryFilter) throws QException
|
||||
private static void processOrderByFromFilter(Integer tableId, List<QueryStatOrderByField> queryStatOrderByFieldList, QQueryFilter queryFilter) throws QException
|
||||
{
|
||||
for(QFilterOrderBy orderBy : CollectionUtils.nonNullList(queryFilter.getOrderBys()))
|
||||
{
|
||||
@ -490,13 +484,13 @@ public class QueryStatManager
|
||||
String[] parts = fieldName.split("\\.");
|
||||
if(parts.length > 1)
|
||||
{
|
||||
queryStatOrderByField.setQqqTableId(getQQQTableId(parts[0]));
|
||||
queryStatOrderByField.setTableId(QQQTableAccessor.getTableId(parts[0]));
|
||||
queryStatOrderByField.setName(parts[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
queryStatOrderByField.setQqqTableId(qqqTableId);
|
||||
queryStatOrderByField.setTableId(tableId);
|
||||
queryStatOrderByField.setName(fieldName);
|
||||
}
|
||||
|
||||
@ -505,43 +499,6 @@ public class QueryStatManager
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private static Integer getQQQTableId(String tableName) throws QException
|
||||
{
|
||||
/////////////////////////////
|
||||
// look in the cache table //
|
||||
/////////////////////////////
|
||||
GetInput getInput = new GetInput();
|
||||
getInput.setTableName(QQQTablesMetaDataProvider.QQQ_TABLE_CACHE_TABLE_NAME);
|
||||
getInput.setUniqueKey(MapBuilder.of("name", tableName));
|
||||
GetOutput getOutput = new GetAction().execute(getInput);
|
||||
|
||||
////////////////////////
|
||||
// upon cache miss... //
|
||||
////////////////////////
|
||||
if(getOutput.getRecord() == null)
|
||||
{
|
||||
///////////////////////////////////////////////////////
|
||||
// insert the record (into the table, not the cache) //
|
||||
///////////////////////////////////////////////////////
|
||||
QTableMetaData tableMetaData = getInstance().qInstance.getTable(tableName);
|
||||
InsertInput insertInput = new InsertInput();
|
||||
insertInput.setTableName(QQQTable.TABLE_NAME);
|
||||
insertInput.setRecords(List.of(new QRecord().withValue("name", tableName).withValue("label", tableMetaData.getLabel())));
|
||||
InsertOutput insertOutput = new InsertAction().execute(insertInput);
|
||||
|
||||
///////////////////////////////////
|
||||
// repeat the get from the cache //
|
||||
///////////////////////////////////
|
||||
getOutput = new GetAction().execute(getInput);
|
||||
}
|
||||
|
||||
return getOutput.getRecord().getValueInteger("id");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.QPossibleVal
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.Capability;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.UniqueKey;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTable;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -46,7 +47,6 @@ import com.kingsrook.qqq.backend.core.model.metadata.tables.UniqueKey;
|
||||
*******************************************************************************/
|
||||
public class AuditsMetaDataProvider
|
||||
{
|
||||
public static final String TABLE_NAME_AUDIT_TABLE = "auditTable";
|
||||
public static final String TABLE_NAME_AUDIT_USER = "auditUser";
|
||||
public static final String TABLE_NAME_AUDIT = "audit";
|
||||
public static final String TABLE_NAME_AUDIT_DETAIL = "auditDetail";
|
||||
@ -72,10 +72,10 @@ public class AuditsMetaDataProvider
|
||||
{
|
||||
instance.addJoin(new QJoinMetaData()
|
||||
.withLeftTable(TABLE_NAME_AUDIT)
|
||||
.withRightTable(TABLE_NAME_AUDIT_TABLE)
|
||||
.withRightTable(QQQTable.TABLE_NAME)
|
||||
.withInferredName()
|
||||
.withType(JoinType.MANY_TO_ONE)
|
||||
.withJoinOn(new JoinOn("auditTableId", "id")));
|
||||
.withJoinOn(new JoinOn("tableId", "id")));
|
||||
|
||||
instance.addJoin(new QJoinMetaData()
|
||||
.withLeftTable(TABLE_NAME_AUDIT)
|
||||
@ -113,11 +113,6 @@ public class AuditsMetaDataProvider
|
||||
*******************************************************************************/
|
||||
public void defineStandardAuditPossibleValueSources(QInstance instance)
|
||||
{
|
||||
instance.addPossibleValueSource(new QPossibleValueSource()
|
||||
.withName(TABLE_NAME_AUDIT_TABLE)
|
||||
.withTableName(TABLE_NAME_AUDIT_TABLE)
|
||||
);
|
||||
|
||||
instance.addPossibleValueSource(new QPossibleValueSource()
|
||||
.withName(TABLE_NAME_AUDIT_USER)
|
||||
.withTableName(TABLE_NAME_AUDIT_USER)
|
||||
@ -138,7 +133,6 @@ public class AuditsMetaDataProvider
|
||||
{
|
||||
List<QTableMetaData> rs = new ArrayList<>();
|
||||
rs.add(enrich(backendDetailEnricher, defineAuditUserTable(backendName)));
|
||||
rs.add(enrich(backendDetailEnricher, defineAuditTableTable(backendName)));
|
||||
rs.add(enrich(backendDetailEnricher, defineAuditTable(backendName)));
|
||||
rs.add(enrich(backendDetailEnricher, defineAuditDetailTable(backendName)));
|
||||
return (rs);
|
||||
@ -160,29 +154,6 @@ public class AuditsMetaDataProvider
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
private QTableMetaData defineAuditTableTable(String backendName)
|
||||
{
|
||||
return new QTableMetaData()
|
||||
.withName(TABLE_NAME_AUDIT_TABLE)
|
||||
.withBackendName(backendName)
|
||||
.withAuditRules(new QAuditRules().withAuditLevel(AuditLevel.NONE))
|
||||
.withRecordLabelFormat("%s")
|
||||
.withRecordLabelFields("label")
|
||||
.withPrimaryKeyField("id")
|
||||
.withUniqueKey(new UniqueKey("name"))
|
||||
.withField(new QFieldMetaData("id", QFieldType.INTEGER))
|
||||
.withField(new QFieldMetaData("name", QFieldType.STRING))
|
||||
.withField(new QFieldMetaData("label", QFieldType.STRING))
|
||||
.withField(new QFieldMetaData("createDate", QFieldType.DATE_TIME))
|
||||
.withField(new QFieldMetaData("modifyDate", QFieldType.DATE_TIME))
|
||||
.withoutCapabilities(Capability.TABLE_INSERT, Capability.TABLE_UPDATE, Capability.TABLE_DELETE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@ -215,10 +186,10 @@ public class AuditsMetaDataProvider
|
||||
.withBackendName(backendName)
|
||||
.withAuditRules(new QAuditRules().withAuditLevel(AuditLevel.NONE))
|
||||
.withRecordLabelFormat("%s %s")
|
||||
.withRecordLabelFields("auditTableId", "recordId")
|
||||
.withRecordLabelFields("tableId", "recordId")
|
||||
.withPrimaryKeyField("id")
|
||||
.withField(new QFieldMetaData("id", QFieldType.INTEGER))
|
||||
.withField(new QFieldMetaData("auditTableId", QFieldType.INTEGER).withPossibleValueSourceName(TABLE_NAME_AUDIT_TABLE))
|
||||
.withField(new QFieldMetaData("tableId", QFieldType.INTEGER).withPossibleValueSourceName(QQQTable.TABLE_NAME))
|
||||
.withField(new QFieldMetaData("auditUserId", QFieldType.INTEGER).withPossibleValueSourceName(TABLE_NAME_AUDIT_USER))
|
||||
.withField(new QFieldMetaData("recordId", QFieldType.INTEGER))
|
||||
.withField(new QFieldMetaData("message", QFieldType.STRING).withMaxLength(250).withBehavior(ValueTooLongBehavior.TRUNCATE_ELLIPSIS))
|
||||
|
@ -27,9 +27,9 @@ import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QField;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.TablesPossibleValueSourceMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.model.savedfilters.SavedFilter;
|
||||
import com.kingsrook.qqq.backend.core.model.scripts.Script;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTable;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -48,8 +48,8 @@ public class TableTrigger extends QRecordEntity
|
||||
@QField(isEditable = false)
|
||||
private Instant modifyDate;
|
||||
|
||||
@QField(possibleValueSourceName = TablesPossibleValueSourceMetaDataProvider.NAME)
|
||||
private String tableName;
|
||||
@QField(possibleValueSourceName = QQQTable.TABLE_NAME)
|
||||
private Integer tableId;
|
||||
|
||||
@QField(possibleValueSourceName = SavedFilter.TABLE_NAME)
|
||||
private Integer filterId;
|
||||
@ -191,40 +191,6 @@ public class TableTrigger extends QRecordEntity
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for tableName
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getTableName()
|
||||
{
|
||||
return tableName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for tableName
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setTableName(String tableName)
|
||||
{
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for tableName
|
||||
**
|
||||
*******************************************************************************/
|
||||
public TableTrigger withTableName(String tableName)
|
||||
{
|
||||
this.tableName = tableName;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for filterId
|
||||
**
|
||||
@ -390,4 +356,35 @@ public class TableTrigger extends QRecordEntity
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for tableId
|
||||
*******************************************************************************/
|
||||
public Integer getTableId()
|
||||
{
|
||||
return (this.tableId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for tableId
|
||||
*******************************************************************************/
|
||||
public void setTableId(Integer tableId)
|
||||
{
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for tableId
|
||||
*******************************************************************************/
|
||||
public TableTrigger withTableId(Integer tableId)
|
||||
{
|
||||
this.tableId = tableId;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ public class QueryStat extends QRecordEntity
|
||||
@QField()
|
||||
private Integer firstResultMillis;
|
||||
|
||||
@QField(label = "Table", possibleValueSourceName = QQQTable.TABLE_NAME)
|
||||
private Integer qqqTableId;
|
||||
@QField(possibleValueSourceName = QQQTable.TABLE_NAME)
|
||||
private Integer tableId;
|
||||
|
||||
@QField(maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE_ELLIPSIS)
|
||||
private String action;
|
||||
@ -413,31 +413,31 @@ public class QueryStat extends QRecordEntity
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for qqqTableId
|
||||
** Getter for tableId
|
||||
*******************************************************************************/
|
||||
public Integer getQqqTableId()
|
||||
public Integer getTableId()
|
||||
{
|
||||
return (this.qqqTableId);
|
||||
return (this.tableId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for qqqTableId
|
||||
** Setter for tableId
|
||||
*******************************************************************************/
|
||||
public void setQqqTableId(Integer qqqTableId)
|
||||
public void setTableId(Integer tableId)
|
||||
{
|
||||
this.qqqTableId = qqqTableId;
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for qqqTableId
|
||||
** Fluent setter for tableId
|
||||
*******************************************************************************/
|
||||
public QueryStat withQqqTableId(Integer qqqTableId)
|
||||
public QueryStat withTableId(Integer tableId)
|
||||
{
|
||||
this.qqqTableId = qqqTableId;
|
||||
this.tableId = tableId;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,8 @@ public class QueryStatCriteriaField extends QRecordEntity
|
||||
@QField(possibleValueSourceName = QueryStat.TABLE_NAME)
|
||||
private Integer queryStatId;
|
||||
|
||||
@QField(label = "Table", possibleValueSourceName = QQQTable.TABLE_NAME)
|
||||
private Integer qqqTableId;
|
||||
@QField(possibleValueSourceName = QQQTable.TABLE_NAME)
|
||||
private Integer tableId;
|
||||
|
||||
@QField(maxLength = 50, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE_ELLIPSIS)
|
||||
private String name;
|
||||
@ -138,31 +138,31 @@ public class QueryStatCriteriaField extends QRecordEntity
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for qqqTableId
|
||||
** Getter for tableId
|
||||
*******************************************************************************/
|
||||
public Integer getQqqTableId()
|
||||
public Integer getTableId()
|
||||
{
|
||||
return (this.qqqTableId);
|
||||
return (this.tableId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for qqqTableId
|
||||
** Setter for tableId
|
||||
*******************************************************************************/
|
||||
public void setQqqTableId(Integer qqqTableId)
|
||||
public void setTableId(Integer tableId)
|
||||
{
|
||||
this.qqqTableId = qqqTableId;
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for qqqTableId
|
||||
** Fluent setter for tableId
|
||||
*******************************************************************************/
|
||||
public QueryStatCriteriaField withQqqTableId(Integer qqqTableId)
|
||||
public QueryStatCriteriaField withTableId(Integer tableId)
|
||||
{
|
||||
this.qqqTableId = qqqTableId;
|
||||
this.tableId = tableId;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,8 @@ public class QueryStatJoinTable extends QRecordEntity
|
||||
@QField(possibleValueSourceName = QueryStat.TABLE_NAME)
|
||||
private Integer queryStatId;
|
||||
|
||||
@QField(label = "Table", possibleValueSourceName = QQQTable.TABLE_NAME)
|
||||
private Integer qqqTableId;
|
||||
@QField(possibleValueSourceName = QQQTable.TABLE_NAME)
|
||||
private Integer tableId;
|
||||
|
||||
@QField(maxLength = 10, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE_ELLIPSIS)
|
||||
private String type;
|
||||
@ -132,31 +132,31 @@ public class QueryStatJoinTable extends QRecordEntity
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for qqqTableId
|
||||
** Getter for tableId
|
||||
*******************************************************************************/
|
||||
public Integer getQqqTableId()
|
||||
public Integer getTableId()
|
||||
{
|
||||
return (this.qqqTableId);
|
||||
return (this.tableId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for qqqTableId
|
||||
** Setter for tableId
|
||||
*******************************************************************************/
|
||||
public void setQqqTableId(Integer qqqTableId)
|
||||
public void setTableId(Integer tableId)
|
||||
{
|
||||
this.qqqTableId = qqqTableId;
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for qqqTableId
|
||||
** Fluent setter for tableId
|
||||
*******************************************************************************/
|
||||
public QueryStatJoinTable withQqqTableId(Integer qqqTableId)
|
||||
public QueryStatJoinTable withTableId(Integer tableId)
|
||||
{
|
||||
this.qqqTableId = qqqTableId;
|
||||
this.tableId = tableId;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class QueryStatMetaDataProvider
|
||||
.withRecordLabelFields("id")
|
||||
.withPrimaryKeyField("id")
|
||||
.withFieldsFromEntity(QueryStat.class)
|
||||
.withSection(new QFieldSection("identity", new QIcon().withName("badge"), Tier.T1, List.of("id", "action", "qqqTableId", "sessionId")))
|
||||
.withSection(new QFieldSection("identity", new QIcon().withName("badge"), Tier.T1, List.of("id", "action", "tableId", "sessionId")))
|
||||
.withSection(new QFieldSection("data", new QIcon().withName("dataset"), Tier.T2, List.of("queryText", "startTimestamp", "firstResultTimestamp", "firstResultMillis")))
|
||||
.withSection(new QFieldSection("joins", new QIcon().withName("merge"), Tier.T2).withWidgetName(joinTablesJoinName + "Widget"))
|
||||
.withSection(new QFieldSection("criteria", new QIcon().withName("filter_alt"), Tier.T2).withWidgetName(criteriaFieldsJoinName + "Widget"))
|
||||
|
@ -42,8 +42,8 @@ public class QueryStatOrderByField extends QRecordEntity
|
||||
@QField(possibleValueSourceName = QueryStat.TABLE_NAME)
|
||||
private Integer queryStatId;
|
||||
|
||||
@QField(label = "Table", possibleValueSourceName = QQQTable.TABLE_NAME)
|
||||
private Integer qqqTableId;
|
||||
@QField(possibleValueSourceName = QQQTable.TABLE_NAME)
|
||||
private Integer tableId;
|
||||
|
||||
@QField(maxLength = 50, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE_ELLIPSIS)
|
||||
private String name;
|
||||
@ -132,31 +132,31 @@ public class QueryStatOrderByField extends QRecordEntity
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for qqqTableId
|
||||
** Getter for tableId
|
||||
*******************************************************************************/
|
||||
public Integer getQqqTableId()
|
||||
public Integer getTableId()
|
||||
{
|
||||
return (this.qqqTableId);
|
||||
return (this.tableId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for qqqTableId
|
||||
** Setter for tableId
|
||||
*******************************************************************************/
|
||||
public void setQqqTableId(Integer qqqTableId)
|
||||
public void setTableId(Integer tableId)
|
||||
{
|
||||
this.qqqTableId = qqqTableId;
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for qqqTableId
|
||||
** Fluent setter for tableId
|
||||
*******************************************************************************/
|
||||
public QueryStatOrderByField withQqqTableId(Integer qqqTableId)
|
||||
public QueryStatOrderByField withTableId(Integer tableId)
|
||||
{
|
||||
this.qqqTableId = qqqTableId;
|
||||
this.tableId = tableId;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QField;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTable;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -48,8 +49,8 @@ public class SavedFilter extends QRecordEntity
|
||||
@QField(isRequired = true)
|
||||
private String label;
|
||||
|
||||
@QField(isEditable = false)
|
||||
private String tableName;
|
||||
@QField(possibleValueSourceName = QQQTable.TABLE_NAME)
|
||||
private Integer tableId;
|
||||
|
||||
@QField(isEditable = false)
|
||||
private String userId;
|
||||
@ -180,40 +181,6 @@ public class SavedFilter extends QRecordEntity
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for tableName
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getTableName()
|
||||
{
|
||||
return tableName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for tableName
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setTableName(String tableName)
|
||||
{
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for tableName
|
||||
**
|
||||
*******************************************************************************/
|
||||
public SavedFilter withTableName(String tableName)
|
||||
{
|
||||
this.tableName = tableName;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for userId
|
||||
**
|
||||
@ -280,4 +247,35 @@ public class SavedFilter extends QRecordEntity
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for tableId
|
||||
*******************************************************************************/
|
||||
public Integer getTableId()
|
||||
{
|
||||
return (this.tableId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for tableId
|
||||
*******************************************************************************/
|
||||
public void setTableId(Integer tableId)
|
||||
{
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for tableId
|
||||
*******************************************************************************/
|
||||
public SavedFilter withTableId(Integer tableId)
|
||||
{
|
||||
this.tableId = tableId;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QField;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.TablesPossibleValueSourceMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTable;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -52,8 +52,8 @@ public class Script extends QRecordEntity
|
||||
@QField(possibleValueSourceName = "scriptType")
|
||||
private Integer scriptTypeId;
|
||||
|
||||
@QField(possibleValueSourceName = TablesPossibleValueSourceMetaDataProvider.NAME)
|
||||
private String tableName;
|
||||
@QField(possibleValueSourceName = QQQTable.TABLE_NAME)
|
||||
private Integer tableId;
|
||||
|
||||
@QField()
|
||||
private Integer maxBatchSize;
|
||||
@ -288,37 +288,6 @@ public class Script extends QRecordEntity
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for tableName
|
||||
*******************************************************************************/
|
||||
public String getTableName()
|
||||
{
|
||||
return (this.tableName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for tableName
|
||||
*******************************************************************************/
|
||||
public void setTableName(String tableName)
|
||||
{
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for tableName
|
||||
*******************************************************************************/
|
||||
public Script withTableName(String tableName)
|
||||
{
|
||||
this.tableName = tableName;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for maxBatchSize
|
||||
*******************************************************************************/
|
||||
@ -348,4 +317,35 @@ public class Script extends QRecordEntity
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for tableId
|
||||
*******************************************************************************/
|
||||
public Integer getTableId()
|
||||
{
|
||||
return (this.tableId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for tableId
|
||||
*******************************************************************************/
|
||||
public void setTableId(Integer tableId)
|
||||
{
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for tableId
|
||||
*******************************************************************************/
|
||||
public Script withTableId(Integer tableId)
|
||||
{
|
||||
this.tableId = tableId;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwith
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.scripts.LoadScriptTestDetailsProcessStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.scripts.RunRecordScriptExtractStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.scripts.RunRecordScriptLoadStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.scripts.RunRecordScriptPreStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.scripts.RunRecordScriptTransformStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.scripts.StoreScriptRevisionProcessStep;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.scripts.TestScriptProcessStep;
|
||||
@ -96,7 +97,11 @@ public class ScriptsMetaDataProvider
|
||||
defineStandardScriptsPossibleValueSources(instance);
|
||||
defineStandardScriptsJoins(instance);
|
||||
defineStandardScriptsWidgets(instance);
|
||||
|
||||
// todo - change this from an enum-backed PVS to use qqqTable table, exposed in-app, in API
|
||||
// so api docs don't always need refreshed
|
||||
instance.addPossibleValueSource(TablesPossibleValueSourceMetaDataProvider.defineTablesPossibleValueSource(instance));
|
||||
|
||||
instance.addProcess(defineStoreScriptRevisionProcess());
|
||||
instance.addProcess(defineTestScriptProcess());
|
||||
instance.addProcess(defineLoadScriptTestDetailsProcess());
|
||||
@ -174,15 +179,25 @@ public class ScriptsMetaDataProvider
|
||||
.withLoadStepClass(RunRecordScriptLoadStep.class)
|
||||
.getProcessMetaData();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// add a screen before the extract step - where user selects their script //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
processMetaData.addStep(0, new QFrontendStepMetaData()
|
||||
.withName("input")
|
||||
.withComponent(new QFrontendComponentMetaData().withType(QComponentType.EDIT_FORM))
|
||||
.withFormField(new QFieldMetaData("scriptId", QFieldType.INTEGER).withPossibleValueSourceName(Script.TABLE_NAME)
|
||||
.withPossibleValueSourceFilter(new QQueryFilter(
|
||||
new QFilterCriteria("scriptType.name", QCriteriaOperator.EQUALS, SCRIPT_TYPE_NAME_RECORD),
|
||||
new QFilterCriteria("tableName", QCriteriaOperator.EQUALS, "${input.tableName}")
|
||||
new QFilterCriteria("tableId", QCriteriaOperator.EQUALS, "${input.tableId}")
|
||||
))));
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// now - insert a step before the input screen, where the table name gets read //
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
processMetaData.addStep(0, new QBackendStepMetaData()
|
||||
.withName("preStep")
|
||||
.withCode(new QCodeReference(RunRecordScriptPreStep.class)));
|
||||
|
||||
return (processMetaData);
|
||||
}
|
||||
|
||||
@ -383,16 +398,16 @@ public class ScriptsMetaDataProvider
|
||||
QTableMetaData tableMetaData = defineStandardTable(backendName, TableTrigger.TABLE_NAME, TableTrigger.class)
|
||||
.withRecordLabelFields("id")
|
||||
.withSection(new QFieldSection("identity", new QIcon().withName("badge"), Tier.T1, List.of("id")))
|
||||
.withSection(new QFieldSection("contents", new QIcon().withName("data_object"), Tier.T2, List.of("tableName", "filterId", "scriptId", "priority", "postInsert", "postUpdate")))
|
||||
.withSection(new QFieldSection("contents", new QIcon().withName("data_object"), Tier.T2, List.of("tableId", "filterId", "scriptId", "priority", "postInsert", "postUpdate")))
|
||||
.withSection(new QFieldSection("dates", new QIcon().withName("calendar_month"), Tier.T3, List.of("createDate", "modifyDate")));
|
||||
|
||||
tableMetaData.getField("scriptId").withPossibleValueSourceFilter(new QQueryFilter(
|
||||
new QFilterCriteria("scriptType.name", QCriteriaOperator.EQUALS, SCRIPT_TYPE_NAME_RECORD),
|
||||
new QFilterCriteria("script.tableName", QCriteriaOperator.EQUALS, "${input.tableName}")
|
||||
new QFilterCriteria("script.tableId", QCriteriaOperator.EQUALS, "${input.tableId}")
|
||||
));
|
||||
|
||||
tableMetaData.getField("filterId").withPossibleValueSourceFilter(new QQueryFilter(
|
||||
new QFilterCriteria("tableName", QCriteriaOperator.EQUALS, "${input.tableName}")
|
||||
new QFilterCriteria("tableId", QCriteriaOperator.EQUALS, "${input.tableId}")
|
||||
));
|
||||
|
||||
return tableMetaData;
|
||||
@ -407,7 +422,7 @@ public class ScriptsMetaDataProvider
|
||||
{
|
||||
QTableMetaData tableMetaData = defineStandardTable(backendName, Script.TABLE_NAME, Script.class)
|
||||
.withSection(new QFieldSection("identity", new QIcon().withName("badge"), Tier.T1, List.of("id", "name", "scriptTypeId", "currentScriptRevisionId")))
|
||||
.withSection(new QFieldSection("recordScriptSettings", new QIcon().withName("table_rows"), Tier.T2, List.of("tableName", "maxBatchSize")))
|
||||
.withSection(new QFieldSection("recordScriptSettings", new QIcon().withName("table_rows"), Tier.T2, List.of("tableId", "maxBatchSize")))
|
||||
.withSection(new QFieldSection("contents", new QIcon().withName("data_object"), Tier.T2).withWidgetName("scriptViewer"))
|
||||
.withSection(new QFieldSection("dates", new QIcon().withName("calendar_month"), Tier.T3, List.of("createDate", "modifyDate")))
|
||||
.withSection(new QFieldSection("lines", new QIcon().withName("horizontal_rule"), Tier.T2).withWidgetName(QJoinMetaData.makeInferredJoinName(Script.TABLE_NAME, ScriptLog.TABLE_NAME)));
|
||||
|
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* QQQ - Low-code Application Framework for Engineers.
|
||||
* Copyright (C) 2021-2023. Kingsrook, LLC
|
||||
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||
* contact@kingsrook.com
|
||||
* https://github.com/Kingsrook/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.kingsrook.qqq.backend.core.model.tables;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.GetAction;
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.utils.collections.MapBuilder;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** One-liner we can use to get a QQQTable record, or just its id (which we often want).
|
||||
** Will insert the record if it wasn't already there.
|
||||
** Also uses in-memory cache table, so rather cheap for normal use-case.
|
||||
*******************************************************************************/
|
||||
public class QQQTableAccessor
|
||||
{
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static QRecord getQQQTableRecord(String tableName) throws QException
|
||||
{
|
||||
/////////////////////////////
|
||||
// look in the cache table //
|
||||
/////////////////////////////
|
||||
GetInput getInput = new GetInput();
|
||||
getInput.setTableName(QQQTablesMetaDataProvider.QQQ_TABLE_CACHE_TABLE_NAME);
|
||||
getInput.setUniqueKey(MapBuilder.of("name", tableName));
|
||||
GetOutput getOutput = new GetAction().execute(getInput);
|
||||
|
||||
////////////////////////
|
||||
// upon cache miss... //
|
||||
////////////////////////
|
||||
if(getOutput.getRecord() == null)
|
||||
{
|
||||
///////////////////////////////////////////////////////
|
||||
// insert the record (into the table, not the cache) //
|
||||
///////////////////////////////////////////////////////
|
||||
QTableMetaData tableMetaData = QContext.getQInstance().getTable(tableName);
|
||||
InsertInput insertInput = new InsertInput();
|
||||
insertInput.setTableName(QQQTable.TABLE_NAME);
|
||||
insertInput.setRecords(List.of(new QRecord().withValue("name", tableName).withValue("label", tableMetaData.getLabel())));
|
||||
InsertOutput insertOutput = new InsertAction().execute(insertInput);
|
||||
|
||||
///////////////////////////////////
|
||||
// repeat the get from the cache //
|
||||
///////////////////////////////////
|
||||
getOutput = new GetAction().execute(getInput);
|
||||
}
|
||||
|
||||
return getOutput.getRecord();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static QRecord getQQQTableRecord(Integer id) throws QException
|
||||
{
|
||||
/////////////////////////////
|
||||
// look in the cache table //
|
||||
/////////////////////////////
|
||||
GetInput getInput = new GetInput();
|
||||
getInput.setTableName(QQQTablesMetaDataProvider.QQQ_TABLE_CACHE_TABLE_NAME);
|
||||
getInput.setPrimaryKey(id);
|
||||
GetOutput getOutput = new GetAction().execute(getInput);
|
||||
|
||||
////////////////////////
|
||||
// upon cache miss... //
|
||||
////////////////////////
|
||||
if(getOutput.getRecord() == null)
|
||||
{
|
||||
GetInput sourceGetInput = new GetInput();
|
||||
sourceGetInput.setTableName(QQQTable.TABLE_NAME);
|
||||
sourceGetInput.setPrimaryKey(id);
|
||||
GetOutput sourceGetOutput = new GetAction().execute(sourceGetInput);
|
||||
|
||||
///////////////////////////////////
|
||||
// repeat the get from the cache //
|
||||
///////////////////////////////////
|
||||
getOutput = new GetAction().execute(sourceGetInput);
|
||||
}
|
||||
|
||||
return getOutput.getRecord();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static Integer getTableId(String tableName) throws QException
|
||||
{
|
||||
return (getQQQTableRecord(tableName).getValueInteger("id"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static String getTableName(Integer id) throws QException
|
||||
{
|
||||
return (getQQQTableRecord(id).getValueString("name"));
|
||||
}
|
||||
|
||||
}
|
@ -50,9 +50,20 @@ public class QQQTablesMetaDataProvider
|
||||
*******************************************************************************/
|
||||
public void defineAll(QInstance instance, String persistentBackendName, String cacheBackendName, Consumer<QTableMetaData> backendDetailEnricher) throws QException
|
||||
{
|
||||
instance.addTable(defineQQQTable(persistentBackendName, backendDetailEnricher));
|
||||
instance.addTable(defineQQQTableCache(cacheBackendName, backendDetailEnricher));
|
||||
instance.addPossibleValueSource(defineQQQTablePossibleValueSource());
|
||||
if(instance.getTable(QQQTable.TABLE_NAME) == null)
|
||||
{
|
||||
instance.addTable(defineQQQTable(persistentBackendName, backendDetailEnricher));
|
||||
}
|
||||
|
||||
if(instance.getTable(QQQ_TABLE_CACHE_TABLE_NAME) == null)
|
||||
{
|
||||
instance.addTable(defineQQQTableCache(cacheBackendName, backendDetailEnricher));
|
||||
}
|
||||
|
||||
if(instance.getPossibleValueSource(QQQTable.TABLE_NAME) == null)
|
||||
{
|
||||
instance.addPossibleValueSource(defineQQQTablePossibleValueSource());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -127,6 +138,7 @@ public class QQQTablesMetaDataProvider
|
||||
return (new QPossibleValueSource()
|
||||
.withType(QPossibleValueSourceType.TABLE)
|
||||
.withName(QQQTable.TABLE_NAME)
|
||||
.withOrderByField("label")
|
||||
.withTableName(QQQTable.TABLE_NAME));
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QBackendStepMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.savedfilters.SavedFilter;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTableAccessor;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -100,7 +101,7 @@ public class QuerySavedFilterProcess implements BackendStep
|
||||
QueryInput input = new QueryInput();
|
||||
input.setTableName(SavedFilter.TABLE_NAME);
|
||||
input.setFilter(new QQueryFilter()
|
||||
.withCriteria(new QFilterCriteria("tableName", QCriteriaOperator.EQUALS, tableName))
|
||||
.withCriteria(new QFilterCriteria("tableId", QCriteriaOperator.EQUALS, QQQTableAccessor.getTableId(tableName)))
|
||||
.withOrderBy(new QFilterOrderBy("label")));
|
||||
|
||||
QueryOutput output = new QueryAction().execute(input);
|
||||
|
@ -42,6 +42,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QBackendStepMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.savedfilters.SavedFilter;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTableAccessor;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -82,7 +83,7 @@ public class StoreSavedFilterProcess implements BackendStep
|
||||
QRecord qRecord = new QRecord()
|
||||
.withValue("id", runBackendStepInput.getValueInteger("id"))
|
||||
.withValue("label", runBackendStepInput.getValueString("label"))
|
||||
.withValue("tableName", runBackendStepInput.getValueString("tableName"))
|
||||
.withValue("tableId", QQQTableAccessor.getTableId(runBackendStepInput.getValueString("tableName")))
|
||||
.withValue("filterJson", runBackendStepInput.getValueString("filterJson"))
|
||||
.withValue("userId", runBackendStepInput.getSession().getUser().getIdReference());
|
||||
|
||||
|
@ -30,6 +30,7 @@ import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
|
||||
import com.kingsrook.qqq.backend.core.model.scripts.Script;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTableAccessor;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.ExtractViaQueryStep;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
|
||||
@ -58,6 +59,11 @@ public class RunRecordScriptExtractStep extends ExtractViaQueryStep
|
||||
|
||||
runBackendStepInput.addValue(FIELD_SOURCE_TABLE, tableName);
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// set this value, for the select-script possible-value filter //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
runBackendStepInput.addValue("tableId", QQQTableAccessor.getTableId(tableName));
|
||||
|
||||
Integer scriptId = runBackendStepInput.getValueInteger("scriptId");
|
||||
GetInput getInput = new GetInput();
|
||||
getInput.setTableName(Script.TABLE_NAME);
|
||||
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* QQQ - Low-code Application Framework for Engineers.
|
||||
* Copyright (C) 2021-2023. Kingsrook, LLC
|
||||
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||
* contact@kingsrook.com
|
||||
* https://github.com/Kingsrook/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.kingsrook.qqq.backend.core.processes.implementations.scripts;
|
||||
|
||||
|
||||
import com.kingsrook.qqq.backend.core.actions.processes.BackendStep;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.processes.RunBackendStepInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.processes.RunBackendStepOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTableAccessor;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamed.StreamedETLProcess;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** pre-step for the run-record-script process. Help deal with this being
|
||||
** a generic process (e.g., no table name defined in the meta data).
|
||||
*******************************************************************************/
|
||||
public class RunRecordScriptPreStep implements BackendStep
|
||||
{
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Override
|
||||
public void run(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// this is a generic (e.g., not table-specific) process - so we must be sure to set the tableName field in the expected slot. //
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
String tableName = runBackendStepInput.getValueString("tableName");
|
||||
if(!StringUtils.hasContent(tableName))
|
||||
{
|
||||
throw (new QException("Table name was not specified as input value"));
|
||||
}
|
||||
|
||||
runBackendStepInput.addValue(StreamedETLProcess.FIELD_SOURCE_TABLE, tableName);
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// set this value, for the select-script possible-value filter //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
runBackendStepInput.addValue("tableId", QQQTableAccessor.getTableId(tableName));
|
||||
}
|
||||
|
||||
}
|
@ -36,6 +36,7 @@ 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.session.QSession;
|
||||
import com.kingsrook.qqq.backend.core.model.session.QUser;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTablesMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.processes.utils.GeneralProcessUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.TestUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -59,6 +60,7 @@ class AuditActionTest extends BaseTest
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
new AuditsMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
new QQQTablesMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
|
||||
String userName = "John Doe";
|
||||
QContext.init(qInstance, new QSession().withUser(new QUser().withFullName(userName)));
|
||||
@ -69,7 +71,6 @@ class AuditActionTest extends BaseTest
|
||||
/////////////////////////////////////
|
||||
// make sure things can be fetched //
|
||||
/////////////////////////////////////
|
||||
GeneralProcessUtils.getRecordByFieldOrElseThrow("auditTable", "name", TestUtils.TABLE_NAME_PERSON_MEMORY);
|
||||
GeneralProcessUtils.getRecordByFieldOrElseThrow("auditUser", "name", userName);
|
||||
QRecord auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow("audit", "recordId", recordId);
|
||||
assertEquals("Test Audit", auditRecord.getValueString("message"));
|
||||
@ -85,6 +86,7 @@ class AuditActionTest extends BaseTest
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
new AuditsMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
new QQQTablesMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
|
||||
String userName = "John Doe";
|
||||
QContext.init(qInstance, new QSession().withUser(new QUser().withFullName(userName)));
|
||||
@ -123,6 +125,7 @@ class AuditActionTest extends BaseTest
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
new AuditsMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
new QQQTablesMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
|
||||
String userName = "John Doe";
|
||||
QContext.init(qInstance, new QSession().withUser(new QUser().withFullName(userName)));
|
||||
@ -137,7 +140,6 @@ class AuditActionTest extends BaseTest
|
||||
/////////////////////////////////////
|
||||
// make sure things can be fetched //
|
||||
/////////////////////////////////////
|
||||
GeneralProcessUtils.getRecordByFieldOrElseThrow("auditTable", "name", TestUtils.TABLE_NAME_PERSON_MEMORY);
|
||||
GeneralProcessUtils.getRecordByFieldOrElseThrow("auditUser", "name", userName);
|
||||
QRecord auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow("audit", "recordId", recordId1);
|
||||
assertEquals("Test Audit", auditRecord.getValueString("message"));
|
||||
@ -157,6 +159,7 @@ class AuditActionTest extends BaseTest
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
new AuditsMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
new QQQTablesMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
|
||||
String userName = "John Doe";
|
||||
QContext.init(qInstance, new QSession().withUser(new QUser().withFullName(userName)));
|
||||
@ -173,7 +176,6 @@ class AuditActionTest extends BaseTest
|
||||
/////////////////////////////////////
|
||||
// make sure things can be fetched //
|
||||
/////////////////////////////////////
|
||||
GeneralProcessUtils.getRecordByFieldOrElseThrow("auditTable", "name", TestUtils.TABLE_NAME_PERSON_MEMORY);
|
||||
GeneralProcessUtils.getRecordByFieldOrElseThrow("auditUser", "name", userName);
|
||||
QRecord auditRecord = GeneralProcessUtils.getRecordByFieldOrElseThrow("audit", "recordId", recordId1);
|
||||
assertEquals("Test Audit", auditRecord.getValueString("message"));
|
||||
|
@ -37,6 +37,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.audits.AuditLevel;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.audits.QAuditRules;
|
||||
import com.kingsrook.qqq.backend.core.model.statusmessages.BadInputStatusMessage;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTablesMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.modules.backend.implementations.memory.MemoryRecordStore;
|
||||
import com.kingsrook.qqq.backend.core.utils.TestUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -60,6 +61,7 @@ class DMLAuditActionTest extends BaseTest
|
||||
{
|
||||
QInstance qInstance = QContext.getQInstance();
|
||||
new AuditsMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
new QQQTablesMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
|
||||
UpdateInput updateInput = new UpdateInput();
|
||||
updateInput.setTableName(TestUtils.TABLE_NAME_PERSON_MEMORY);
|
||||
|
@ -49,6 +49,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.statusmessages.BadInputStatusMessage;
|
||||
import com.kingsrook.qqq.backend.core.model.statusmessages.QWarningMessage;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTablesMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.utils.TestUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.collections.ListBuilder;
|
||||
import com.kingsrook.qqq.backend.core.utils.collections.MapBuilder;
|
||||
@ -124,6 +125,7 @@ class DeleteActionTest extends BaseTest
|
||||
new InsertAction().execute(insertInput);
|
||||
|
||||
new AuditsMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
new QQQTablesMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
qInstance.getTable(TestUtils.TABLE_NAME_PERSON_MEMORY).setAuditRules(new QAuditRules().withAuditLevel(AuditLevel.RECORD));
|
||||
|
||||
DeleteInput deleteInput = new DeleteInput();
|
||||
@ -154,6 +156,7 @@ class DeleteActionTest extends BaseTest
|
||||
new InsertAction().execute(insertInput);
|
||||
|
||||
new AuditsMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
new QQQTablesMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
qInstance.getTable(TestUtils.TABLE_NAME_PERSON_MEMORY).setAuditRules(new QAuditRules().withAuditLevel(AuditLevel.RECORD));
|
||||
|
||||
DeleteInput deleteInput = new DeleteInput();
|
||||
|
@ -35,6 +35,7 @@ import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
|
||||
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.savedfilters.SavedFiltersMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTablesMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.utils.JsonUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.TestUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -56,6 +57,8 @@ class SavedFilterProcessTests extends BaseTest
|
||||
{
|
||||
QInstance qInstance = QContext.getQInstance();
|
||||
new SavedFiltersMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
new QQQTablesMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
|
||||
String tableName = TestUtils.TABLE_NAME_PERSON_MEMORY;
|
||||
|
||||
{
|
||||
|
@ -35,6 +35,7 @@ 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.scripts.Script;
|
||||
import com.kingsrook.qqq.backend.core.model.scripts.ScriptsMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTablesMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.utils.TestUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.collections.MapBuilder;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -55,6 +56,7 @@ class RunRecordScriptTest extends BaseTest
|
||||
{
|
||||
QInstance qInstance = QContext.getQInstance();
|
||||
new ScriptsMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
new QQQTablesMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
|
||||
TestUtils.insertRecords(qInstance, qInstance.getTable(TestUtils.TABLE_NAME_PERSON_MEMORY), List.of(new QRecord().withValue("id", 1)));
|
||||
TestUtils.insertRecords(qInstance, qInstance.getTable(Script.TABLE_NAME), List.of(new QRecord().withValue("id", 1).withTableName(TestUtils.TABLE_NAME_PERSON_MEMORY)));
|
||||
|
@ -37,6 +37,8 @@ import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||
import com.kingsrook.qqq.backend.core.model.scripts.Script;
|
||||
import com.kingsrook.qqq.backend.core.model.scripts.ScriptType;
|
||||
import com.kingsrook.qqq.backend.core.model.scripts.ScriptsMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTableAccessor;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTablesMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.utils.TestUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ -58,6 +60,8 @@ class TestScriptProcessStepTest extends BaseTest
|
||||
{
|
||||
QInstance qInstance = QContext.getQInstance();
|
||||
new ScriptsMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
new QQQTablesMetaDataProvider().defineAll(qInstance, TestUtils.MEMORY_BACKEND_NAME, TestUtils.MEMORY_BACKEND_NAME, null);
|
||||
|
||||
InsertInput insertInput = new InsertInput();
|
||||
insertInput.setTableName(ScriptType.TABLE_NAME);
|
||||
insertInput.setRecords(List.of(new ScriptType()
|
||||
@ -71,7 +75,7 @@ class TestScriptProcessStepTest extends BaseTest
|
||||
insertInput.setRecords(List.of(new Script()
|
||||
.withName("TestScript")
|
||||
.withScriptTypeId(insertOutput.getRecords().get(0).getValueInteger("id"))
|
||||
.withTableName(TestUtils.TABLE_NAME_SHAPE)
|
||||
.withTableId(QQQTableAccessor.getTableId(TestUtils.TABLE_NAME_SHAPE))
|
||||
.toQRecord()));
|
||||
insertOutput = new InsertAction().execute(insertInput);
|
||||
|
||||
@ -89,7 +93,10 @@ class TestScriptProcessStepTest extends BaseTest
|
||||
// expect an error because the javascript module isn't available //
|
||||
//////////////////////////////////////////////////////////////////
|
||||
assertNotNull(output.getValue("exception"));
|
||||
assertThat((Exception) output.getValue("exception")).hasRootCauseInstanceOf(ClassNotFoundException.class);
|
||||
assertThat((Exception) output.getValue("exception"))
|
||||
.hasRootCauseInstanceOf(ClassNotFoundException.class)
|
||||
.rootCause()
|
||||
.hasMessageContaining("QJavaScriptExecutor");
|
||||
}
|
||||
|
||||
}
|
@ -26,7 +26,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QInstanceValidationException;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.processes.ProcessSummaryLine;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.processes.RunProcessOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.processes.Status;
|
||||
@ -52,7 +52,7 @@ class QJavalinAccessLoggerTest
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testDefaultOn() throws QInstanceValidationException
|
||||
void testDefaultOn() throws QException
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
new QJavalinImplementation(qInstance, new QJavalinMetaData());
|
||||
@ -74,7 +74,7 @@ class QJavalinAccessLoggerTest
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testTurnedOffByCode() throws QInstanceValidationException
|
||||
void testTurnedOffByCode() throws QException
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
new QJavalinImplementation(qInstance, new QJavalinMetaData()
|
||||
@ -97,7 +97,7 @@ class QJavalinAccessLoggerTest
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testTurnedOffBySystemPropertyWithJavalinMetaData() throws QInstanceValidationException
|
||||
void testTurnedOffBySystemPropertyWithJavalinMetaData() throws QException
|
||||
{
|
||||
System.setProperty(DISABLED_PROPERTY, "true");
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
@ -114,7 +114,7 @@ class QJavalinAccessLoggerTest
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testTurnedOffBySystemPropertyWithoutJavalinMetaData() throws QInstanceValidationException
|
||||
void testTurnedOffBySystemPropertyWithoutJavalinMetaData() throws QException
|
||||
{
|
||||
System.setProperty(DISABLED_PROPERTY, "true");
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
@ -131,7 +131,7 @@ class QJavalinAccessLoggerTest
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testFilter() throws QInstanceValidationException
|
||||
void testFilter() throws QException
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
new QJavalinImplementation(qInstance, new QJavalinMetaData()
|
||||
|
@ -27,7 +27,7 @@ import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QInstanceValidationException;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
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.authentication.TableBasedAuthenticationMetaData;
|
||||
@ -61,7 +61,7 @@ public class QJavalinImplementationAuthenticationTest extends QJavalinTestBase
|
||||
**
|
||||
*******************************************************************************/
|
||||
@BeforeEach
|
||||
public void beforeEach() throws QInstanceValidationException
|
||||
public void beforeEach() throws QException
|
||||
{
|
||||
Unirest.config().reset().enableCookieManagement(false);
|
||||
setupTableBasedAuthenticationInstance();
|
||||
@ -188,7 +188,7 @@ public class QJavalinImplementationAuthenticationTest extends QJavalinTestBase
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void setupTableBasedAuthenticationInstance() throws QInstanceValidationException
|
||||
static void setupTableBasedAuthenticationInstance() throws QException
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
TableBasedAuthenticationMetaData tableBasedAuthenticationMetaData = new TableBasedAuthenticationMetaData();
|
||||
|
@ -22,6 +22,7 @@
|
||||
package com.kingsrook.qqq.backend.javalin;
|
||||
|
||||
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QInstanceValidationException;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||
import com.kingsrook.qqq.backend.core.modules.backend.implementations.memory.MemoryRecordStore;
|
||||
@ -60,7 +61,7 @@ public class QJavalinTestBase
|
||||
**
|
||||
*******************************************************************************/
|
||||
@BeforeAll
|
||||
public static void beforeAll() throws QInstanceValidationException
|
||||
public static void beforeAll() throws QException
|
||||
{
|
||||
qJavalinImplementation = new QJavalinImplementation(TestUtils.defineInstance());
|
||||
QJavalinProcessHandler.setAsyncStepTimeoutMillis(250);
|
||||
|
@ -68,6 +68,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.tables.AssociatedScript;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.savedfilters.SavedFiltersMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.model.scripts.ScriptsMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.model.tables.QQQTablesMetaDataProvider;
|
||||
import com.kingsrook.qqq.backend.core.processes.implementations.mock.MockBackendStep;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.jdbc.QueryManager;
|
||||
@ -138,7 +139,7 @@ public class TestUtils
|
||||
** Define the q-instance for testing (h2 rdbms and 'person' table)
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static QInstance defineInstance()
|
||||
public static QInstance defineInstance() throws QException
|
||||
{
|
||||
QInstance qInstance = new QInstance();
|
||||
qInstance.setAuthentication(defineAuthentication());
|
||||
@ -154,6 +155,8 @@ public class TestUtils
|
||||
qInstance.addPossibleValueSource(definePossibleValueSourcePerson());
|
||||
defineWidgets(qInstance);
|
||||
|
||||
new QQQTablesMetaDataProvider().defineAll(qInstance, BACKEND_NAME_MEMORY, BACKEND_NAME_MEMORY, null);
|
||||
|
||||
qInstance.addBackend(defineMemoryBackend());
|
||||
try
|
||||
{
|
||||
|
Reference in New Issue
Block a user