misc fixes

This commit is contained in:
2023-03-31 16:30:56 -05:00
parent 6fbfbe9db2
commit f79bf85c14
4 changed files with 28 additions and 24 deletions

View File

@ -183,21 +183,14 @@ public class DeleteAction
if(CollectionUtils.nullSafeHasContents(primaryKeyList)) if(CollectionUtils.nullSafeHasContents(primaryKeyList))
{ {
if(CollectionUtils.nullSafeHasContents(deleteInput.getTable().getRecordSecurityLocks())) ////////////////////////////////////////////////////////////////////////////////////
{ // always fetch the records - we'll use them anyway for checking not-exist below //
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
// if the table has any security locks, then we need full entities (to record the keys), not just ids // QueryInput queryInput = new QueryInput();
//////////////////////////////////////////////////////////////////////////////////////////////////////// queryInput.setTableName(deleteInput.getTableName());
QueryInput queryInput = new QueryInput(); queryInput.setFilter(new QQueryFilter(new QFilterCriteria(deleteInput.getTable().getPrimaryKeyField(), QCriteriaOperator.IN, primaryKeyList)));
queryInput.setTableName(deleteInput.getTableName()); QueryOutput queryOutput = new QueryAction().execute(queryInput);
queryInput.setFilter(new QQueryFilter(new QFilterCriteria(deleteInput.getTable().getPrimaryKeyField(), QCriteriaOperator.IN, primaryKeyList))); recordListForAudit = queryOutput.getRecords();
QueryOutput queryOutput = new QueryAction().execute(queryInput);
recordListForAudit = queryOutput.getRecords();
}
else
{
recordListForAudit = primaryKeyList.stream().map(pk -> new QRecord().withValue(deleteInput.getTable().getPrimaryKeyField(), pk)).toList();
}
} }
} }
@ -241,7 +234,9 @@ public class DeleteAction
{ {
for(QRecord record : oldRecordList) for(QRecord record : oldRecordList)
{ {
lookedUpRecords.put(record.getValue(table.getPrimaryKeyField()), record); Serializable primaryKeyValue = record.getValue(table.getPrimaryKeyField());
primaryKeyValue = ValueUtils.getValueAsFieldType(primaryKeyField.getType(), primaryKeyValue);
lookedUpRecords.put(primaryKeyValue, record);
} }
} }
else if(!primaryKeysToLookup.isEmpty()) else if(!primaryKeysToLookup.isEmpty())

View File

@ -81,6 +81,11 @@ public class InsertAction extends AbstractQActionFunction<InsertInput, InsertOut
ActionHelper.validateSession(insertInput); ActionHelper.validateSession(insertInput);
QTableMetaData table = insertInput.getTable(); QTableMetaData table = insertInput.getTable();
if(table == null)
{
throw (new QException("Error: Undefined table: " + insertInput.getTableName()));
}
Optional<AbstractPostInsertCustomizer> postInsertCustomizer = QCodeLoader.getTableCustomizer(AbstractPostInsertCustomizer.class, table, TableCustomizers.POST_INSERT_RECORD.getRole()); Optional<AbstractPostInsertCustomizer> postInsertCustomizer = QCodeLoader.getTableCustomizer(AbstractPostInsertCustomizer.class, table, TableCustomizers.POST_INSERT_RECORD.getRole());
setAutomationStatusField(insertInput); setAutomationStatusField(insertInput);

View File

@ -24,6 +24,7 @@ package com.kingsrook.qqq.backend.core.model.metadata.tables;
import java.util.List; import java.util.List;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QIcon; import com.kingsrook.qqq.backend.core.model.metadata.layout.QIcon;
import com.kingsrook.qqq.backend.core.utils.collections.MutableList;
/******************************************************************************* /*******************************************************************************
@ -63,7 +64,7 @@ public class QFieldSection
this.label = label; this.label = label;
this.icon = icon; this.icon = icon;
this.tier = tier; this.tier = tier;
this.fieldNames = fieldNames; this.fieldNames = new MutableList<>(fieldNames);
} }
@ -76,7 +77,7 @@ public class QFieldSection
this.name = name; this.name = name;
this.icon = icon; this.icon = icon;
this.tier = tier; this.tier = tier;
this.fieldNames = fieldNames; this.fieldNames = new MutableList<>(fieldNames);
} }

View File

@ -650,12 +650,15 @@ public class QJavalinApiHandler
{ {
try try
{ {
InsertInput insertInput = new InsertInput(); if(QContext.getQInstance().getTable(APILog.TABLE_NAME) != null)
insertInput.setTableName(APILog.TABLE_NAME); {
// todo - security fields!!!!! InsertInput insertInput = new InsertInput();
// todo - user!!!! insertInput.setTableName(APILog.TABLE_NAME);
insertInput.setRecords(List.of(apiLog.toQRecord())); // todo - security fields!!!!!
new InsertAction().executeAsync(insertInput); // todo - user!!!!
insertInput.setRecords(List.of(apiLog.toQRecord()));
new InsertAction().executeAsync(insertInput);
}
} }
catch(Exception e) catch(Exception e)
{ {