Add overload of loadTableToMap that takes Consumer<QueryInput> (e.g., to request heavy fields)

This commit is contained in:
2023-06-01 16:32:34 -05:00
parent b67813b7ad
commit 499d59ade2

View File

@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import com.kingsrook.qqq.backend.core.actions.tables.CountAction;
import com.kingsrook.qqq.backend.core.actions.tables.GetAction;
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
@ -394,9 +395,25 @@ public class GeneralProcessUtils
** 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
{
return (loadTableToMap(tableName, keyFieldName, entityClass, null));
}
/*******************************************************************************
** Note - null values from the key field are NOT put in the map.
*******************************************************************************/
public static <T extends QRecordEntity> Map<Serializable, T> loadTableToMap(String tableName, String keyFieldName, Class<T> entityClass, Consumer<QueryInput> queryInputCustomizer) throws QException
{
QueryInput queryInput = new QueryInput();
queryInput.setTableName(tableName);
if(queryInputCustomizer != null)
{
queryInputCustomizer.accept(queryInput);
}
QueryOutput queryOutput = new QueryAction().execute(queryInput);
List<QRecord> records = queryOutput.getRecords();