Merge branch 'feature/CTLE-421-migrate-to-use-api-keys' into integration/sprint-25

This commit is contained in:
Tim Chamberlain
2023-05-02 11:32:27 -05:00
7 changed files with 163 additions and 7 deletions

View File

@ -34,6 +34,7 @@ import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertOutput;
import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateInput;
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.CollectionUtils;
/*******************************************************************************
@ -120,6 +121,11 @@ public abstract class ChildInserterPostInsertCustomizer extends AbstractPostInse
InsertOutput insertOutput = new InsertAction().execute(insertInput);
Iterator<QRecord> insertedRecordIterator = insertOutput.getRecords().iterator();
/////////////////////////////////////////////////////////////////////////////////
// check for any errors when inserting the children, if any errors were found, //
// then set a warning in the parent with the details of the problem //
/////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
// iterate over the original list of records again - for any that need a child (e.g., are missing //
// foreign key), set their foreign key to a newly inserted child's key, and add them to be updated. //
@ -130,7 +136,21 @@ public abstract class ChildInserterPostInsertCustomizer extends AbstractPostInse
Serializable primaryKey = record.getValue(table.getPrimaryKeyField());
if(record.getValue(getForeignKeyFieldName()) == null)
{
Serializable foreignKey = insertedRecordIterator.next().getValue(childTable.getPrimaryKeyField());
///////////////////////////////////////////////////////////////////////////////////////////////////
// get the corresponding child record, if it has any errors, set that as a warning in the parent //
///////////////////////////////////////////////////////////////////////////////////////////////////
QRecord childRecord = insertedRecordIterator.next();
if(CollectionUtils.nullSafeHasContents(childRecord.getErrors()))
{
for(String childWarning : childRecord.getErrors())
{
record.addWarning("Error creating child " + childTable.getLabel() + " (" + childWarning + ")");
}
rs.add(record);
continue;
}
Serializable foreignKey = childRecord.getValue(childTable.getPrimaryKeyField());
recordsToUpdate.add(new QRecord().withValue(table.getPrimaryKeyField(), primaryKey).withValue(getForeignKeyFieldName(), foreignKey));
record.setValue(getForeignKeyFieldName(), foreignKey);
rs.add(record);

View File

@ -53,7 +53,6 @@ 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.data.QRecord;
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.metadata.tables.cache.CacheUseCase;
import com.kingsrook.qqq.backend.core.modules.backend.QBackendModuleDispatcher;
@ -380,8 +379,12 @@ public class GetAction
Map<String, QFieldMetaData> fields = QContext.getQInstance().getTable(getInput.getTableName()).getFields();
for(String fieldName : fields.keySet())
{
QFieldType fieldType = fields.get(fieldName).getType();
if(fieldType != null && fieldType.needsMasked())
QFieldMetaData field = fields.get(fieldName);
if(getInput.getShouldOmitHiddenFields() && field.getIsHidden())
{
returnRecord.removeValue(fieldName);
}
else if(field.getType() != null && field.getType().needsMasked())
{
//////////////////////////////////////////////////////////////////////
// empty out the value completely first (which will remove from //
@ -395,7 +398,6 @@ public class GetAction
}
}
}
QValueFormatter.setDisplayValuesInRecords(getInput.getTable(), List.of(returnRecord));
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -65,6 +65,7 @@ public class QRecord implements Serializable
private Map<String, String> displayValues = new LinkedHashMap<>();
private Map<String, Serializable> backendDetails = new LinkedHashMap<>();
private List<String> errors = new ArrayList<>();
private List<String> warnings = new ArrayList<>();
private Map<String, List<QRecord>> associatedRecords = new HashMap<>();
@ -652,4 +653,46 @@ public class QRecord implements Serializable
return (this);
}
/*******************************************************************************
** Getter for warnings
*******************************************************************************/
public List<String> getWarnings()
{
return (this.warnings);
}
/*******************************************************************************
** Setter for warnings
*******************************************************************************/
public void setWarnings(List<String> warnings)
{
this.warnings = warnings;
}
/*******************************************************************************
** Fluent setter for warnings
*******************************************************************************/
public QRecord withWarnings(List<String> warnings)
{
this.warnings = warnings;
return (this);
}
/*******************************************************************************
** Add one warning to this record
**
*******************************************************************************/
public void addWarning(String warning)
{
this.warnings.add(warning);
}
}

View File

@ -39,6 +39,7 @@ public enum AdornmentType
SIZE,
CODE_EDITOR,
RENDER_HTML,
REVEAL,
ERROR;
//////////////////////////////////////////////////////////////////////////
// keep these values in sync with AdornmentType.ts in qqq-frontend-core //

View File

@ -151,7 +151,7 @@ public class Auth0AuthenticationModule implements QAuthenticationModuleInterface
///////////////////////////////////////////////////////////
if(context.containsKey(BASIC_AUTH_KEY))
{
AuthAPI auth = new AuthAPI(metaData.getBaseUrl(), metaData.getClientId(), metaData.getClientSecret());
AuthAPI auth = AuthAPI.newBuilder(metaData.getBaseUrl(), metaData.getClientId(), metaData.getClientSecret()).build();
try
{
/////////////////////////////////////////////////