QQQ-28 small cleanups

This commit is contained in:
2022-07-25 11:35:52 -05:00
parent 3ac8642693
commit c4240815e4
2 changed files with 19 additions and 1 deletions

View File

@ -26,6 +26,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.kingsrook.qqq.backend.core.actions.ActionHelper;
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
import com.kingsrook.qqq.backend.core.exceptions.QException;
@ -107,6 +108,7 @@ public class RunBackendStepAction
}
List<QFieldMetaData> fieldsToGet = new ArrayList<>();
List<QFieldMetaData> requiredFieldsMissing = new ArrayList<>();
for(QFieldMetaData field : inputMetaData.getFieldList())
{
Serializable value = runBackendStepInput.getValue(field.getName());
@ -118,8 +120,11 @@ public class RunBackendStepAction
}
else
{
// todo - check if required?
fieldsToGet.add(field);
if(field.getIsRequired())
{
requiredFieldsMissing.add(field);
}
}
}
}
@ -129,6 +134,18 @@ public class RunBackendStepAction
QProcessCallback callback = runBackendStepInput.getCallback();
if(callback == null)
{
if(requiredFieldsMissing.isEmpty())
{
///////////////////////////////////////////////////////////////
// if no required fields are missing, just return gracefully //
///////////////////////////////////////////////////////////////
return;
}
///////////////////////////////////////////////////////////////////
// but if any required fields ARE missing, then that's an error. //
///////////////////////////////////////////////////////////////////
LOG.info("Missing value for required fields: " + requiredFieldsMissing.stream().map(QFieldMetaData::getName).collect(Collectors.joining(", ")));
throw (new QUserFacingException("Missing values for one or more fields",
new QException("Function is missing values for fields, but no callback was present to request fields from a user")));
}

View File

@ -55,6 +55,7 @@ public class LoadInitialRecordsStep implements BackendStep
// but, while we're here, go ahead and put the query filter in the payload as a value, in case //
// someone else wants it (see BulkDelete) //
/////////////////////////////////////////////////////////////////////////////////////////////////
runBackendStepInput.getAsyncJobCallback().updateStatus("Loading records");
QQueryFilter queryFilter = runBackendStepInput.getCallback().getQueryFilter();
runBackendStepOutput.addValue("queryFilterJSON", JsonUtils.toJson(queryFilter));
}