CE-1406 Add Cloneable

This commit is contained in:
2024-07-08 14:35:49 -05:00
parent 27a6c0d53c
commit 1a6cc5bf3c
2 changed files with 74 additions and 2 deletions

View File

@ -56,7 +56,7 @@ import com.kingsrook.qqq.backend.core.utils.StringUtils;
** JoinsContext is constructed before executing a query, and not meant to be set ** JoinsContext is constructed before executing a query, and not meant to be set
** by users. ** by users.
*******************************************************************************/ *******************************************************************************/
public class QueryJoin public class QueryJoin implements Cloneable
{ {
private String baseTableOrAlias; private String baseTableOrAlias;
private String joinTable; private String joinTable;
@ -69,6 +69,40 @@ public class QueryJoin
/*******************************************************************************
**
*******************************************************************************/
@Override
public QueryJoin clone()
{
try
{
QueryJoin clone = (QueryJoin) super.clone();
if(joinMetaData != null)
{
clone.joinMetaData = joinMetaData.clone();
}
if(securityCriteria != null)
{
clone.securityCriteria = new ArrayList<>();
for(QFilterCriteria securityCriterion : securityCriteria)
{
clone.securityCriteria.add(securityCriterion.clone());
}
}
return clone;
}
catch(CloneNotSupportedException e)
{
throw new AssertionError();
}
}
/******************************************************************************* /*******************************************************************************
** define the types of joins - INNER, LEFT, RIGHT, or FULL. ** define the types of joins - INNER, LEFT, RIGHT, or FULL.
*******************************************************************************/ *******************************************************************************/

View File

@ -33,7 +33,7 @@ import com.kingsrook.qqq.backend.core.utils.StringUtils;
/******************************************************************************* /*******************************************************************************
** Definition of how 2 tables join together within a QQQ Instance. ** Definition of how 2 tables join together within a QQQ Instance.
*******************************************************************************/ *******************************************************************************/
public class QJoinMetaData implements TopLevelMetaDataInterface public class QJoinMetaData implements TopLevelMetaDataInterface, Cloneable
{ {
private String name; private String name;
private JoinType type; private JoinType type;
@ -62,6 +62,44 @@ public class QJoinMetaData implements TopLevelMetaDataInterface
/*******************************************************************************
**
*******************************************************************************/
@Override
public QJoinMetaData clone()
{
try
{
QJoinMetaData clone = (QJoinMetaData) super.clone();
if(joinOns != null)
{
clone.joinOns = new ArrayList<>();
for(JoinOn joinOn : joinOns)
{
clone.joinOns.add(joinOn.clone());
}
}
if(orderBys != null)
{
clone.orderBys = new ArrayList<>();
for(QFilterOrderBy orderBy : orderBys)
{
clone.orderBys.add(orderBy.clone());
}
}
return clone;
}
catch(CloneNotSupportedException e)
{
throw new AssertionError();
}
}
/******************************************************************************* /*******************************************************************************
** Getter for name ** Getter for name
** **