Add "convenience wrappers"

This commit is contained in:
2024-05-31 11:16:07 -05:00
parent e1a63752ca
commit 7c6c02ab28
2 changed files with 54 additions and 11 deletions

View File

@ -65,16 +65,6 @@ public class GetAction
/*******************************************************************************
**
*******************************************************************************/
public QRecord executeForRecord(GetInput getInput) throws QException
{
return (execute(getInput).getRecord());
}
/*******************************************************************************
**
*******************************************************************************/
@ -140,6 +130,43 @@ public class GetAction
/*******************************************************************************
** shorthand way to call for the most common use-case, when you just want the
** output record to be returned.
*******************************************************************************/
public QRecord executeForRecord(GetInput getInput) throws QException
{
return (execute(getInput).getRecord());
}
/*******************************************************************************
** more shorthand way to call for the most common use-case, when you just want the
** output record to be returned, and you just want to pass in a table name and primary key.
*******************************************************************************/
public static QRecord execute(String tableName, Serializable primaryKey) throws QException
{
GetAction getAction = new GetAction();
GetInput getInput = new GetInput(tableName).withPrimaryKey(primaryKey);
return getAction.executeForRecord(getInput);
}
/*******************************************************************************
** more shorthand way to call for the most common use-case, when you just want the
** output record to be returned, and you just want to pass in a table name and unique key
*******************************************************************************/
public static QRecord execute(String tableName, Map<String, Serializable> uniqueKey) throws QException
{
GetAction getAction = new GetAction();
GetInput getInput = new GetInput(tableName).withUniqueKey(uniqueKey);
return getAction.executeForRecord(getInput);
}
/*******************************************************************************
** Run a GetAction by using the QueryAction instead (e.g., with a filter made
** from the pkey/ukey, and returning the single record if found).

View File

@ -151,6 +151,22 @@ public class QueryAction
/*******************************************************************************
** shorthand way to call for the most common use-case, when you just want the
** records to be returned, and you just want to pass in a table name and filter.
*******************************************************************************/
public static List<QRecord> execute(String tableName, QQueryFilter filter) throws QException
{
QueryAction queryAction = new QueryAction();
QueryInput queryInput = new QueryInput();
queryInput.setTableName(tableName);
queryInput.setFilter(filter);
QueryOutput queryOutput = queryAction.execute(queryInput);
return (queryOutput.getRecords());
}
/*******************************************************************************
**
*******************************************************************************/