Introduce QueryOrCountInputInterface

This commit is contained in:
2025-05-27 11:33:45 -05:00
parent 4b9e8e0c51
commit 2a76736474
4 changed files with 123 additions and 3 deletions

View File

@ -41,6 +41,7 @@ import com.kingsrook.qqq.backend.core.actions.tables.UpdateAction;
import com.kingsrook.qqq.backend.core.context.QContext; import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QException; import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.logging.QLogger; import com.kingsrook.qqq.backend.core.logging.QLogger;
import com.kingsrook.qqq.backend.core.model.actions.tables.QueryOrGetInputInterface;
import com.kingsrook.qqq.backend.core.model.actions.tables.delete.DeleteInput; import com.kingsrook.qqq.backend.core.model.actions.tables.delete.DeleteInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetInput; import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetOutput; import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetOutput;
@ -569,7 +570,7 @@ public class QueryActionCacheHelper
QQueryFilter filter = new QQueryFilter().withBooleanOperator(QQueryFilter.BooleanOperator.OR); QQueryFilter filter = new QQueryFilter().withBooleanOperator(QQueryFilter.BooleanOperator.OR);
sourceQueryInput.setFilter(filter); sourceQueryInput.setFilter(filter);
sourceQueryInput.setCommonParamsFrom(cacheQueryInput); ((QueryOrGetInputInterface) sourceQueryInput).setCommonParamsFrom(cacheQueryInput);
for(List<Serializable> uniqueKeyValue : uniqueKeyValues) for(List<Serializable> uniqueKeyValue : uniqueKeyValues)
{ {

View File

@ -0,0 +1,117 @@
/*
* QQQ - Low-code Application Framework for Engineers.
* Copyright (C) 2021-2023. Kingsrook, LLC
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
* contact@kingsrook.com
* https://github.com/Kingsrook/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.kingsrook.qqq.backend.core.model.actions.tables;
import java.util.EnumSet;
import java.util.List;
import com.kingsrook.qqq.backend.core.actions.QBackendTransaction;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryJoin;
/*******************************************************************************
** Common getters & setters, shared by both QueryInput and CountInput.
**
** Original impetus for this class is the setCommonParamsFrom() method - for cases
** where we need to change a Query to a Get, or vice-versa, and we want to copy over
** all of those input params.
*******************************************************************************/
public interface QueryOrCountInputInterface
{
/*******************************************************************************
** Set in THIS, the "common params" (e.g., common to both Query & Count inputs)
** from the parameter SOURCE object.
*******************************************************************************/
default void setCommonParamsFrom(QueryOrCountInputInterface source)
{
this.setTransaction(source.getTransaction());
this.setFilter(source.getFilter());
this.setTableName(source.getTableName());
this.setQueryJoins(source.getQueryJoins());
this.setTimeoutSeconds(source.getTimeoutSeconds());
this.setQueryHints(source.getQueryHints());
}
/*******************************************************************************
**
*******************************************************************************/
String getTableName();
/***************************************************************************
**
***************************************************************************/
void setTableName(String tableName);
/*******************************************************************************
**
*******************************************************************************/
QQueryFilter getFilter();
/***************************************************************************
**
***************************************************************************/
void setFilter(QQueryFilter filter);
/*******************************************************************************
** Getter for transaction
*******************************************************************************/
QBackendTransaction getTransaction();
/*******************************************************************************
** Setter for transaction
*******************************************************************************/
void setTransaction(QBackendTransaction transaction);
/*******************************************************************************
** Getter for queryJoins
*******************************************************************************/
List<QueryJoin> getQueryJoins();
/*******************************************************************************
** Setter for queryJoins
**
*******************************************************************************/
void setQueryJoins(List<QueryJoin> queryJoins);
/*******************************************************************************
**
*******************************************************************************/
Integer getTimeoutSeconds();
/***************************************************************************
**
***************************************************************************/
void setTimeoutSeconds(Integer timeoutSeconds);
/*******************************************************************************
** Getter for queryHints
*******************************************************************************/
EnumSet<QueryHint> getQueryHints();
/*******************************************************************************
** Setter for queryHints
*******************************************************************************/
void setQueryHints(EnumSet<QueryHint> queryHints);
}

View File

@ -28,6 +28,7 @@ import java.util.List;
import com.kingsrook.qqq.backend.core.actions.QBackendTransaction; import com.kingsrook.qqq.backend.core.actions.QBackendTransaction;
import com.kingsrook.qqq.backend.core.model.actions.AbstractTableActionInput; import com.kingsrook.qqq.backend.core.model.actions.AbstractTableActionInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.QueryHint; import com.kingsrook.qqq.backend.core.model.actions.tables.QueryHint;
import com.kingsrook.qqq.backend.core.model.actions.tables.QueryOrCountInputInterface;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter; import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryJoin; import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryJoin;
@ -36,7 +37,7 @@ import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryJoin;
** Input data for the Count action ** Input data for the Count action
** **
*******************************************************************************/ *******************************************************************************/
public class CountInput extends AbstractTableActionInput public class CountInput extends AbstractTableActionInput implements QueryOrCountInputInterface
{ {
private QBackendTransaction transaction; private QBackendTransaction transaction;
private QQueryFilter filter; private QQueryFilter filter;

View File

@ -32,6 +32,7 @@ import com.kingsrook.qqq.backend.core.actions.QBackendTransaction;
import com.kingsrook.qqq.backend.core.actions.reporting.RecordPipe; import com.kingsrook.qqq.backend.core.actions.reporting.RecordPipe;
import com.kingsrook.qqq.backend.core.model.actions.AbstractTableActionInput; import com.kingsrook.qqq.backend.core.model.actions.AbstractTableActionInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.QueryHint; import com.kingsrook.qqq.backend.core.model.actions.tables.QueryHint;
import com.kingsrook.qqq.backend.core.model.actions.tables.QueryOrCountInputInterface;
import com.kingsrook.qqq.backend.core.model.actions.tables.QueryOrGetInputInterface; import com.kingsrook.qqq.backend.core.model.actions.tables.QueryOrGetInputInterface;
@ -42,7 +43,7 @@ import com.kingsrook.qqq.backend.core.model.actions.tables.QueryOrGetInputInterf
** CountInput, and AggregateInput}, with common attributes for all of these ** CountInput, and AggregateInput}, with common attributes for all of these
** "read" operations (like, queryHints, ** "read" operations (like, queryHints,
*******************************************************************************/ *******************************************************************************/
public class QueryInput extends AbstractTableActionInput implements QueryOrGetInputInterface, Cloneable public class QueryInput extends AbstractTableActionInput implements QueryOrGetInputInterface, QueryOrCountInputInterface, Cloneable
{ {
private QBackendTransaction transaction; private QBackendTransaction transaction;
private QQueryFilter filter; private QQueryFilter filter;